summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-06-14 12:41:21 +0000
committerpjd <pjd@FreeBSD.org>2012-06-14 12:41:21 +0000
commit6634e42976a701b01eb967c1b46dc3f27ac64ef0 (patch)
treef7f1f37eb1c02ce5ea46acb6f4672c992a1f1cf7 /sys/kern/kern_descrip.c
parent841890f62ae87ce2a3baa7dbdf49dc8494db620a (diff)
downloadFreeBSD-src-6634e42976a701b01eb967c1b46dc3f27ac64ef0.zip
FreeBSD-src-6634e42976a701b01eb967c1b46dc3f27ac64ef0.tar.gz
When we are closing capabilities during exec, we want to call mq_fdclose()
on the underlying object and not on the capability itself. Similar bug was fixed in r236853. MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 5a9f9e1..09343fa 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -2025,7 +2025,7 @@ void
fdcloseexec(struct thread *td)
{
struct filedesc *fdp;
- struct file *fp;
+ struct file *fp, *fp_object;
int i;
/* Certain daemons might not have file descriptors. */
@@ -2050,8 +2050,14 @@ fdcloseexec(struct thread *td)
fdp->fd_ofileflags[i] = 0;
fdunused(fdp, i);
knote_fdclose(td, i);
- if (fp->f_type == DTYPE_MQUEUE)
- mq_fdclose(td, i, fp);
+ /*
+ * When we're closing an fd with a capability, we need
+ * to notify mqueue if the underlying object is of type
+ * mqueue.
+ */
+ (void)cap_funwrap(fp, 0, &fp_object);
+ if (fp_object->f_type == DTYPE_MQUEUE)
+ mq_fdclose(td, i, fp_object);
FILEDESC_XUNLOCK(fdp);
(void) closef(fp, td);
FILEDESC_XLOCK(fdp);
OpenPOWER on IntegriCloud