Page MenuHomeFreeBSD

witness: support a configurable output channel
ClosedPublic

Authored by markj on Nov 16 2015, 6:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 12:41 AM
Unknown Object (File)
Sun, Apr 14, 12:40 AM
Unknown Object (File)
Mar 14 2024, 8:11 AM
Unknown Object (File)
Mar 14 2024, 8:11 AM
Unknown Object (File)
Feb 5 2024, 2:42 AM
Unknown Object (File)
Jan 11 2024, 6:21 AM
Unknown Object (File)
Jan 11 2024, 6:21 AM
Unknown Object (File)
Jan 11 2024, 6:21 AM
Subscribers

Details

Summary

At the moment, witness always reports LORs and other lock rule
violations by printing to the console. This is problematic for
environments that use pexpect-ish tools to configure FreeBSD systems via
the console: they can get confused by unexpected witness output.

This change adds a witness "output channel" sysctl that lets one tell
witness to use log(9) to log warnings rather than printing to the
console. It wraps all the printf() calls with witness_output(), which
selects the output channel. This change also adds vlog(9), since we
didn't already have it; it'll be committed separately.

Diff Detail

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

Event Timeline

markj retitled this revision from to witness: support a configurable output channel.
markj edited the test plan for this revision. (Show Details)
markj updated this object.
cem edited edge metadata.
cem added inline comments.
sys/kern/subr_witness.c
432–433 ↗(On Diff #10242)

The man page documents this as tunable.

2692 ↗(On Diff #10242)

static const?

2701 ↗(On Diff #10242)

I'd use an unsigned type for i.

2718 ↗(On Diff #10242)

break;?

2989 ↗(On Diff #10242)

"%.*s", len, data? I guess we don't need it if sbuf always nul-terminates strings.

This revision is now accepted and ready to land.Nov 16 2015, 7:06 PM
markj edited edge metadata.

Address review comments from cem.

This revision now requires review to proceed.Nov 16 2015, 7:17 PM
cem edited edge metadata.
This revision is now accepted and ready to land.Nov 16 2015, 7:19 PM
markj added inline comments.
sys/kern/subr_witness.c
432–433 ↗(On Diff #10243)

Oops, thanks. I wasn't sure if RWTUN+SYSCTL_PROC would work, and forgot to actually check. Turns out that it works fine.

2991 ↗(On Diff #10243)

Yeah, I don't think that's needed. There's an SBUF_INCLUDENUL flag, but that only determines whether the null byte is included in len - the buffer itself should always be null-terminated.

sys/kern/subr_witness.c
319 ↗(On Diff #10243)

Better to drop the leading _ from the function name and drop the macro altogether.

2601 ↗(On Diff #10243)

This looks unrelated (though a worthy cleanup)

3009 ↗(On Diff #10243)

I think it would be clearer if we instead made stack_*_ddb() present in the kernel when WITNESS is enabled. and always use it instead of depending on '#ifdef DDB' here.

markj edited edge metadata.
markj marked an inline comment as done.

Address review comments from jhb.

This revision now requires review to proceed.Nov 16 2015, 10:00 PM
markj added inline comments.
sys/kern/subr_witness.c
2601 ↗(On Diff #10248)

Oops, indeed. I'll commit that separately.

3002 ↗(On Diff #10248)

That's what I've done in the latest upload, but I wonder if it wouldn't be best to just define stack_*_ddb unconditionally. We already define linker_ddb_* unconditionally, and these functions are misnomers anyway. They're for any caller that wants to avoid acquiring locks during symbol resolution.

jhb edited edge metadata.
jhb added inline comments.
sys/kern/subr_witness.c
3002 ↗(On Diff #10248)

Yes, I almost suggested doing s/ddb/unlocked/ or some such on the names while you are at it. Having them still be conditional is nice to the embedded folks perhaps, but agree that for that to truly be worthwhile the linker ones would need the same treatment.

This revision is now accepted and ready to land.Nov 16 2015, 10:56 PM
This revision was automatically updated to reflect the committed changes.
markj marked an inline comment as done.