All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"security@kernel.org" <security@kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Willy Tarreau <w@1wt.eu>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	Brad Spengler <spender@grsecurity.net>
Subject: Re: [PATCH] vfs: Tighten up linkat(..., AT_EMPTY_PATH)
Date: Wed, 21 Aug 2013 20:47:06 +0200	[thread overview]
Message-ID: <20130821184706.GA20591@redhat.com> (raw)
In-Reply-To: <CALCETrXtJBDqkvO3mHxDrHL3whCWX_B-LAXOnue7r90nyyWY_A@mail.gmail.com>

On 08/21, Andy Lutomirski wrote:
>
> On Wed, Aug 21, 2013 at 11:20 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> > Can't really comment the patch, just a nit:
> >
> > On 08/21, Andy Lutomirski wrote:
> >>
> >> +static bool may_flink(const struct path *path)
> >> +{
> >> +     bool ret;
> >> +     struct inode *inode = path->dentry->d_inode;
> >> +
> >> +     /*
> >> +      * This is racy: I_LINKABLE could be cleared between this check
> >> +      * and the actual link operation.
> >
> > OK,
> >
> >> +     spin_lock(&inode->i_lock);
> >> +     ret = !!(inode->i_state & I_LINKABLE);
> >> +     spin_unlock(&inode->i_lock);
> >
> > so why do we need to take a lock ?
> >
>
> We probably don't.  But other accesses to this field take that lock,

Not if you only need to check ->i_lock,

> (In principle, someone could take the lock, write I_LINKABLE, clear
> it, and unlock, and we'd get confused if we didn't take the lock
> ourselves.)

Or it can be cleared right after we drop i_lock, I do not think there
is any difference.

But OK, I won't argue.

Oleg.

      reply	other threads:[~2013-08-21 18:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CALCETrXMQdjRyvP8RHOd5xjciurS7-hKUOExvkvQ1RWmdRdypA@mail.gmail.com>
2013-08-21 18:05 ` [PATCH] vfs: Tighten up linkat(..., AT_EMPTY_PATH) Andy Lutomirski
2013-08-21 18:20   ` Oleg Nesterov
2013-08-21 18:43     ` Andy Lutomirski
2013-08-21 18:47       ` Oleg Nesterov [this message]

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=20130821184706.GA20591@redhat.com \
    --to=oleg@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=security@kernel.org \
    --cc=spender@grsecurity.net \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=w@1wt.eu \
    /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.