Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 23 Mar 2013 21:45:26 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: proposed popen replacement using posix_spawn

On Sat, Mar 23, 2013 at 09:40:57PM -0400, Rich Felker wrote:
> 	/* Remove close-on-exec flag if dup2 will be a no-op in the child */
> 	if (p[1-op] == 1-op) fcntl(1-op, F_SETFD, 0);

This part is wrong; it creates a file descriptor leak race condition
in the parent. The only solution I can see is that the parent must
ensure p[1-op]!=1-op before calling posix_spawn. The easiest way to do
that is to move p[1-op] to a new fd number using F_DUPFD_CLOEXEC when
this happens, and fail the entire operation if this fails. I'll update
the code accordingly.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.