Page MenuHomeFreeBSD

capsicum: Statically initialize commonly used capability rights
ClosedPublic

Authored by markj on Mon, May 19, 4:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 20, 8:26 PM
Unknown Object (File)
Tue, May 20, 8:43 AM
Unknown Object (File)
Tue, May 20, 8:38 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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Mon, May 19, 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.Mon, May 19, 7:34 PM
markj marked 2 inline comments as done.

Simplify the initializer macro.

This revision now requires review to proceed.Tue, May 20, 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.Tue, May 20, 9:40 AM
sys/sys/capsicum.h
374–375

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

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

IMO also worth noting cap_chflags_rights in the commit message