kern/kern_descrip.c: avoid leaking pwd hold when vnode export fails
kern_proc_filedesc_out() gotos around the pwd_drop() call on errors from
export_vnode_to_sb(), leaking the hold.
Reported by: llm-postcr
Fixes: 36bd49ac4db8 ("fd: Avoid truncating output buffers for KERN_PROC_{CWD,FILEDESC}")
kern/kern_descrip.c: avoid leaking vnode use count hold when vnode export fails
export_vnode_to_sb() returns on remainder == 0 without calling
export_vnode_to_kinfo(), which vrele()s it.
Fixes: fe52cf547580 ("Re-factor the code to provide kern_proc_filedesc_out(), kern_proc_out(), and kern_proc_vmmap_out() functions ...")
kern/kern_descrip.c: do not leak ctty/textvp/tracevp use counts
If the export of one of the special process vnodes failed, the
references on the remaining ones leaked, since export_vnode_to_sb() was
not called for them.
Each reference is now taken just before its export, with the process
held in between.
Fixes: 36bd49ac4db8 ("fd: Avoid truncating output buffers for KERN_PROC_{CWD,FILEDESC}")Details
Details
- Reviewers
markj
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
| sys/kern/kern_descrip.c | ||
|---|---|---|
| 5062 | Don't we also need the session lock here, to fetch the tty vp? | |
| sys/kern/kern_descrip.c | ||
|---|---|---|
| 5062 | I think proctree_lock is enough, and it is easier. | |
| sys/kern/kern_descrip.c | ||
|---|---|---|
| 5062 | Is the shared lock sufficient? devfs_ioctl() swaps the ctty with the shared proctree lock held. killjobc() only asserts that the proctree lock is held, it doesn't assert the exclusive lock. | |
Comment Actions
Engage with the full locking protocol for ctty. Lock session in addition to slocking proctree.