mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix uninitialized variable in ext4_inlinedir_to_tree
@ 2024-05-01  3:30 Xiaxi Shen
  2024-06-28 17:17 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaxi Shen @ 2024-05-01  3:30 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-ext4, linux-kernel
  Cc: shenxiaxi26, skhan, javier.carrasco.cruz, syzkaller-bugs,
	syzbot+eaba5abe296837a640c0

Syzbot has found an uninit-value bug in ext4_inlinedir_to_tree

This error happens because ext4_inlinedir_to_tree does not
handle the case when ext4fs_dirhash returns an error

This can be avoided by checking the return value of ext4fs_dirhash 
and propagating the error,
similar to how it's done with ext4_htree_store_dirent

Signed-off-by: Xiaxi Shen <shenxiaxi26@gmail.com>
Reported-and-tested-by: syzbot+eaba5abe296837a640c0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=eaba5abe296837a640c0
---
 fs/ext4/inline.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index d5bd1e3a5d36..e7a09a99837b 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1410,7 +1410,11 @@ int ext4_inlinedir_to_tree(struct file *dir_file,
 			hinfo->hash = EXT4_DIRENT_HASH(de);
 			hinfo->minor_hash = EXT4_DIRENT_MINOR_HASH(de);
 		} else {
-			ext4fs_dirhash(dir, de->name, de->name_len, hinfo);
+			err = ext4fs_dirhash(dir, de->name, de->name_len, hinfo);
+			if (err) {
+				ret = err;
+				goto out;
+			}
 		}
 		if ((hinfo->hash < start_hash) ||
 		    ((hinfo->hash == start_hash) &&
-- 
2.34.1


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

* Re: [PATCH] Fix uninitialized variable in ext4_inlinedir_to_tree
  2024-05-01  3:30 [PATCH] Fix uninitialized variable in ext4_inlinedir_to_tree Xiaxi Shen
@ 2024-06-28 17:17 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2024-06-28 17:17 UTC (permalink / raw)
  To: adilger.kernel, linux-ext4, linux-kernel, Xiaxi Shen
  Cc: Theodore Ts'o, skhan, javier.carrasco.cruz, syzkaller-bugs,
	syzbot+eaba5abe296837a640c0


On Tue, 30 Apr 2024 20:30:17 -0700, Xiaxi Shen wrote:
> Syzbot has found an uninit-value bug in ext4_inlinedir_to_tree
> 
> This error happens because ext4_inlinedir_to_tree does not
> handle the case when ext4fs_dirhash returns an error
> 
> This can be avoided by checking the return value of ext4fs_dirhash
> and propagating the error,
> similar to how it's done with ext4_htree_store_dirent
> 
> [...]

Applied, thanks!

[1/1] Fix uninitialized variable in ext4_inlinedir_to_tree
      commit: 8dc9c3da79c84b13fdb135e2fb0a149a8175bffe

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

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

end of thread, other threads:[~2024-06-28 17:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-01  3:30 [PATCH] Fix uninitialized variable in ext4_inlinedir_to_tree Xiaxi Shen
2024-06-28 17:17 ` Theodore Ts'o

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®