Page MenuHomeFreeBSD

kevent: Disallow certain filter types in capability mode
Needs ReviewPublic

Authored by markj on Jul 22 2026, 3:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 4, 12:15 PM
Unknown Object (File)
Fri, Sep 4, 12:08 AM
Unknown Object (File)
Mon, Aug 17, 11:01 PM
Unknown Object (File)
Sun, Aug 16, 9:43 PM
Unknown Object (File)
Aug 12 2026, 6:13 PM
Unknown Object (File)
Aug 9 2026, 1:50 AM
Unknown Object (File)
Aug 8 2026, 10:49 AM
Unknown Object (File)
Aug 8 2026, 9:22 AM
Subscribers

Details

Reviewers
kib
kevans
Group Reviewers
capsicum
Summary

EVFILT_PROC, EVFILT_JAIL and EVFILT_FS knotes let a process collect
information about objects without requiring a capability. They
shouldn't be allowed when the process is in capability mode, so add
checks to this effect.

Note, this does nothing about knotes that are registered already at the
time cap_enter() is called, but I think this is acceptable.

Diff Detail

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

Event Timeline

markj requested review of this revision.Jul 22 2026, 3:48 PM

This would prevent a process from tracking itself using EVFILT_PROC. Not sure how useful it is, but maybe it makes sense to add an exception for ident == getpid().

Same for EVFILT_JAIL.

This would prevent a process from tracking itself using EVFILT_PROC. Not sure how useful it is, but maybe it makes sense to add an exception for ident == getpid().

Yes, there is some precedent for that. For instance, raise() is supposed to work in capability mode.

Same for EVFILT_JAIL.

Why? The current process doesn't own its containing jail in any sense.

This would prevent a process from tracking itself using EVFILT_PROC. Not sure how useful it is, but maybe it makes sense to add an exception for ident == getpid().

Yes, there is some precedent for that. For instance, raise() is supposed to work in capability mode.

But then what to do with NOTE_TRACK, without which EVFILT_PROC is useless. Esp. it is useless on itself.

sys/kern/kern_event.c
457

If we do not need much flexibility, it might be better to add a flag to filterops which would deny attach if in_cap_mode() && flag && !f_isfd.

Same for EVFILT_JAIL.

Why? The current process doesn't own its containing jail in any sense.

Yes, you're correct, don't mind me.

In D58397#1339785, @kib wrote:

This would prevent a process from tracking itself using EVFILT_PROC. Not sure how useful it is, but maybe it makes sense to add an exception for ident == getpid().

Yes, there is some precedent for that. For instance, raise() is supposed to work in capability mode.

But then what to do with NOTE_TRACK, without which EVFILT_PROC is useless. Esp. it is useless on itself.

Yeah, it does not seem very useful. Without some use-case I am inclined to disallow all uses of EVFILT_PROC in capmode.

sys/kern/kern_event.c
457

If anything I would invert such a flag, so !f_isfd filters are disallowed in capmode unless they set the flag.

sys/kern/kern_event.c
457

Sure., Technically, I think that f_isfd should become a flag word instead of bool.