Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1326469 > unrolled thread

[PATCH] xattr handlers: plug a lock leak in simple_xattr_list

Started byAndreas Gruenbacher <agruenba@redhat.com>
First post2016-02-04 09:00 +0100
Last post2016-02-08 00:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] xattr handlers: plug a lock leak in simple_xattr_list Andreas Gruenbacher <agruenba@redhat.com> - 2016-02-04 09:00 +0100
    Re: [PATCH] xattr handlers: plug a lock leak in simple_xattr_list James Morris <jmorris@namei.org> - 2016-02-08 00:00 +0100

#1326469 — [PATCH] xattr handlers: plug a lock leak in simple_xattr_list

FromAndreas Gruenbacher <agruenba@redhat.com>
Date2016-02-04 09:00 +0100
Subject[PATCH] xattr handlers: plug a lock leak in simple_xattr_list
Message-ID<qYmZB-5D0-23@gated-at.bofh.it>
From: Mateusz Guzik <mguzik@redhat.com>

The code could leak xattrs->lock on error.

Problem introduced with 786534b92f3ce68f4 "tmpfs: listxattr should
include POSIX ACL xattrs".

Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Cc: <stable@vger.kernel.org> # 4.4

---
 fs/xattr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index 07d0e47..4861322 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -940,7 +940,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
 	bool trusted = capable(CAP_SYS_ADMIN);
 	struct simple_xattr *xattr;
 	ssize_t remaining_size = size;
-	int err;
+	int err = 0;
 
 #ifdef CONFIG_FS_POSIX_ACL
 	if (inode->i_acl) {
@@ -965,11 +965,11 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
 
 		err = xattr_list_one(&buffer, &remaining_size, xattr->name);
 		if (err)
-			return err;
+			break;
 	}
 	spin_unlock(&xattrs->lock);
 
-	return size - remaining_size;
+	return err ? err : size - remaining_size;
 }
 
 /*
-- 
2.5.0

[toc] | [next] | [standalone]


#1328648

FromJames Morris <jmorris@namei.org>
Date2016-02-08 00:00 +0100
Message-ID<qZGtc-4zn-7@gated-at.bofh.it>
In reply to#1326469
On Thu, 4 Feb 2016, Andreas Gruenbacher wrote:

> From: Mateusz Guzik <mguzik@redhat.com>
> 
> The code could leak xattrs->lock on error.
> 
> Problem introduced with 786534b92f3ce68f4 "tmpfs: listxattr should
> include POSIX ACL xattrs".
> 
> Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> Cc: <stable@vger.kernel.org> # 4.4


Acked-by: James Morris <james.l.morris@oracle.com>


-- 
James Morris
<jmorris@namei.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web