All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 0/2] overlayfs multiple mount protection
Date: Tue, 23 May 2017 12:50:31 +0300	[thread overview]
Message-ID: <1495533033-22367-1-git-send-email-amir73il@gmail.com> (raw)

Miklos,

I've implemented verification that lower root dir matches the origin file
handle stored at upper root dir with the verify_lower mount option [1].

As you correctly noted, before we move on to verifying that upper dir
'belongs to' lower dir and that index dir 'belongs to' upper dir for the
case of mounting not at the same time, we first need to cover the case of
mount at the same time.

This patch set provides protection against reuse of upperdir and workdir
by two different overlay instances at the same time, e.g.:

root@kvm-xfstests:~/unionmount-testsuite# mount -t overlay
overlay on /mnt type overlay (rw,noatime,lowerdir=/lower,upperdir=/upper/0,workdir=/upper/work)
root@kvm-xfstests:~/unionmount-testsuite# mount -t overlay overlay /backup/ -o rw,noatime,lowerdir=/lower,upperdir=/upper/0,workdir=/upper/work
overlayfs: upperdir in-use by another overlay mount?
mount: overlay is already mounted or /backup busy
       overlay is already mounted on /mnt
root@kvm-xfstests:~/unionmount-testsuite# mkdir /upper/1
root@kvm-xfstests:~/unionmount-testsuite# mount -t overlay overlay /snapshot/ -o rw,noatime,lowerdir=/lower,upperdir=/upper/1,workdir=/upper/work
overlayfs: workdir in-use by another overlay mount?
mount: overlay is already mounted or /snapshot busy
       overlay is already mounted on /mnt

It also provides protection against removal of workdir just after mount,
which would have caused failures to copy up:

root@kvm-xfstests:~/unionmount-testsuite# rmdir /upper/work/work/
rmdir: failed to remove '/upper/work/work/': Device or resource busy

[1] https://github.com/amir73il/linux/commits/ovl-verify-dir

Amir Goldstein (2):
  vfs: introduce inode 'inuse' lock
  ovl: get exclusive ownership on upper/work dirs

 fs/btrfs/ioctl.c     |  3 +++
 fs/inode.c           | 40 ++++++++++++++++++++++++++++++
 fs/namei.c           |  3 +++
 fs/overlayfs/super.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++---
 include/linux/fs.h   | 16 ++++++++++++
 5 files changed, 129 insertions(+), 3 deletions(-)

-- 
2.7.4

             reply	other threads:[~2017-05-23  9:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23  9:50 Amir Goldstein [this message]
2017-05-23  9:50 ` [PATCH 1/2] vfs: introduce inode 'inuse' lock Amir Goldstein
2017-05-31 10:09   ` Miklos Szeredi
2017-05-31 13:54     ` Amir Goldstein
2017-05-31 14:30       ` Miklos Szeredi
2017-05-31 15:16         ` Amir Goldstein
2017-05-23  9:50 ` [PATCH 2/2] ovl: get exclusive ownership on upper/work dirs Amir Goldstein
2017-05-31 10:18   ` Miklos Szeredi
2017-05-31 12:47     ` Amir Goldstein
2017-05-31 13:05       ` Amir Goldstein
2017-05-31 13:24         ` Miklos Szeredi

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=1495533033-22367-1-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --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.