* [PATCH] btrfs: fix uninit pointer free on read_alloc_one_name error
@ 2024-10-10 19:47 Roi Martin
2024-10-10 23:57 ` Anand Jain
2024-10-11 16:09 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Roi Martin @ 2024-10-10 19:47 UTC (permalink / raw)
To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Roi Martin
The read_alloc_one_name function does not initialize the name field of
the passed fscrypt_str struct if kmalloc fails to allocate the
corresponding buffer. Thus, it is not guaranteed that
fscrypt_str.name is initialized when freeing it.
This is a follow-up to the linked patch that fixes the remaining
instances of the bug introduced by commit e43eec81c516 ("btrfs: use
struct qstr instead of name and namelen pairs").
Link: https://lore.kernel.org/linux-btrfs/20241009080833.1355894-1-jroi.martin@gmail.com/
Fixes: e43eec81c516 ("btrfs: use struct qstr instead of name and namelen pairs")
Signed-off-by: Roi Martin <jroi.martin@gmail.com>
---
fs/btrfs/tree-log.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index e2ed2a791f8f..d2e5781701f9 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1845,7 +1845,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
struct btrfs_dir_item *di,
struct btrfs_key *key)
{
- struct fscrypt_str name;
+ struct fscrypt_str name = { 0 };
struct btrfs_dir_item *dir_dst_di;
struct btrfs_dir_item *index_dst_di;
bool dir_dst_matches = false;
@@ -2125,7 +2125,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
struct extent_buffer *eb;
int slot;
struct btrfs_dir_item *di;
- struct fscrypt_str name;
+ struct fscrypt_str name = { 0 };
struct inode *inode = NULL;
struct btrfs_key location;
base-commit: eb952c47d154ba2aac794b99c66c3c45eb4cc4ec
--
2.46.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: fix uninit pointer free on read_alloc_one_name error
2024-10-10 19:47 [PATCH] btrfs: fix uninit pointer free on read_alloc_one_name error Roi Martin
@ 2024-10-10 23:57 ` Anand Jain
2024-10-11 16:09 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2024-10-10 23:57 UTC (permalink / raw)
To: Roi Martin, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel
LGTM
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Thx.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: fix uninit pointer free on read_alloc_one_name error
2024-10-10 19:47 [PATCH] btrfs: fix uninit pointer free on read_alloc_one_name error Roi Martin
2024-10-10 23:57 ` Anand Jain
@ 2024-10-11 16:09 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2024-10-11 16:09 UTC (permalink / raw)
To: Roi Martin; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel
On Thu, Oct 10, 2024 at 09:47:17PM +0200, Roi Martin wrote:
> The read_alloc_one_name function does not initialize the name field of
> the passed fscrypt_str struct if kmalloc fails to allocate the
> corresponding buffer. Thus, it is not guaranteed that
> fscrypt_str.name is initialized when freeing it.
>
> This is a follow-up to the linked patch that fixes the remaining
> instances of the bug introduced by commit e43eec81c516 ("btrfs: use
> struct qstr instead of name and namelen pairs").
>
> Link: https://lore.kernel.org/linux-btrfs/20241009080833.1355894-1-jroi.martin@gmail.com/
> Fixes: e43eec81c516 ("btrfs: use struct qstr instead of name and namelen pairs")
> Signed-off-by: Roi Martin <jroi.martin@gmail.com>
Added to for-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-11 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 19:47 [PATCH] btrfs: fix uninit pointer free on read_alloc_one_name error Roi Martin
2024-10-10 23:57 ` Anand Jain
2024-10-11 16:09 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®