diff options
Diffstat (limited to 'fs/xattr.c')
-rw-r--r-- | fs/xattr.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/xattr.c b/fs/xattr.c index c32f15b5f60f..395635100f77 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -135,6 +135,26 @@ vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size) | |||
135 | } | 135 | } |
136 | EXPORT_SYMBOL_GPL(vfs_getxattr); | 136 | EXPORT_SYMBOL_GPL(vfs_getxattr); |
137 | 137 | ||
138 | ssize_t | ||
139 | vfs_listxattr(struct dentry *d, char *list, size_t size) | ||
140 | { | ||
141 | ssize_t error; | ||
142 | |||
143 | error = security_inode_listxattr(d); | ||
144 | if (error) | ||
145 | return error; | ||
146 | error = -EOPNOTSUPP; | ||
147 | if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { | ||
148 | error = d->d_inode->i_op->listxattr(d, list, size); | ||
149 | } else { | ||
150 | error = security_inode_listsecurity(d->d_inode, list, size); | ||
151 | if (size && error > size) | ||
152 | error = -ERANGE; | ||
153 | } | ||
154 | return error; | ||
155 | } | ||
156 | EXPORT_SYMBOL_GPL(vfs_listxattr); | ||
157 | |||
138 | int | 158 | int |
139 | vfs_removexattr(struct dentry *dentry, char *name) | 159 | vfs_removexattr(struct dentry *dentry, char *name) |
140 | { | 160 | { |
@@ -346,17 +366,7 @@ listxattr(struct dentry *d, char __user *list, size_t size) | |||
346 | return -ENOMEM; | 366 | return -ENOMEM; |
347 | } | 367 | } |
348 | 368 | ||
349 | error = security_inode_listxattr(d); | 369 | error = vfs_listxattr(d, klist, size); |
350 | if (error) | ||
351 | goto out; | ||
352 | error = -EOPNOTSUPP; | ||
353 | if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { | ||
354 | error = d->d_inode->i_op->listxattr(d, klist, size); | ||
355 | } else { | ||
356 | error = security_inode_listsecurity(d->d_inode, klist, size); | ||
357 | if (size && error > size) | ||
358 | error = -ERANGE; | ||
359 | } | ||
360 | if (error > 0) { | 370 | if (error > 0) { |
361 | if (size && copy_to_user(list, klist, error)) | 371 | if (size && copy_to_user(list, klist, error)) |
362 | error = -EFAULT; | 372 | error = -EFAULT; |
@@ -365,7 +375,6 @@ listxattr(struct dentry *d, char __user *list, size_t size) | |||
365 | than XATTR_LIST_MAX bytes. Not possible. */ | 375 | than XATTR_LIST_MAX bytes. Not possible. */ |
366 | error = -E2BIG; | 376 | error = -E2BIG; |
367 | } | 377 | } |
368 | out: | ||
369 | kfree(klist); | 378 | kfree(klist); |
370 | return error; | 379 | return error; |
371 | } | 380 | } |