Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177859642
D61859.1795448964.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61859.1795448964.diff
View Options
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -4996,8 +4996,10 @@
{
int error;
- if (efbuf->remainder == 0)
+ if (efbuf->remainder == 0) {
+ vrele(vp);
return (ENOMEM);
+ }
if (efbuf->pdp != NULL)
PWDDESC_XUNLOCK(efbuf->pdp);
export_vnode_to_kinfo(vp, fd, fflags, &efbuf->kif, efbuf->flags);
@@ -5022,24 +5024,13 @@
struct export_fd_buf *efbuf;
struct vnode *cttyvp, *textvp, *tracevp;
struct pwd *pwd;
+ struct session *sess;
int error, i;
cap_rights_t rights;
PROC_LOCK_ASSERT(p, MA_OWNED);
+ _PHOLD(p);
- /* ktrace vnode */
- tracevp = ktr_get_tracevp(p, true);
- /* text vnode */
- textvp = p->p_textvp;
- if (textvp != NULL)
- vrefact(textvp);
- /* Controlling tty. */
- cttyvp = NULL;
- if (p->p_pgrp != NULL && p->p_pgrp->pg_session != NULL) {
- cttyvp = p->p_pgrp->pg_session->s_ttyvp;
- if (cttyvp != NULL)
- vrefact(cttyvp);
- }
fdp = fdhold(p);
pdp = pdhold(p);
PROC_UNLOCK(p);
@@ -5052,15 +5043,43 @@
efbuf->flags = flags;
error = 0;
- if (tracevp != NULL)
+ PROC_LOCK(p);
+ tracevp = ktr_get_tracevp(p, true);
+ if (tracevp != NULL) {
+ PROC_UNLOCK(p);
error = export_vnode_to_sb(tracevp, KF_FD_TYPE_TRACE,
FREAD | FWRITE, efbuf);
- if (error == 0 && textvp != NULL)
+ PROC_LOCK(p);
+ }
+ if (error == 0 && (textvp = p->p_textvp) != NULL) {
+ vrefact(textvp);
+ PROC_UNLOCK(p);
error = export_vnode_to_sb(textvp, KF_FD_TYPE_TEXT, FREAD,
efbuf);
- if (error == 0 && cttyvp != NULL)
- error = export_vnode_to_sb(cttyvp, KF_FD_TYPE_CTTY,
- FREAD | FWRITE, efbuf);
+ PROC_LOCK(p);
+ }
+ if (error == 0) {
+ PROC_UNLOCK(p);
+ sx_slock(&proctree_lock);
+ sess = p->p_session;
+ SESS_LOCK(sess);
+ PROC_LOCK(p);
+ if (p->p_pgrp != NULL && p->p_pgrp->pg_session != NULL &&
+ (cttyvp = p->p_pgrp->pg_session->s_ttyvp) != NULL) {
+ vrefact(cttyvp);
+ PROC_UNLOCK(p);
+ SESS_UNLOCK(sess);
+ sx_sunlock(&proctree_lock);
+ error = export_vnode_to_sb(cttyvp, KF_FD_TYPE_CTTY,
+ FREAD | FWRITE, efbuf);
+ PROC_LOCK(p);
+ } else {
+ SESS_UNLOCK(sess);
+ sx_sunlock(&proctree_lock);
+ }
+ }
+ _PRELE(p);
+ PROC_UNLOCK(p);
if (error != 0 || pdp == NULL || fdp == NULL)
goto fail;
efbuf->fdp = fdp;
@@ -5095,10 +5114,10 @@
}
}
PWDDESC_XUNLOCK(pdp);
- if (error != 0)
- goto fail;
if (pwd != NULL)
pwd_drop(pwd);
+ if (error != 0)
+ goto fail;
FILEDESC_SLOCK(fdp);
if (refcount_load(&fdp->fd_refcnt) == 0)
goto skip;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 23, 3:49 PM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41934282
Default Alt Text
D61859.1795448964.diff (2 KB)
Attached To
Mode
D61859: Fix several leaks in kern_proc_filedesc_out()
Attached
Detach File
Event Timeline