Page MenuHomeFreeBSD

capsicum: Statically initialize commonly used capability rights
ClosedPublic

Authored by markj on May 19 2025, 4:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 14, 4:26 AM
Unknown Object (File)
Tue, Aug 12, 10:35 PM
Unknown Object (File)
Tue, Aug 12, 9:40 AM
Unknown Object (File)
Sat, Aug 9, 10:44 PM
Unknown Object (File)
Fri, Aug 8, 3:32 PM
Unknown Object (File)
Tue, Jul 29, 10:30 AM
Unknown Object (File)
Fri, Jul 25, 9:37 AM
Unknown Object (File)
Fri, Jul 25, 4:33 AM
Subscribers

Details

Summary

Rather than initializing all of these sets during boot, define a macro
which can do so at compile-time. This lets us get rid of the silly
sysinit and furthermore allows the sets to live in .rodata, where they
ought to be anyway.

The CAP_RIGHTS_INITIALIZER2 macro can create a set out of up to two
capsicum rights. This could be made more general, but we currently
don't have any use for a more abstract implementation, so just keep it
simple for now.

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 64302
Build 61186: arc lint + arc unit

Event Timeline

markj requested review of this revision.May 19 2025, 4:31 PM

I like this change, but I will verify it tomorrow if its fine with you :)
As I need to wrap my head around this calculations.

olce added inline comments.
sys/sys/capsicum.h
374–376

Simplification.

You might want to also move the enclosing CAPRIGHT() in CAP_RIGHTS_INITIALIZER2() (see other inline comment).

381–389

If CAPRIGHT() is removed from _CAP_RIGHTS_WORD_INITIALIZER().

This revision is now accepted and ready to land.May 19 2025, 7:34 PM
markj marked 2 inline comments as done.

Simplify the initializer macro.

This revision now requires review to proceed.May 20 2025, 12:47 AM
sys/sys/capsicum.h
374–376

Actually, these CAPRIGHT() uses aren't needed at all. r already contains the index bits.

olce added inline comments.
sys/sys/capsicum.h
374–376

👍

This revision is now accepted and ready to land.May 20 2025, 9:40 AM
sys/sys/capsicum.h
374–375

You can still remove the redundant (r) & though.

This revision now requires review to proceed.May 20 2025, 1:38 PM
This revision is now accepted and ready to land.May 20 2025, 1:50 PM

IMO also worth noting cap_chflags_rights in the commit message