From: Mike Snitzer <snitzer@redhat.com>
To: Seth Forshee <seth.forshee@canonical.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Kent Overstreet <kent.overstreet@gmail.com>,
Alasdair Kergon <agk@redhat.com>,
dm-devel@redhat.com, Neil Brown <neilb@suse.com>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.com>, Jeff Layton <jlayton@poochiereds.net>,
"J. Bruce Fields" <bfields@fieldses.org>,
Serge Hallyn <serge.hallyn@canonical.com>,
Andy Lutomirski <luto@amacapital.net>,
linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov,
linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org
Subject: Re: [PATCH 1/5] fs: Verify access of user towards block device file when mounting
Date: Wed, 30 Sep 2015 19:42:15 -0400 [thread overview]
Message-ID: <20150930234215.GA24127@redhat.com> (raw)
In-Reply-To: <1443644116-41366-2-git-send-email-seth.forshee@canonical.com>
On Wed, Sep 30 2015 at 4:15pm -0400,
Seth Forshee <seth.forshee@canonical.com> wrote:
> When mounting a filesystem on a block device there is currently
> no verification that the user has appropriate access to the
> device file passed to mount. This has not been an issue so far
> since the user in question has always been root, but this must
> be changed before allowing unprivileged users to mount in user
> namespaces.
>
> To fix this, add an argument to lookup_bdev() to specify the
> required permissions. If the mask of permissions is zero, or
> if the user has CAP_SYS_ADMIN, the permission check is skipped,
> otherwise the lookup fails if the user does not have the
> specified access rights for the inode at the supplied path.
>
> Callers associated with mounting are updated to pass permission
> masks to lookup_bdev() so that these mounts will fail for an
> unprivileged user who lacks permissions for the block device
> inode. All other callers pass 0 to maintain their current
> behaviors.
>
> Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
> ---
> drivers/md/bcache/super.c | 2 +-
> drivers/md/dm-table.c | 2 +-
> drivers/mtd/mtdsuper.c | 6 +++++-
> fs/block_dev.c | 18 +++++++++++++++---
> fs/quota/quota.c | 2 +-
> include/linux/fs.h | 2 +-
> 6 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index e76ed003769e..35bb3ea4cbe2 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -380,7 +380,7 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode,
> BUG_ON(!t);
>
> /* convert the path to a device */
> - bdev = lookup_bdev(path);
> + bdev = lookup_bdev(path, 0);
> if (IS_ERR(bdev)) {
> dev = name_to_dev_t(path);
> if (!dev)
Given dm_get_device() is passed @mode why not have it do something like
you did in blkdev_get_by_path()? e.g.:
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 26cee058dc02..54d94cd64577 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1394,9 +1394,14 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
> void *holder)
> {
> struct block_device *bdev;
> + int perm = 0;
> int err;
>
> - bdev = lookup_bdev(path);
> + if (mode & FMODE_READ)
> + perm |= MAY_READ;
> + if (mode & FMODE_WRITE)
> + perm |= MAY_WRITE;
> + bdev = lookup_bdev(path, perm);
> if (IS_ERR(bdev))
> return bdev;
>
next prev parent reply other threads:[~2015-09-30 23:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 20:15 [PATCH 0/5] User namespace mount updates Seth Forshee
2015-09-30 20:15 ` [PATCH 1/5] fs: Verify access of user towards block device file when mounting Seth Forshee
2015-09-30 23:42 ` Mike Snitzer [this message]
2015-10-01 12:55 ` Seth Forshee
2015-10-01 13:40 ` Mike Snitzer
2015-10-01 14:41 ` Seth Forshee
2015-10-08 15:41 ` Seth Forshee
2015-10-01 15:55 ` Eric W. Biederman
2015-10-01 23:07 ` Jan Kara
2015-10-05 14:26 ` Seth Forshee
2015-10-01 15:40 ` Eric W. Biederman
2015-10-01 15:55 ` Seth Forshee
2015-09-30 20:15 ` [PATCH 2/5] fs: Treat foreign mounts as nosuid Seth Forshee
2015-09-30 20:15 ` [PATCH 3/5] selinux: Add support for unprivileged mounts from user namespaces Seth Forshee
2015-09-30 20:15 ` [PATCH 4/5] userns: Replace in_userns with current_in_userns Seth Forshee
2015-09-30 20:15 ` [PATCH 5/5] Smack: Handle labels consistently in untrusted mounts Seth Forshee
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=20150930234215.GA24127@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=bfields@fieldses.org \
--cc=computersforpeace@gmail.com \
--cc=dm-devel@redhat.com \
--cc=dwmw2@infradead.org \
--cc=ebiederm@xmission.com \
--cc=jack@suse.com \
--cc=jlayton@poochiereds.net \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=neilb@suse.com \
--cc=selinux@tycho.nsa.gov \
--cc=serge.hallyn@canonical.com \
--cc=seth.forshee@canonical.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).