Blame view
fs/reiserfs/xattr_security.c
2.72 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
f466c6fdb move private bits... |
2 |
#include "reiserfs.h" |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 |
#include <linux/errno.h> #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/xattr.h> |
5a0e3ad6a include cleanup: ... |
7 |
#include <linux/slab.h> |
c45ac8887 take private bits... |
8 |
#include "xattr.h" |
57fe60df6 reiserfs: add ato... |
9 |
#include <linux/security.h> |
17093991a fs/reiserfs: use ... |
10 |
#include <linux/uaccess.h> |
1da177e4c Linux-2.6.12-rc2 |
11 |
|
1da177e4c Linux-2.6.12-rc2 |
12 |
static int |
b296821a7 xattr_handler: pa... |
13 14 |
security_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *buffer, size_t size) |
1da177e4c Linux-2.6.12-rc2 |
15 |
{ |
b296821a7 xattr_handler: pa... |
16 |
if (IS_PRIVATE(inode)) |
bd4c625c0 reiserfs: run scr... |
17 |
return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
18 |
|
b296821a7 xattr_handler: pa... |
19 |
return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
79a628d14 reiserfs: switch ... |
20 |
buffer, size); |
1da177e4c Linux-2.6.12-rc2 |
21 22 23 |
} static int |
593012268 switch xattr_hand... |
24 25 26 |
security_set(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, const void *buffer, size_t size, int flags) |
1da177e4c Linux-2.6.12-rc2 |
27 |
{ |
593012268 switch xattr_hand... |
28 |
if (IS_PRIVATE(inode)) |
bd4c625c0 reiserfs: run scr... |
29 |
return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
30 |
|
593012268 switch xattr_hand... |
31 |
return reiserfs_xattr_set(inode, |
79a628d14 reiserfs: switch ... |
32 33 |
xattr_full_name(handler, name), buffer, size, flags); |
1da177e4c Linux-2.6.12-rc2 |
34 |
} |
764a5c6b1 xattr handlers: S... |
35 |
static bool security_list(struct dentry *dentry) |
1da177e4c Linux-2.6.12-rc2 |
36 |
{ |
764a5c6b1 xattr handlers: S... |
37 |
return !IS_PRIVATE(d_inode(dentry)); |
1da177e4c Linux-2.6.12-rc2 |
38 |
} |
57fe60df6 reiserfs: add ato... |
39 40 41 42 |
/* Initializes the security context for a new inode and returns the number * of blocks needed for the transaction. If successful, reiserfs_security * must be released using reiserfs_security_free when the caller is done. */ int reiserfs_security_init(struct inode *dir, struct inode *inode, |
2a7dba391 fs/vfs/security: ... |
43 |
const struct qstr *qstr, |
57fe60df6 reiserfs: add ato... |
44 45 46 |
struct reiserfs_security_handle *sec) { int blocks = 0; |
b82bb72ba reiserfs: dont as... |
47 48 49 50 51 52 53 |
int error; sec->name = NULL; /* Don't add selinux attributes on xattrs - they'll never get used */ if (IS_PRIVATE(dir)) return 0; |
9d8f13ba3 security: new sec... |
54 55 |
error = security_old_inode_init_security(inode, dir, qstr, &sec->name, &sec->value, &sec->length); |
57fe60df6 reiserfs: add ato... |
56 57 58 59 60 61 62 63 64 |
if (error) { if (error == -EOPNOTSUPP) error = 0; sec->name = NULL; sec->value = NULL; sec->length = 0; return error; } |
6cb4aff0a reiserfs: fix oop... |
65 |
if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) { |
57fe60df6 reiserfs: add ato... |
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
blocks = reiserfs_xattr_jcreate_nblocks(inode) + reiserfs_xattr_nblocks(inode, sec->length); /* We don't want to count the directories twice if we have * a default ACL. */ REISERFS_I(inode)->i_flags |= i_has_xattr_dir; } return blocks; } int reiserfs_security_write(struct reiserfs_transaction_handle *th, struct inode *inode, struct reiserfs_security_handle *sec) { int error; if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX)) return -EINVAL; error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value, sec->length, XATTR_CREATE); if (error == -ENODATA || error == -EOPNOTSUPP) error = 0; return error; } void reiserfs_security_free(struct reiserfs_security_handle *sec) { kfree(sec->name); kfree(sec->value); sec->name = NULL; sec->value = NULL; } |
94d09a98c reiserfs: constif... |
98 |
const struct xattr_handler reiserfs_xattr_security_handler = { |
1da177e4c Linux-2.6.12-rc2 |
99 100 101 |
.prefix = XATTR_SECURITY_PREFIX, .get = security_get, .set = security_set, |
1da177e4c Linux-2.6.12-rc2 |
102 103 |
.list = security_list, }; |