mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fuse: add a null-ptr check
@ 2024-11-30  6:51 Nihar Chaithanya
  2024-11-30  8:22 ` Bernd Schubert
  0 siblings, 1 reply; 7+ messages in thread
From: Nihar Chaithanya @ 2024-11-30  6:51 UTC (permalink / raw)
  To: miklos
  Cc: joannelkoong, linux-fsdevel, linux-kernel, skhan,
	Nihar Chaithanya, syzbot+87b8e6ed25dbc41759f7

The bug KASAN: null-ptr-deref is triggered due to *val being
dereferenced when it is null in fuse_copy_do() when performing
memcpy().
Add a check in fuse_copy_one() to prevent this.

Reported-by: syzbot+87b8e6ed25dbc41759f7@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=87b8e6ed25dbc41759f7
Fixes: 3b97c3652d91 ("fuse: convert direct io to use folios")
Tested-by: syzbot+87b8e6ed25dbc41759f7@syzkaller.appspotmail.com
Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
---
 fs/fuse/dev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 563a0bfa0e95..9c93759ac14b 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1070,6 +1070,9 @@ static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes,
 /* Copy a single argument in the request to/from userspace buffer */
 static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size)
 {
+	if (!val)
+		return -EINVAL;
+
 	while (size) {
 		if (!cs->len) {
 			int err = fuse_copy_fill(cs);
-- 
2.34.1


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

end of thread, other threads:[~2024-12-02 22:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-30  6:51 [PATCH] fuse: add a null-ptr check Nihar Chaithanya
2024-11-30  8:22 ` Bernd Schubert
2024-12-02 20:40   ` Joanne Koong
2024-12-02 20:53     ` Bernd Schubert
2024-12-02 21:17     ` Bernd Schubert
2024-12-02 21:50       ` Bernd Schubert
2024-12-02 22:26         ` Joanne Koong

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®