All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann Droneaud <ydroneaud@opteya.com>
To: Mateusz Guzik <mguzik@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yann Droneaud <ydroneaud@opteya.com>
Subject: Re: [PATCH] fs: clear close-on-exec flag as part of put_unused_fd()
Date: Thu, 12 Dec 2013 11:45:50 +0100	[thread overview]
Message-ID: <1386845150.9959.3.camel@localhost.localdomain> (raw)
In-Reply-To: <20131211223634.GA13828@mguzik.redhat.com>

Hi,

Le mercredi 11 décembre 2013 à 23:36 +0100, Mateusz Guzik a écrit :
> 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);
> >  
> >  	if (tofree)
> 
> From my reading this will break at least the following:
> fd = open(..., .. | O_CLOEXEC);
> dup2(whatever, fd);
> 
> now fd has O_CLOEXEC even though it should not
> 

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.

-- 
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

WARNING: multiple messages have this Message-ID (diff)
From: Yann Droneaud <ydroneaud@opteya.com>
To: Mateusz Guzik <mguzik@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yann Droneaud <ydroneaud@opteya.com>
Subject: Re: [PATCH] fs: clear close-on-exec flag as part of put_unused_fd()
Date: Thu, 12 Dec 2013 11:45:50 +0100	[thread overview]
Message-ID: <1386845150.9959.3.camel@localhost.localdomain> (raw)
In-Reply-To: <20131211223634.GA13828@mguzik.redhat.com>

Hi,

Le mercredi 11 décembre 2013 à 23:36 +0100, Mateusz Guzik a écrit :
> 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);
> >  
> >  	if (tofree)
> 
> From my reading this will break at least the following:
> fd = open(..., .. | O_CLOEXEC);
> dup2(whatever, fd);
> 
> now fd has O_CLOEXEC even though it should not
> 

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.

-- 
Yann Droneaud
OPTEYA



  parent reply	other threads:[~2013-12-12 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 21:08 [PATCH] fs: clear close-on-exec flag as part of put_unused_fd() Yann Droneaud
2013-12-11 22:36 ` Mateusz Guzik
2013-12-11 23:30   ` Al Viro
2013-12-12 11:36     ` Yann Droneaud
2013-12-12 11:57       ` [PATCH] fs: bits in .close_on_exec are only defined for matching bits in .open_fds bits Yann Droneaud
2013-12-12 10:45   ` Yann Droneaud [this message]
2013-12-12 10:45     ` [PATCH] fs: clear close-on-exec flag as part of put_unused_fd() Yann Droneaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386845150.9959.3.camel@localhost.localdomain \
    --to=ydroneaud@opteya.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mguzik@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.