xattr.c 17 KB

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