b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) // SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 2) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 3) * linux/fs/ext2/xattr_trusted.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 4) * Handler for trusted extended attributes.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 5) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 6) * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8)
f7699f2b0114f (Al Viro 2012-03-23 16:45:51 -0400 9) #include "ext2.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 10) #include "xattr.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11)
764a5c6b1fa43 (Andreas Gruenbacher 2015-12-02 14:44:43 +0100 12) static bool
764a5c6b1fa43 (Andreas Gruenbacher 2015-12-02 14:44:43 +0100 13) ext2_xattr_trusted_list(struct dentry *dentry)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 14) {
764a5c6b1fa43 (Andreas Gruenbacher 2015-12-02 14:44:43 +0100 15) return capable(CAP_SYS_ADMIN);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 16) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 17)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 18) static int
d9a82a04033f8 (Andreas Gruenbacher 2015-10-04 19:18:51 +0200 19) ext2_xattr_trusted_get(const struct xattr_handler *handler,
b296821a7c42f (Al Viro 2016-04-10 20:48:24 -0400 20) struct dentry *unused, struct inode *inode,
b296821a7c42f (Al Viro 2016-04-10 20:48:24 -0400 21) const char *name, void *buffer, size_t size)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 22) {
b296821a7c42f (Al Viro 2016-04-10 20:48:24 -0400 23) return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 24) buffer, size);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 25) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 26)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 27) static int
d9a82a04033f8 (Andreas Gruenbacher 2015-10-04 19:18:51 +0200 28) ext2_xattr_trusted_set(const struct xattr_handler *handler,
e65ce2a50cf6a (Christian Brauner 2021-01-21 14:19:27 +0100 29) struct user_namespace *mnt_userns,
5930122683dff (Al Viro 2016-05-27 10:19:30 -0400 30) struct dentry *unused, struct inode *inode,
5930122683dff (Al Viro 2016-05-27 10:19:30 -0400 31) const char *name, const void *value,
5930122683dff (Al Viro 2016-05-27 10:19:30 -0400 32) size_t size, int flags)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 33) {
5930122683dff (Al Viro 2016-05-27 10:19:30 -0400 34) return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 35) value, size, flags);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 36) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 37)
749c72efa4bd9 (Stephen Hemminger 2010-05-13 17:53:16 -0700 38) const struct xattr_handler ext2_xattr_trusted_handler = {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 39) .prefix = XATTR_TRUSTED_PREFIX,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 40) .list = ext2_xattr_trusted_list,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 41) .get = ext2_xattr_trusted_get,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 42) .set = ext2_xattr_trusted_set,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 43) };