public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* suggested patch to allow user to access their own file...
@ 2020-12-29 12:25 L.A. Walsh
  2021-01-04 17:08 ` Brian Foster
  2021-01-09 21:13 ` Dave Chinner
  0 siblings, 2 replies; 6+ messages in thread
From: L.A. Walsh @ 2020-12-29 12:25 UTC (permalink / raw)
  To: xfs-oss

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xfs_ioctl-perm.diff --]
[-- Type: text/x-diff; name="xfs_ioctl-perm.diff", Size: 768 bytes --]

--- 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;
 
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
+	if (!capable(CAP_SYS_ADMIN)) conditional_perm=1;
 
 	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;
+	}
+
 	/* Restrict xfs_open_by_handle to directories & regular files. */
 	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) {
 		error = -EPERM;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-09 21:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox