[libos] Fix size checking bug for shmget

This commit is contained in:
Zheng, Qi 2023-02-16 11:10:21 +08:00 committed by volcano
parent 6b86f37bd4
commit 0f33e93fd5

@ -360,8 +360,8 @@ impl ShmManager {
key, size, shmflg key, size, shmflg
); );
// Check the size from user // Check the size from user for shm creation
if size < SHMMIN || size > SHMMAX { if shmflg.contains(ShmFlags::IPC_CREAT) && (size < SHMMIN || size > SHMMAX) {
return_errno!(EINVAL, "invalid size"); return_errno!(EINVAL, "invalid size");
} }
@ -374,10 +374,7 @@ impl ShmManager {
|| mode.contains(FileMode::S_IWGRP) || mode.contains(FileMode::S_IWGRP)
|| mode.contains(FileMode::S_IWOTH); || mode.contains(FileMode::S_IWOTH);
if !(read_per && write_per) { if !(read_per && write_per) {
return_errno!( warn!("shared memory segement in occlum should have rw permission");
EINVAL,
"shared memory segement in occlum should have rw permission now"
);
} }
let mut shm_segments = self.shm_segments.write().unwrap(); let mut shm_segments = self.shm_segments.write().unwrap();