Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | File: fs/xattr.c |
| 3 | |
| 4 | Extended attribute handling. |
| 5 | |
| 6 | Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org> |
| 7 | Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com> |
| 8 | Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com> |
| 9 | */ |
| 10 | #include <linux/fs.h> |
| 11 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/file.h> |
| 13 | #include <linux/xattr.h> |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 14 | #include <linux/mount.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/namei.h> |
| 16 | #include <linux/security.h> |
| 17 | #include <linux/syscalls.h> |
| 18 | #include <linux/module.h> |
Robert Love | 0eeca28 | 2005-07-12 17:06:03 -0400 | [diff] [blame] | 19 | #include <linux/fsnotify.h> |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 20 | #include <linux/audit.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/uaccess.h> |
| 22 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 23 | |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 24 | /* |
| 25 | * Check permissions for extended attribute access. This is a bit complicated |
| 26 | * because different namespaces have very different rules. |
| 27 | */ |
| 28 | static int |
| 29 | xattr_permission(struct inode *inode, const char *name, int mask) |
| 30 | { |
| 31 | /* |
| 32 | * We can never set or remove an extended attribute on a read-only |
| 33 | * filesystem or on an immutable / append-only inode. |
| 34 | */ |
| 35 | if (mask & MAY_WRITE) { |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 36 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
| 37 | return -EPERM; |
| 38 | } |
| 39 | |
| 40 | /* |
| 41 | * No restriction for security.* and system.* from the VFS. Decision |
| 42 | * on these is left to the underlying filesystem / security module. |
| 43 | */ |
| 44 | if (!strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) || |
| 45 | !strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) |
| 46 | return 0; |
| 47 | |
| 48 | /* |
Andreas Gruenbacher | 55b23bd | 2011-05-27 14:50:36 +0200 | [diff] [blame^] | 49 | * The trusted.* namespace can only be accessed by privileged users. |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 50 | */ |
Andreas Gruenbacher | 55b23bd | 2011-05-27 14:50:36 +0200 | [diff] [blame^] | 51 | if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) { |
| 52 | if (!capable(CAP_SYS_ADMIN)) |
| 53 | return (mask & MAY_WRITE) ? -EPERM : -ENODATA; |
| 54 | return 0; |
| 55 | } |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 56 | |
Andreas Gruenbacher | 55b23bd | 2011-05-27 14:50:36 +0200 | [diff] [blame^] | 57 | /* |
| 58 | * In the user.* namespace, only regular files and directories can have |
Andreas Gruenbacher | f1f2d87 | 2006-11-02 22:07:29 -0800 | [diff] [blame] | 59 | * extended attributes. For sticky directories, only the owner and |
Andreas Gruenbacher | 55b23bd | 2011-05-27 14:50:36 +0200 | [diff] [blame^] | 60 | * privileged users can write attributes. |
Andreas Gruenbacher | f1f2d87 | 2006-11-02 22:07:29 -0800 | [diff] [blame] | 61 | */ |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 62 | if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) { |
Andreas Gruenbacher | f1f2d87 | 2006-11-02 22:07:29 -0800 | [diff] [blame] | 63 | if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) |
Andreas Gruenbacher | 55b23bd | 2011-05-27 14:50:36 +0200 | [diff] [blame^] | 64 | return (mask & MAY_WRITE) ? -EPERM : -ENODATA; |
Andreas Gruenbacher | f1f2d87 | 2006-11-02 22:07:29 -0800 | [diff] [blame] | 65 | if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) && |
Serge E. Hallyn | 2e14967 | 2011-03-23 16:43:26 -0700 | [diff] [blame] | 66 | (mask & MAY_WRITE) && !inode_owner_or_capable(inode)) |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 67 | return -EPERM; |
| 68 | } |
| 69 | |
Al Viro | f419a2e | 2008-07-22 00:07:17 -0400 | [diff] [blame] | 70 | return inode_permission(inode, mask); |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 71 | } |
| 72 | |
David P. Quigley | b1ab7e4 | 2009-09-03 14:25:56 -0400 | [diff] [blame] | 73 | /** |
| 74 | * __vfs_setxattr_noperm - perform setxattr operation without performing |
| 75 | * permission checks. |
| 76 | * |
| 77 | * @dentry - object to perform setxattr on |
| 78 | * @name - xattr name to set |
| 79 | * @value - value to set @name to |
| 80 | * @size - size of @value |
| 81 | * @flags - flags to pass into filesystem operations |
| 82 | * |
| 83 | * returns the result of the internal setxattr or setsecurity operations. |
| 84 | * |
| 85 | * This function requires the caller to lock the inode's i_mutex before it |
| 86 | * is executed. It also assumes that the caller will make the appropriate |
| 87 | * permission checks. |
| 88 | */ |
| 89 | int __vfs_setxattr_noperm(struct dentry *dentry, const char *name, |
| 90 | const void *value, size_t size, int flags) |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 91 | { |
| 92 | struct inode *inode = dentry->d_inode; |
David P. Quigley | b1ab7e4 | 2009-09-03 14:25:56 -0400 | [diff] [blame] | 93 | int error = -EOPNOTSUPP; |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 94 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 95 | if (inode->i_op->setxattr) { |
| 96 | error = inode->i_op->setxattr(dentry, name, value, size, flags); |
| 97 | if (!error) { |
| 98 | fsnotify_xattr(dentry); |
| 99 | security_inode_post_setxattr(dentry, name, value, |
| 100 | size, flags); |
| 101 | } |
| 102 | } else if (!strncmp(name, XATTR_SECURITY_PREFIX, |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 103 | XATTR_SECURITY_PREFIX_LEN)) { |
| 104 | const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 105 | error = security_inode_setsecurity(inode, suffix, value, |
| 106 | size, flags); |
| 107 | if (!error) |
| 108 | fsnotify_xattr(dentry); |
| 109 | } |
David P. Quigley | b1ab7e4 | 2009-09-03 14:25:56 -0400 | [diff] [blame] | 110 | |
| 111 | return error; |
| 112 | } |
| 113 | |
| 114 | |
| 115 | int |
| 116 | vfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
| 117 | size_t size, int flags) |
| 118 | { |
| 119 | struct inode *inode = dentry->d_inode; |
| 120 | int error; |
| 121 | |
| 122 | error = xattr_permission(inode, name, MAY_WRITE); |
| 123 | if (error) |
| 124 | return error; |
| 125 | |
| 126 | mutex_lock(&inode->i_mutex); |
| 127 | error = security_inode_setxattr(dentry, name, value, size, flags); |
| 128 | if (error) |
| 129 | goto out; |
| 130 | |
| 131 | error = __vfs_setxattr_noperm(dentry, name, value, size, flags); |
| 132 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 133 | out: |
| 134 | mutex_unlock(&inode->i_mutex); |
| 135 | return error; |
| 136 | } |
| 137 | EXPORT_SYMBOL_GPL(vfs_setxattr); |
| 138 | |
| 139 | ssize_t |
David P. Quigley | 4249259 | 2008-02-04 22:29:39 -0800 | [diff] [blame] | 140 | xattr_getsecurity(struct inode *inode, const char *name, void *value, |
| 141 | size_t size) |
| 142 | { |
| 143 | void *buffer = NULL; |
| 144 | ssize_t len; |
| 145 | |
| 146 | if (!value || !size) { |
| 147 | len = security_inode_getsecurity(inode, name, &buffer, false); |
| 148 | goto out_noalloc; |
| 149 | } |
| 150 | |
| 151 | len = security_inode_getsecurity(inode, name, &buffer, true); |
| 152 | if (len < 0) |
| 153 | return len; |
| 154 | if (size < len) { |
| 155 | len = -ERANGE; |
| 156 | goto out; |
| 157 | } |
| 158 | memcpy(value, buffer, len); |
| 159 | out: |
| 160 | security_release_secctx(buffer, len); |
| 161 | out_noalloc: |
| 162 | return len; |
| 163 | } |
| 164 | EXPORT_SYMBOL_GPL(xattr_getsecurity); |
| 165 | |
| 166 | ssize_t |
David Howells | 8f0cfa5 | 2008-04-29 00:59:41 -0700 | [diff] [blame] | 167 | vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 168 | { |
| 169 | struct inode *inode = dentry->d_inode; |
| 170 | int error; |
| 171 | |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 172 | error = xattr_permission(inode, name, MAY_READ); |
| 173 | if (error) |
| 174 | return error; |
| 175 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 176 | error = security_inode_getxattr(dentry, name); |
| 177 | if (error) |
| 178 | return error; |
| 179 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 180 | if (!strncmp(name, XATTR_SECURITY_PREFIX, |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 181 | XATTR_SECURITY_PREFIX_LEN)) { |
| 182 | const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; |
David P. Quigley | 4249259 | 2008-02-04 22:29:39 -0800 | [diff] [blame] | 183 | int ret = xattr_getsecurity(inode, suffix, value, size); |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 184 | /* |
| 185 | * Only overwrite the return value if a security module |
| 186 | * is actually active. |
| 187 | */ |
David P. Quigley | 4bea580 | 2008-02-04 22:29:40 -0800 | [diff] [blame] | 188 | if (ret == -EOPNOTSUPP) |
| 189 | goto nolsm; |
| 190 | return ret; |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 191 | } |
David P. Quigley | 4bea580 | 2008-02-04 22:29:40 -0800 | [diff] [blame] | 192 | nolsm: |
| 193 | if (inode->i_op->getxattr) |
| 194 | error = inode->i_op->getxattr(dentry, name, value, size); |
| 195 | else |
| 196 | error = -EOPNOTSUPP; |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 197 | |
| 198 | return error; |
| 199 | } |
| 200 | EXPORT_SYMBOL_GPL(vfs_getxattr); |
| 201 | |
Bill Nottingham | 659564c | 2006-10-09 16:10:48 -0400 | [diff] [blame] | 202 | ssize_t |
| 203 | vfs_listxattr(struct dentry *d, char *list, size_t size) |
| 204 | { |
| 205 | ssize_t error; |
| 206 | |
| 207 | error = security_inode_listxattr(d); |
| 208 | if (error) |
| 209 | return error; |
| 210 | error = -EOPNOTSUPP; |
Al Viro | acfa438 | 2008-12-04 10:06:33 -0500 | [diff] [blame] | 211 | if (d->d_inode->i_op->listxattr) { |
Bill Nottingham | 659564c | 2006-10-09 16:10:48 -0400 | [diff] [blame] | 212 | error = d->d_inode->i_op->listxattr(d, list, size); |
| 213 | } else { |
| 214 | error = security_inode_listsecurity(d->d_inode, list, size); |
| 215 | if (size && error > size) |
| 216 | error = -ERANGE; |
| 217 | } |
| 218 | return error; |
| 219 | } |
| 220 | EXPORT_SYMBOL_GPL(vfs_listxattr); |
| 221 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 222 | int |
David Howells | 8f0cfa5 | 2008-04-29 00:59:41 -0700 | [diff] [blame] | 223 | vfs_removexattr(struct dentry *dentry, const char *name) |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 224 | { |
| 225 | struct inode *inode = dentry->d_inode; |
| 226 | int error; |
| 227 | |
| 228 | if (!inode->i_op->removexattr) |
| 229 | return -EOPNOTSUPP; |
| 230 | |
akpm@osdl.org | e0ad7b0 | 2006-01-09 20:51:56 -0800 | [diff] [blame] | 231 | error = xattr_permission(inode, name, MAY_WRITE); |
| 232 | if (error) |
| 233 | return error; |
| 234 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 235 | error = security_inode_removexattr(dentry, name); |
| 236 | if (error) |
| 237 | return error; |
| 238 | |
| 239 | mutex_lock(&inode->i_mutex); |
| 240 | error = inode->i_op->removexattr(dentry, name); |
| 241 | mutex_unlock(&inode->i_mutex); |
| 242 | |
| 243 | if (!error) |
| 244 | fsnotify_xattr(dentry); |
| 245 | return error; |
| 246 | } |
| 247 | EXPORT_SYMBOL_GPL(vfs_removexattr); |
| 248 | |
| 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | /* |
| 251 | * Extended attribute SET operations |
| 252 | */ |
| 253 | static long |
David Howells | 8f0cfa5 | 2008-04-29 00:59:41 -0700 | [diff] [blame] | 254 | setxattr(struct dentry *d, const char __user *name, const void __user *value, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | size_t size, int flags) |
| 256 | { |
| 257 | int error; |
| 258 | void *kvalue = NULL; |
| 259 | char kname[XATTR_NAME_MAX + 1]; |
| 260 | |
| 261 | if (flags & ~(XATTR_CREATE|XATTR_REPLACE)) |
| 262 | return -EINVAL; |
| 263 | |
| 264 | error = strncpy_from_user(kname, name, sizeof(kname)); |
| 265 | if (error == 0 || error == sizeof(kname)) |
| 266 | error = -ERANGE; |
| 267 | if (error < 0) |
| 268 | return error; |
| 269 | |
| 270 | if (size) { |
| 271 | if (size > XATTR_SIZE_MAX) |
| 272 | return -E2BIG; |
Li Zefan | 3939fcd | 2009-04-08 15:06:12 +0800 | [diff] [blame] | 273 | kvalue = memdup_user(value, size); |
| 274 | if (IS_ERR(kvalue)) |
| 275 | return PTR_ERR(kvalue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 278 | error = vfs_setxattr(d, kname, kvalue, size, flags); |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 279 | kfree(kvalue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | return error; |
| 281 | } |
| 282 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 283 | SYSCALL_DEFINE5(setxattr, const char __user *, pathname, |
| 284 | const char __user *, name, const void __user *, value, |
| 285 | size_t, size, int, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 287 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | int error; |
| 289 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 290 | error = user_path(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | if (error) |
| 292 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 293 | error = mnt_want_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 294 | if (!error) { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 295 | error = setxattr(path.dentry, name, value, size, flags); |
| 296 | mnt_drop_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 297 | } |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 298 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | return error; |
| 300 | } |
| 301 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 302 | SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname, |
| 303 | const char __user *, name, const void __user *, value, |
| 304 | size_t, size, int, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 306 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | int error; |
| 308 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 309 | error = user_lpath(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | if (error) |
| 311 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 312 | error = mnt_want_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 313 | if (!error) { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 314 | error = setxattr(path.dentry, name, value, size, flags); |
| 315 | mnt_drop_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 316 | } |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 317 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | return error; |
| 319 | } |
| 320 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 321 | SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, |
| 322 | const void __user *,value, size_t, size, int, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | { |
| 324 | struct file *f; |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 325 | struct dentry *dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | int error = -EBADF; |
| 327 | |
| 328 | f = fget(fd); |
| 329 | if (!f) |
| 330 | return error; |
Josef "Jeff" Sipek | 0f7fc9e | 2006-12-08 02:36:35 -0800 | [diff] [blame] | 331 | dentry = f->f_path.dentry; |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 332 | audit_inode(NULL, dentry); |
npiggin@suse.de | 96029c4 | 2009-04-26 20:25:55 +1000 | [diff] [blame] | 333 | error = mnt_want_write_file(f); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 334 | if (!error) { |
| 335 | error = setxattr(dentry, name, value, size, flags); |
| 336 | mnt_drop_write(f->f_path.mnt); |
| 337 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | fput(f); |
| 339 | return error; |
| 340 | } |
| 341 | |
| 342 | /* |
| 343 | * Extended attribute GET operations |
| 344 | */ |
| 345 | static ssize_t |
David Howells | 8f0cfa5 | 2008-04-29 00:59:41 -0700 | [diff] [blame] | 346 | getxattr(struct dentry *d, const char __user *name, void __user *value, |
| 347 | size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | { |
| 349 | ssize_t error; |
| 350 | void *kvalue = NULL; |
| 351 | char kname[XATTR_NAME_MAX + 1]; |
| 352 | |
| 353 | error = strncpy_from_user(kname, name, sizeof(kname)); |
| 354 | if (error == 0 || error == sizeof(kname)) |
| 355 | error = -ERANGE; |
| 356 | if (error < 0) |
| 357 | return error; |
| 358 | |
| 359 | if (size) { |
| 360 | if (size > XATTR_SIZE_MAX) |
| 361 | size = XATTR_SIZE_MAX; |
James Morris | d381d8a | 2005-10-30 14:59:22 -0800 | [diff] [blame] | 362 | kvalue = kzalloc(size, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | if (!kvalue) |
| 364 | return -ENOMEM; |
| 365 | } |
| 366 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 367 | error = vfs_getxattr(d, kname, kvalue, size); |
Stephen Smalley | f549d6c | 2005-09-03 15:55:18 -0700 | [diff] [blame] | 368 | if (error > 0) { |
| 369 | if (size && copy_to_user(value, kvalue, error)) |
| 370 | error = -EFAULT; |
| 371 | } else if (error == -ERANGE && size >= XATTR_SIZE_MAX) { |
| 372 | /* The file system tried to returned a value bigger |
| 373 | than XATTR_SIZE_MAX bytes. Not possible. */ |
| 374 | error = -E2BIG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | } |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 376 | kfree(kvalue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | return error; |
| 378 | } |
| 379 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 380 | SYSCALL_DEFINE4(getxattr, const char __user *, pathname, |
| 381 | const char __user *, name, void __user *, value, size_t, size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 383 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | ssize_t error; |
| 385 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 386 | error = user_path(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | if (error) |
| 388 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 389 | error = getxattr(path.dentry, name, value, size); |
| 390 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | return error; |
| 392 | } |
| 393 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 394 | SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname, |
| 395 | const char __user *, name, void __user *, value, size_t, size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 397 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | ssize_t error; |
| 399 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 400 | error = user_lpath(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | if (error) |
| 402 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 403 | error = getxattr(path.dentry, name, value, size); |
| 404 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | return error; |
| 406 | } |
| 407 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 408 | SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, |
| 409 | void __user *, value, size_t, size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | { |
| 411 | struct file *f; |
| 412 | ssize_t error = -EBADF; |
| 413 | |
| 414 | f = fget(fd); |
| 415 | if (!f) |
| 416 | return error; |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 417 | audit_inode(NULL, f->f_path.dentry); |
Josef "Jeff" Sipek | 0f7fc9e | 2006-12-08 02:36:35 -0800 | [diff] [blame] | 418 | error = getxattr(f->f_path.dentry, name, value, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | fput(f); |
| 420 | return error; |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * Extended attribute LIST operations |
| 425 | */ |
| 426 | static ssize_t |
| 427 | listxattr(struct dentry *d, char __user *list, size_t size) |
| 428 | { |
| 429 | ssize_t error; |
| 430 | char *klist = NULL; |
| 431 | |
| 432 | if (size) { |
| 433 | if (size > XATTR_LIST_MAX) |
| 434 | size = XATTR_LIST_MAX; |
| 435 | klist = kmalloc(size, GFP_KERNEL); |
| 436 | if (!klist) |
| 437 | return -ENOMEM; |
| 438 | } |
| 439 | |
Bill Nottingham | 659564c | 2006-10-09 16:10:48 -0400 | [diff] [blame] | 440 | error = vfs_listxattr(d, klist, size); |
Stephen Smalley | f549d6c | 2005-09-03 15:55:18 -0700 | [diff] [blame] | 441 | if (error > 0) { |
| 442 | if (size && copy_to_user(list, klist, error)) |
| 443 | error = -EFAULT; |
| 444 | } else if (error == -ERANGE && size >= XATTR_LIST_MAX) { |
| 445 | /* The file system tried to returned a list bigger |
| 446 | than XATTR_LIST_MAX bytes. Not possible. */ |
| 447 | error = -E2BIG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | } |
Jesper Juhl | f99d49a | 2005-11-07 01:01:34 -0800 | [diff] [blame] | 449 | kfree(klist); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | return error; |
| 451 | } |
| 452 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 453 | SYSCALL_DEFINE3(listxattr, const char __user *, pathname, char __user *, list, |
| 454 | size_t, size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 456 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | ssize_t error; |
| 458 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 459 | error = user_path(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | if (error) |
| 461 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 462 | error = listxattr(path.dentry, list, size); |
| 463 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | return error; |
| 465 | } |
| 466 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 467 | SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list, |
| 468 | size_t, size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 470 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | ssize_t error; |
| 472 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 473 | error = user_lpath(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | if (error) |
| 475 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 476 | error = listxattr(path.dentry, list, size); |
| 477 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | return error; |
| 479 | } |
| 480 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 481 | SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | { |
| 483 | struct file *f; |
| 484 | ssize_t error = -EBADF; |
| 485 | |
| 486 | f = fget(fd); |
| 487 | if (!f) |
| 488 | return error; |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 489 | audit_inode(NULL, f->f_path.dentry); |
Josef "Jeff" Sipek | 0f7fc9e | 2006-12-08 02:36:35 -0800 | [diff] [blame] | 490 | error = listxattr(f->f_path.dentry, list, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | fput(f); |
| 492 | return error; |
| 493 | } |
| 494 | |
| 495 | /* |
| 496 | * Extended attribute REMOVE operations |
| 497 | */ |
| 498 | static long |
David Howells | 8f0cfa5 | 2008-04-29 00:59:41 -0700 | [diff] [blame] | 499 | removexattr(struct dentry *d, const char __user *name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | { |
| 501 | int error; |
| 502 | char kname[XATTR_NAME_MAX + 1]; |
| 503 | |
| 504 | error = strncpy_from_user(kname, name, sizeof(kname)); |
| 505 | if (error == 0 || error == sizeof(kname)) |
| 506 | error = -ERANGE; |
| 507 | if (error < 0) |
| 508 | return error; |
| 509 | |
Christoph Hellwig | 5be196e | 2006-01-09 20:51:55 -0800 | [diff] [blame] | 510 | return vfs_removexattr(d, kname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } |
| 512 | |
Heiko Carstens | 64fd1de | 2009-01-14 14:14:14 +0100 | [diff] [blame] | 513 | SYSCALL_DEFINE2(removexattr, const char __user *, pathname, |
| 514 | const char __user *, name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 516 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | int error; |
| 518 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 519 | error = user_path(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | if (error) |
| 521 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 522 | error = mnt_want_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 523 | if (!error) { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 524 | error = removexattr(path.dentry, name); |
| 525 | mnt_drop_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 526 | } |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 527 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | return error; |
| 529 | } |
| 530 | |
Heiko Carstens | 6a6160a | 2009-01-14 14:14:15 +0100 | [diff] [blame] | 531 | SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname, |
| 532 | const char __user *, name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 534 | struct path path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | int error; |
| 536 | |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 537 | error = user_lpath(pathname, &path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | if (error) |
| 539 | return error; |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 540 | error = mnt_want_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 541 | if (!error) { |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 542 | error = removexattr(path.dentry, name); |
| 543 | mnt_drop_write(path.mnt); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 544 | } |
Al Viro | 2d8f303 | 2008-07-22 09:59:21 -0400 | [diff] [blame] | 545 | path_put(&path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | return error; |
| 547 | } |
| 548 | |
Heiko Carstens | 6a6160a | 2009-01-14 14:14:15 +0100 | [diff] [blame] | 549 | SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | { |
| 551 | struct file *f; |
Amy Griffis | 73241cc | 2005-11-03 16:00:25 +0000 | [diff] [blame] | 552 | struct dentry *dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | int error = -EBADF; |
| 554 | |
| 555 | f = fget(fd); |
| 556 | if (!f) |
| 557 | return error; |
Josef "Jeff" Sipek | 0f7fc9e | 2006-12-08 02:36:35 -0800 | [diff] [blame] | 558 | dentry = f->f_path.dentry; |
Al Viro | 5a190ae | 2007-06-07 12:19:32 -0400 | [diff] [blame] | 559 | audit_inode(NULL, dentry); |
npiggin@suse.de | 96029c4 | 2009-04-26 20:25:55 +1000 | [diff] [blame] | 560 | error = mnt_want_write_file(f); |
Dave Hansen | 18f335a | 2008-02-15 14:37:38 -0800 | [diff] [blame] | 561 | if (!error) { |
| 562 | error = removexattr(dentry, name); |
| 563 | mnt_drop_write(f->f_path.mnt); |
| 564 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | fput(f); |
| 566 | return error; |
| 567 | } |
| 568 | |
| 569 | |
| 570 | static const char * |
| 571 | strcmp_prefix(const char *a, const char *a_prefix) |
| 572 | { |
| 573 | while (*a_prefix && *a == *a_prefix) { |
| 574 | a++; |
| 575 | a_prefix++; |
| 576 | } |
| 577 | return *a_prefix ? NULL : a; |
| 578 | } |
| 579 | |
| 580 | /* |
| 581 | * In order to implement different sets of xattr operations for each xattr |
| 582 | * prefix with the generic xattr API, a filesystem should create a |
| 583 | * null-terminated array of struct xattr_handler (one for each prefix) and |
| 584 | * hang a pointer to it off of the s_xattr field of the superblock. |
| 585 | * |
| 586 | * The generic_fooxattr() functions will use this list to dispatch xattr |
| 587 | * operations to the correct xattr_handler. |
| 588 | */ |
| 589 | #define for_each_xattr_handler(handlers, handler) \ |
| 590 | for ((handler) = *(handlers)++; \ |
| 591 | (handler) != NULL; \ |
| 592 | (handler) = *(handlers)++) |
| 593 | |
| 594 | /* |
| 595 | * Find the xattr_handler with the matching prefix. |
| 596 | */ |
Stephen Hemminger | bb43545 | 2010-05-13 17:53:14 -0700 | [diff] [blame] | 597 | static const struct xattr_handler * |
| 598 | xattr_resolve_name(const struct xattr_handler **handlers, const char **name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | { |
Stephen Hemminger | bb43545 | 2010-05-13 17:53:14 -0700 | [diff] [blame] | 600 | const struct xattr_handler *handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | |
| 602 | if (!*name) |
| 603 | return NULL; |
| 604 | |
| 605 | for_each_xattr_handler(handlers, handler) { |
| 606 | const char *n = strcmp_prefix(*name, handler->prefix); |
| 607 | if (n) { |
| 608 | *name = n; |
| 609 | break; |
| 610 | } |
| 611 | } |
| 612 | return handler; |
| 613 | } |
| 614 | |
| 615 | /* |
| 616 | * Find the handler for the prefix and dispatch its get() operation. |
| 617 | */ |
| 618 | ssize_t |
| 619 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) |
| 620 | { |
Stephen Hemminger | bb43545 | 2010-05-13 17:53:14 -0700 | [diff] [blame] | 621 | const struct xattr_handler *handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 623 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | if (!handler) |
| 625 | return -EOPNOTSUPP; |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 626 | return handler->get(dentry, name, buffer, size, handler->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | /* |
| 630 | * Combine the results of the list() operation from every xattr_handler in the |
| 631 | * list. |
| 632 | */ |
| 633 | ssize_t |
| 634 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 635 | { |
Stephen Hemminger | bb43545 | 2010-05-13 17:53:14 -0700 | [diff] [blame] | 636 | const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | unsigned int size = 0; |
| 638 | |
| 639 | if (!buffer) { |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 640 | for_each_xattr_handler(handlers, handler) { |
| 641 | size += handler->list(dentry, NULL, 0, NULL, 0, |
| 642 | handler->flags); |
| 643 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | } else { |
| 645 | char *buf = buffer; |
| 646 | |
| 647 | for_each_xattr_handler(handlers, handler) { |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 648 | size = handler->list(dentry, buf, buffer_size, |
| 649 | NULL, 0, handler->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | if (size > buffer_size) |
| 651 | return -ERANGE; |
| 652 | buf += size; |
| 653 | buffer_size -= size; |
| 654 | } |
| 655 | size = buf - buffer; |
| 656 | } |
| 657 | return size; |
| 658 | } |
| 659 | |
| 660 | /* |
| 661 | * Find the handler for the prefix and dispatch its set() operation. |
| 662 | */ |
| 663 | int |
| 664 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) |
| 665 | { |
Stephen Hemminger | bb43545 | 2010-05-13 17:53:14 -0700 | [diff] [blame] | 666 | const struct xattr_handler *handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | |
| 668 | if (size == 0) |
| 669 | value = ""; /* empty EA, do not remove */ |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 670 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | if (!handler) |
| 672 | return -EOPNOTSUPP; |
Jan Kara | df7e130 | 2011-04-20 20:30:40 +0200 | [diff] [blame] | 673 | return handler->set(dentry, name, value, size, flags, handler->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | /* |
| 677 | * Find the handler for the prefix and dispatch its set() operation to remove |
| 678 | * any associated extended attribute. |
| 679 | */ |
| 680 | int |
| 681 | generic_removexattr(struct dentry *dentry, const char *name) |
| 682 | { |
Stephen Hemminger | bb43545 | 2010-05-13 17:53:14 -0700 | [diff] [blame] | 683 | const struct xattr_handler *handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 685 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | if (!handler) |
| 687 | return -EOPNOTSUPP; |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 688 | return handler->set(dentry, name, NULL, 0, |
| 689 | XATTR_REPLACE, handler->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | EXPORT_SYMBOL(generic_getxattr); |
| 693 | EXPORT_SYMBOL(generic_listxattr); |
| 694 | EXPORT_SYMBOL(generic_setxattr); |
| 695 | EXPORT_SYMBOL(generic_removexattr); |