summaryrefslogtreecommitdiffstats
path: root/patches/boot_time_opt_guest/0114-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/boot_time_opt_guest/0114-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch')
-rw-r--r--patches/boot_time_opt_guest/0114-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/patches/boot_time_opt_guest/0114-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch b/patches/boot_time_opt_guest/0114-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch
new file mode 100644
index 0000000..dee9058
--- /dev/null
+++ b/patches/boot_time_opt_guest/0114-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch
@@ -0,0 +1,56 @@
1From 02fd2e6a7c708bf973209f9b238c5c61cbf15239 Mon Sep 17 00:00:00 2001
2From: Alan Cox <alan@linux.intel.com>
3Date: Thu, 10 Mar 2016 15:11:28 +0000
4Subject: [PATCH 114/114] xattr: allow setting user.* attributes on symlinks by
5 owner
6
7Kvmtool and clear containers supports using user attributes to label host
8files with the virtual uid/guid of the file in the container. This allows an
9end user to manage their files and a complete uid space without all the ugly
10namespace stuff.
11
12The one gap in the support is symlinks because an end user can change the
13ownership of a symbolic link. We support attributes on these files as you
14can already (as root) set security attributes on them.
15
16The current rules seem slightly over-paranoid and as we have a use case this
17patch enables updating the attributes on a symbolic link IFF you are the
18owner of the synlink (as permissions are not usually meaningful on the link
19itself).
20
21Signed-off-by: Alan Cox <alan@linux.intel.com>
22---
23 fs/xattr.c | 14 ++++++++------
24 1 file changed, 8 insertions(+), 6 deletions(-)
25
26diff --git a/fs/xattr.c b/fs/xattr.c
27index 7e3317cf4045..e005c30acb2c 100644
28--- a/fs/xattr.c
29+++ b/fs/xattr.c
30@@ -118,15 +118,17 @@ xattr_permission(struct inode *inode, const char *name, int mask)
31 }
32
33 /*
34- * In the user.* namespace, only regular files and directories can have
35- * extended attributes. For sticky directories, only the owner and
36- * privileged users can write attributes.
37+ * In the user.* namespace, only regular files, symbolic links, and
38+ * directories can have extended attributes. For symbolic links and
39+ * sticky directories, only the owner and privileged users can write
40+ * attributes.
41 */
42 if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
43- if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
44+ if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) && !S_ISLNK(inode->i_mode))
45 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
46- if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
47- (mask & MAY_WRITE) && !inode_owner_or_capable(inode))
48+ if (((S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX))
49+ || S_ISLNK(inode->i_mode)) && (mask & MAY_WRITE)
50+ && !inode_owner_or_capable(inode))
51 return -EPERM;
52 }
53
54--
552.11.1
56