All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix memory leak in the extent_same ioctl
@ 2015-07-03  7:48 fdmanana
  2015-07-03 10:36 ` [PATCH v2] " fdmanana
  2015-07-03 16:15 ` [PATCH] " Mark Fasheh
  0 siblings, 2 replies; 4+ messages in thread
From: fdmanana @ 2015-07-03  7:48 UTC (permalink / raw)
  To: linux-btrfs; +Cc: ritter.marcel, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

We were allocating memory with memdup_user() but we were never releasing
that memory. This affected pretty much every call to the ioctl, whether
it deduplicated extents or not.

This issue was reported on IRC by Julian Taylor and on the mailing list
by Marcel Ritter, credit goes to them for finding the issue.

Reported-by: Julian Taylor (jtaylor@IRC)
Reported-by: Marcel Ritter <ritter.marcel@gmail.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c86b835..78e6a28 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2958,7 +2958,7 @@ out_unlock:
 static long btrfs_ioctl_file_extent_same(struct file *file,
 			struct btrfs_ioctl_same_args __user *argp)
 {
-	struct btrfs_ioctl_same_args *same;
+	struct btrfs_ioctl_same_args *same = NULL;
 	struct btrfs_ioctl_same_extent_info *info;
 	struct inode *src = file_inode(file);
 	u64 off;
@@ -2988,6 +2988,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
 	if (IS_ERR(same)) {
 		ret = PTR_ERR(same);
+		same = NULL;
 		goto out;
 	}
 
@@ -3058,6 +3059,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
 out:
 	mnt_drop_write_file(file);
+	kfree(same);
 	return ret;
 }
 
-- 
2.1.3


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

* [PATCH v2] Btrfs: fix memory leak in the extent_same ioctl
  2015-07-03  7:48 [PATCH] Btrfs: fix memory leak in the extent_same ioctl fdmanana
@ 2015-07-03 10:36 ` fdmanana
  2015-07-06 16:57   ` Mark Fasheh
  2015-07-03 16:15 ` [PATCH] " Mark Fasheh
  1 sibling, 1 reply; 4+ messages in thread
From: fdmanana @ 2015-07-03 10:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe Manana, stable

From: Filipe Manana <fdmanana@suse.com>

We were allocating memory with memdup_user() but we were never releasing
that memory. This affected pretty much every call to the ioctl, whether
it deduplicated extents or not.

This issue was reported on IRC by Julian Taylor and on the mailing list
by Marcel Ritter, credit goes to them for finding the issue.

Reported-by: Julian Taylor <jtaylor.debian@googlemail.com>
Reported-by: Marcel Ritter <ritter.marcel@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---

V2: Added cc to stable, forgotten in v1, and Julian's mail address.

 fs/btrfs/ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c86b835..78e6a28 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2958,7 +2958,7 @@ out_unlock:
 static long btrfs_ioctl_file_extent_same(struct file *file,
 			struct btrfs_ioctl_same_args __user *argp)
 {
-	struct btrfs_ioctl_same_args *same;
+	struct btrfs_ioctl_same_args *same = NULL;
 	struct btrfs_ioctl_same_extent_info *info;
 	struct inode *src = file_inode(file);
 	u64 off;
@@ -2988,6 +2988,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
 	if (IS_ERR(same)) {
 		ret = PTR_ERR(same);
+		same = NULL;
 		goto out;
 	}
 
@@ -3058,6 +3059,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
 
 out:
 	mnt_drop_write_file(file);
+	kfree(same);
 	return ret;
 }
 
-- 
2.1.3


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

* Re: [PATCH] Btrfs: fix memory leak in the extent_same ioctl
  2015-07-03  7:48 [PATCH] Btrfs: fix memory leak in the extent_same ioctl fdmanana
  2015-07-03 10:36 ` [PATCH v2] " fdmanana
@ 2015-07-03 16:15 ` Mark Fasheh
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Fasheh @ 2015-07-03 16:15 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs, ritter.marcel, Filipe Manana

That looks great, thanks for fixing this Filipe.

On Fri, Jul 03, 2015 at 08:48:22AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We were allocating memory with memdup_user() but we were never releasing
> that memory. This affected pretty much every call to the ioctl, whether
> it deduplicated extents or not.
> 
> This issue was reported on IRC by Julian Taylor and on the mailing list
> by Marcel Ritter, credit goes to them for finding the issue.
> 
> Reported-by: Julian Taylor (jtaylor@IRC)
> Reported-by: Marcel Ritter <ritter.marcel@gmail.com>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Mark Fasheh <mfasheh@suse.de>
	--Mark

--
Mark Fasheh

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

* Re: [PATCH v2] Btrfs: fix memory leak in the extent_same ioctl
  2015-07-03 10:36 ` [PATCH v2] " fdmanana
@ 2015-07-06 16:57   ` Mark Fasheh
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Fasheh @ 2015-07-06 16:57 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs, Filipe Manana, stable

Thanks for this Filipe,

On Fri, Jul 03, 2015 at 11:36:49AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We were allocating memory with memdup_user() but we were never releasing
> that memory. This affected pretty much every call to the ioctl, whether
> it deduplicated extents or not.
> 
> This issue was reported on IRC by Julian Taylor and on the mailing list
> by Marcel Ritter, credit goes to them for finding the issue.
> 
> Reported-by: Julian Taylor <jtaylor.debian@googlemail.com>
> Reported-by: Marcel Ritter <ritter.marcel@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Mark Fasheh <mfasheh@suse.de>
	--Mark

--
Mark Fasheh

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

end of thread, other threads:[~2015-07-06 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03  7:48 [PATCH] Btrfs: fix memory leak in the extent_same ioctl fdmanana
2015-07-03 10:36 ` [PATCH v2] " fdmanana
2015-07-06 16:57   ` Mark Fasheh
2015-07-03 16:15 ` [PATCH] " Mark Fasheh

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.