Page MenuHomeFreeBSD

lib{c,sys}: expose __libsys_interposer consumers
AbandonedPublic

Authored by brooks on Feb 27 2024, 6:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 4, 1:18 PM
Unknown Object (File)
Mon, Apr 22, 2:22 PM
Unknown Object (File)
Apr 14 2024, 5:43 PM
Unknown Object (File)
Apr 12 2024, 2:50 AM
Unknown Object (File)
Mar 2 2024, 10:35 PM
Unknown Object (File)
Mar 2 2024, 12:03 PM
Subscribers

Details

Reviewers
kib
Summary

When I moved these functions, I failed to move some of the symbol
versions.

Fixes: 29d079c96491 libsys: move __libsys_interposer consumers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 56284
Build 53172: arc lint + arc unit

Event Timeline

I think it is backward. I do not see a reason to have these live in libsys, esp. they 'fat' C implementation. Placing them in libc is more logical IMO, and it seems that the only reason they were attempted to be moved to libsys is use of the __libsys_interposed array. with __libsys_interposed_slot() you can place them in libc trivially, same as I handled sleep/usleep(3).

In D44111#1006732, @kib wrote:

I think it is backward. I do not see a reason to have these live in libsys, esp. they 'fat' C implementation. Placing them in libc is more logical IMO, and it seems that the only reason they were attempted to be moved to libsys is use of the __libsys_interposed array. with __libsys_interposed_slot() you can place them in libc trivially, same as I handled sleep/usleep(3).

Sure, I can do that instead.

In D44111#1006732, @kib wrote:

I think it is backward. I do not see a reason to have these live in libsys, esp. they 'fat' C implementation. Placing them in libc is more logical IMO, and it seems that the only reason they were attempted to be moved to libsys is use of the __libsys_interposed array. with __libsys_interposed_slot() you can place them in libc trivially, same as I handled sleep/usleep(3).

Looking into it more, I'm less certain this is the right take. These are all thin wrappers that would now get a little more expensive due to an extra function call. More importantly, why should interposed system calls have their <sys>() interface provided by libc, when non-interposed ones come from libsys since they are the same as _<sys>() and __sys_<sys>()? Conceivably we could generate <sys>() for non-interposed ones if we really want to go that route, but I'm not excited by doing that.

(Note that this review only fixes the ones where I messed up the move by not moving symbol map entries, there are another ~38 of them that were previously in lib/libc/sys and thus already handled.)

One argument in favor of moving all the interposed functions back to libc is that this review stack effectively reverts rGbd6060a1c661b3. I find the log message for that commit frustrating as it doesn't describe the reported issue (correctness, performance, ???), only the change.

One argument in favor of moving all the interposed functions back to libc is that this review stack effectively reverts rGbd6060a1c661b3. I find the log message for that commit frustrating as it doesn't describe the reported issue (correctness, performance, ???), only the change.

The commit message is quite explicit explaining the breakage (libthr interposition of the signal handlers was overwritten, which makes libthr critical sections nonoperational and cancellation broken among other things).

In D44111#1006732, @kib wrote:

I think it is backward. I do not see a reason to have these live in libsys, esp. they 'fat' C implementation. Placing them in libc is more logical IMO, and it seems that the only reason they were attempted to be moved to libsys is use of the __libsys_interposed array. with __libsys_interposed_slot() you can place them in libc trivially, same as I handled sleep/usleep(3).

Looking into it more, I'm less certain this is the right take. These are all thin wrappers that would now get a little more expensive due to an extra function call. More importantly, why should interposed system calls have their <sys>() interface provided by libc, when non-interposed ones come from libsys since they are the same as _<sys>() and __sys_<sys>()? Conceivably we could generate <sys>() for non-interposed ones if we really want to go that route, but I'm not excited by doing that.

(Note that this review only fixes the ones where I messed up the move by not moving symbol map entries, there are another ~38 of them that were previously in lib/libc/sys and thus already handled.)

My take is ideally libsys.so should only export 'real' syscalls, and anything that is handled by intermediate code (e.g. interposed) should be left to upper layers e.g. libc. But this is too much for this stage, so we moved some interpositions into libsys. The sys_XXX symbol movement reflects that, and since both libsys and sys_XXX are implementation details, it is fine. After we fix and harden the current libsys extraction step, we could re-visit that. We must do something before we claim libsys is part of the ABI.

Additional argument is that all the 'syscalls' like open/wait/etc are no longer syscalls, they forward the call to more generic openat/waitid.

I'm going to go the route of pulling these symbols back into libc.