Page MenuHomeFreeBSD

procdesc: add NOTE_PDSIGCHLD
ClosedPublic

Authored by kib on Thu, Jul 9, 11:10 AM.
Tags
None
Referenced Files
F162611245: D58123.id181717.diff
Wed, Jul 15, 1:13 AM
F162600243: D58123.id181715.diff
Tue, Jul 14, 10:43 PM
Unknown Object (File)
Tue, Jul 14, 5:54 AM
Unknown Object (File)
Tue, Jul 14, 4:14 AM
Unknown Object (File)
Tue, Jul 14, 12:36 AM
Unknown Object (File)
Mon, Jul 13, 6:04 PM
Unknown Object (File)
Mon, Jul 13, 4:24 AM
Unknown Object (File)
Mon, Jul 13, 3:59 AM

Details

Summary

The note type wakes up when there is something for pdwait(2) to report on the process descriptor.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Thu, Jul 9, 11:10 AM
sys/sys/event.h
206

Why repurpose NOTE_FORK? Isn't it possible someone might want to use a procdesc to wait for NOTE_FORK events?

kib marked an inline comment as done.Thu, Jul 9, 2:57 PM
kib added inline comments.
sys/sys/event.h
206

Should we ever allow it? NOTE_FORK is very close to limited tracing functionality, and you was explicitly against the ptrace attach over procdesc

I just acted under assumption that procdesc knote actions should not extend the functionality of existing syscalls, mainly pdwait().

If you prefer, I can reuse the free bit from PCTRLMASK but may be instead we should split the namespace between _PROC and _PROCDESC filters?

sys/sys/event.h
206

you was explicitly against the ptrace attach over procdesc

Well, to be clear, I was against enabling ptrace() in capability mode, at least without some more design and discussion; PT_ATTACH_PD on its own is fine I suppose, but I do not really see the point unless you want to enable capmode ptrace(). Meanwhile, NOTE_FORK already exists, and supporting it from procdesc does not require much complexity (I think?), and procdescs already implement NOTE_EXIT. Plus, with procdescs you can avoid PID reuse races. For ptrace() I think such races are probably not a real concern (but correct me if I am wrong).

So, I think it makes some sense to leave NOTE_FORK available for procdescs.

BTW, does anything prevent a capmode process from using EVFILT_PROC? If not, then that is a bug.

kib marked an inline comment as done.Thu, Jul 9, 7:24 PM
kib added inline comments.
sys/sys/event.h
206

you was explicitly against the ptrace attach over procdesc

Well, to be clear, I was against enabling ptrace() in capability mode, at least without some more design and discussion; PT_ATTACH_PD on its own is fine I suppose, but I do not really see the point unless you want to enable capmode ptrace(). Meanwhile, NOTE_FORK already exists, and supporting it from procdesc does not require much complexity (I think?), and procdescs already implement NOTE_EXIT. Plus, with procdescs you can avoid PID reuse races. For ptrace() I think such races are probably not a real concern (but correct me if I am wrong).

For ptrace() the races are impossible since the target is reparented to the debugger.

So, I think it makes some sense to leave NOTE_FORK available for procdescs.

Ok, consumed the new bit for NOTE_PDSIGCHLD.

BTW, does anything prevent a capmode process from using EVFILT_PROC? If not, then that is a bug.

Yes, this seems to be a bug. It is easy to disallow registering new knotes when in cap mode. What should we do about knotes that are were registered before entering the cap mode?

markj added inline comments.
sys/sys/event.h
206

It is easy to disallow registering new knotes when in cap mode.

Maybe kqueue filters with f_isfd == 0 should be disallowed by default in capability mode, with some mechanism to opt in. We have:

  • EVFILT_JAIL, should be disallowed by default
  • EVFILT_PROC, should be disallowed by default
  • EVFILT_TIMER, seems ok
  • EVFILT_SIGNAL, seems ok
  • EVFILT_AIO/LIO, probably ok, I am not sure
  • EVFILT_FS, should be disallowed by default

What should we do about knotes that are were registered before entering the cap mode?

The only real choices seem to be 1) ignore them, 2) in cap_enter(), go through all of the process' kqueues and knotes, and somehow purge them.

I think 1) is probably acceptable. 2) is significant complexity for a very rare and easily avoidable situation. Maybe @emaste or @oshogbo have an opinion there.

sys/kern/sys_procdesc.c
351

In procdesc_kqops_event() there is a test, if (event == NOTE_EXIT). Probably that needs to change to if (event & NOTE_EXIT).

kib marked an inline comment as done.

Properly test for the no longer solo flag.

sys/kern/sys_procdesc.c
524–525

Should this generate NOTE_PDSIGCHLD too?

kib marked an inline comment as done.

Always report PDSIGCHLD when reporting EXIT.

This revision is now accepted and ready to land.Mon, Jul 13, 12:34 AM
This revision was automatically updated to reflect the committed changes.