Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1620773

Re: net/ipv6: use-after-free in ipv6_sock_ac_close

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Cong Wang <xiyou.wangcong@gmail.com>
Newsgroups linux.kernel
Subject Re: net/ipv6: use-after-free in ipv6_sock_ac_close
Date Tue, 11 Apr 2017 01:20:02 +0200
Message-ID <tuQLg-7ps-3@gated-at.bofh.it> (permalink)
References <tuIum-1Rg-25@gated-at.bofh.it>
X-Original-To Andrey Konovalov <andreyknvl@google.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KLwHudb/BWqdZxF5SuMmwkl3CkkOHxU3/tBpYiL3PpM=; b=MfBnqiIQBf1OkSKYdrhvzcERkZqIOcEEC3nolWR5YihvpFUWJvfTQzL3eH+yTUvGRm qwin3mWuB/lLSJsZJBTjW5TsCATz6MvekaRbpVlE3nhzFcPelt9bIqhwZA6ZcN9JtYBA VOAnSQZm6DWr9dtXtnohQfKKxd6xO/waWd93cKcXMiei13Svo8mbsPcCru5IWtqLmxm5 evXO6CDHtcja2y9kljsyfaHpNfGr44V2MnxXUZJIr0Uqh3uGpYBXO/JPqTKRoPejEMLa VAzMNFcenjX64/x40L24ZZG6Lvzx8bDwzIWbDCb7XLuqYGQHJpsyoLr1LXLKCziLsu6/ owlA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=KLwHudb/BWqdZxF5SuMmwkl3CkkOHxU3/tBpYiL3PpM=; b=EL/JtIDyOVzQiX/20JqKNq+4u9UF6DukmvKo41ONr4oLPIvwHhX6Gwoosqp/TZIrwj C0ISgTRdnrTEe+4TweZF/n4/LX/f3sDlj2NcMOgpGe+Yd51+iyOvn4GWBt3ggAabtJT7 B5A7haoBif/GkU40rZfr0EyCO94aBPAT8Nba9DTMczjbMHHgZ9EUjDq2qnTraVq5ou5Y TMVppVZV8I6PBa7/tkiOAix0LVIAFL7k5PXaKdE442GcryhdIL/XvunzKH9FcVIDBYht 2A+XxXMPdfuWr7rgACHSf0ydEUiHK4/azWrN+raem5mCvOXR4OVdF7OEq4Ij64wxan89 pj5Q==
X-Gm-Message-State AFeK/H2qZLmU8opmWc7e+56epOt/fN1jQF/ZzYZtXiITY/awGeGGoWLfX72sdY0o9o2dWGct2RxLg24m0LGY1w==
X-Received by 10.223.135.134 with SMTP id b6mr22838269wrb.48.1491865914864; Mon, 10 Apr 2017 16:11:54 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 111
Organization linux.* mail to news gateway
X-Original-Cc "David S. Miller" <davem@davemloft.net>, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>, James Morris <jmorris@namei.org>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Patrick McHardy <kaber@trash.net>, netdev <netdev@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, syzkaller <syzkaller@googlegroups.com>, Eric Dumazet <edumazet@google.com>, Dmitry Vyukov <dvyukov@google.com>, Kostya Serebryany <kcc@google.com>
X-Original-Date Mon, 10 Apr 2017 16:11:34 -0700
X-Original-Message-ID <CAM_iQpVV8srXTTSAR=YoKTmWkJc9Ai-ggZLPOfdpSFKJWEysNA@mail.gmail.com>
X-Original-References <CAAeHK+y_7fyLyJnmUKOruWrw3_8a1V1S4htBTa_Psza=VvQdTg@mail.gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1620773

Show key headers only | View raw


On Mon, Apr 10, 2017 at 7:28 AM, Andrey Konovalov <andreyknvl@google.com> wrote:
> Hi,
>
> I've got the following error report while fuzzing the kernel with syzkaller.
>
> On commit 39da7c509acff13fc8cb12ec1bb20337c988ed36 (4.11-rc6).
>
> Unfortunately it's not reproducible.
>
> ==================================================================
> BUG: KASAN: use-after-free in ipv6_sock_ac_close+0x3d6/0x3f0
> net/ipv6/anycast.c:190 at addr ffff88005d6ce020
> Read of size 8 by task syz-executor6/18308
> CPU: 0 PID: 18308 Comm: syz-executor6 Not tainted 4.11.0-rc6+ #206
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:16 [inline]
>  dump_stack+0x292/0x398 lib/dump_stack.c:52
>  kasan_object_err+0x1c/0x70 mm/kasan/report.c:164
>  print_address_description mm/kasan/report.c:202 [inline]
>  kasan_report_error mm/kasan/report.c:291 [inline]
>  kasan_report+0x252/0x510 mm/kasan/report.c:347
>  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:368
>  ipv6_sock_ac_close+0x3d6/0x3f0 net/ipv6/anycast.c:190
>  inet6_release+0x48/0x70 net/ipv6/af_inet6.c:430
>  sock_release+0x8d/0x1e0 net/socket.c:597
>  sock_close+0x16/0x20 net/socket.c:1072
>  __fput+0x332/0x7f0 fs/file_table.c:209
>  ____fput+0x15/0x20 fs/file_table.c:245
>  task_work_run+0x19b/0x270 kernel/task_work.c:116
>  exit_task_work include/linux/task_work.h:21 [inline]
>  do_exit+0x18b6/0x2830 kernel/exit.c:878
>  do_group_exit+0x149/0x420 kernel/exit.c:982
>  get_signal+0x76d/0x17e0 kernel/signal.c:2318
>  do_signal+0xd2/0x2190 arch/x86/kernel/signal.c:808
>  exit_to_usermode_loop+0x170/0x200 arch/x86/entry/common.c:157
>  prepare_exit_to_usermode arch/x86/entry/common.c:191 [inline]
>  syscall_return_slowpath+0x3d3/0x420 arch/x86/entry/common.c:260
>  entry_SYSCALL_64_fastpath+0xc0/0xc2


