Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16209

Re: process substitution fd lifetime race condition

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From "Jason A. Donenfeld" <Jason@zx2c4.com>
Newsgroups gnu.bash.bug
Subject Re: process substitution fd lifetime race condition
Date Mon, 20 Apr 2020 16:02:39 -0600
Lines 24
Approved bug-bash@gnu.org
Message-ID <mailman.844.1587420178.3066.bug-bash@gnu.org> (permalink)
References <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> <CAHmME9p_n_W6721mY4=MWpKJvDTNsvEQbA9EB5chsrwyOzSgqw@mail.gmail.com> <e6560e95-7d3f-4651-ebbb-147c82c2dbd8@case.edu> <CAHmME9pSGcv6-b6oDjJzDi5ar7a6o19-MKBix4UofQn=khRvKg@mail.gmail.com> <01e85de9-95ef-20fd-7221-a54a0a2a304a@case.edu> <CAHmME9rRU5PAwoDrpdX-2JhwEB16S+w1QZQLJ1NKb4+AkguWyw@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1587420179 18408 209.51.188.17 (20 Apr 2020 22:02:59 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To Chester Ramey <chet.ramey@case.edu>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=I9s6JE5Grmt0d39cpB0nWZS6VDA=; b=Nk1LOF wJd0R3dfSBzNABAqnW5t6LhGzRsDxOknpVYTdYOvrnRHrTlwLkeqKAkUv4gpRNZI cBeIWv1keyx3MFDfat2ggXHukW+OiQ4bnsJ/ctzutvdA3py6LH0b02vGa9vkZZn2 YcYurZMAl7XCcPa20jMn8pDVbkQHXQKsonBnxUqHWp8RhiNp8eKZjbYuGcJGXhSf YIBJrdQUFBTTRbFV5A+UPUDXGgEMDZlPhaA8m5aeCPyS9wbysEllJ/0qcwXaoPbJ eGHT2KAPiXJKNKjKtJb4kv/tyc4IFnnuxZnn6ZsBQ+Hj/rFnXqxK/BJhmv19C5hA /OqW1xDDxQdbIQ3g==
X-Gm-Message-State AGi0Puaau2Bpc0wyuacTD8g5dT6QHVC0684H9bEv6ELD4qFCMEPAqC7r H7WDDsugZZn69VDXmPZ/nx5vjScwSP6V8HgzB0A=
X-Google-Smtp-Source APiQypL5lgCE89mzeGn8cGD3dkrs26fu7j7xG+xogOeS96VvYO4cPxiRxGfOwhOzqmshZ2+1BwEerOdWZuSxdhKG7A8=
X-Received by 2002:a02:b88e:: with SMTP id p14mr12062120jam.36.1587420170517; Mon, 20 Apr 2020 15:02:50 -0700 (PDT)
In-Reply-To <01e85de9-95ef-20fd-7221-a54a0a2a304a@case.edu>
X-Gmail-Original-Message-ID <CAHmME9rRU5PAwoDrpdX-2JhwEB16S+w1QZQLJ1NKb4+AkguWyw@mail.gmail.com>
Received-SPF pass client-ip=192.95.5.64; envelope-from=Jason@zx2c4.com; helo=mail.zx2c4.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/04/20 17:01:28
X-ACL-Warn Detected OS = Linux 3.11 and newer
X-Received-From 192.95.5.64
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAHmME9rRU5PAwoDrpdX-2JhwEB16S+w1QZQLJ1NKb4+AkguWyw@mail.gmail.com>
X-Mailman-Original-References <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> <CAHmME9p_n_W6721mY4=MWpKJvDTNsvEQbA9EB5chsrwyOzSgqw@mail.gmail.com> <e6560e95-7d3f-4651-ebbb-147c82c2dbd8@case.edu> <CAHmME9pSGcv6-b6oDjJzDi5ar7a6o19-MKBix4UofQn=khRvKg@mail.gmail.com> <01e85de9-95ef-20fd-7221-a54a0a2a304a@case.edu>
Xref csiph.com gnu.bash.bug:16209

Show key headers only | View raw


On Mon, Apr 20, 2020 at 3:58 PM Chet Ramey <chet.ramey@case.edu> wrote:
> OK, good. It was either that or closing the fd after reaping the child
> process -- I couldn't tell 100% from the system call trace.

The latter is an interesting possibility. I assume SIGCHLD comes in
through a signal handler, so it's asynchronous, which means it could
race. But in the case that fd 63 hasn't already been closed, wont
subsequent fifos use different fds, which means the signal handler
doesn't need to synchronize with anything?

Either way, glad to hear that your patch fixes the issue. Looking
forward to the release of 5.0.017.

It seems like process substitution fifo lifetime is really tricky. You
can't really reference track, since the path is just a string that
could be manipulated. So how do you know when it's safe to clean up
that fd and that nobody is using it? I suppose you have a set of
lexical heuristics that fit for "most common cases"? And I guess those
are undocumented and can't really be relied upon since evidently they
do change.

I wonder if one general improvement would be to never close a fifo if
it has data in it, but it's read position is still at zero.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: process substitution fd lifetime race condition "Jason A. Donenfeld" <Jason@zx2c4.com> - 2020-04-20 16:02 -0600

csiph-web