[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250925184139.403156-1-mssola@mssola.com>
Date: Thu, 25 Sep 2025 20:41:39 +0200
From: Miquel Sabaté Solà <mssola@...ola.com>
To: linux-btrfs@...r.kernel.org
Cc: clm@...com,
dsterba@...e.com,
wqu@...e.com,
linux-kernel@...r.kernel.org,
Miquel Sabaté Solà <mssola@...ola.com>,
Boris Burkov <boris@....io>
Subject: [PATCH v2] btrfs: ioctl: Fix memory leak on duplicated memory
On 'btrfs_ioctl_qgroup_assign' we first duplicate the argument as
provided by the user, which is kfree'd in the end. But this was not the
case when allocating memory for 'prealloc'. In this case, if it somehow
failed, then the previous code would go directly into calling
'mnt_drop_write_file', without freeing the string duplicated from the
user space.
Fixes: 4addc1ffd67a ("btrfs: qgroup: preallocate memory before adding a relation")
Reviewed-by: Boris Burkov <boris@....io>
Signed-off-by: Miquel Sabaté Solà <mssola@...ola.com>
---
fs/btrfs/ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 185bef0df1c2..8cb7d5a462ef 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3740,7 +3740,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
if (!prealloc) {
ret = -ENOMEM;
- goto drop_write;
+ goto out;
}
}
--
2.51.0
Powered by blists - more mailing lists