KASAN: use-after-free Read in soft_cursor

Status: auto-obsoleted due to no activity on 2022/09/23 11:46
Subsystems: fbdev
[Documentation on labels]
Reported-by: syzbot+cf43fb300aa142fb024b@syzkaller.appspotmail.com
First crash: 2544d, last: 2268d
Cause bisection: introduced by (bisect log) :
commit 2de50e9674fc4ca3c6174b04477f69eb26b4ee31
Author: Russell Currey <ruscur@russell.cc>
Date: Mon Feb 8 04:08:20 2016 +0000

  powerpc/powernv: Remove support for p5ioc2

Crash: BUG: spinlock lockup suspected in nf_conntrack_lock (log)
Repro: C syz .config
Fix bisection the fix commit could be any of (bisect log):
commit 6b643a07a7e41f9e11cfbb9bba4c5c9791ac2997
Author: Peter Zijlstra <peterz@infradead.org>
Date: Wed Jun 3 18:09:06 2020 +0000

  x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*()

commit 8e8bb06d199a5aa7a534aa3b3fc0abbbc11ca438
Author: Peter Zijlstra <peterz@infradead.org>
Date: Thu Jun 4 09:17:40 2020 +0000

  x86/entry, bug: Comment the instrumentation_begin() usage for WARN()

commit 14d3b376b6c3f66d62559d457d32edf565472163
Author: Peter Zijlstra <peterz@infradead.org>
Date: Wed Jun 3 11:32:48 2020 +0000

  x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline()

commit 33aea07f30c261eff7ba229f19fd1b161e0fb851
Author: Marco Elver <elver@google.com>
Date: Mon Jun 15 23:15:29 2020 +0000

  compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

commit 5144f8a8dfd7b3681f0a2b5bf599a210b2315018
Author: Marco Elver <elver@google.com>
Date: Thu Jun 4 05:58:11 2020 +0000

  compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr

commit acf7b0bf7dcf5a96d9b44a0997227c7210d995c1
Author: Marco Elver <elver@google.com>
Date: Tue Jun 23 11:24:48 2020 +0000

  kasan: Fix required compiler version

commit 734d099ba644f5a92c70efa3d54d0ba2500ce162
Author: Peter Zijlstra <peterz@infradead.org>
Date: Wed Jun 17 16:22:31 2020 +0000

  objtool: Don't consider vmlinux a C-file

commit 7b861a53e46b6b42ab8560b105af308cb72d7285
Author: Marco Elver <elver@google.com>
Date: Thu Jun 4 05:58:10 2020 +0000

  kasan: Bump required compiler version

commit 5ddbc4082e1072eeeae52ff561a88620a05be08f
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jun 2 16:47:11 2020 +0000

  x86, kcsan: Add __no_kcsan to noinstr

commit e3a9e681adb779b39565a28b3252c3be1033f994
Author: Peter Zijlstra <peterz@infradead.org>
Date: Wed Jun 17 16:21:16 2020 +0000

  x86/entry: Fixup bad_iret vs noinstr

commit c7aadc09321d8f9a1d3bd1e6d8a47222ecddf6c5
Author: Peter Zijlstra <peterz@infradead.org>
Date: Wed Jun 17 16:25:57 2020 +0000

  x86/entry: Increase entry_stack size to a full page

commit e79302ae8c8cceb51cf642d5ace9da02668cb7b4
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jun 2 15:04:03 2020 +0000

  kcsan: Remove __no_kcsan_or_inline

commit 145a773aef83181d47ebab21bb33c89233aadb1e
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jun 16 11:28:36 2020 +0000

  x86/entry: Fix #UD vs WARN more

commit e82587336695f14283987c9aa0bfd775b520856d
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jun 2 12:24:47 2020 +0000

  x86, kcsan: Remove __no_kcsan_or_inline usage

commit 2c92d787cc9fad57d05c96bd117782183768258a
Author: Ingo Molnar <mingo@kernel.org>
Date: Fri Jun 26 10:24:42 2020 +0000

  Merge branch 'linus' into x86/entry, to resolve conflicts
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in soft_cursor 1 (3) 2019/12/07 07:22
▶ ▼ Similar bugs (5)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in soft_cursor 19 syz, C done 16 2249d 2546d 1/1 fixed on 2020/10/26 21:28
linux-6.1 KASAN: slab-out-of-bounds Read in soft_cursor 19 7 2d10h 123d 0/3 upstream: reported on 2026/07/24 00:48
linux-4.19 KASAN: use-after-free Read in soft_cursor (2) 19 2 2158d 2196d 0/1 auto-closed as invalid on 2021/04/26 05:01
linux-4.14 KASAN: use-after-free Read in soft_cursor 19 syz, C inconclusive 7 2035d 2546d 0/1 upstream: reported C repro on 2019/12/04 13:11
upstream KASAN: global-out-of-bounds Read in soft_cursor (3) fbdev 19 234 1d17h 109d 28/29 upstream: reported on 2026/08/07 00:01
▶ ▼ Last patch testing requests (4)
Created Duration User Patch Repo Result
2022/09/23 09:30 16m retest repro upstream no crash log
2022/09/21 20:29 16m retest repro linux-next no crash log
2022/09/20 12:29 16m retest repro upstream no crash log
2021/03/15 01:50 15m ducheng2@gmail.com upstream no crash
▶ ▼ Fix bisection attempts (4)
Created Duration User Patch Repo Result
2020/07/25 12:52 6h10m bisect fix upstream OK (15) job log
2020/05/28 04:05 20m bisect fix upstream OK (0) job log log
2020/04/17 20:18 19m bisect fix upstream OK (0) job log log
2020/01/26 21:17 23m bisect fix upstream OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in memcpy include/linux/string.h:380 [inline]
BUG: KASAN: use-after-free in soft_cursor+0x439/0xa30 drivers/video/fbdev/core/softcursor.c:70
Read of size 9 at addr ffff88809826c851 by task syz-executor602/9482

