bisecting fixing commit since 174651bdf802a2139065e8e31ce950e2f3fc4a94 building syzkaller on ab342da3f9aa45e3f2d9e872576ab5cd3e3c350b testing commit 174651bdf802a2139065e8e31ce950e2f3fc4a94 with gcc (GCC) 8.1.0 kernel signature: e544a7bf2ddfcbe365baad9d1c943692b42eaf70772abcbe16b70c08431ed2ac all runs: crashed: KASAN: use-after-free Read in tty_open testing current HEAD 6dd0e32665e591e9debe3edaf73c2f8135bf047e testing commit 6dd0e32665e591e9debe3edaf73c2f8135bf047e with gcc (GCC) 8.1.0 kernel signature: b76f85a050ee217f0462a0066c0daf62cbede7d5012939004366ddea297c2e19 all runs: OK # git bisect start 6dd0e32665e591e9debe3edaf73c2f8135bf047e 174651bdf802a2139065e8e31ce950e2f3fc4a94 Bisecting: 1761 revisions left to test after this (roughly 11 steps) [fe8d74c8190482e09a34862b64dee60f3c4253e1] regulator: pv88080: Fix array out-of-bounds access testing commit fe8d74c8190482e09a34862b64dee60f3c4253e1 with gcc (GCC) 8.1.0 kernel signature: e594fd9e64fc85e001076575d2580d18e424722631e91eea153a1ea98269f842 run #0: crashed: KASAN: use-after-free Write in release_tty run #1: crashed: KASAN: use-after-free Read in tty_open run #2: crashed: KASAN: use-after-free Read in tty_open run #3: crashed: KASAN: use-after-free Read in tty_open run #4: crashed: KASAN: use-after-free Read in tty_open run #5: crashed: KASAN: use-after-free Read in tty_open run #6: crashed: KASAN: use-after-free Read in tty_open run #7: crashed: KASAN: use-after-free Read in tty_open run #8: crashed: KASAN: use-after-free Read in tty_open run #9: crashed: KASAN: use-after-free Read in tty_open # git bisect good fe8d74c8190482e09a34862b64dee60f3c4253e1 Bisecting: 880 revisions left to test after this (roughly 10 steps) [a23409cee466c636eb74e42c8a139ba9a714b0f5] mtd: sharpslpart: Fix unsigned comparison to zero testing commit a23409cee466c636eb74e42c8a139ba9a714b0f5 with gcc (GCC) 8.1.0 kernel signature: ed5f407743024a47b4f14849a6db0d10b44049a9a182021c7505d2e354107be7 all runs: crashed: KASAN: use-after-free Read in tty_open # git bisect good a23409cee466c636eb74e42c8a139ba9a714b0f5 Bisecting: 440 revisions left to test after this (roughly 9 steps) [440aafddc4ff49ebfebaf94156817695bb4820f9] net: ks8851-ml: Remove 8-bit bus accessors testing commit 440aafddc4ff49ebfebaf94156817695bb4820f9 with gcc (GCC) 8.1.0 kernel signature: 075d63da10bf3be43fb7f53774f6a4b8e6f91d3efcc067932631e459602bb586 run #0: crashed: KASAN: use-after-free Write in release_tty run #1: crashed: KASAN: use-after-free Read in tty_open run #2: crashed: KASAN: use-after-free Read in tty_open run #3: crashed: KASAN: use-after-free Read in tty_open run #4: crashed: KASAN: use-after-free Read in tty_open run #5: crashed: KASAN: use-after-free Read in tty_open run #6: crashed: KASAN: use-after-free Read in tty_open run #7: crashed: KASAN: use-after-free Read in tty_open run #8: crashed: KASAN: use-after-free Read in tty_open run #9: crashed: KASAN: use-after-free Read in tty_open # git bisect good 440aafddc4ff49ebfebaf94156817695bb4820f9 Bisecting: 220 revisions left to test after this (roughly 8 steps) [3cbfc33d43d5667c7948e60495dafaa89f1e4c99] block, bfq: fix overwrite of bfq_group pointer in bfq_find_set_group() testing commit 3cbfc33d43d5667c7948e60495dafaa89f1e4c99 with gcc (GCC) 8.1.0 kernel signature: 501f068fa05dc644cc99686a3ada2d925bb356326a4c72cf22748cdf0f2abe6c run #0: crashed: KASAN: use-after-free Write in release_tty run #1: crashed: KASAN: use-after-free Read in tty_open run #2: crashed: KASAN: use-after-free Read in tty_open run #3: crashed: KASAN: use-after-free Read in tty_open run #4: crashed: KASAN: use-after-free Read in tty_open run #5: crashed: KASAN: use-after-free Read in tty_open run #6: crashed: KASAN: use-after-free Read in tty_open run #7: crashed: KASAN: use-after-free Read in tty_open run #8: crashed: KASAN: use-after-free Read in tty_open run #9: crashed: KASAN: use-after-free Read in tty_open # git bisect good 3cbfc33d43d5667c7948e60495dafaa89f1e4c99 Bisecting: 110 revisions left to test after this (roughly 7 steps) [e3aaea29e241f2848969af443bb1d4f861428120] gpiolib: acpi: Add quirk to ignore EC wakeups on HP x2 10 BYT + AXP288 model testing commit e3aaea29e241f2848969af443bb1d4f861428120 with gcc (GCC) 8.1.0 kernel signature: 4ba9a419676e50ed517012ec257f2b15b26e841dec672af8c2671e69c6a82ae3 all runs: crashed: KASAN: use-after-free Read in tty_open # git bisect good e3aaea29e241f2848969af443bb1d4f861428120 Bisecting: 55 revisions left to test after this (roughly 6 steps) [dda0e2920330128e0dbdeb11c8f25031aa40b11c] Linux 4.19.114 testing commit dda0e2920330128e0dbdeb11c8f25031aa40b11c with gcc (GCC) 8.1.0 kernel signature: 0cfa3ad981a6668909acaf552d3a104b0746ff3bcc49ea2c7f65ab362816f9a8 all runs: OK # git bisect bad dda0e2920330128e0dbdeb11c8f25031aa40b11c Bisecting: 27 revisions left to test after this (roughly 5 steps) [b2f60325a350e229f13750a175391a3ec558d6a7] staging: wlan-ng: fix use-after-free Read in hfa384x_usbin_callback testing commit b2f60325a350e229f13750a175391a3ec558d6a7 with gcc (GCC) 8.1.0 kernel signature: 35ce5f1871ac3f018549d4b69289f049d39fe9186262cdbdd3b2e70f976e2750 all runs: crashed: KASAN: use-after-free Read in tty_open # git bisect good b2f60325a350e229f13750a175391a3ec558d6a7 Bisecting: 13 revisions left to test after this (roughly 4 steps) [2ff2b207f3556e4c68fbbe3c3c8d65c0e0e949cf] vt: vt_ioctl: fix use-after-free in vt_in_use() testing commit 2ff2b207f3556e4c68fbbe3c3c8d65c0e0e949cf with gcc (GCC) 8.1.0 kernel signature: b5a6394a024c63a2b87e1f85984c0378f7a33b3015c81d89a7b619179bdba328 all runs: OK # git bisect bad 2ff2b207f3556e4c68fbbe3c3c8d65c0e0e949cf Bisecting: 6 revisions left to test after this (roughly 3 steps) [a4f68ecf73363564822a8f0266630427f25aa393] mac80211: Check port authorization in the ieee80211_tx_dequeue() case testing commit a4f68ecf73363564822a8f0266630427f25aa393 with gcc (GCC) 8.1.0 kernel signature: 459dc26658258e6491340a7e3c2cb3084ced1ae694c1b12bebce5a7e9b02a149 all runs: crashed: KASAN: use-after-free Read in tty_open # git bisect good a4f68ecf73363564822a8f0266630427f25aa393 Bisecting: 3 revisions left to test after this (roughly 2 steps) [7de934f4099b037b04c08761b77588ea9a805cdf] vt: ioctl, switch VT_IS_IN_USE and VT_BUSY to inlines testing commit 7de934f4099b037b04c08761b77588ea9a805cdf with gcc (GCC) 8.1.0 kernel signature: 0cedf682a7be2cd190da504b36383127fd8c3222663d6542e280c7ab373ae0f3 all runs: crashed: KASAN: use-after-free Read in tty_open # git bisect good 7de934f4099b037b04c08761b77588ea9a805cdf Bisecting: 1 revision left to test after this (roughly 1 step) [9fbd55e4f951cdd9491ee7d07220f8ee58d77f33] vt: vt_ioctl: remove unnecessary console allocation checks testing commit 9fbd55e4f951cdd9491ee7d07220f8ee58d77f33 with gcc (GCC) 8.1.0 kernel signature: 26e0fb45e664094a9d6db4056110d61e55c7c33c475f0d3614b14a12451694ea all runs: crashed: KASAN: use-after-free Read in tty_open # git bisect good 9fbd55e4f951cdd9491ee7d07220f8ee58d77f33 Bisecting: 0 revisions left to test after this (roughly 0 steps) [54584f79579b9f6ed49b93cadcd2361223ecce28] vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console testing commit 54584f79579b9f6ed49b93cadcd2361223ecce28 with gcc (GCC) 8.1.0 kernel signature: db473781c22cb1bd7a16fd8b2dcbe13976af95901c234c93cfef4fb7ca6b6b29 all runs: OK # git bisect bad 54584f79579b9f6ed49b93cadcd2361223ecce28 54584f79579b9f6ed49b93cadcd2361223ecce28 is the first bad commit commit 54584f79579b9f6ed49b93cadcd2361223ecce28 Author: Eric Biggers Date: Sat Mar 21 20:43:04 2020 -0700 vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console commit ca4463bf8438b403596edd0ec961ca0d4fbe0220 upstream. The VT_DISALLOCATE ioctl can free a virtual console while tty_release() is still running, causing a use-after-free in con_shutdown(). This occurs because VT_DISALLOCATE considers a virtual console's 'struct vc_data' to be unused as soon as the corresponding tty's refcount hits 0. But actually it may be still being closed. Fix this by making vc_data be reference-counted via the embedded 'struct tty_port'. A newly allocated virtual console has refcount 1. Opening it for the first time increments the refcount to 2. Closing it for the last time decrements the refcount (in tty_operations::cleanup() so that it happens late enough), as does VT_DISALLOCATE. Reproducer: #include #include #include #include int main() { if (fork()) { for (;;) close(open("/dev/tty5", O_RDWR)); } else { int fd = open("/dev/tty10", O_RDWR); for (;;) ioctl(fd, VT_DISALLOCATE, 5); } } KASAN report: BUG: KASAN: use-after-free in con_shutdown+0x76/0x80 drivers/tty/vt/vt.c:3278 Write of size 8 at addr ffff88806a4ec108 by task syz_vt/129 CPU: 0 PID: 129 Comm: syz_vt Not tainted 5.6.0-rc2 #11 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20191223_100556-anatol 04/01/2014 Call Trace: [...] con_shutdown+0x76/0x80 drivers/tty/vt/vt.c:3278 release_tty+0xa8/0x410 drivers/tty/tty_io.c:1514 tty_release_struct+0x34/0x50 drivers/tty/tty_io.c:1629 tty_release+0x984/0xed0 drivers/tty/tty_io.c:1789 [...] Allocated by task 129: [...] kzalloc include/linux/slab.h:669 [inline] vc_allocate drivers/tty/vt/vt.c:1085 [inline] vc_allocate+0x1ac/0x680 drivers/tty/vt/vt.c:1066 con_install+0x4d/0x3f0 drivers/tty/vt/vt.c:3229 tty_driver_install_tty drivers/tty/tty_io.c:1228 [inline] tty_init_dev+0x94/0x350 drivers/tty/tty_io.c:1341 tty_open_by_driver drivers/tty/tty_io.c:1987 [inline] tty_open+0x3ca/0xb30 drivers/tty/tty_io.c:2035 [...] Freed by task 130: [...] kfree+0xbf/0x1e0 mm/slab.c:3757 vt_disallocate drivers/tty/vt/vt_ioctl.c:300 [inline] vt_ioctl+0x16dc/0x1e30 drivers/tty/vt/vt_ioctl.c:818 tty_ioctl+0x9db/0x11b0 drivers/tty/tty_io.c:2660 [...] Fixes: 4001d7b7fc27 ("vt: push down the tty lock so we can see what is left to tackle") Cc: # v3.4+ Reported-by: syzbot+522643ab5729b0421998@syzkaller.appspotmail.com Acked-by: Jiri Slaby Signed-off-by: Eric Biggers Link: https://lore.kernel.org/r/20200322034305.210082-2-ebiggers@kernel.org Signed-off-by: Greg Kroah-Hartman drivers/tty/vt/vt.c | 23 ++++++++++++++++++++++- drivers/tty/vt/vt_ioctl.c | 12 ++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) culprit signature: db473781c22cb1bd7a16fd8b2dcbe13976af95901c234c93cfef4fb7ca6b6b29 parent signature: 26e0fb45e664094a9d6db4056110d61e55c7c33c475f0d3614b14a12451694ea revisions tested: 14, total time: 3h54m15.635178485s (build: 2h8m30.715671058s, test: 1h44m20.280200685s) first good commit: 54584f79579b9f6ed49b93cadcd2361223ecce28 vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console cc: ["ebiggers@google.com" "gregkh@linuxfoundation.org" "jslaby@suse.cz"]