Skip to contentSkip to conversation

Prevent oopsing in posix_acl_valid()

PATCH In review Daniel J Blueman 3 participants 3 messages May 3, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Prevent oopsing in posix_acl_valid()

If posix_acl_from_xattr() returns an error code, a negative address is dereferenced causing an oops; fix by checking for error code first.

---
 fs/btrfs/acl.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/acl.c +3 -2
index 5d505aa..cad6fbb 100644
@@ -178,12 +178,13 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
 
 	if (value) {
 		acl = posix_acl_from_xattr(value, size);
+		if (IS_ERR(acl)
+			return PTR_ERR(acl);
+
 		if (acl) {
 			ret = posix_acl_valid(acl);
 			if (ret)
 				goto out;
-		} else if (IS_ERR(acl)) {
-			return PTR_ERR(acl);
 		}
 	}
 
Signature · 1 line
1.7.4.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Daniel J Blueman

If posix_acl_from_xattr() returns an error code, a negative address is dereferenced causing an oops; fix by checking for error code first.

---
  fs/btrfs/acl.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/acl.c +2 -0
index 5d505aa..cad6fbb 100644
@@ -178,12 +178,13 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
 
  	if (value) {
  		acl = posix_acl_from_xattr(value, size);
+		if (IS_ERR(acl)
+			return PTR_ERR(acl);

fs/btrfs/acl.c static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, · line 190

Quoted 10 lines
fs/btrfs/acl.c +1 -2
+
  		if (acl) {
  			ret = posix_acl_valid(acl);
  			if (ret)
  				goto out;
-		} else if (IS_ERR(acl)) {
-			return PTR_ERR(acl);
  		}
  	}
 

Thanks,

Josef

#2 lore raw

2011/5/3 Josef Bacik <[email protected]>:

Quoted 3 lines · Daniel J Blueman
Quoted 2 lines

If posix_acl_from_xattr() returns an error code, a negative address =

is

Quoted 14 lines
Quoted 14 lines

dereferenced causing an oops; fix by checking for error code first.

---
=A0fs/btrfs/acl.c | =A0 =A05 +++--
=A01 files changed, 3 insertions(+), 2 deletions(-)

fs/btrfs/acl.c +0 -0
index 5d505aa..cad6fbb 100644
@@ -178,12 +178,13 @@ static int btrfs_xattr_acl_set(struct dentry
 *dentry, const char *name,
 
Quoted 2 lines
Quoted 2 lines
fs/btrfs/acl.c +0 -0
 =A0 =A0 =A0 =A0if (value) {

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0acl =3D posix_acl_from_xattr(value, s=

ize);

Quoted 1 line
Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (IS_ERR(acl)

A small typo: The right parenthesis is missing.

Christian
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html