[PATCH] reiserfs: don't leak memory referenced by struct reiserfs_security_handle fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ever since its introduction in 2.6.30 reiserfs_security_free() was
unused. Make all four users of reiserfs_security_init() use it. For
this to be safe (avoiding attempts to free an uninitialized ->value
member), remove a (now?) pointless shortcut from the latter function:
security_old_inode_init_security() properly returns -EOPNOTSUPP when
IS_PRIVATE(inode) (with the private flag getting propagated from dir),
and hence the respective exit path can be used uniformly.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Jeff Mahoney <jeffm@xxxxxxxx>
---
 fs/reiserfs/namei.c          |    4 ++++
 fs/reiserfs/xattr_security.c |    6 ------
 2 files changed, 4 insertions(+), 6 deletions(-)

--- 4.2-rc8/fs/reiserfs/namei.c
+++ 4.2-rc8-reiserfs-free-security/fs/reiserfs/namei.c
@@ -688,6 +688,7 @@ static int reiserfs_create(struct inode 
 
 out_failed:
 	reiserfs_write_unlock(dir->i_sb);
+	reiserfs_security_free(&security);
 	return retval;
 }
 
@@ -769,6 +770,7 @@ static int reiserfs_mknod(struct inode *
 
 out_failed:
 	reiserfs_write_unlock(dir->i_sb);
+	reiserfs_security_free(&security);
 	return retval;
 }
 
@@ -862,6 +864,7 @@ static int reiserfs_mkdir(struct inode *
 	retval = journal_end(&th);
 out_failed:
 	reiserfs_write_unlock(dir->i_sb);
+	reiserfs_security_free(&security);
 	return retval;
 }
 
@@ -1167,6 +1170,7 @@ static int reiserfs_symlink(struct inode
 	retval = journal_end(&th);
 out_failed:
 	reiserfs_write_unlock(parent_dir->i_sb);
+	reiserfs_security_free(&security);
 	return retval;
 }
 
--- 4.2-rc8/fs/reiserfs/xattr_security.c
+++ 4.2-rc8-reiserfs-free-security/fs/reiserfs/xattr_security.c
@@ -60,12 +60,6 @@ int reiserfs_security_init(struct inode 
 	int blocks = 0;
 	int error;
 
-	sec->name = NULL;
-
-	/* Don't add selinux attributes on xattrs - they'll never get used */
-	if (IS_PRIVATE(dir))
-		return 0;
-
 	error = security_old_inode_init_security(inode, dir, qstr, &sec->name,
 						 &sec->value, &sec->length);
 	if (error) {



--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux File System Development]     [Linux BTRFS]     [Linux NFS]     [Linux Filesystems]     [Ext4 Filesystem]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Resources]

  Powered by Linux