2004-04-14 00:40:11

by Chris Wright

[permalink] [raw]
Subject: mq_open() and close_on_exec?

SUSv3 doesn't seem to specify one way or the other. I don't have the
POSIX specs, and the old docs I have suggest that mq_open() creates an
object which is to be closed upon exec. Anyone have a clue if this is
actually required? Patch below sets this as default (if indeed it's
valid/required).

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net

===== ipc/mqueue.c 1.6 vs edited =====
--- 1.6/ipc/mqueue.c Mon Apr 12 10:54:17 2004
+++ edited/ipc/mqueue.c Tue Apr 13 16:05:36 2004
@@ -641,6 +641,7 @@
goto out_putfd;
}

+ set_close_on_exec(fd, 1);
fd_install(fd, filp);
goto out_upsem;


2004-04-14 04:48:34

by Manfred Spraul

[permalink] [raw]
Subject: Re: mq_open() and close_on_exec?

Chris Wright wrote:

>SUSv3 doesn't seem to specify one way or the other. I don't have the
>POSIX specs, and the old docs I have suggest that mq_open() creates an
>object which is to be closed upon exec. Anyone have a clue if this is
>actually required? Patch below sets this as default (if indeed it's
>valid/required).
>
>
Did you test what other unices do? I think the patch is correct - at
least solaris implements message queues in user space, and then an exec
should close everything.

--
Manfred

2004-04-14 06:13:30

by Jakub Jelinek

[permalink] [raw]
Subject: Re: mq_open() and close_on_exec?

On Tue, Apr 13, 2004 at 05:40:05PM -0700, Chris Wright wrote:
> SUSv3 doesn't seem to specify one way or the other. I don't have the
> POSIX specs, and the old docs I have suggest that mq_open() creates an
> object which is to be closed upon exec. Anyone have a clue if this is
> actually required? Patch below sets this as default (if indeed it's
> valid/required).

I think it is valid and required:
http://www.opengroup.org/onlinepubs/007904975/functions/exec.html

^[MSG] [Option Start] All open message queue descriptors in the calling process shall be closed, as described in
mq_close() . [Option End]

I'll add a new test for this into glibc testsuite.

Jakub

2004-04-14 16:53:13

by Chris Wright

[permalink] [raw]
Subject: Re: mq_open() and close_on_exec?

* Jakub Jelinek ([email protected]) wrote:
> I think it is valid and required:
> http://www.opengroup.org/onlinepubs/007904975/functions/exec.html
>
> ^[MSG] [Option Start] All open message queue descriptors in the calling process shall be closed, as described in
> mq_close() . [Option End]
>
> I'll add a new test for this into glibc testsuite.

Thanks, I managed to miss that in the spec.

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net

2004-04-14 16:50:53

by Chris Wright

[permalink] [raw]
Subject: Re: mq_open() and close_on_exec?

* Manfred Spraul ([email protected]) wrote:
> Chris Wright wrote:
> >SUSv3 doesn't seem to specify one way or the other. I don't have the
> >POSIX specs, and the old docs I have suggest that mq_open() creates an
> >object which is to be closed upon exec. Anyone have a clue if this is
> >actually required? Patch below sets this as default (if indeed it's
> >valid/required).
> >
> Did you test what other unices do? I think the patch is correct - at
> least solaris implements message queues in user space, and then an exec
> should close everything.

No, I haven't. Looks like I missed the SUSv3 specification that indeed
requires closing on exec. So, I believe the patch is needed.

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net