Page MenuHomeFreeBSD

kern_shm_open: push O_CLOEXEC into caller controller
ClosedPublic

Authored by kevans on Jul 30 2019, 7:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 11, 5:55 AM
Unknown Object (File)
Fri, May 10, 3:04 PM
Unknown Object (File)
Feb 20 2024, 6:57 PM
Unknown Object (File)
Feb 19 2024, 10:48 PM
Unknown Object (File)
Jan 6 2024, 1:52 AM
Unknown Object (File)
Dec 22 2023, 11:24 PM
Unknown Object (File)
Dec 12 2023, 12:45 AM
Unknown Object (File)
Dec 10 2023, 2:09 AM
Subscribers

Details

Summary

The motivation for this change is to allow wrappers around shm to be written that don't set CLOEXEC. kern_shm_open currently accepts O_CLOEXEC but sets it unconditionally. kern_shm_open is used by the shm_open(2) syscall, which is mandated by POSIX to set CLOEXEC, and CloudABI's sys_fd_create1(). Presumably O_CLOEXEC is intended in the latter caller, but it's unclear from the context.

sys_shm_open() now unconditionally sets O_CLOEXEC to meet POSIX requirements, and a comment has been dropped in to kern_fd_open() to explain the situation and add a pointer to where O_CLOEXEC setting is maintained for shm_open(2) correctness. CloudABI's sys_fd_create1() also unconditionally sets O_CLOEXEC to match previous behavior.

This also has the side-effect of making flags correctly reflect the O_CLOEXEC status on this fd for the rest of kern_shm_open(), but a glance-over leads me to believe that it didn't really matter.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

What about cloudabi_sys_fd_create1()? There is no reference to CLOEXEC at all in the cloudabi code, so it's not clear to me whether it cares about this particular case.

What about cloudabi_sys_fd_create1()? There is no reference to CLOEXEC at all in the cloudabi code, so it's not clear to me whether it cares about this particular case.

Hmm... not sure how I missed this one, I thought I grepped all of sys/. I guess it must set O_CLOEXEC to remain compatible, but maybe @ed can provide some insight as to whether that's correct going forward -- I kind of suspect it is.

sys/kern/uipc_shm.c
737 ↗(On Diff #60306)

sys_shm_open()

kevans edited the summary of this revision. (Show Details)
  • sys_shm_open -> sys_shm_open()
  • update previously missed cloudabi caller to also unconditionally set O_CLOEXEC to maintain previous behavior
This revision is now accepted and ready to land.Jul 31 2019, 5:16 AM
This revision was automatically updated to reflect the committed changes.