Page MenuHomeFreeBSD

getpgrp(2), getsid(2): allow to call on zombies
ClosedPublic

Authored by kib on Wed, Jul 22, 9:51 AM.
Tags
None
Referenced Files
F163545240: D58393.diff
Fri, Jul 24, 8:12 AM
Unknown Object (File)
Thu, Jul 23, 2:19 PM
Unknown Object (File)
Thu, Jul 23, 1:17 PM
Unknown Object (File)
Wed, Jul 22, 6:09 PM
Unknown Object (File)
Wed, Jul 22, 4:08 PM
Subscribers

Details

Reviewers
markj
kevans
kib
Summary

Also be more protective in getsid().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Wed, Jul 22, 9:51 AM

Why?

sys/kern/kern_prot.c
247–250

There is no corresponding check p->p_pgrp != NULL in sys_getpgid() above.

I suspect it's impossible to have a NULL p->p_pgrp or p->p_pgrp->pg_session.

Why?

https://gitlab.haskell.org/ghc/ghc/-/work_items/27512#note_686988
> But the hypothesis here is that getpgid on a zombie process fails, probably ESRCH.
sys/kern/kern_prot.c
247–250

For p_pgrp yes, it is only cleared on reap.
But for the pg_session, I am not sure. What makes me wonder is the number of checks for p->p_session != NULL in the tree.

sys/kern/kern_prot.c
247–250

Yeah, it's not very clear to me either. I suspect it is always non-NULL. e.g., pgdelete() will unconditionally dereference pg_session.

252
kib marked 2 inline comments as done.Wed, Jul 22, 10:01 PM
kib added inline comments.
sys/kern/kern_prot.c
247–250

I dropped the p_pgrp check, but kept pg_session. I think this should follow the existing pattern for now, and cleaned with the global sweep.

kib marked 2 inline comments as done.

Return error.

markj added inline comments.
sys/kern/kern_prot.c
252

Also need to initialize error to 0 for the pid == 0 case.

This revision is now accepted and ready to land.Thu, Jul 23, 1:21 PM
This revision now requires review to proceed.Thu, Jul 23, 3:13 PM
This revision is now accepted and ready to land.Thu, Jul 23, 11:53 PM