[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEkJfYM9PZ7Py6aeHOf5YgD8KiczthM5_opEOXDjp2rE=3ry+Q@mail.gmail.com>
Date: Fri, 1 Mar 2024 23:22:52 +0800
From: Sam Sun <samsun1006219@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org, j.vosburgh@...il.com,
andy@...yhouse.net, davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
syzkaller@...glegroups.com
Subject: Re: [Kernel bug] KASAN: slab-out-of-bounds Read in in4_pton
On Fri, Mar 1, 2024 at 4:18 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> On Fri, Mar 1, 2024 at 3:41 AM Sam Sun <samsun1006219@...il.com> wrote:
> >
> > Dear developers and maintainers,
> >
> > We found a bug through our modified Syzkaller. Kernel version is b401b621758,
> > Linux 6.8-rc5. The C reproducer and kernel config are attached.
> >
> > KASAN report is listed below
> >
> > ```
> > ==================================================================
> > BUG: KASAN: slab-out-of-bounds in strlen+0x7d/0xa0 lib/string.c:418
> > Read of size 1 at addr ffff8881119c4781 by task syz-executor665/8107
> >
> > CPU: 1 PID: 8107 Comm: syz-executor665 Not tainted 6.7.0-rc7 #1
> > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
> > Call Trace:
> > <TASK>
> > __dump_stack lib/dump_stack.c:88 [inline]
> > dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
> > print_address_description mm/kasan/report.c:364 [inline]
> > print_report+0xc1/0x5e0 mm/kasan/report.c:475
> > kasan_report+0xbe/0xf0 mm/kasan/report.c:588
> > strlen+0x7d/0xa0 lib/string.c:418
> > __fortify_strlen include/linux/fortify-string.h:210 [inline]
> > in4_pton+0xa3/0x3f0 net/core/utils.c:130
> > bond_option_arp_ip_targets_set+0xc2/0x910 drivers/net/bonding/bond_options.c:1201
> > __bond_opt_set+0x2a4/0x1030 drivers/net/bonding/bond_options.c:767
> > __bond_opt_set_notify+0x48/0x150 drivers/net/bonding/bond_options.c:792
> > bond_opt_tryset_rtnl+0xda/0x160 drivers/net/bonding/bond_options.c:817
> > bonding_sysfs_store_option+0xa1/0x120 drivers/net/bonding/bond_sysfs.c:156
> > dev_attr_store+0x54/0x80 drivers/base/core.c:2366
> > sysfs_kf_write+0x114/0x170 fs/sysfs/file.c:136
> > kernfs_fop_write_iter+0x337/0x500 fs/kernfs/file.c:334
> > call_write_iter include/linux/fs.h:2020 [inline]
> > new_sync_write fs/read_write.c:491 [inline]
> > vfs_write+0x96a/0xd80 fs/read_write.c:584
> > ksys_write+0x122/0x250 fs/read_write.c:637
> > do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> > do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83
> > entry_SYSCALL_64_after_hwframe+0x63/0x6b
> > RIP: 0033:0x7f797835cfcd
> > Code: 28 c3 e8 46 1e 00 00 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
> > RSP: 002b:00007ffff464ffb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> > RAX: ffffffffffffffda RBX: 00007ffff46501b8 RCX: 00007f797835cfcd
> > RDX: 00000000000000f5 RSI: 0000000020000140 RDI: 0000000000000003
> > RBP: 0000000000000001 R08: 0000000000000000 R09: 00007ffff46501b8
> > R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
> > R13: 00007ffff46501a8 R14: 00007f79783da530 R15: 0000000000000001
> > </TASK>
> >
> > All
>
>
> >
> > We analyzed the cause of this bug. In the function "bond_option_arp_ip_targets_set" in
> > drivers/net/bonding/bond_options.c, newval->string can be controlled by users. If string
> >
> > is empty, newval->string+1 points to the address after newval->string, causing potential
> >
> > info leak.
> >
> > One possible fix is to check before calling in4_pton, whether strnlen(newval->string) > 1.
> >
> > If you have any questions or require more information, please feel
> > free to contact us.
> >
> > Reported by Yue Sun <samsun1006219@...il.com>
> >
>
> Thanks for the report and analysis.
>
> Are you willing to provide a patch ?
>
> You would get more credits than a "Reported-by:" tag :)
>
> Thanks
Dear Eric,
Thanks for letting me provide a patch! One possible patch
is listed below.
diff --git a/drivers/net/bonding/bond_options.c
b/drivers/net/bonding/bond_options.c
index f3f27f0bd2a6..a6d01055f455 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -1198,7 +1198,7 @@ static int bond_option_arp_ip_targets_set(struct
bonding *bond,
__be32 target;
if (newval->string) {
- if (!in4_pton(newval->string+1, -1, (u8 *)&target, -1, NULL)) {
+ if (!strlen(newval->string) || !in4_pton(newval->string+1,
-1, (u8 *)&target, -1, NULL)) {
netdev_err(bond->dev, "invalid ARP target %pI4 specified\n",
&target);
return ret;
This patch was tested on kernel commit b401b621758,
tag Linux 6.8-rc5 against the C repro listed in previous
email.
If you have any questions, please contact us.
Best Regards,
Yue
Powered by blists - more mailing lists