From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann Droneaud Subject: Re: [PATCH] fs: clear close-on-exec flag as part of put_unused_fd() Date: Thu, 12 Dec 2013 11:45:50 +0100 Message-ID: <1386845150.9959.3.camel@localhost.localdomain> References: <1386796107-4197-1-git-send-email-ydroneaud@opteya.com> <20131211223634.GA13828@mguzik.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yann Droneaud To: Mateusz Guzik Return-path: Received: from smtp6-g21.free.fr ([212.27.42.6]:48568 "EHLO smtp6-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382Ab3LLKqF (ORCPT ); Thu, 12 Dec 2013 05:46:05 -0500 In-Reply-To: <20131211223634.GA13828@mguzik.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi, Le mercredi 11 d=C3=A9cembre 2013 =C3=A0 23:36 +0100, Mateusz Guzik a =C3= =A9crit : > On Wed, Dec 11, 2013 at 10:08:27PM +0100, Yann Droneaud wrote: > > @@ -806,8 +803,6 @@ static int do_dup2(struct files_struct *files, > > __set_open_fd(fd, fdt); > > if (flags & O_CLOEXEC) > > __set_close_on_exec(fd, fdt); > > - else > > - __clear_close_on_exec(fd, fdt); > > spin_unlock(&files->file_lock); > > =20 > > if (tofree) >=20 > From my reading this will break at least the following: > fd =3D open(..., .. | O_CLOEXEC); > dup2(whatever, fd); >=20 > now fd has O_CLOEXEC even though it should not >=20 Thanks for the review. You're right. I've misunderstood the portion of the code handling the case where the destination fd is already marked as used: -EBUSY is only returned when the file descriptor is allocaged but not yet installed. So close-on-exec flag must be cleared in do_dup2(). Regards. --=20 Yann Droneaud OPTEYA -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html