I don't see how this is possible except when we have a loop in the
singly linked list np->ipv6_ac_list, it is protected by RTNL lock anyway.

The insertion and removal code looks correct too. But I may miss
something too obvious...

Thanks!

> RIP: 0033:0x4458d9
> RSP: 002b:00007f59304e1cf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
> RAX: 0000000000000000 RBX: 0000000000708218 RCX: 00000000004458d9
> RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000708218
> RBP: 00000000007081f8 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: 0000000000000000 R14: 00007f59304e29c0 R15: 00007f59304e2700
> Object at ffff88005d6ce008, in cache kmalloc-32 size: 32
> Allocated:
> PID = 18270
>  save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
>  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
>  set_track mm/kasan/kasan.c:525 [inline]
>  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:616
>  __kmalloc+0xa0/0x2d0 mm/slub.c:3745
>  kmalloc include/linux/slab.h:495 [inline]
>  sock_kmalloc+0x11e/0x1b0 net/core/sock.c:1804
>  ipv6_sock_ac_join+0x21f/0x7b0 net/ipv6/anycast.c:72
>  do_ipv6_setsockopt.isra.7+0x2a77/0x3bc0 net/ipv6/ipv6_sockglue.c:655
>  ipv6_setsockopt+0x9b/0x140 net/ipv6/ipv6_sockglue.c:919
>  sctp_setsockopt+0x2b4/0x5f10 net/sctp/socket.c:3909
>  sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2750
>  SYSC_setsockopt net/socket.c:1798 [inline]
>  SyS_setsockopt+0x270/0x3a0 net/socket.c:1777
>  entry_SYSCALL_64_fastpath+0x1f/0xc2
> Freed:
> PID = 18308
>  save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
>  save_stack+0x43/0xd0 mm/kasan/kasan.c:513
>  set_track mm/kasan/kasan.c:525 [inline]
>  kasan_slab_free+0x73/0xc0 mm/kasan/kasan.c:589
>  slab_free_hook mm/slub.c:1357 [inline]
>  slab_free_freelist_hook mm/slub.c:1379 [inline]
>  slab_free mm/slub.c:2961 [inline]
>  kfree+0xe8/0x2b0 mm/slub.c:3882
>  __sock_kfree_s net/core/sock.c:1825 [inline]
>  sock_kfree_s+0x29/0x70 net/core/sock.c:1831
>  ipv6_sock_ac_close+0x2d0/0x3f0 net/ipv6/anycast.c:198
>  inet6_release+0x48/0x70 net/ipv6/af_inet6.c:430
>  sock_release+0x8d/0x1e0 net/socket.c:597
>  sock_close+0x16/0x20 net/socket.c:1072
>  __fput+0x332/0x7f0 fs/file_table.c:209
>  ____fput+0x15/0x20 fs/file_table.c:245
>  task_work_run+0x19b/0x270 kernel/task_work.c:116
>  exit_task_work include/linux/task_work.h:21 [inline]
>  do_exit+0x18b6/0x2830 kernel/exit.c:878
>  do_group_exit+0x149/0x420 kernel/exit.c:982
>  get_signal+0x76d/0x17e0 kernel/signal.c:2318
>  do_signal+0xd2/0x2190 arch/x86/kernel/signal.c:808
>  exit_to_usermode_loop+0x170/0x200 arch/x86/entry/common.c:157
>  prepare_exit_to_usermode arch/x86/entry/common.c:191 [inline]
>  syscall_return_slowpath+0x3d3/0x420 arch/x86/entry/common.c:260
>  entry_SYSCALL_64_fastpath+0xc0/0xc2
> Memory state around the buggy address:
>  ffff88005d6cdf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>  ffff88005d6cdf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>>ffff88005d6ce000: fc fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
>                                ^
>  ffff88005d6ce080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>  ffff88005d6ce100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ==================================================================
> Disabling lock debugging due to kernel taint

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: net/ipv6: use-after-free in ipv6_sock_ac_close Cong Wang <xiyou.wangcong@gmail.com> - 2017-04-11 01:20 +0200

csiph-web