Page MenuHomeFreeBSD

Some fixes for nosys()/SIGSYS
ClosedPublic

Authored by kib on Sep 25 2023, 4:45 PM.
Tags
None
Referenced Files
F82554664: D41976.id.diff
Tue, Apr 30, 6:06 AM
Unknown Object (File)
Mon, Apr 29, 11:46 AM
Unknown Object (File)
Sun, Apr 28, 10:20 AM
Unknown Object (File)
Sat, Apr 27, 2:42 AM
Unknown Object (File)
Fri, Apr 26, 7:54 PM
Unknown Object (File)
Thu, Apr 25, 11:41 PM
Unknown Object (File)
Mon, Apr 22, 5:30 PM
Unknown Object (File)
Sun, Apr 21, 5:07 AM

Details

Summary

This changeset ensures that we call nosys() for each situation where ENOSYS is returned, which fixes situations with missed SIGSYS from e.g. too high syscall number.

In nosys(), allow ABI to indicate that SIGSYS should be not sent at all. Also allow to disable SIGSYS for FreeBSD native processes.

Right now only amd64 is handled.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Sep 25 2023, 4:45 PM
This revision is now accepted and ready to land.Sep 25 2023, 5:47 PM
sys/kern/kern_sig.c
163 ↗(On Diff #127793)

SYSCTL_INT(_kern, OID_AUTO, signosys, CTLFLAG_RWTUN, &kern_signosys, 0,

kib marked an inline comment as done.
kib added reviewers: jhb, markj.

Fix sysctl var name.
Add tests.

This revision now requires review to proceed.Sep 25 2023, 7:03 PM

Add FF copyright for the tests.

sys/kern/kern_sig.c
4226 ↗(On Diff #127802)

It might be more readable if we had a SV_SIGSYS that opted in to getting the signals that the FreeBSD ABIs set in their flags and then this would be SV_PROC_FLAG(p, SV_SIGSYS) != 0

tests/sys/kern/sigsys.c
19 ↗(On Diff #127802)

static volatile?

61 ↗(On Diff #127802)

Do you want another version of this test that adjusts the sysctl and then verifies there is no sigsys? Or perhaps you should fetch the sysctl and alter the expected test results based on its value?

kib marked 3 inline comments as done.Sep 26 2023, 9:52 AM
kib added inline comments.
tests/sys/kern/sigsys.c
61 ↗(On Diff #127802)

I remember there is some atf knob to allow/disallow changing global system state during the test. It would be needed there.

In fact Dmitry has another version of the tests, that I hope he will incorporate into this draft after I commit my parts. D41979

kib marked an inline comment as done.

SV_SIGSYS
Use sig_atomic_t for signal handler counter
Plug !x86 places

btw, you didn't change the arm64 and i386 Linuxulator

tests/sys/kern/sigsys.c
61 ↗(On Diff #127802)

I remember there is some atf knob to allow/disallow changing global system state during the test. It would be needed there.

Well, I don't know such knob,
my test stupidly returned the knob state to the default state because the kyua is ugly in that case, however that's enought in my POV

In fact Dmitry has another version of the tests, that I hope he will incorporate into this draft after I commit my parts. D41979

ok

Handle i386 and arm64 linuxolators

tests/sys/kern/sigsys.c
17 ↗(On Diff #127817)

<errno.h>, <stdbool.h> and <stdlib.h> seem redundant

kib marked an inline comment as done.Sep 26 2023, 1:18 PM
kib added inline comments.
tests/sys/kern/sigsys.c
17 ↗(On Diff #127817)

Only stdlib.h, if tests written properly.

kib marked an inline comment as done.

Improve tests, use ATF in more correct way.

sys/i386/i386/trap.c
1116 ↗(On Diff #127823)
kib marked an inline comment as done.Sep 26 2023, 3:38 PM
tests/sys/kern/sigsys.c
61 ↗(On Diff #127802)

See tests/sys/kern/kern_descrip_test.c for an example. You need to set "allow_sysctl_side_effects" and presumably also "require.user".

Alternately, at the beginning of the test, check whether the sysctl is set, and skip the test if not. Since kern_signosys = 1 by default, this is probably sufficient.

tests/sys/kern/sigsys.c
61 ↗(On Diff #127802)

See tests/sys/kern/kern_descrip_test.c for an example. You need to set "allow_sysctl_side_effects" and presumably also "require.user".

Alternately, at the beginning of the test, check whether the sysctl is set, and skip the test if not. Since kern_signosys = 1 by default, this is probably sufficient.

Thank you, D41979 updated

This revision is now accepted and ready to land.Sep 30 2023, 7:42 AM