Skip to content

Commit d82dcd9

Browse files
robertosassupcmoore
authored andcommitted
reiserfs: Add security prefix to xattr name in reiserfs_security_write()
Reiserfs sets a security xattr at inode creation time in two stages: first, it calls reiserfs_security_init() to obtain the xattr from active LSMs; then, it calls reiserfs_security_write() to actually write that xattr. Unfortunately, it seems there is a wrong expectation that LSMs provide the full xattr name in the form 'security.<suffix>'. However, LSMs always provided just the suffix, causing reiserfs to not write the xattr at all (if the suffix is shorter than the prefix), or to write an xattr with the wrong name. Add a temporary buffer in reiserfs_security_write(), and write to it the full xattr name, before passing it to reiserfs_xattr_set_handle(). Also replace the name length check with a check that the full xattr name is not larger than XATTR_NAME_MAX. Cc: stable@vger.kernel.org # v2.6.x Fixes: 57fe60d ("reiserfs: add atomic addition of selinux attributes during inode creation") Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 0d57b97 commit d82dcd9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

fs/reiserfs/xattr_security.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ int reiserfs_security_write(struct reiserfs_transaction_handle *th,
9595
struct inode *inode,
9696
struct reiserfs_security_handle *sec)
9797
{
98+
char xattr_name[XATTR_NAME_MAX + 1] = XATTR_SECURITY_PREFIX;
9899
int error;
99-
if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX))
100+
101+
if (XATTR_SECURITY_PREFIX_LEN + strlen(sec->name) > XATTR_NAME_MAX)
100102
return -EINVAL;
101103

102-
error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value,
104+
strlcat(xattr_name, sec->name, sizeof(xattr_name));
105+
106+
error = reiserfs_xattr_set_handle(th, inode, xattr_name, sec->value,
103107
sec->length, XATTR_CREATE);
104108
if (error == -ENODATA || error == -EOPNOTSUPP)
105109
error = 0;

0 commit comments

Comments
 (0)