Linux Audio

Check our new training course

Yocto / OpenEmbedded training

Feb 10-13, 2025
Register
Loading...
v4.6
 
 1#include "reiserfs.h"
 2#include <linux/capability.h>
 3#include <linux/errno.h>
 4#include <linux/fs.h>
 5#include <linux/pagemap.h>
 6#include <linux/xattr.h>
 7#include "xattr.h"
 8#include <linux/uaccess.h>
 9
10static int
11trusted_get(const struct xattr_handler *handler, struct dentry *dentry,
12	    const char *name, void *buffer, size_t size)
13{
14	if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
15		return -EINVAL;
16
17	if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
18		return -EPERM;
19
20	return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
 
21}
22
23static int
24trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
25	    const char *name, const void *buffer, size_t size, int flags)
 
 
26{
27	if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
28		return -EINVAL;
29
30	if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
31		return -EPERM;
32
33	return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
 
 
34}
35
36static bool trusted_list(struct dentry *dentry)
37{
38	return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
39}
40
41const struct xattr_handler reiserfs_xattr_trusted_handler = {
42	.prefix = XATTR_TRUSTED_PREFIX,
43	.get = trusted_get,
44	.set = trusted_set,
45	.list = trusted_list,
46};
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2#include "reiserfs.h"
 3#include <linux/capability.h>
 4#include <linux/errno.h>
 5#include <linux/fs.h>
 6#include <linux/pagemap.h>
 7#include <linux/xattr.h>
 8#include "xattr.h"
 9#include <linux/uaccess.h>
10
11static int
12trusted_get(const struct xattr_handler *handler, struct dentry *unused,
13	    struct inode *inode, const char *name, void *buffer, size_t size)
14{
15	if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
 
 
 
16		return -EPERM;
17
18	return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
19				  buffer, size);
20}
21
22static int
23trusted_set(const struct xattr_handler *handler,
24	    struct mnt_idmap *idmap, struct dentry *unused,
25	    struct inode *inode, const char *name, const void *buffer,
26	    size_t size, int flags)
27{
28	if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
 
 
 
29		return -EPERM;
30
31	return reiserfs_xattr_set(inode,
32				  xattr_full_name(handler, name),
33				  buffer, size, flags);
34}
35
36static bool trusted_list(struct dentry *dentry)
37{
38	return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
39}
40
41const struct xattr_handler reiserfs_xattr_trusted_handler = {
42	.prefix = XATTR_TRUSTED_PREFIX,
43	.get = trusted_get,
44	.set = trusted_set,
45	.list = trusted_list,
46};