public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 6/7] xfs: check that eofblocks ioctl caller can write matched inodes
@ 2013-07-17 15:47 Dwight Engen
  2013-07-19  6:02 ` Dave Chinner
  0 siblings, 1 reply; 6+ messages in thread
From: Dwight Engen @ 2013-07-17 15:47 UTC (permalink / raw)
  To: xfs

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
---
 fs/xfs/xfs_fs.h     | 1 +
 fs/xfs/xfs_icache.c | 4 ++++
 fs/xfs/xfs_ioctl.c  | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 7eb4a5e..aee4b12 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -361,6 +361,7 @@ struct xfs_fs_eofblocks {
 #define XFS_EOF_FLAGS_GID		(1 << 2) /* filter by gid */
 #define XFS_EOF_FLAGS_PRID		(1 << 3) /* filter by project id */
 #define XFS_EOF_FLAGS_MINFILESIZE	(1 << 4) /* filter by min file size */
+#define XFS_EOF_FLAGS_PERM_CHECK	(1 << 5) /* check can write inode */
 #define XFS_EOF_FLAGS_VALID	\
 	(XFS_EOF_FLAGS_SYNC |	\
 	 XFS_EOF_FLAGS_UID |	\
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index d873ab9e..728283a 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1247,6 +1247,10 @@ xfs_inode_free_eofblocks(
 		if (!xfs_inode_match_id(ip, eofb))
 			return 0;
 
+		if (eofb->eof_flags & XFS_EOF_FLAGS_PERM_CHECK &&
+		    inode_permission(VFS_I(ip), MAY_WRITE))
+			return 0;
+
 		/* skip the inode if the file size is too small */
 		if (eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE &&
 		    XFS_ISIZE(ip) < eofb->eof_min_file_size)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index abbbdcf..e63e359 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1636,6 +1636,8 @@ xfs_file_ioctl(
 		    !gid_valid(keofb.eof_gid))
 			return XFS_ERROR(EINVAL);
 
+		keofb.eof_flags |= XFS_EOF_FLAGS_PERM_CHECK;
+
 		error = xfs_icache_free_eofblocks(mp, &keofb);
 		return -error;
 	}
-- 
1.8.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2013-07-24  3:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-17 15:47 [PATCH v4 6/7] xfs: check that eofblocks ioctl caller can write matched inodes Dwight Engen
2013-07-19  6:02 ` Dave Chinner
2013-07-19 16:13   ` Dwight Engen
2013-07-24  3:40     ` Dave Chinner
2013-07-22 16:00   ` Dwight Engen
2013-07-24  3:46     ` Dave Chinner

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