[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1435640524.4110.116.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Tue, 30 Jun 2015 07:02:04 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Al Viro <viro@...IV.linux.org.uk>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Dmitry Vyukov <dvyukov@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] fs/file.c: __fget() and dup2() atomicity rules
On Mon, 2015-06-29 at 18:46 +0100, Al Viro wrote:
> On Mon, Jun 29, 2015 at 05:10:30PM +0200, Eric Dumazet wrote:
> > From: Eric Dumazet <edumazet@...gle.com>
> >
> > __fget() makes sure a file refcount is not zero before
> > taking a reference. It should also fetch again file pointer
> > in order to respect dup2() atomicity requirements.
> >
> > It should either read a NULL pointer or a file on which
> > a refcount can be taken.
>
> Hmm... The problem is real, but I wonder if one could trigger a long
> spin there...
I do not believe we can spin a long time.
By the time do_dup2() calls filp_close(tofree, files), we already have a
stable fdt->fd[fd], because of spin_unlock(&files->file_lock) was called
before filp_close()
A loop would require threads doing dup2() calls like crazy on same
destination fd.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists