2019-11-05 04:24:39

by syzbot

[permalink] [raw]
Subject: KASAN: use-after-free Read in j1939_session_get_by_addr

Hello,

syzbot found the following crash on:

HEAD commit: a99d8080 Linux 5.4-rc6
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14d0cc58e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=8c5e2eca3f31f9bf
dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1796b4dce00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=142798dce00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: [email protected]

vcan0: j1939_xtp_rx_abort_one: 0x00000000a2ba57cc: 0x00000: (3) A timeout
occurred and this is the connection abort to close the session.
vcan0: j1939_xtp_rx_abort_one: 0x00000000f495a5ef: 0x00000: (3) A timeout
occurred and this is the connection abort to close the session.
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3a8b/0x4a00
kernel/locking/lockdep.c:3828
Read of size 8 at addr ffff888094225080 by task ksoftirqd/0/9

CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.4.0-rc6 #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+0x172/0x1f0 lib/dump_stack.c:113
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:634
__asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
__lock_acquire+0x3a8b/0x4a00 kernel/locking/lockdep.c:3828
lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4487
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
_raw_spin_lock_bh+0x33/0x50 kernel/locking/spinlock.c:175
spin_lock_bh include/linux/spinlock.h:343 [inline]
j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
j1939_session_get_by_addr+0x2d/0x60 net/can/j1939/transport.c:530
j1939_xtp_rx_abort_one+0x8d/0x100 net/can/j1939/transport.c:1242
j1939_xtp_rx_abort net/can/j1939/transport.c:1270 [inline]
j1939_tp_cmd_recv net/can/j1939/transport.c:1943 [inline]
j1939_tp_recv+0x513/0x9b0 net/can/j1939/transport.c:1973
j1939_can_recv+0x4bb/0x620 net/can/j1939/main.c:100
deliver net/can/af_can.c:568 [inline]
can_rcv_filter+0x292/0x8e0 net/can/af_can.c:602
can_receive+0x2e7/0x530 net/can/af_can.c:659
can_rcv+0x133/0x1b0 net/can/af_can.c:685
__netif_receive_skb_one_core+0x113/0x1a0 net/core/dev.c:4929
__netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5043
process_backlog+0x206/0x750 net/core/dev.c:5874
napi_poll net/core/dev.c:6311 [inline]
net_rx_action+0x508/0x1120 net/core/dev.c:6379
__do_softirq+0x262/0x98c kernel/softirq.c:292
run_ksoftirqd kernel/softirq.c:603 [inline]
run_ksoftirqd+0x8e/0x110 kernel/softirq.c:595
smpboot_thread_fn+0x6a3/0xa40 kernel/smpboot.c:165
kthread+0x361/0x430 kernel/kthread.c:255
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

Allocated by task 9736:
save_stack+0x23/0x90 mm/kasan/common.c:69
set_track mm/kasan/common.c:77 [inline]
__kasan_kmalloc mm/kasan/common.c:510 [inline]
__kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
kasan_kmalloc+0x9/0x10 mm/kasan/common.c:524
kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3550
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:690 [inline]
j1939_priv_create net/can/j1939/main.c:122 [inline]
j1939_netdev_start+0xa4/0x550 net/can/j1939/main.c:251
j1939_sk_bind+0x65a/0x8e0 net/can/j1939/socket.c:438
__sys_bind+0x239/0x290 net/socket.c:1647
__do_sys_bind net/socket.c:1658 [inline]
__se_sys_bind net/socket.c:1656 [inline]
__x64_sys_bind+0x73/0xb0 net/socket.c:1656
do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9:
save_stack+0x23/0x90 mm/kasan/common.c:69
set_track mm/kasan/common.c:77 [inline]
kasan_set_free_info mm/kasan/common.c:332 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
__cache_free mm/slab.c:3425 [inline]
kfree+0x10a/0x2c0 mm/slab.c:3756
__j1939_priv_release net/can/j1939/main.c:154 [inline]
kref_put include/linux/kref.h:65 [inline]
j1939_priv_put+0x8b/0xb0 net/can/j1939/main.c:159
j1939_session_destroy net/can/j1939/transport.c:271 [inline]
__j1939_session_release net/can/j1939/transport.c:280 [inline]
kref_put include/linux/kref.h:65 [inline]
j1939_session_put+0x12c/0x180 net/can/j1939/transport.c:285
j1939_xtp_rx_abort_one+0xc7/0x100 net/can/j1939/transport.c:1261
j1939_xtp_rx_abort net/can/j1939/transport.c:1269 [inline]
j1939_tp_cmd_recv net/can/j1939/transport.c:1943 [inline]
j1939_tp_recv+0x4fb/0x9b0 net/can/j1939/transport.c:1973
j1939_can_recv+0x4bb/0x620 net/can/j1939/main.c:100
deliver net/can/af_can.c:568 [inline]
can_rcv_filter+0x292/0x8e0 net/can/af_can.c:602
can_receive+0x2e7/0x530 net/can/af_can.c:659
can_rcv+0x133/0x1b0 net/can/af_can.c:685
__netif_receive_skb_one_core+0x113/0x1a0 net/core/dev.c:4929
__netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5043
process_backlog+0x206/0x750 net/core/dev.c:5874
napi_poll net/core/dev.c:6311 [inline]
net_rx_action+0x508/0x1120 net/core/dev.c:6379
__do_softirq+0x262/0x98c kernel/softirq.c:292