CPU: 1 PID: 9482 Comm: syz-executor602 Not tainted 5.4.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:639
 check_memory_region_inline mm/kasan/generic.c:185 [inline]
 check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
 memcpy+0x24/0x50 mm/kasan/common.c:125
 memcpy include/linux/string.h:380 [inline]
 soft_cursor+0x439/0xa30 drivers/video/fbdev/core/softcursor.c:70
 bit_cursor+0x12fc/0x1a60 drivers/video/fbdev/core/bitblit.c:386
 fbcon_cursor+0x487/0x660 drivers/video/fbdev/core/fbcon.c:1402
 hide_cursor+0x9d/0x2b0 drivers/tty/vt/vt.c:895
 redraw_screen+0x60b/0x7d0 drivers/tty/vt/vt.c:988
 vc_do_resize+0x10c9/0x1460 drivers/tty/vt/vt.c:1284
 vc_resize+0x4d/0x60 drivers/tty/vt/vt.c:1304
 vt_ioctl+0x2076/0x26d0 drivers/tty/vt/vt_ioctl.c:887
 tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660
 vfs_ioctl fs/ioctl.c:47 [inline]
 file_ioctl fs/ioctl.c:545 [inline]
 do_vfs_ioctl+0x977/0x14e0 fs/ioctl.c:732
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:749
 __do_sys_ioctl fs/ioctl.c:756 [inline]
 __se_sys_ioctl fs/ioctl.c:754 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:754
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440219
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 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 0f 83 5b 14 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fff7d7f09e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440219
RDX: 00000000200002c0 RSI: 000000000000560a RDI: 0000000000000004
RBP: 00000000006ca018 R08: 0000000000000001 R09: 00000000004002c8
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000401b00
R13: 0000000000401b90 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9477:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:513 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:486
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:527
 __do_kmalloc_node mm/slab.c:3616 [inline]
 __kmalloc_node_track_caller+0x4e/0x70 mm/slab.c:3630
 __kmalloc_reserve.isra.0+0x40/0xf0 net/core/skbuff.c:141
 __alloc_skb+0x10b/0x5e0 net/core/skbuff.c:209
 alloc_skb include/linux/skbuff.h:1049 [inline]
 sock_wmalloc+0xd9/0x120 net/core/sock.c:2093
 unix_stream_connect+0x22a/0x146b net/unix/af_unix.c:1249
 __sys_connect_file+0x25d/0x2e0 net/socket.c:1848
 __sys_connect+0x51/0x90 net/socket.c:1861
 __do_sys_connect net/socket.c:1872 [inline]
 __se_sys_connect net/socket.c:1869 [inline]
 __x64_sys_connect+0x73/0xb0 net/socket.c:1869
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9477:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:335 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:474
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:483
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 skb_free_head+0x93/0xb0 net/core/skbuff.c:591
 skb_release_data+0x551/0x8d0 net/core/skbuff.c:611
 skb_release_all+0x4d/0x60 net/core/skbuff.c:665
 __kfree_skb net/core/skbuff.c:679 [inline]
 kfree_skb net/core/skbuff.c:697 [inline]
 kfree_skb+0x101/0x420 net/core/skbuff.c:691
 unix_stream_connect+0x1342/0x146b net/unix/af_unix.c:1391
 __sys_connect_file+0x25d/0x2e0 net/socket.c:1848
 __sys_connect+0x51/0x90 net/socket.c:1861
 __do_sys_connect net/socket.c:1872 [inline]
 __se_sys_connect net/socket.c:1869 [inline]
 __x64_sys_connect+0x73/0xb0 net/socket.c:1869
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809826c800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 81 bytes inside of
 512-byte region [ffff88809826c800, ffff88809826ca00)
The buggy address belongs to the page:
page:ffffea0002609b00 refcount:1 mapcount:0 mapping:ffff8880aa400a80 index:0xffff88809826c000
raw: 00fffe0000000200 ffffea00029e84c8 ffffea0002594288 ffff8880aa400a80
raw: ffff88809826c000 ffff88809826c000 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809826c700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809826c780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809826c800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff88809826c880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809826c900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/12/06 11:48 upstream b0d4beaa5a4b 98b4ef2d .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/12/06 11:06 upstream b0d4beaa5a4b 98b4ef2d .config console log report syz C ci-upstream-kasan-gce-root
2019/12/18 13:06 linux-next b9c5ef25038d f2fe0772 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/09/07 20:05 upstream f4d51dffc6c0 abf9ba4f .config console log report ci-upstream-kasan-gce-selinux-root
2020/08/09 06:24 upstream 06a81c1c7db9 f721e4a0 .config console log report ci-upstream-kasan-gce-root
2020/04/28 04:05 upstream 51184ae37e05 0ce7569e .config console log report ci-upstream-kasan-gce-root
2020/03/18 17:50 upstream 5076190daded 0a96a13c .config console log report ci-upstream-kasan-gce-smack-root
2020/03/14 18:54 upstream 69a4d0baeeb1 749688d2 .config console log report ci-upstream-kasan-gce-smack-root
2019/12/18 23:40 upstream 2187f215ebaa 79b211f7 .config console log report ci-upstream-kasan-gce-selinux-root
2019/12/21 17:39 upstream 6210469417fd bc586918 .config console log report ci-qemu-upstream-386
2020/02/25 19:10 linux-next bdc5461b23ca 59b57593 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/21 04:53 linux-next bee46b309a13 bd2a74a3 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.