Index: head/sys/kern/uipc_shm.c =================================================================== --- head/sys/kern/uipc_shm.c +++ head/sys/kern/uipc_shm.c @@ -833,6 +833,7 @@ } shmfd = shm_alloc(td->td_ucred, cmode); shmfd->shm_seals = initial_seals; + shmfd->shm_flags = shmflags; } else { error = shm_copyin_path(td, userpath, &path); if (error != 0) { @@ -855,6 +856,7 @@ #endif shmfd = shm_alloc(td->td_ucred, cmode); shmfd->shm_seals = initial_seals; + shmfd->shm_flags = shmflags; shm_insert(path, fnv, shmfd); #ifdef MAC } @@ -898,6 +900,8 @@ else if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) error = EEXIST; + else if (shmflags != 0 && shmflags != shmfd->shm_flags) + error = EINVAL; else { #ifdef MAC error = mac_posixshm_check_open(td->td_ucred, @@ -947,7 +951,6 @@ } } - shmfd->shm_flags = shmflags; finit(fp, FFLAGS(flags & O_ACCMODE), DTYPE_SHM, shmfd, &shm_ops); td->td_retval[0] = fd;