linux_dsm_epyc7002/fs/btrfs
Jeff Mahoney 12fa8ec64f Btrfs: Add workaround for AppArmor changing remove_suid()
In openSUSE 10.3, AppArmor modifies remove_suid to take a struct path
rather than just a dentry. This patch tests that the kernel is openSUSE
10.3 or newer and adjusts the call accordingly.

Debian/Ubuntu with AppArmor applied will also need a similar patch.
Maintainers of btrfs under those distributions should build on this
patch or, alternatively, alter their package descriptions to add
-DREMOVE_SUID_PATH to the compiler command line.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
- --- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ b/compat.h	2008-02-06 16:46:13.000000000 -0500
@@ -0,0 +1,15 @@
+#ifndef _COMPAT_H_
+#define _COMPAT_H_
+
+
+/*
+ * Even if AppArmor isn't enabled, it still has different prototypes.
+ * Add more distro/version pairs here to declare which has AppArmor applied.
+ */
+#if defined(CONFIG_SUSE_KERNEL)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+# define REMOVE_SUID_PATH 1
+# endif
+#endif
+
+#endif /* _COMPAT_H_ */
- --- a/file.c	2008-02-06 11:37:39.000000000 -0500
+++ b/file.c	2008-02-06 16:46:23.000000000 -0500
@@ -37,6 +37,7 @@
 #include "ordered-data.h"
 #include "ioctl.h"
 #include "print-tree.h"
+#include "compat.h"

 static int btrfs_copy_from_user(loff_t pos, int num_pages, int write_bytes,
@@ -790,7 +791,11 @@ static ssize_t btrfs_file_write(struct f
 		goto out_nolock;
 	if (count == 0)
 		goto out_nolock;
+#ifdef REMOVE_SUID_PATH
+	err = remove_suid(&file->f_path);
+#else
 	err = remove_suid(fdentry(file));
+#endif
 	if (err)
 		goto out_nolock;
 	file_update_time(file);

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2008-09-25 11:04:02 -04:00
..
acl.c Btrfs: Include sched.h in the acl code for current (fixes compile on 2.6.23) 2008-09-25 11:03:59 -04:00
bit-radix.c Btrfs: trivial include fixups 2007-07-11 10:00:37 -04:00
bit-radix.h Btrfs: add GPLv2 2007-06-12 09:07:21 -04:00
btrfs_inode.h Btrfs: Throttle file_write when data=ordered is flushing the inode 2008-09-25 11:04:02 -04:00
compat.h Btrfs: Add workaround for AppArmor changing remove_suid() 2008-09-25 11:04:02 -04:00
COPYING Btrfs: add GPLv2 2007-06-12 09:07:21 -04:00
crc32c.h Btrfs: Endianess bug fix for v0.13 with kernels 2008-09-25 11:04:01 -04:00
ctree.c Btrfs: Fix balance_level to free the middle block if there is room in the left one 2008-09-25 11:04:02 -04:00
ctree.h Btrfs: Clone file data ioctl 2008-09-25 11:04:02 -04:00
dir-item.c Btrfs: unaligned access fixes 2008-09-25 11:04:00 -04:00
disk-io.c Btrfs: Fixes for 2.6.18 enterprise kernels 2008-09-25 11:04:02 -04:00
disk-io.h Btrfs: Create a work queue for bio writes 2008-09-25 11:04:01 -04:00
extent_io.c Btrfs: Drop some verbose printks 2008-09-25 11:04:02 -04:00
extent_io.h Btrfs: Don't drop extent_map cache during releasepage on the btree inode 2008-09-25 11:04:02 -04:00
extent_map.c Btrfs: Split the extent_map code into two parts 2008-09-25 11:03:59 -04:00
extent_map.h Btrfs: Split the extent_map code into two parts 2008-09-25 11:03:59 -04:00
extent-tree.c Btrfs: Deal with failed writes in mirrored configurations 2008-09-25 11:04:02 -04:00
file-item.c Btrfs: Clone file data ioctl 2008-09-25 11:04:02 -04:00
file.c Btrfs: Add workaround for AppArmor changing remove_suid() 2008-09-25 11:04:02 -04:00
hash.c btrfs-progs: Stop stomping on 'name' input parameter 2008-09-25 11:04:01 -04:00
hash.h Btrfs: unaligned access fixes 2008-09-25 11:04:00 -04:00
inode-item.c Btrfs: Add back pointers from the inode to the directory that references it 2008-09-25 11:03:58 -04:00
inode-map.c Fix for btrfs_find_free_objectid 2008-09-25 11:03:59 -04:00
inode.c Btrfs: Clone file data ioctl 2008-09-25 11:04:02 -04:00
INSTALL Btrfs: Documentation update 2007-06-22 14:49:31 -04:00
ioctl.h Btrfs: Clone file data ioctl 2008-09-25 11:04:02 -04:00
Makefile Btrfs: Add support for multiple devices per filesystem 2008-09-25 11:04:00 -04:00
ordered-data.c Btrfs: Fixes for 2.6.18 enterprise kernels 2008-09-25 11:04:02 -04:00
ordered-data.h Btrfs: Throttle file_write when data=ordered is flushing the inode 2008-09-25 11:04:02 -04:00
print-tree.c Btrfs: Add chunk uuids and update multi-device back references 2008-09-25 11:04:01 -04:00
print-tree.h Btrfs: Create extent_buffer interface for large blocksizes 2008-09-25 11:03:56 -04:00
root-tree.c Btrfs: Change st_blocksize to 4k 2008-09-25 11:03:59 -04:00
struct-funcs.c Btrfs: unaligned access fixes 2008-09-25 11:04:00 -04:00
super.c Btrfs: Add new ioctl to add devices 2008-09-25 11:04:02 -04:00
sysfs.c Btrfs: Disable sysfs files on older kernels 2008-09-25 11:04:00 -04:00
TODO Btrfs: add GPLv2 2007-06-12 09:07:21 -04:00
transaction.c Btrfs: Fixes for 2.6.18 enterprise kernels 2008-09-25 11:04:02 -04:00
transaction.h Btrfs: Split the extent_map code into two parts 2008-09-25 11:03:59 -04:00
tree-defrag.c Btrfs: Verify checksums on tree blocks found without read_tree_block 2008-09-25 11:04:01 -04:00
volumes.c Btrfs: Compile warning fixup in volume.c 2008-09-25 11:04:02 -04:00
volumes.h Btrfs: Deal with failed writes in mirrored configurations 2008-09-25 11:04:02 -04:00
xattr.c Btrfs: Fix compile on kernel without ACLs enabled 2008-09-25 11:03:59 -04:00
xattr.h xattr support for btrfs 2008-09-25 11:03:57 -04:00