[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_10DB52C0066E89812EDE2ECC0CB0E7EE4606@qq.com>
Date: Sun, 22 Dec 2024 16:14:13 +0800
From: Edward Adam Davis <eadavis@...com>
To: syzbot+fc519d7875f2d9186c1f@...kaller.appspotmail.com
Cc: devel@...ts.orangefs.org,
hubcap@...ibond.com,
linux-kernel@...r.kernel.org,
martin@...ibond.com,
syzkaller-bugs@...glegroups.com
Subject: [PATCH] orangefs: fix a oob in orangefs_debug_write
syzbot report a slab-out-of-bounds Read in orangefs_debug_write. [1]
The string passed in from userspace is not terminated with a NULL character,
which causes strlen to go out of bounds.
Use kstrndup to replace kstrdup.
[1]
BUG: KASAN: slab-out-of-bounds in strlen+0x93/0xa0 lib/string.c:413
Read of size 1 at addr ffff88814d695800 by task syz-executor153/5822
CPU: 0 UID: 0 PID: 5822 Comm: syz-executor153 Not tainted 6.13.0-rc3-syzkaller-00026-g59dbb9d81adf #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xc3/0x620 mm/kasan/report.c:489
kasan_report+0xd9/0x110 mm/kasan/report.c:602
strlen+0x93/0xa0 lib/string.c:413
kstrdup+0x29/0xb0 mm/util.c:81
debug_string_to_mask+0x82/0x570 fs/orangefs/orangefs-debugfs.c:836
orangefs_debug_write+0x22e/0x780 fs/orangefs/orangefs-debugfs.c:423
full_proxy_write+0xfb/0x1b0 fs/debugfs/file.c:356
vfs_write+0x24c/0x1150 fs/read_write.c:677
ksys_write+0x12b/0x250 fs/read_write.c:731
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Reported-by: syzbot+fc519d7875f2d9186c1f@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fc519d7875f2d9186c1f
Tested-by: syzbot+fc519d7875f2d9186c1f@...kaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@...com>
---
fs/orangefs/orangefs-debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 1b508f543384..c2637c966e52 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -833,7 +833,9 @@ static void debug_string_to_mask(char *debug_string, void *mask, int type)
{
char *unchecked_keyword;
int i;
- char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL);
+ char *strsep_fodder = kstrndup(debug_string,
+ ORANGEFS_MAX_DEBUG_STRING_LEN,
+ GFP_KERNEL);
char *original_pointer;
int element_count = 0;
struct client_debug_mask *c_mask = NULL;
--
2.47.0
Powered by blists - more mailing lists