diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-11 16:32:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-11 16:32:10 -0500 |
commit | ddf1d6238dd13a3bd948e8fcb1109798ef0af49b (patch) | |
tree | daa25447e4b791b2868a0338f872975ec480862b /fs/squashfs | |
parent | 32fb378437a1d716e72a442237d7ead1f435ecf0 (diff) | |
parent | 764a5c6b1fa4306dd7573c1d80914254909cd036 (diff) |
Merge branch 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs xattr updates from Al Viro:
"Andreas' xattr cleanup series.
It's a followup to his xattr work that went in last cycle; -0.5KLoC"
* 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
xattr handlers: Simplify list operation
ocfs2: Replace list xattr handler operations
nfs: Move call to security_inode_listsecurity into nfs_listxattr
xfs: Change how listxattr generates synthetic attributes
tmpfs: listxattr should include POSIX ACL xattrs
tmpfs: Use xattr handler infrastructure
btrfs: Use xattr handler infrastructure
vfs: Distinguish between full xattr names and proper prefixes
posix acls: Remove duplicate xattr name definitions
gfs2: Remove gfs2_xattr_acl_chmod
vfs: Remove vfs_xattr_cmp
Diffstat (limited to 'fs/squashfs')
-rw-r--r-- | fs/squashfs/xattr.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c index 6a4cc344085c..1e9de96288d8 100644 --- a/fs/squashfs/xattr.c +++ b/fs/squashfs/xattr.c | |||
@@ -58,7 +58,7 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer, | |||
58 | struct squashfs_xattr_entry entry; | 58 | struct squashfs_xattr_entry entry; |
59 | struct squashfs_xattr_val val; | 59 | struct squashfs_xattr_val val; |
60 | const struct xattr_handler *handler; | 60 | const struct xattr_handler *handler; |
61 | int name_size, prefix_size = 0; | 61 | int name_size; |
62 | 62 | ||
63 | err = squashfs_read_metadata(sb, &entry, &start, &offset, | 63 | err = squashfs_read_metadata(sb, &entry, &start, &offset, |
64 | sizeof(entry)); | 64 | sizeof(entry)); |
@@ -67,15 +67,16 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer, | |||
67 | 67 | ||
68 | name_size = le16_to_cpu(entry.size); | 68 | name_size = le16_to_cpu(entry.size); |
69 | handler = squashfs_xattr_handler(le16_to_cpu(entry.type)); | 69 | handler = squashfs_xattr_handler(le16_to_cpu(entry.type)); |
70 | if (handler) | 70 | if (handler && (!handler->list || handler->list(d))) { |
71 | prefix_size = handler->list(handler, d, buffer, rest, | 71 | const char *prefix = handler->prefix ?: handler->name; |
72 | NULL, name_size); | 72 | size_t prefix_size = strlen(prefix); |
73 | if (prefix_size) { | 73 | |
74 | if (buffer) { | 74 | if (buffer) { |
75 | if (prefix_size + name_size + 1 > rest) { | 75 | if (prefix_size + name_size + 1 > rest) { |
76 | err = -ERANGE; | 76 | err = -ERANGE; |
77 | goto failed; | 77 | goto failed; |
78 | } | 78 | } |
79 | memcpy(buffer, prefix, prefix_size); | ||
79 | buffer += prefix_size; | 80 | buffer += prefix_size; |
80 | } | 81 | } |
81 | err = squashfs_read_metadata(sb, buffer, &start, | 82 | err = squashfs_read_metadata(sb, buffer, &start, |
@@ -212,25 +213,10 @@ failed: | |||
212 | } | 213 | } |
213 | 214 | ||
214 | 215 | ||
215 | static size_t squashfs_xattr_handler_list(const struct xattr_handler *handler, | ||
216 | struct dentry *d, char *list, | ||
217 | size_t list_size, const char *name, | ||
218 | size_t name_len) | ||
219 | { | ||
220 | int len = strlen(handler->prefix); | ||
221 | |||
222 | if (list && len <= list_size) | ||
223 | memcpy(list, handler->prefix, len); | ||
224 | return len; | ||
225 | } | ||
226 | |||
227 | static int squashfs_xattr_handler_get(const struct xattr_handler *handler, | 216 | static int squashfs_xattr_handler_get(const struct xattr_handler *handler, |
228 | struct dentry *d, const char *name, | 217 | struct dentry *d, const char *name, |
229 | void *buffer, size_t size) | 218 | void *buffer, size_t size) |
230 | { | 219 | { |
231 | if (name[0] == '\0') | ||
232 | return -EINVAL; | ||
233 | |||
234 | return squashfs_xattr_get(d_inode(d), handler->flags, name, | 220 | return squashfs_xattr_get(d_inode(d), handler->flags, name, |
235 | buffer, size); | 221 | buffer, size); |
236 | } | 222 | } |
@@ -241,22 +227,15 @@ static int squashfs_xattr_handler_get(const struct xattr_handler *handler, | |||
241 | static const struct xattr_handler squashfs_xattr_user_handler = { | 227 | static const struct xattr_handler squashfs_xattr_user_handler = { |
242 | .prefix = XATTR_USER_PREFIX, | 228 | .prefix = XATTR_USER_PREFIX, |
243 | .flags = SQUASHFS_XATTR_USER, | 229 | .flags = SQUASHFS_XATTR_USER, |
244 | .list = squashfs_xattr_handler_list, | ||
245 | .get = squashfs_xattr_handler_get | 230 | .get = squashfs_xattr_handler_get |
246 | }; | 231 | }; |
247 | 232 | ||
248 | /* | 233 | /* |
249 | * Trusted namespace support | 234 | * Trusted namespace support |
250 | */ | 235 | */ |
251 | static size_t squashfs_trusted_xattr_handler_list(const struct xattr_handler *handler, | 236 | static bool squashfs_trusted_xattr_handler_list(struct dentry *d) |
252 | struct dentry *d, char *list, | ||
253 | size_t list_size, const char *name, | ||
254 | size_t name_len) | ||
255 | { | 237 | { |
256 | if (!capable(CAP_SYS_ADMIN)) | 238 | return capable(CAP_SYS_ADMIN); |
257 | return 0; | ||
258 | return squashfs_xattr_handler_list(handler, d, list, list_size, name, | ||
259 | name_len); | ||
260 | } | 239 | } |
261 | 240 | ||
262 | static const struct xattr_handler squashfs_xattr_trusted_handler = { | 241 | static const struct xattr_handler squashfs_xattr_trusted_handler = { |
@@ -272,7 +251,6 @@ static const struct xattr_handler squashfs_xattr_trusted_handler = { | |||
272 | static const struct xattr_handler squashfs_xattr_security_handler = { | 251 | static const struct xattr_handler squashfs_xattr_security_handler = { |
273 | .prefix = XATTR_SECURITY_PREFIX, | 252 | .prefix = XATTR_SECURITY_PREFIX, |
274 | .flags = SQUASHFS_XATTR_SECURITY, | 253 | .flags = SQUASHFS_XATTR_SECURITY, |
275 | .list = squashfs_xattr_handler_list, | ||
276 | .get = squashfs_xattr_handler_get | 254 | .get = squashfs_xattr_handler_get |
277 | }; | 255 | }; |
278 | 256 | ||