hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/fs/reiserfs/xattr_security.c
....@@ -11,7 +11,8 @@
1111
1212 static int
1313 security_get(const struct xattr_handler *handler, struct dentry *unused,
14
- struct inode *inode, const char *name, void *buffer, size_t size)
14
+ struct inode *inode, const char *name, void *buffer, size_t size,
15
+ int flags)
1516 {
1617 if (IS_PRIVATE(inode))
1718 return -EPERM;
....@@ -49,6 +50,7 @@
4950 int error;
5051
5152 sec->name = NULL;
53
+ sec->value = NULL;
5254
5355 /* Don't add selinux attributes on xattrs - they'll never get used */
5456 if (IS_PRIVATE(dir))
....@@ -80,11 +82,15 @@
8082 struct inode *inode,
8183 struct reiserfs_security_handle *sec)
8284 {
85
+ char xattr_name[XATTR_NAME_MAX + 1] = XATTR_SECURITY_PREFIX;
8386 int error;
84
- if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX))
87
+
88
+ if (XATTR_SECURITY_PREFIX_LEN + strlen(sec->name) > XATTR_NAME_MAX)
8589 return -EINVAL;
8690
87
- error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value,
91
+ strlcat(xattr_name, sec->name, sizeof(xattr_name));
92
+
93
+ error = reiserfs_xattr_set_handle(th, inode, xattr_name, sec->value,
8894 sec->length, XATTR_CREATE);
8995 if (error == -ENODATA || error == -EOPNOTSUPP)
9096 error = 0;
....@@ -94,7 +100,6 @@
94100
95101 void reiserfs_security_free(struct reiserfs_security_handle *sec)
96102 {
97
- kfree(sec->name);
98103 kfree(sec->value);
99104 sec->name = NULL;
100105 sec->value = NULL;