The buggy address belongs to the object at ffff888094224000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 4224 bytes inside of
8192-byte region [ffff888094224000, ffff888094226000)
The buggy address belongs to the page:
page:ffffea0002508900 refcount:1 mapcount:0 mapping:ffff8880aa4021c0
index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea000252a808 ffffea000232f808 ffff8880aa4021c0
raw: 0000000000000000 ffff888094224000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888094224f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888094225000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff888094225080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888094225100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888094225180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches


2019-11-05 08:06:24

by syzbot

[permalink] [raw]
Subject: Re: KASAN: use-after-free Read in j1939_session_get_by_addr

syzbot has bisected this bug to:

commit 2af6106ae949651d529c8c3f0734c3a7babd0d4b
Author: Jose Abreu <[email protected]>
Date: Tue Jul 9 08:03:00 2019 +0000

net: stmmac: Introducing support for Page Pool

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15f481c8e00000
start commit: 1574cf83 Merge tag 'mlx5-updates-2019-11-01' of git://git...
git tree: net-next
final crash: https://syzkaller.appspot.com/x/report.txt?x=17f481c8e00000
console output: https://syzkaller.appspot.com/x/log.txt?x=13f481c8e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=c26333525dde4c39
dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16050314e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=159c59b2e00000

Reported-by: [email protected]
Fixes: 2af6106ae949 ("net: stmmac: Introducing support for Page Pool")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

2019-11-05 08:22:29

by Jose Abreu

[permalink] [raw]
Subject: RE: KASAN: use-after-free Read in j1939_session_get_by_addr

From: syzbot <[email protected]>
Date: Nov/05/2019, 08:05:01 (UTC+00:00)

> syzbot has bisected this bug to:
>
> commit 2af6106ae949651d529c8c3f0734c3a7babd0d4b
> Author: Jose Abreu <[email protected]>
> Date: Tue Jul 9 08:03:00 2019 +0000
>
> net: stmmac: Introducing support for Page Pool

From the config provided, stmmac driver is not even enabled. Can you
please confirm the bisection process ?

---
Thanks,
Jose Miguel Abreu

2019-11-05 08:37:36

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: KASAN: use-after-free Read in j1939_session_get_by_addr

On 11/5/19 9:21 AM, Jose Abreu wrote:
> From: syzbot <[email protected]>
> Date: Nov/05/2019, 08:05:01 (UTC+00:00)
>
>> syzbot has bisected this bug to:
>>
>> commit 2af6106ae949651d529c8c3f0734c3a7babd0d4b
>> Author: Jose Abreu <[email protected]>
>> Date: Tue Jul 9 08:03:00 2019 +0000
>>
>> net: stmmac: Introducing support for Page Pool
>
> From the config provided, stmmac driver is not even enabled. Can you
> please confirm the bisection process ?

Looks like a false positive, as j1939 (net/can/j1939/) hit mainline with
v5.4-rc1~131^2~78^2.

While the bisected commit is v5.3-rc1~140^2~13^2.

regards,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |


Attachments:
signature.asc (499.00 B)
OpenPGP digital signature

2019-11-05 08:41:06

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: KASAN: use-after-free Read in j1939_session_get_by_addr

On Tue, Nov 5, 2019 at 9:35 AM Marc Kleine-Budde <[email protected]> wrote:
>
> On 11/5/19 9:21 AM, Jose Abreu wrote:
> > From: syzbot <[email protected]>
> > Date: Nov/05/2019, 08:05:01 (UTC+00:00)
> >
> >> syzbot has bisected this bug to:
> >>
> >> commit 2af6106ae949651d529c8c3f0734c3a7babd0d4b
> >> Author: Jose Abreu <[email protected]>
> >> Date: Tue Jul 9 08:03:00 2019 +0000
> >>
> >> net: stmmac: Introducing support for Page Pool
> >
> > From the config provided, stmmac driver is not even enabled. Can you
> > please confirm the bisection process ?
>
> Looks like a false positive, as j1939 (net/can/j1939/) hit mainline with
> v5.4-rc1~131^2~78^2.
>
> While the bisected commit is v5.3-rc1~140^2~13^2.


Yes, the commit is most likely irrelevant. As you can see in the
bisection log the process was diverged by "WARNING: ODEBUG bug in
netdev_freemem". I think it's not the first and not the second time I
see that crash breaks bisection:
https://syzkaller.appspot.com/bug?id=96a64fde216dca408a5c25db4e57838c51e435aa

2023-07-11 14:12:49

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos

2023-07-25 14:26:25

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos

2023-08-08 16:27:20

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos

2023-08-08 17:39:50

by Aleksandr Nogikh

[permalink] [raw]
Subject: Re: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

> But I can't find it in the tested trees[1] for more than 90 days.
> Is it a correct commit? Please update it by replying:

#syz fix: can: j1939: transport: make sure the aborted session will be deactivated only once

2023-11-06 14:35:43

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be deactivated only once

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos

2023-11-20 14:38:36

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be deactivated only once

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos

2023-12-04 14:36:07

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be deactivated only once

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos

2023-12-18 14:36:37

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: use-after-free Read in j1939_session_get_by_addr

This bug is marked as fixed by commit:
can: j1939: transport: make sure the aborted session will be deactivated only once

But I can't find it in the tested trees[1] for more than 90 days.
Is it a correct commit? Please update it by replying:

#syz fix: exact-commit-title

Until then the bug is still considered open and new crashes with
the same signature are ignored.

Kernel: Linux
Dashboard link: https://syzkaller.appspot.com/bug?extid=d9536adc269404a984f8

---
[1] I expect the commit to be present in:

1. for-kernelci branch of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

2. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

3. master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

4. main branch of
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

The full list of 9 trees can be found at
https://syzkaller.appspot.com/upstream/repos