All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux-Fsdevel <linux-fsdevel@vger.kernel.org>,
	"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>
Subject: Re: Can ovl_drop_write() be called earlier in ovl_dentry_open()
Date: Mon, 1 Jun 2015 16:22:40 +0200	[thread overview]
Message-ID: <CAJfpegsuVxOAGenfxeSsQEKZR+_+OfR6uOxm2USGvbAuCWRhvg@mail.gmail.com> (raw)
In-Reply-To: <21902.1433166736@warthog.procyon.org.uk>

On Mon, Jun 1, 2015 at 3:52 PM, David Howells <dhowells@redhat.com> wrote:
> In ovl_dentry_open(), ovl_drop_write() is called after vfs_open() - but is
> this actually necessary?  Can't we just drop it post-copyup?  After all,
> that's all we wanted the write lock for, right?

Hmm,  that could result in a race where remount r/o of upper fs comes
in between copy-up and vfs_open() so copy-up succeeds but the actual
open fails.  It's harmless, though, and not  very likely.  So I guess
your patch is OK.

Thanks,
Miklos




>
> David
> ---
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -356,16 +356,14 @@ static int ovl_dentry_open(struct dentry *dentry, struct inode *inode,
>                         err = ovl_copy_up_last(dentry, NULL, true);
>                 else
>                         err = ovl_copy_up(dentry);
> +               ovl_drop_write(dentry);
>                 if (err)
> -                       goto out_drop_write;
> +                       goto out;
>
>                 ovl_path_upper(dentry, &realpath);
>         }
>
>         err = vfs_open(&realpath, d_backing_inode(realpath.dentry), file, cred);
> -out_drop_write:
> -       if (want_write)
> -               ovl_drop_write(dentry);
>  out:
>         return err;
>  }

  parent reply	other threads:[~2015-06-01 14:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 13:52 Can ovl_drop_write() be called earlier in ovl_dentry_open() David Howells
2015-06-01 14:21 ` [PATCH] overlay: Call ovl_drop_write() " David Howells
2015-06-01 14:22 ` Miklos Szeredi [this message]
2015-06-01 15:45 ` Can ovl_drop_write() be called " David Howells
2015-06-01 15:51   ` Miklos Szeredi
2015-06-01 15:53   ` David Howells

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=CAJfpegsuVxOAGenfxeSsQEKZR+_+OfR6uOxm2USGvbAuCWRhvg@mail.gmail.com \
    --to=miklos@szeredi.hu \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --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.