All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xattr handlers: plug a lock leak in simple_xattr_list
@ 2016-02-04  7:54 Andreas Gruenbacher
  2016-02-07 22:53 ` James Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Gruenbacher @ 2016-02-04  7:54 UTC (permalink / raw)
  To: Alexander Viro
  Cc: Mateusz Guzik, linux-fsdevel, linux-kernel, stable, James Morris,
	Andreas Gruenbacher

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xattr handlers: plug a lock leak in simple_xattr_list
  2016-02-04  7:54 [PATCH] xattr handlers: plug a lock leak in simple_xattr_list Andreas Gruenbacher
@ 2016-02-07 22:53 ` James Morris
  0 siblings, 0 replies; 4+ messages in thread
From: James Morris @ 2016-02-07 22:53 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Alexander Viro, Mateusz Guzik, linux-fsdevel, linux-kernel,
	stable, James Morris

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xattr handlers: plug a lock leak in simple_xattr_list
  2016-02-04  1:56 Mateusz Guzik
@ 2016-02-04  3:08 ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2016-02-04  3:08 UTC (permalink / raw)
  To: Mateusz Guzik
  Cc: Alexander Viro, linux-fsdevel, linux-kernel, stable,
	Andreas Gruenbacher, James Morris

On Thu, Feb 04, 2016 at 02:56:30AM +0100, Mateusz Guzik wrote:
> 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>
> ---
>  fs/xattr.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read Documentation/stable_kernel_rules.txt
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] xattr handlers: plug a lock leak in simple_xattr_list
@ 2016-02-04  1:56 Mateusz Guzik
  2016-02-04  3:08 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Mateusz Guzik @ 2016-02-04  1:56 UTC (permalink / raw)
  To: Alexander Viro
  Cc: linux-fsdevel, linux-kernel, stable, Andreas Gruenbacher, James Morris

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>
---
 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;
 }
 
 /*
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-07 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04  7:54 [PATCH] xattr handlers: plug a lock leak in simple_xattr_list Andreas Gruenbacher
2016-02-07 22:53 ` James Morris
  -- strict thread matches above, loose matches on Subject: below --
2016-02-04  1:56 Mateusz Guzik
2016-02-04  3:08 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.