Page MenuHomeFreeBSD

Log ENOSYS in init
ClosedPublic

Authored by brooks on Sep 1 2020, 8:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 15, 10:21 PM
Unknown Object (File)
Fri, Mar 15, 10:21 PM
Unknown Object (File)
Fri, Mar 15, 10:21 PM
Unknown Object (File)
Tue, Mar 12, 3:57 AM
Unknown Object (File)
Tue, Mar 12, 2:47 AM
Unknown Object (File)
Dec 22 2023, 10:44 PM
Unknown Object (File)
Dec 11 2023, 4:46 AM
Unknown Object (File)
Oct 31 2023, 2:20 AM
Subscribers
None

Details

Summary

While rare, encountering an unimplemented system call early in init is
catastrophic and difficult to debug. Even after a SIGSYS handler is
registered, such configurations are problematic. As such, always log
such events for pid 1.

Diff Detail

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

Event Timeline

brooks requested review of this revision.Sep 1 2020, 8:58 PM
brooks created this revision.

I ran into this on a CHERI system where we've added new revocation related system calls used in malloc. Unfortunately, we call malloc in strdup even before the (rather questionable) badsys hander is installed. Due to someone changing the kernel configs and me not noticing I lost a half day to not having those syscalls...

badsys is a piece of work...

This revision is now accepted and ready to land.Sep 1 2020, 9:08 PM

It might not be a bad idea to make it (p->p_pid == 1 && (kern_lognosys & 3) == 0) -- kern.lognosys is RWTUN, so one could theoretically have chosen an explicit behavior in loader or static kenv and that should probably be followed. OTOH, with the current check, the behavior's OK:

kern.lognosys=0: Log to console
kern.lognosys=1: Log to both
kern.lognosys=2: Log to console
kern.lognosys=3: Log to both

Obviously the only one that would change is lognosys=1 to keep the message on ctty only. Either way, I agree that it should be logged even if it's explicitly set to 0 and don't insist on the above at all.

sys/kern/kern_sig.c
3798 ↗(On Diff #76514)

As an aside, it'd be nice to document the values for lognosys somewhere or differently; as far as I can tell, they're only documented in the commit message of rS321627.

  • Honor kern.lognosys if non-zero.
This revision now requires review to proceed.Sep 2 2020, 10:17 PM
This revision is now accepted and ready to land.Sep 2 2020, 10:19 PM
This revision was automatically updated to reflect the committed changes.