Page MenuHomeFreeBSD

Mark closefrom(2) COMPAT12, reimplement in libc to wrap close_range
ClosedPublic

Authored by kevans on Apr 13 2020, 6:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 11:48 PM
Unknown Object (File)
Fri, Dec 20, 9:30 PM
Unknown Object (File)
Nov 17 2024, 5:56 AM
Unknown Object (File)
Nov 15 2024, 3:17 PM
Unknown Object (File)
Nov 15 2024, 2:01 PM
Unknown Object (File)
Nov 10 2024, 2:59 PM
Unknown Object (File)
Nov 10 2024, 2:40 AM
Unknown Object (File)
Nov 9 2024, 11:53 PM
Subscribers

Details

Summary

Include a temporarily compatibility shim as well for kernels predating close_range, since closefrom is used in some critical areas.

Diff Detail

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

Event Timeline

Makefile.inc1
960–961 ↗(On Diff #70508)

We ought to implement this in tools/build/depend-cleanup.sh instead. I could move shm_open there first if you like.

Move .depend cleanup to the proper fancy place

tools/build/depend-cleanup.sh
38 ↗(On Diff #70511)

Re-reading the extension logic, I whoops'd it again and somehow whoops'd it with shm_open. These were S...

This revision is now accepted and ready to land.Apr 13 2020, 8:19 PM
lib/libc/sys/closefrom.c
37 ↗(On Diff #70511)

I think this is wrong. If somebody referenced __sys_closefrom then she probably ought to get the syscall entry point still, regardless of the syscall presence in the kernel.

Also, I am not sure what is the reason to still export _closefrom.

49 ↗(On Diff #70511)

Does this depend on a kernel config ? I.e. if there is a default kernel config without COMPAT12, do we still get SYS_freebsd12_closefrom in sys/syscall.h ?

lib/libc/sys/closefrom.c
37 ↗(On Diff #70511)

Hmm... the problem is that if someone referenced __sys_closefrom and their kernel doesn't have COMPAT12 anymore (or yet), then closefrom is trivially ENOSYS at runtime, assuming I understand you right (i.e. that it should be point to __sys_freebsd12_closefrom instead of here)

Unsure about _closefrom; I modelled this after _shm_open still existing, but since I did that one, too, it's not clear to me whether it's really needed. I would suspect not.

lib/libc/sys/closefrom.c
49 ↗(On Diff #70511)

As of right now, no- makesyscalls will unconditionally(*) emit SYS_freebsd12_closefrom.

(*) Cheri has some changes that lets an ABI configure a minimum compat version to honor so they can omit COMPAT_43 and FREEBSD4, or something like that, but this should be the only edge-case.

lib/libc/sys/closefrom.c
37 ↗(On Diff #70511)

I mean, if somebody calls __sys_closefrom, then there was a reason to want the syscall wrapper and not something else from libc. If kernel does not implement the syscall, then ENOSYS/SIGSYS is deserved.

I believe we should not produce new _XXX symbols unless they are needed. One day we might clean the private version namespace.

Just drop _closefrom and __sys_closefrom; these are in the private namespace and nothing in base referred to them, at least.

This revision now requires review to proceed.Apr 14 2020, 4:19 AM
This revision is now accepted and ready to land.Apr 14 2020, 4:28 AM