lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADvbK_dhz36U7DbNTMimS47iQD3Ayx-W+aVGp6bOt_ByY350yw@mail.gmail.com>
Date:   Wed, 17 Jan 2018 18:39:04 +0800
From:   Xin Long <lucien.xin@...il.com>
To:     syzbot <syzbot+03bee3680a37466775e7@...kaller.appspotmail.com>
Cc:     Jason@...c4.com, Andrey Vagin <avagin@...nvz.org>,
        davem <davem@...emloft.net>, David Ahern <dsahern@...il.com>,
        dwindsor@...il.com, elena.reshetova@...el.com,
        Herbert Xu <herbert@...dor.apana.org.au>,
        johannes.berg@...el.com, LKML <linux-kernel@...r.kernel.org>,
        network dev <netdev@...r.kernel.org>,
        syzkaller-bugs@...glegroups.com,
        Américo Wang <xiyou.wangcong@...il.com>
Subject: Re: KASAN: stack-out-of-bounds Read in __nla_put

On Wed, Jan 17, 2018 at 1:58 AM, syzbot
<syzbot+03bee3680a37466775e7@...kaller.appspotmail.com> wrote:
> Hello,
>
> syzkaller hit the following crash on
> fdddade65d7b5f8779374eb73d09889185280f60
> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
>
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+03bee3680a37466775e7@...kaller.appspotmail.com
> It will help syzbot understand when the bug is fixed. See footer for
> details.
> If you forward the report, please keep this part and the footer.
>
> audit: type=1400 audit(1516082805.746:7): avc:  denied  { map } for
> pid=3670 comm="syzkaller084676" path="/root/syzkaller084676122" dev="sda1"
> ino=16481 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
> tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
> ==================================================================
> BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:344
> [inline]
> BUG: KASAN: stack-out-of-bounds in __nla_put+0x37/0x40 lib/nlattr.c:569
> Read of size 255 at addr ffff8801c62f7968 by task syzkaller084676/3670
Hi, David A.

I guess you need to move up your memset(0) a little bit:

@@ -2427,6 +2443,7 @@ int netlink_rcv_skb(struct sk_buff *skb, int
(*cb)(struct sk_buff *,
                nlh = nlmsg_hdr(skb);
                err = 0;

+               memset(&extack, 0, sizeof(extack));
                if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
                        return 0;

@@ -2438,7 +2455,6 @@ int netlink_rcv_skb(struct sk_buff *skb, int
(*cb)(struct sk_buff *,
                if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
                        goto ack;

-               memset(&extack, 0, sizeof(extack));
                err = cb(skb, nlh, &extack);

So that 'goto ack's won't skip it. :-)

>
> CPU: 1 PID: 3670 Comm: syzkaller084676 Not tainted 4.15.0-rc8-next-20180116+
> #98
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:17 [inline]
>  dump_stack+0x194/0x257 lib/dump_stack.c:53
>  print_address_description+0x73/0x250 mm/kasan/report.c:256
>  kasan_report_error mm/kasan/report.c:354 [inline]
>  kasan_report+0x23b/0x360 mm/kasan/report.c:412
>  check_memory_region_inline mm/kasan/kasan.c:260 [inline]
>  check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
>  memcpy+0x23/0x50 mm/kasan/kasan.c:302
>  memcpy include/linux/string.h:344 [inline]
>  __nla_put+0x37/0x40 lib/nlattr.c:569
>  nla_put+0xf5/0x130 lib/nlattr.c:627
>  netlink_ack+0x78a/0xa10 net/netlink/af_netlink.c:2404
>  netlink_rcv_skb+0x2d1/0x400 net/netlink/af_netlink.c:2448
>  rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4548
>  netlink_unicast_kernel net/netlink/af_netlink.c:1308 [inline]
>  netlink_unicast+0x4c4/0x6b0 net/netlink/af_netlink.c:1334
>  netlink_sendmsg+0xa4a/0xe60 net/netlink/af_netlink.c:1897
>  sock_sendmsg_nosec net/socket.c:630 [inline]
>  sock_sendmsg+0xca/0x110 net/socket.c:640
>  sock_write_iter+0x31a/0x5d0 net/socket.c:909
>  call_write_iter include/linux/fs.h:1775 [inline]
>  new_sync_write fs/read_write.c:469 [inline]
>  __vfs_write+0x684/0x970 fs/read_write.c:482
>  vfs_write+0x189/0x510 fs/read_write.c:544
>  SYSC_write fs/read_write.c:589 [inline]
>  SyS_write+0xef/0x220 fs/read_write.c:581
>  entry_SYSCALL_64_fastpath+0x29/0xa0
> RIP: 0033:0x43fce9
> RSP: 002b:00007ffe2c7f0b68 EFLAGS: 00000217 ORIG_RAX: 0000000000000001
> RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043fce9
> RDX: 0000000000000022 RSI: 0000000020d1f000 RDI: 0000000000000003
> RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000004 R11: 0000000000000217 R12: 0000000000401650
> R13: 00000000004016e0 R14: 0000000000000000 R15: 0000000000000000
>
> The buggy address belongs to the page:
> page:ffffea000718bdc0 count:0 mapcount:0 mapping:          (null) index:0x0
> flags: 0x2fffc0000000000()
> raw: 02fffc0000000000 0000000000000000 0000000000000000 00000000ffffffff
> raw: 0000000000000000 ffffea0007180101 0000000000000000 0000000000000000
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
>  ffff8801c62f7880: f1 f1 f1 04 f2 f2 f2 f3 f3 f3 f3 00 00 00 00 00
>  ffff8801c62f7900: 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00 00
>>
>> ffff8801c62f7980: f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00 00
>
>                    ^
>  ffff8801c62f7a00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2
>  ffff8801c62f7a80: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
> ==================================================================
>
>
> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to syzkaller@...glegroups.com.
>
> syzbot will keep track of this bug report.
> If you forgot to add the Reported-by tag, once the fix for this bug is
> merged
> into any tree, please reply to this email with:
> #syz fix: exact-commit-title
> If you want to test a patch for this bug, please reply with:
> #syz test: git://repo/address.git branch
> and provide the patch inline or as an attachment.
> To mark this as a duplicate of another syzbot report, please reply with:
> #syz dup: exact-subject-of-another-report
> If it's a one-off invalid bug report, please reply with:
> #syz invalid
> Note: if the crash happens again, it will cause creation of a new bug
> report.
> Note: all commands must start from beginning of the line in the email body.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