From: Brian Foster <bfoster@redhat.com>
To: "L.A. Walsh" <xfs@tlinx.org>
Cc: xfs-oss <linux-xfs@vger.kernel.org>
Subject: Re: suggested patch to allow user to access their own file...
Date: Mon, 4 Jan 2021 12:08:15 -0500 [thread overview]
Message-ID: <20210104170815.GB254939@bfoster> (raw)
In-Reply-To: <5FEB204B.9090109@tlinx.org>
On Tue, Dec 29, 2020 at 04:25:47AM -0800, L.A. Walsh wrote:
> xfs_io checks for CAP_SYS_ADMIN in order to open a
> file_by_inode -- however, if the file one is opening
> is owned by the user performing the call, the call should
> not fail.
>
> (i.e. it opens the user's own file).
>
> patch against 5.10.2 is attached.
>
> It gets rid of some unnecessary error messages if you
> run xfs_restore to restore one of your own files.
>
The current logic seems to go a ways back. Can you or somebody elaborate
on whether there's any risks with loosening the permissions as such?
E.g., any reason we might not want to allow regular users to perform
handle lookups, etc.? If not, should some of the other _by_handle() ops
get similar treatment?
> --- fs/xfs/xfs_ioctl.c 2020-12-22 21:11:02.000000000 -0800
> +++ fs/xfs/xfs_ioctl.c 2020-12-29 04:14:48.681102804 -0800
> @@ -194,15 +194,21 @@
> struct dentry *dentry;
> fmode_t fmode;
> struct path path;
> + bool conditional_perm = 0;
Variable name alignment and I believe we try to use true/false for
boolean values.
>
> - if (!capable(CAP_SYS_ADMIN))
> - return -EPERM;
> + if (!capable(CAP_SYS_ADMIN)) conditional_perm=1;
This should remain two lines..
>
> dentry = xfs_handlereq_to_dentry(parfilp, hreq);
> if (IS_ERR(dentry))
> return PTR_ERR(dentry);
> inode = d_inode(dentry);
>
> + /* only allow user access to their own file */
> + if (conditional_perm && !inode_owner_or_capable(inode)) {
> + error = -EPERM;
> + goto out_dput;
> + }
> +
... but then again, is there any reason we couldn't just move the
capable() check down to this hunk and avoid the new variable?
Brian
> /* Restrict xfs_open_by_handle to directories & regular files. */
> if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) {
> error = -EPERM;
next prev parent reply other threads:[~2021-01-04 17:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 12:25 suggested patch to allow user to access their own file L.A. Walsh
2021-01-04 17:08 ` Brian Foster [this message]
2021-01-04 18:44 ` Darrick J. Wong
[not found] ` <5FF3796E.5050409@tlinx.org>
2021-01-04 23:15 ` Darrick J. Wong
2021-01-05 0:03 ` L A Walsh
2021-01-09 21:13 ` Dave Chinner
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=20210104170815.GB254939@bfoster \
--to=bfoster@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=xfs@tlinx.org \
/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