Skip to contentSkip to conversation

xfs: change the immutable in xfs_open_by_handle

PATCH In review Mark Tinguely 4 participants 6 messages Sep 10, 2013 – Sep 11, 2013 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: change the immutable in xfs_open_by_handle

This patch allows clients like DMF to modify an immutable file without changing the immutable capability on the file, which would expose the file to change.

This patch is restricted to holders of the CAP_LINUX_IMMUTABLE, so no addition security risk has been introduced.

---
 fs/xfs/xfs_ioctl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/xfs/xfs_ioctl.c +3 -1
Index: b/fs/xfs/xfs_ioctl.c
===================================================================
@@ -237,7 +237,9 @@ xfs_open_by_handle(
 		goto out_dput;
 	}
 
-	if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
+	if ((permflag & FMODE_WRITE) &&
+	    IS_IMMUTABLE(inode) &&
+	    !capable(CAP_LINUX_IMMUTABLE)) {
 		error = -XFS_ERROR(EACCES);
 		goto out_dput;
 	}

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 18 lines · Mark Tinguely

This patch allows clients like DMF to modify an immutable file without changing the immutable capability on the file, which would expose the file to change.

This patch is restricted to holders of the CAP_LINUX_IMMUTABLE, so no addition security risk has been introduced.

---
 fs/xfs/xfs_ioctl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: b/fs/xfs/xfs_ioctl.c
===================================================================

fs/xfs/xfs_ioctl.c xfs_open_by_handle( · line 240

Quoted 5 lines
fs/xfs/xfs_ioctl.c +1 -1
@@ -237,7 +237,9 @@ xfs_open_by_handle(
 		goto out_dput;
 	}
 
-	if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
+	if ((permflag & FMODE_WRITE) &&

Why the conversion from fmode to permflag? At minimum, this will probably throw sparse warnings for comparing a FMODE_* flag against a variable that is not a fmode_t....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 29 lines · Dave Chinner
Quoted 18 lines · Mark Tinguely

This patch allows clients like DMF to modify an immutable file without changing the immutable capability on the file, which would expose the file to change.

This patch is restricted to holders of the CAP_LINUX_IMMUTABLE, so no addition security risk has been introduced.

---
  fs/xfs/xfs_ioctl.c |    4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Index: b/fs/xfs/xfs_ioctl.c
===================================================================

fs/xfs/xfs_ioctl.c xfs_open_by_handle( · line 240

Quoted 5 lines
fs/xfs/xfs_ioctl.c +1 -1
@@ -237,7 +237,9 @@ xfs_open_by_handle(
  		goto out_dput;
  	}
 
-	if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
+	if ((permflag & FMODE_WRITE)&&

Why the conversion from fmode to permflag? At minimum, this will probably throw sparse warnings for comparing a FMODE_* flag against a variable that is not a fmode_t....

Quoted 3 lines

Cheers,

Dave.

Yes, my mistake - a case of posting a Linux 3.0.X based patch.

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
In reply to Mark Tinguely
Quoted 6 lines · Mark Tinguely

This patch allows clients like DMF to modify an immutable file without changing the immutable capability on the file, which would expose the file to change.

This patch is restricted to holders of the CAP_LINUX_IMMUTABLE, so no addition security risk has been introduced.

The immutable flag means that the file can't be modified, and CAP_LINUX_IMMUTABLE allows setting/removing that restriction, but not ignoring it.

So: NAK, this is a change in semantics and long-standing behaviour.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Mark Tinguely

This patch allows clients like DMF to modify an immutable file without changing the immutable capability on the file, which would expose the file to change.

Quoted 9 lines
Quoted 2 lines

This patch is restricted to holders of the CAP_LINUX_IMMUTABLE, so no addition security risk has been introduced.

The immutable flag means that the file can't be modified, and CAP_LINUX_IMMUTABLE allows setting/removing that restriction, but not ignoring it.

So: NAK, this is a change in semantics and long-standing behaviour.

As you said, the CAP_LINUX_IMMUTABLE allows the holder of the capability to turn on/off the restriction. The holder of CAP_LINUX_IMMUTABLE could turn off immutability, modify it and then turn it back on, but during that window, others could modify it too which may be more undesirable than changing the behavior.

--Mark.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
Quoted 13 lines · Mark Tinguely
Quoted 12 lines · Christoph Hellwig
Quoted 6 lines · Mark Tinguely

This patch allows clients like DMF to modify an immutable file without changing the immutable capability on the file, which would expose the file to change.

This patch is restricted to holders of the CAP_LINUX_IMMUTABLE, so no addition security risk has been introduced.

The immutable flag means that the file can't be modified, and CAP_LINUX_IMMUTABLE allows setting/removing that restriction, but not ignoring it.

Quoted 8 lines
Quoted 2 lines

So: NAK, this is a change in semantics and long-standing behaviour.

As you said, the CAP_LINUX_IMMUTABLE allows the holder of the capability to turn on/off the restriction. The holder of CAP_LINUX_IMMUTABLE could turn off immutability, modify it and then turn it back on, but during that window, others could modify it too which may be more undesirable than changing the behavior.

It's like setting a file you own "444" only because you CAN set it to 666 doesn't mean that the check should be short-circuted.

$ touch test
$ chmod 444 test
$ echo 'Hallo' > test
-bash: test: Permission denied
Signature · 6 lines
Matthias

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs