kern/kern_exit.c: some style kern/kern_fork/exit.c: organize includes Remove sys/cdefs.h. Remove sys/param.h. Order the sys/*.h includes alphabetically. kern/kern_fork.c: define the exterror category for fork Convert EINVALs in kern_fork.c into EXTERRORs. sys: add AUE_PDRFORK contrib/openbsm: add AUE_PDRFORK sys: add pdrfork(2) lib/libsys, lib/libc: export pdrfork(2) kern/kern_exit.c: define the exterror category for exit/wait Convert EINVALs in kern_exit.c into EXTERRORs. kern/kern_exit.c: extract some helpers from proc_to_reap() kern/kern_exit.c: extract wait6_check_alive() helper Add pdwait(2) lib/libsys, lib/libc: export pdwait Regen for the fork and exit/wait exterror category addition Regen syscall tables after pdfork(2) and pdwait(2) additions
Details
- Reviewers
asomers brooks emaste markj - Group Reviewers
capsicum - Commits
- rG2d555ec85a71: lib/libsys, lib/libc: export pdwait
rGf7b56887cc07: Document pdrfork(2) and pdwait(2)
rG4d707825bf62: Add pdwait(2)
rG09984871d8ca: procdesc: postpone freeing the zombie' pid until procdesc is freed
rGaa72df78d799: sys: Add cap_pdwait_rights
rGa560abedfb4f: audit: handle AUE_PDWAIT
rG7fe33d58a826: kern/kern_exit.c: extract wait6_check_alive() helper
rG2b67cfa39d83: kern/kern_exit.c: extract some helpers from proc_to_reap()
rG109b9f48ec4e: kern/kern_exit.c: define the exterror category for exit/wait
rGf10b4b6131d4: lib/libsys, lib/libc: export pdrfork(2)
rG5c2ee618d5ec: sys: add pdrfork(2)
rGd0d4b9b9df2a: sys: add AUE_PDRFORK
rG7211cd2cce74: kern/kern_fork.c: define the exterror category for fork
rG472c32a83b27: kern/kern_fork/exit.c: organize includes
rGf5acbacb28f9: kern/kern_exit.c: some style
rG6af3cf27ed00: freebsd32_rusage_out(): bzero the compat32 structure
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Renumber AUE_PDRFORK.
Drop contrib/openbsm patch, similar to how other new AUE_ constants are not imported there.
Do not release procdesc->pd_pid if the descriptor was already detached from the struct proc. In this case, the pid is freed by reaping.
This looks great, @kib! If you commit it, I'll follow up with the test suite. A few questions:
- Are you planning to write the man page yourself, or would you like help with that?
- Even if you don't MFC the new syscalls, would it be possible to MFC the pid recycling change?
I prototyped the initial version of the docs. Feel free to suggest improvements.
- Even if you don't MFC the new syscalls, would it be possible to MFC the pid recycling change?
I plan to MFC everything. It depends on how the live testing in HEAD goes, of course.
Thanks for writing the man page too. I've made a few comments, mostly to make the English more grammatical and idiomatic.
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 33 | Don't forget to adjust .Dd too | |
| 104 | More idiomatic English. | |
| 112–114 | number agreement | |
| 117 | ||
| 118 | ||
| 136–137 | ||
| 140 | ||
| 179–180 | ||
| 239 | Or perhaps sooner, if MFCd? I'll set a reminder for myself to update the man page before 15.1, if you've MFCd by then. | |
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 80 | ||
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 102 | Sure, except you're missing a space in "betweenthe". | |
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 239 | Yes, it is only a safest estimation. | |
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 182–183 | Missing macro dots | |
| sys/kern/kern_exit.c | ||
|---|---|---|
| 1322 | Why "%jx"? options is an int. | |
| 1452 | Is it formally correct to dereference p here? AFAICS there is nothing preventing it from being recycled after the proc lock is dropped. | |
| 1559 | Why do we check p_state == PRS_ZOMBIE twice? I do not see how it can change: if wait6_check_alive() returns false, the proc lock will not have been dropped. | |
| 1573 | I think this path is missing fdrop()? | |
| sys/kern/kern_exit.c | ||
|---|---|---|
| 1322 | The format is utilized by usermode, which always casts the arguments to uintmax_t: we do not know the real types of the values passed by the kernel, we only know that they are integer. I noted it in the exterror(9) man page that the 'j' modifier must always be applied. | |
| 1452 | Formally yes because struct proc are type-stable. Of course there is a possible race with the 'p' reuse, whatever unlikely it is. I changed this to use the local variable pid that already caches the pid, same as in line 1432. | |
| 1559 | Yes, I think this if(){} block can be removed. This is a remnant of earlier, different, structure of the pdwait() loop. | |
Avoid racy access to the p_pid member of possibly reclaimed struct proc.
Other review' comments are handled.
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 115 | Either the "the" should be removed, or you should write "The .Fn pdrfork system call". | |
| 136 | ||
| sys/compat/freebsd32/freebsd32_misc.c | ||
| 303 | BTW, I suspect freebsd32_rusage_out() should do some zeroing. struct timeval32 will have a hole on non-amd64 platforms, so we are copying out uninitialized memory there. | |
| sys/kern/kern_exit.c | ||
| 1452 | Right, I was referring to the race. | |
| sys/kern/subr_capability.c | ||
| 93 | rights.4 should be updated to mention the new CAP_PDWAIT. | |
| sys/kern/sys_procdesc.c | ||
| 317 | Do we need to wake up the kern_pdwait() loop here too? I guess not, since the pdwait() caller must be holding a reference on the procdesc, so PDF_CLOSED cannot be set? | |
| lib/libsys/pdfork.2 | ||
|---|---|---|
| 136 | It is function as well, and might become a wrapper some day. | |
| sys/kern/sys_procdesc.c | ||
| 317 | If PDF_CLOSED set, then indeed no process might have the file installed into the descriptors table. | |
Assert that PDF_CLOSED is not set for fd operated by pdwait().
Make pdwait() cancellable.
I have completed a full stress2 test run without seeing any issues. This on the pdrfork-5982326ec607 branch.