Skip to content
Snippets Groups Projects
  1. Mar 03, 2025
  2. Jan 14, 2025
    • Ignat Korchagin's avatar
      net: af_can: do not leave a dangling sk pointer in can_create() · 0f5e4d7d
      Ignat Korchagin authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit 811a7ca7320c062e15d0f5b171fe6ad8592d1434 ]
      
      On error can_create() frees the allocated sk object, but sock_init_data()
      has already attached it to the provided sock object. This will leave a
      dangling sk pointer in the sock object and may cause use-after-free later.
      
      Signed-off-by: default avatarIgnat Korchagin <ignat@cloudflare.com>
      Reviewed-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Link: https://patch.msgid.link/20241014153808.51894-5-ignat@cloudflare.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0f5e4d7d
    • Dmitry Antipov's avatar
      can: j1939: j1939_session_new(): fix skb reference counting · b430f1b5
      Dmitry Antipov authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit a8c695005bfe6569acd73d777ca298ddddd66105 ]
      
      Since j1939_session_skb_queue() does an extra skb_get() for each new
      skb, do the same for the initial one in j1939_session_new() to avoid
      refcount underflow.
      
      Reported-by: default avatar <syzbot+d4e8dc385d9258220c31@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=d4e8dc385d9258220c31
      
      
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Signed-off-by: default avatarDmitry Antipov <dmantipov@yandex.ru>
      Tested-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://patch.msgid.link/20241105094823.2403806-1-dmantipov@yandex.ru
      
      
      [mkl: clean up commit message]
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b430f1b5
    • Kuniyuki Iwashima's avatar
      can: bcm: Clear bo->bcm_proc_read after remove_proc_entry(). · 3a3d9c2a
      Kuniyuki Iwashima authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit 94b0818f ]
      
      syzbot reported a warning in bcm_release(). [0]
      
      The blamed change fixed another warning that is triggered when
      connect() is issued again for a socket whose connect()ed device has
      been unregistered.
      
      However, if the socket is just close()d without the 2nd connect(), the
      remaining bo->bcm_proc_read triggers unnecessary remove_proc_entry()
      in bcm_release().
      
      Let's clear bo->bcm_proc_read after remove_proc_entry() in bcm_notify().
      
      [0]
      name '4986'
      WARNING: CPU: 0 PID: 5234 at fs/proc/generic.c:711 remove_proc_entry+0x2e7/0x5d0 fs/proc/generic.c:711
      Modules linked in:
      CPU: 0 UID: 0 PID: 5234 Comm: syz-executor606 Not tainted 6.11.0-rc5-syzkaller-00178-g5517ae241919 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
      RIP: 0010:remove_proc_entry+0x2e7/0x5d0 fs/proc/generic.c:711
      Code: ff eb 05 e8 cb 1e 5e ff 48 8b 5c 24 10 48 c7 c7 e0 f7 aa 8e e8 2a 38 8e 09 90 48 c7 c7 60 3a 1b 8c 48 89 de e8 da 42 20 ff 90 <0f> 0b 90 90 48 8b 44 24 18 48 c7 44 24 40 0e 36 e0 45 49 c7 04 07
      RSP: 0018:ffffc9000345fa20 EFLAGS: 00010246
      RAX: 2a2d0aee2eb64600 RBX: ffff888032f1f548 RCX: ffff888029431e00
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
      RBP: ffffc9000345fb08 R08: ffffffff8155b2f2 R09: 1ffff1101710519a
      R10: dffffc0000000000 R11: ffffed101710519b R12: ffff888011d38640
      R13: 0000000000000004 R14: 0000000000000000 R15: dffffc0000000000
      FS:  0000000000000000(0000) GS:ffff8880b8800000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fcfb52722f0 CR3: 000000000e734000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       bcm_release+0x250/0x880 net/can/bcm.c:1578
       __sock_release net/socket.c:659 [inline]
       sock_close+0xbc/0x240 net/socket.c:1421
       __fput+0x24a/0x8a0 fs/file_table.c:422
       task_work_run+0x24f/0x310 kernel/task_work.c:228
       exit_task_work include/linux/task_work.h:40 [inline]
       do_exit+0xa2f/0x27f0 kernel/exit.c:882
       do_group_exit+0x207/0x2c0 kernel/exit.c:1031
       __do_sys_exit_group kernel/exit.c:1042 [inline]
       __se_sys_exit_group kernel/exit.c:1040 [inline]
       __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1040
       x64_sys_call+0x2634/0x2640 arch/x86/include/generated/asm/syscalls_64.h:232
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f
      RIP: 0033:0x7fcfb51ee969
      Code: Unable to access opcode bytes at 0x7fcfb51ee93f.
      RSP: 002b:00007ffce0109ca8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
      RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fcfb51ee969
      RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000001
      RBP: 00007fcfb526f3b0 R08: ffffffffffffffb8 R09: 0000555500000000
      R10: 0000555500000000 R11: 0000000000000246 R12: 00007fcfb526f3b0
      R13: 0000000000000000 R14: 00007fcfb5271ee0 R15: 00007fcfb51bf160
       </TASK>
      
      Fixes: 76fe372c ("can: bcm: Remove proc entry when dev is unregistered.")
      Reported-by: default avatar <syzbot+0532ac7a06fb1a03187e@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=0532ac7a06fb1a03187e
      
      
      Tested-by: default avatar <syzbot+0532ac7a06fb1a03187e@syzkaller.appspotmail.com>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Link: https://patch.msgid.link/20240905012237.79683-1-kuniyu@amazon.com
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3a3d9c2a
    • Zhang Changzhong's avatar
      can: j1939: use correct function name in comment · f07bfbac
      Zhang Changzhong authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit dc2ddcd1 ]
      
      The function j1939_cancel_all_active_sessions() was renamed to
      j1939_cancel_active_session() but name in comment wasn't updated.
      
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Link: https://patch.msgid.link/1724935703-44621-1-git-send-email-zhangchangzhong@huawei.com
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f07bfbac
    • Kuniyuki Iwashima's avatar
      can: bcm: Remove proc entry when dev is unregistered. · 6d3e3609
      Kuniyuki Iwashima authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit 76fe372c ]
      
      syzkaller reported a warning in bcm_connect() below. [0]
      
      The repro calls connect() to vxcan1, removes vxcan1, and calls
      connect() with ifindex == 0.
      
      Calling connect() for a BCM socket allocates a proc entry.
      Then, bcm_sk(sk)->bound is set to 1 to prevent further connect().
      
      However, removing the bound device resets bcm_sk(sk)->bound to 0
      in bcm_notify().
      
      The 2nd connect() tries to allocate a proc entry with the same
      name and sets NULL to bcm_sk(sk)->bcm_proc_read, leaking the
      original proc entry.
      
      Since the proc entry is available only for connect()ed sockets,
      let's clean up the entry when the bound netdev is unregistered.
      
      [0]:
      proc_dir_entry 'can-bcm/2456' already registered
      WARNING: CPU: 1 PID: 394 at fs/proc/generic.c:376 proc_register+0x645/0x8f0 fs/proc/generic.c:375
      Modules linked in:
      CPU: 1 PID: 394 Comm: syz-executor403 Not tainted 6.10.0-rc7-g852e42cc2dd4
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
      RIP: 0010:proc_register+0x645/0x8f0 fs/proc/generic.c:375
      Code: 00 00 00 00 00 48 85 ed 0f 85 97 02 00 00 4d 85 f6 0f 85 9f 02 00 00 48 c7 c7 9b cb cf 87 48 89 de 4c 89 fa e8 1c 6f eb fe 90 <0f> 0b 90 90 48 c7 c7 98 37 99 89 e8 cb 7e 22 05 bb 00 00 00 10 48
      RSP: 0018:ffa0000000cd7c30 EFLAGS: 00010246
      RAX: 9e129be1950f0200 RBX: ff1100011b51582c RCX: ff1100011857cd80
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000002
      RBP: 0000000000000000 R08: ffd400000000000f R09: ff1100013e78cac0
      R10: ffac800000cd7980 R11: ff1100013e12b1f0 R12: 0000000000000000
      R13: 0000000000000000 R14: 0000000000000000 R15: ff1100011a99a2ec
      FS:  00007fbd7086f740(0000) GS:ff1100013fd00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000200071c0 CR3: 0000000118556004 CR4: 0000000000771ef0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
      PKRU: 55555554
      Call Trace:
       <TASK>
       proc_create_net_single+0x144/0x210 fs/proc/proc_net.c:220
       bcm_connect+0x472/0x840 net/can/bcm.c:1673
       __sys_connect_file net/socket.c:2049 [inline]
       __sys_connect+0x5d2/0x690 net/socket.c:2066
       __do_sys_connect net/socket.c:2076 [inline]
       __se_sys_connect net/socket.c:2073 [inline]
       __x64_sys_connect+0x8f/0x100 net/socket.c:2073
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xd9/0x1c0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x4b/0x53
      RIP: 0033:0x7fbd708b0e5d
      Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 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 73 01 c3 48 8b 0d 73 9f 1b 00 f7 d8 64 89 01 48
      RSP: 002b:00007fff8cd33f08 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fbd708b0e5d
      RDX: 0000000000000010 RSI: 0000000020000040 RDI: 0000000000000003
      RBP: 0000000000000000 R08: 0000000000000040 R09: 0000000000000040
      R10: 0000000000000040 R11: 0000000000000246 R12: 00007fff8cd34098
      R13: 0000000000401280 R14: 0000000000406de8 R15: 00007fbd70ab9000
       </TASK>
      remove_proc_entry: removing non-empty directory 'net/can-bcm', leaking at least '2456'
      
      Fixes: ffd980f9 ("[CAN]: Add broadcast manager (bcm) protocol")
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/all/20240722192842.37421-1-kuniyu@amazon.com
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6d3e3609
  3. Jul 11, 2024
    • Oleksij Rempel's avatar
      net: can: j1939: enhanced error handling for tightly received RTS messages in... · 2063908b
      Oleksij Rempel authored and Frieder Schrempf's avatar Frieder Schrempf committed
      net: can: j1939: enhanced error handling for tightly received RTS messages in xtp_rx_rts_session_new
      
      commit d3e2904f upstream.
      
      This patch enhances error handling in scenarios with RTS (Request to
      Send) messages arriving closely. It replaces the less informative WARN_ON_ONCE
      backtraces with a new error handling method. This provides clearer error
      messages and allows for the early termination of problematic sessions.
      Previously, sessions were only released at the end of j1939_xtp_rx_rts().
      
      Potentially this could be reproduced with something like:
      testj1939 -r vcan0:0x80 &
      while true; do
      	# send first RTS
      	cansend vcan0 18EC8090#1014000303002301;
      	# send second RTS
      	cansend vcan0 18EC8090#1014000303002301;
      	# send abort
      	cansend vcan0 18EC8090#ff00000000002301;
      done
      
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Reported-by: default avatar <syzbot+daa36413a5cedf799ae4@syzkaller.appspotmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20231117124959.961171-1-o.rempel@pengutronix.de
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2063908b
    • Oleksij Rempel's avatar
      net: can: j1939: recover socket queue on CAN bus error during BAM transmission · 15b64e88
      Oleksij Rempel authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      commit 9ad1da14 upstream.
      
      Addresses an issue where a CAN bus error during a BAM transmission
      could stall the socket queue, preventing further transmissions even
      after the bus error is resolved. The fix activates the next queued
      session after the error recovery, allowing communication to continue.
      
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarAlexander Hölzl <alexander.hoelzl@gmx.net>
      Tested-by: default avatarAlexander Hölzl <alexander.hoelzl@gmx.net>
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20240528070648.1947203-1-o.rempel@pengutronix.de
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15b64e88
    • Shigeru Yoshida's avatar
      net: can: j1939: Initialize unused data in j1939_send_one() · 2d08a701
      Shigeru Yoshida authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      commit b7cdf1dd upstream.
      
      syzbot reported kernel-infoleak in raw_recvmsg() [1]. j1939_send_one()
      creates full frame including unused data, but it doesn't initialize
      it. This causes the kernel-infoleak issue. Fix this by initializing
      unused data.
      
      [1]
      BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
      BUG: KMSAN: kernel-infoleak in copy_to_user_iter lib/iov_iter.c:24 [inline]
      BUG: KMSAN: kernel-infoleak in iterate_ubuf include/linux/iov_iter.h:29 [inline]
      BUG: KMSAN: kernel-infoleak in iterate_and_advance2 include/linux/iov_iter.h:245 [inline]
      BUG: KMSAN: kernel-infoleak in iterate_and_advance include/linux/iov_iter.h:271 [inline]
      BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x366/0x2520 lib/iov_iter.c:185
       instrument_copy_to_user include/linux/instrumented.h:114 [inline]
       copy_to_user_iter lib/iov_iter.c:24 [inline]
       iterate_ubuf include/linux/iov_iter.h:29 [inline]
       iterate_and_advance2 include/linux/iov_iter.h:245 [inline]
       iterate_and_advance include/linux/iov_iter.h:271 [inline]
       _copy_to_iter+0x366/0x2520 lib/iov_iter.c:185
       copy_to_iter include/linux/uio.h:196 [inline]
       memcpy_to_msg include/linux/skbuff.h:4113 [inline]
       raw_recvmsg+0x2b8/0x9e0 net/can/raw.c:1008
       sock_recvmsg_nosec net/socket.c:1046 [inline]
       sock_recvmsg+0x2c4/0x340 net/socket.c:1068
       ____sys_recvmsg+0x18a/0x620 net/socket.c:2803
       ___sys_recvmsg+0x223/0x840 net/socket.c:2845
       do_recvmmsg+0x4fc/0xfd0 net/socket.c:2939
       __sys_recvmmsg net/socket.c:3018 [inline]
       __do_sys_recvmmsg net/socket.c:3041 [inline]
       __se_sys_recvmmsg net/socket.c:3034 [inline]
       __x64_sys_recvmmsg+0x397/0x490 net/socket.c:3034
       x64_sys_call+0xf6c/0x3b50 arch/x86/include/generated/asm/syscalls_64.h:300
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f
      
      Uninit was created at:
       slab_post_alloc_hook mm/slub.c:3804 [inline]
       slab_alloc_node mm/slub.c:3845 [inline]
       kmem_cache_alloc_node+0x613/0xc50 mm/slub.c:3888
       kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:577
       __alloc_skb+0x35b/0x7a0 net/core/skbuff.c:668
       alloc_skb include/linux/skbuff.h:1313 [inline]
       alloc_skb_with_frags+0xc8/0xbf0 net/core/skbuff.c:6504
       sock_alloc_send_pskb+0xa81/0xbf0 net/core/sock.c:2795
       sock_alloc_send_skb include/net/sock.h:1842 [inline]
       j1939_sk_alloc_skb net/can/j1939/socket.c:878 [inline]
       j1939_sk_send_loop net/can/j1939/socket.c:1142 [inline]
       j1939_sk_sendmsg+0xc0a/0x2730 net/can/j1939/socket.c:1277
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg+0x30f/0x380 net/socket.c:745
       ____sys_sendmsg+0x877/0xb60 net/socket.c:2584
       ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
       __sys_sendmsg net/socket.c:2667 [inline]
       __do_sys_sendmsg net/socket.c:2676 [inline]
       __se_sys_sendmsg net/socket.c:2674 [inline]
       __x64_sys_sendmsg+0x307/0x4a0 net/socket.c:2674
       x64_sys_call+0xc4b/0x3b50 arch/x86/include/generated/asm/syscalls_64.h:47
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f
      
      Bytes 12-15 of 16 are uninitialized
      Memory access of size 16 starts at ffff888120969690
      Data copied to user address 00000000200017c0
      
      CPU: 1 PID: 5050 Comm: syz-executor198 Not tainted 6.9.0-rc5-syzkaller-00031-g71b1543c83d6 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
      
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Reported-and-tested-by: default avatar <syzbot+5681e40d297b30f5b513@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=5681e40d297b30f5b513
      
      
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Link: https://lore.kernel.org/all/20240517035953.2617090-1-syoshida@redhat.com
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d08a701
  4. Mar 11, 2024
    • Oleksij Rempel's avatar
      can: j1939: Fix UAF in j1939_sk_match_filter during setsockopt(SO_J1939_FILTER) · b48c9c60
      Oleksij Rempel authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      commit efe7cf82 upstream.
      
      Lock jsk->sk to prevent UAF when setsockopt(..., SO_J1939_FILTER, ...)
      modifies jsk->filters while receiving packets.
      
      Following trace was seen on affected system:
       ==================================================================
       BUG: KASAN: slab-use-after-free in j1939_sk_recv_match_one+0x1af/0x2d0 [can_j1939]
       Read of size 4 at addr ffff888012144014 by task j1939/350
      
       CPU: 0 PID: 350 Comm: j1939 Tainted: G        W  OE      6.5.0-rc5 #1
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
       Call Trace:
        print_report+0xd3/0x620
        ? kasan_complete_mode_report_info+0x7d/0x200
        ? j1939_sk_recv_match_one+0x1af/0x2d0 [can_j1939]
        kasan_report+0xc2/0x100
        ? j1939_sk_recv_match_one+0x1af/0x2d0 [can_j1939]
        __asan_load4+0x84/0xb0
        j1939_sk_recv_match_one+0x1af/0x2d0 [can_j1939]
        j1939_sk_recv+0x20b/0x320 [can_j1939]
        ? __kasan_check_write+0x18/0x20
        ? __pfx_j1939_sk_recv+0x10/0x10 [can_j1939]
        ? j1939_simple_recv+0x69/0x280 [can_j1939]
        ? j1939_ac_recv+0x5e/0x310 [can_j1939]
        j1939_can_recv+0x43f/0x580 [can_j1939]
        ? __pfx_j1939_can_recv+0x10/0x10 [can_j1939]
        ? raw_rcv+0x42/0x3c0 [can_raw]
        ? __pfx_j1939_can_recv+0x10/0x10 [can_j1939]
        can_rcv_filter+0x11f/0x350 [can]
        can_receive+0x12f/0x190 [can]
        ? __pfx_can_rcv+0x10/0x10 [can]
        can_rcv+0xdd/0x130 [can]
        ? __pfx_can_rcv+0x10/0x10 [can]
        __netif_receive_skb_one_core+0x13d/0x150
        ? __pfx___netif_receive_skb_one_core+0x10/0x10
        ? __kasan_check_write+0x18/0x20
        ? _raw_spin_lock_irq+0x8c/0xe0
        __netif_receive_skb+0x23/0xb0
        process_backlog+0x107/0x260
        __napi_poll+0x69/0x310
        net_rx_action+0x2a1/0x580
        ? __pfx_net_rx_action+0x10/0x10
        ? __pfx__raw_spin_lock+0x10/0x10
        ? handle_irq_event+0x7d/0xa0
        __do_softirq+0xf3/0x3f8
        do_softirq+0x53/0x80
        </IRQ>
        <TASK>
        __local_bh_enable_ip+0x6e/0x70
        netif_rx+0x16b/0x180
        can_send+0x32b/0x520 [can]
        ? __pfx_can_send+0x10/0x10 [can]
        ? __check_object_size+0x299/0x410
        raw_sendmsg+0x572/0x6d0 [can_raw]
        ? __pfx_raw_sendmsg+0x10/0x10 [can_raw]
        ? apparmor_socket_sendmsg+0x2f/0x40
        ? __pfx_raw_sendmsg+0x10/0x10 [can_raw]
        sock_sendmsg+0xef/0x100
        sock_write_iter+0x162/0x220
        ? __pfx_sock_write_iter+0x10/0x10
        ? __rtnl_unlock+0x47/0x80
        ? security_file_permission+0x54/0x320
        vfs_write+0x6ba/0x750
        ? __pfx_vfs_write+0x10/0x10
        ? __fget_light+0x1ca/0x1f0
        ? __rcu_read_unlock+0x5b/0x280
        ksys_write+0x143/0x170
        ? __pfx_ksys_write+0x10/0x10
        ? __kasan_check_read+0x15/0x20
        ? fpregs_assert_state_consistent+0x62/0x70
        __x64_sys_write+0x47/0x60
        do_syscall_64+0x60/0x90
        ? do_syscall_64+0x6d/0x90
        ? irqentry_exit+0x3f/0x50
        ? exc_page_fault+0x79/0xf0
        entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      
       Allocated by task 348:
        kasan_save_stack+0x2a/0x50
        kasan_set_track+0x29/0x40
        kasan_save_alloc_info+0x1f/0x30
        __kasan_kmalloc+0xb5/0xc0
        __kmalloc_node_track_caller+0x67/0x160
        j1939_sk_setsockopt+0x284/0x450 [can_j1939]
        __sys_setsockopt+0x15c/0x2f0
        __x64_sys_setsockopt+0x6b/0x80
        do_syscall_64+0x60/0x90
        entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      
       Freed by task 349:
        kasan_save_stack+0x2a/0x50
        kasan_set_track+0x29/0x40
        kasan_save_free_info+0x2f/0x50
        __kasan_slab_free+0x12e/0x1c0
        __kmem_cache_free+0x1b9/0x380
        kfree+0x7a/0x120
        j1939_sk_setsockopt+0x3b2/0x450 [can_j1939]
        __sys_setsockopt+0x15c/0x2f0
        __x64_sys_setsockopt+0x6b/0x80
        do_syscall_64+0x60/0x90
        entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Reported-by: default avatarSili Luo <rootlab@huawei.com>
      Suggested-by: default avatarSili Luo <rootlab@huawei.com>
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20231020133814.383996-1-o.rempel@pengutronix.de
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b48c9c60
    • Ziqi Zhao's avatar
      can: j1939: prevent deadlock by changing j1939_socks_lock to rwlock · 5c773e1e
      Ziqi Zhao authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      commit 6cdedc18 upstream.
      
      The following 3 locks would race against each other, causing the
      deadlock situation in the Syzbot bug report:
      
      - j1939_socks_lock
      - active_session_list_lock
      - sk_session_queue_lock
      
      A reasonable fix is to change j1939_socks_lock to an rwlock, since in
      the rare situations where a write lock is required for the linked list
      that j1939_socks_lock is protecting, the code does not attempt to
      acquire any more locks. This would break the circular lock dependency,
      where, for example, the current thread already locks j1939_socks_lock
      and attempts to acquire sk_session_queue_lock, and at the same time,
      another thread attempts to acquire j1939_socks_lock while holding
      sk_session_queue_lock.
      
      NOTE: This patch along does not fix the unregister_netdevice bug
      reported by Syzbot; instead, it solves a deadlock situation to prepare
      for one or more further patches to actually fix the Syzbot bug, which
      appears to be a reference counting problem within the j1939 codebase.
      
      Reported-by: default avatar <syzbot+1591462f226d9cbf0564@syzkaller.appspotmail.com>
      Signed-off-by: default avatarZiqi Zhao <astrajoan@yahoo.com>
      Reviewed-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20230721162226.8639-1-astrajoan@yahoo.com
      
      
      [mkl: remove unrelated newline change]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c773e1e
  5. Jan 23, 2024
  6. Oct 31, 2023
  7. Sep 11, 2023
    • Oliver Hartkopp's avatar
      can: raw: add missing refcount for memory leak fix · a909280d
      Oliver Hartkopp authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      commit c275a176 upstream.
      
      Commit ee8b94c8 ("can: raw: fix receiver memory leak") introduced
      a new reference to the CAN netdevice that has assigned CAN filters.
      But this new ro->dev reference did not maintain its own refcount which
      lead to another KASAN use-after-free splat found by Eric Dumazet.
      
      This patch ensures a proper refcount for the CAN nedevice.
      
      Fixes: ee8b94c8 ("can: raw: fix receiver memory leak")
      Reported-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Ziyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Link: https://lore.kernel.org/r/20230821144547.6658-3-socketcan@hartkopp.net
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a909280d
    • Oliver Hartkopp's avatar
      can: isotp: fix support for transmission of SF without flow control · 508ffc43
      Oliver Hartkopp authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit 0bfe7115 ]
      
      The original implementation had a very simple handling for single frame
      transmissions as it just sent the single frame without a timeout handling.
      
      With the new echo frame handling the echo frame was also introduced for
      single frames but the former exception ('simple without timers') has been
      maintained by accident. This leads to a 1 second timeout when closing the
      socket and to an -ECOMM error when CAN_ISOTP_WAIT_TX_DONE is selected.
      
      As the echo handling is always active (also for single frames) remove the
      wrong extra condition for single frames.
      
      Fixes: 9f39d365 ("can: isotp: add support for transmission without flow control")
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Link: https://lore.kernel.org/r/20230821144547.6658-2-socketcan@hartkopp.net
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      508ffc43
    • Eric Dumazet's avatar
      can: raw: fix lockdep issue in raw_release() · 0ceb88cf
      Eric Dumazet authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit 11c9027c ]
      
      syzbot complained about a lockdep issue [1]
      
      Since raw_bind() and raw_setsockopt() first get RTNL
      before locking the socket, we must adopt the same order in raw_release()
      
      [1]
      WARNING: possible circular locking dependency detected
      6.5.0-rc1-syzkaller-00192-g78adb4bcf99e #0 Not tainted
      ------------------------------------------------------
      syz-executor.0/14110 is trying to acquire lock:
      ffff88804e4b6130 (sk_lock-AF_CAN){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1708 [inline]
      ffff88804e4b6130 (sk_lock-AF_CAN){+.+.}-{0:0}, at: raw_bind+0xb1/0xab0 net/can/raw.c:435
      
      but task is already holding lock:
      ffffffff8e3df368 (rtnl_mutex){+.+.}-{3:3}, at: raw_bind+0xa7/0xab0 net/can/raw.c:434
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #1 (rtnl_mutex){+.+.}-{3:3}:
      __mutex_lock_common kernel/locking/mutex.c:603 [inline]
      __mutex_lock+0x181/0x1340 kernel/locking/mutex.c:747
      raw_release+0x1c6/0x9b0 net/can/raw.c:391
      __sock_release+0xcd/0x290 net/socket.c:654
      sock_close+0x1c/0x20 net/socket.c:1386
      __fput+0x3fd/0xac0 fs/file_table.c:384
      task_work_run+0x14d/0x240 kernel/task_work.c:179
      resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
      exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
      exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
      __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
      syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
      do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      -> #0 (sk_lock-AF_CAN){+.+.}-{0:0}:
      check_prev_add kernel/locking/lockdep.c:3142 [inline]
      check_prevs_add kernel/locking/lockdep.c:3261 [inline]
      validate_chain kernel/locking/lockdep.c:3876 [inline]
      __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5144
      lock_acquire kernel/locking/lockdep.c:5761 [inline]
      lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5726
      lock_sock_nested+0x3a/0xf0 net/core/sock.c:3492
      lock_sock include/net/sock.h:1708 [inline]
      raw_bind+0xb1/0xab0 net/can/raw.c:435
      __sys_bind+0x1ec/0x220 net/socket.c:1792
      __do_sys_bind net/socket.c:1803 [inline]
      __se_sys_bind net/socket.c:1801 [inline]
      __x64_sys_bind+0x72/0xb0 net/socket.c:1801
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      other info that might help us debug this:
      
      Possible unsafe locking scenario:
      
      CPU0 CPU1
      ---- ----
      lock(rtnl_mutex);
              lock(sk_lock-AF_CAN);
              lock(rtnl_mutex);
      lock(sk_lock-AF_CAN);
      
      *** DEADLOCK ***
      
      1 lock held by syz-executor.0/14110:
      
      stack backtrace:
      CPU: 0 PID: 14110 Comm: syz-executor.0 Not tainted 6.5.0-rc1-syzkaller-00192-g78adb4bcf99e #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
      check_noncircular+0x311/0x3f0 kernel/locking/lockdep.c:2195
      check_prev_add kernel/locking/lockdep.c:3142 [inline]
      check_prevs_add kernel/locking/lockdep.c:3261 [inline]
      validate_chain kernel/locking/lockdep.c:3876 [inline]
      __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5144
      lock_acquire kernel/locking/lockdep.c:5761 [inline]
      lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5726
      lock_sock_nested+0x3a/0xf0 net/core/sock.c:3492
      lock_sock include/net/sock.h:1708 [inline]
      raw_bind+0xb1/0xab0 net/can/raw.c:435
      __sys_bind+0x1ec/0x220 net/socket.c:1792
      __do_sys_bind net/socket.c:1803 [inline]
      __se_sys_bind net/socket.c:1801 [inline]
      __x64_sys_bind+0x72/0xb0 net/socket.c:1801
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7fd89007cb29
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fd890d2a0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000031
      RAX: ffffffffffffffda RBX: 00007fd89019bf80 RCX: 00007fd89007cb29
      RDX: 0000000000000010 RSI: 0000000020000040 RDI: 0000000000000003
      RBP: 00007fd8900c847a R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 000000000000000b R14: 00007fd89019bf80 R15: 00007ffebf8124f8
      </TASK>
      
      Fixes: ee8b94c8 ("can: raw: fix receiver memory leak")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Ziyang Xuan <william.xuanziyang@huawei.com>
      Cc: Oliver Hartkopp <socketcan@hartkopp.net>
      Cc: stable@vger.kernel.org
      Cc: Marc Kleine-Budde <mkl@pengutronix.de>
      Link: https://lore.kernel.org/all/20230720114438.172434-1-edumazet@google.com
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ceb88cf
    • Ziyang Xuan's avatar
      can: raw: fix receiver memory leak · 2607f227
      Ziyang Xuan authored and Frieder Schrempf's avatar Frieder Schrempf committed
      
      [ Upstream commit ee8b94c8 ]
      
      Got kmemleak errors with the following ltp can_filter testcase:
      
      for ((i=1; i<=100; i++))
      do
              ./can_filter &
              sleep 0.1
      done
      
      ==============================================================
      [<00000000db4a4943>] can_rx_register+0x147/0x360 [can]
      [<00000000a289549d>] raw_setsockopt+0x5ef/0x853 [can_raw]
      [<000000006d3d9ebd>] __sys_setsockopt+0x173/0x2c0
      [<00000000407dbfec>] __x64_sys_setsockopt+0x61/0x70
      [<00000000fd468496>] do_syscall_64+0x33/0x40
      [<00000000b7e47d51>] entry_SYSCALL_64_after_hwframe+0x61/0xc6
      
      It's a bug in the concurrent scenario of unregister_netdevice_many()
      and raw_release() as following:
      
                   cpu0                                        cpu1
      unregister_netdevice_many(can_dev)
        unlist_netdevice(can_dev) // dev_get_by_index() return NULL after this
        net_set_todo(can_dev)
      						raw_release(can_socket)
      						  dev = dev_get_by_index(, ro->ifindex); // dev == NULL
      						  if (dev) { // receivers in dev_rcv_lists not free because dev is NULL
      						    raw_disable_allfilters(, dev, );
      						    dev_put(dev);
      						  }
      						  ...
      						  ro->bound = 0;
      						  ...
      
      call_netdevice_notifiers(NETDEV_UNREGISTER, )
        raw_notify(, NETDEV_UNREGISTER, )
          if (ro->bound) // invalid because ro->bound has been set 0
            raw_disable_allfilters(, dev, ); // receivers in dev_rcv_lists will never be freed
      
      Add a net_device pointer member in struct raw_sock to record bound
      can_dev, and use rtnl_lock to serialize raw_socket members between
      raw_bind(), raw_release(), raw_setsockopt() and raw_notify(). Use
      ro->dev to decide whether to free receivers in dev_rcv_lists.
      
      Fixes: 8d0caedb ("can: bcm/raw/isotp: use per module netdevice notifier")
      Reviewed-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Link: https://lore.kernel.org/all/20230711011737.1969582-1-william.xuanziyang@huawei.com
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2607f227
  8. Aug 17, 2023
  9. Apr 13, 2023
  10. Apr 06, 2023
    • Oleksij Rempel's avatar
      can: j1939: prevent deadlock by moving j1939_sk_errqueue() · ace6aa2a
      Oleksij Rempel authored
      
      commit d1366b28 upstream.
      
      This commit addresses a deadlock situation that can occur in certain
      scenarios, such as when running data TP/ETP transfer and subscribing to
      the error queue while receiving a net down event. The deadlock involves
      locks in the following order:
      
      3
        j1939_session_list_lock ->  active_session_list_lock
        j1939_session_activate
        ...
        j1939_sk_queue_activate_next -> sk_session_queue_lock
        ...
        j1939_xtp_rx_eoma_one
      
      2
        j1939_sk_queue_drop_all  ->  sk_session_queue_lock
        ...
        j1939_sk_netdev_event_netdown -> j1939_socks_lock
        j1939_netdev_notify
      
      1
        j1939_sk_errqueue -> j1939_socks_lock
        __j1939_session_cancel -> active_session_list_lock
        j1939_tp_rxtimer
      
             CPU0                    CPU1
             ----                    ----
        lock(&priv->active_session_list_lock);
                                     lock(&jsk->sk_session_queue_lock);
                                     lock(&priv->active_session_list_lock);
        lock(&priv->j1939_socks_lock);
      
      The solution implemented in this commit is to move the
      j1939_sk_errqueue() call out of the active_session_list_lock context,
      thus preventing the deadlock situation.
      
      Reported-by: default avatar <syzbot+ee1cd780f69483a8616b@syzkaller.appspotmail.com>
      Fixes: 5b9272e9 ("can: j1939: extend UAPI to notify about RX status")
      Co-developed-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20230324130141.2132787-1-o.rempel@pengutronix.de
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ace6aa2a
    • Ivan Orlov's avatar
      can: bcm: bcm_tx_setup(): fix KMSAN uninit-value in vfs_write · c11dbc77
      Ivan Orlov authored
      
      [ Upstream commit 2b4c99f7 ]
      
      Syzkaller reported the following issue:
      
      =====================================================
      BUG: KMSAN: uninit-value in aio_rw_done fs/aio.c:1520 [inline]
      BUG: KMSAN: uninit-value in aio_write+0x899/0x950 fs/aio.c:1600
       aio_rw_done fs/aio.c:1520 [inline]
       aio_write+0x899/0x950 fs/aio.c:1600
       io_submit_one+0x1d1c/0x3bf0 fs/aio.c:2019
       __do_sys_io_submit fs/aio.c:2078 [inline]
       __se_sys_io_submit+0x293/0x770 fs/aio.c:2048
       __x64_sys_io_submit+0x92/0xd0 fs/aio.c:2048
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Uninit was created at:
       slab_post_alloc_hook mm/slab.h:766 [inline]
       slab_alloc_node mm/slub.c:3452 [inline]
       __kmem_cache_alloc_node+0x71f/0xce0 mm/slub.c:3491
       __do_kmalloc_node mm/slab_common.c:967 [inline]
       __kmalloc+0x11d/0x3b0 mm/slab_common.c:981
       kmalloc_array include/linux/slab.h:636 [inline]
       bcm_tx_setup+0x80e/0x29d0 net/can/bcm.c:930
       bcm_sendmsg+0x3a2/0xce0 net/can/bcm.c:1351
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg net/socket.c:734 [inline]
       sock_write_iter+0x495/0x5e0 net/socket.c:1108
       call_write_iter include/linux/fs.h:2189 [inline]
       aio_write+0x63a/0x950 fs/aio.c:1600
       io_submit_one+0x1d1c/0x3bf0 fs/aio.c:2019
       __do_sys_io_submit fs/aio.c:2078 [inline]
       __se_sys_io_submit+0x293/0x770 fs/aio.c:2048
       __x64_sys_io_submit+0x92/0xd0 fs/aio.c:2048
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      CPU: 1 PID: 5034 Comm: syz-executor350 Not tainted 6.2.0-rc6-syzkaller-80422-geda666ff2276 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
      =====================================================
      
      We can follow the call chain and find that 'bcm_tx_setup' function
      calls 'memcpy_from_msg' to copy some content to the newly allocated
      frame of 'op->frames'. After that the 'len' field of copied structure
      being compared with some constant value (64 or 8). However, if
      'memcpy_from_msg' returns an error, we will compare some uninitialized
      memory. This triggers 'uninit-value' issue.
      
      This patch will add 'memcpy_from_msg' possible errors processing to
      avoid uninit-value issue.
      
      Tested via syzkaller
      
      Reported-by: default avatar <syzbot+c9bfd85eca611ebf5db1@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=47f897f8ad958bbde5790ebf389b5e7e0a345089
      
      
      Signed-off-by: default avatarIvan Orlov <ivan.orlov0322@gmail.com>
      Fixes: 6f3b911d ("can: bcm: add support for CAN FD frames")
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Link: https://lore.kernel.org/all/20230314120445.12407-1-ivan.orlov0322@gmail.com
      
      
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c11dbc77
  11. Mar 10, 2023
  12. Feb 14, 2023
    • Devid Antonio Filoni's avatar
      can: j1939: do not wait 250 ms if the same addr was already claimed · c86e6d30
      Devid Antonio Filoni authored
      
      commit 4ae5e1e9 upstream.
      
      The ISO 11783-5 standard, in "4.5.2 - Address claim requirements", states:
        d) No CF shall begin, or resume, transmission on the network until 250
           ms after it has successfully claimed an address except when
           responding to a request for address-claimed.
      
      But "Figure 6" and "Figure 7" in "4.5.4.2 - Address-claim
      prioritization" show that the CF begins the transmission after 250 ms
      from the first AC (address-claimed) message even if it sends another AC
      message during that time window to resolve the address contention with
      another CF.
      
      As stated in "4.4.2.3 - Address-claimed message":
        In order to successfully claim an address, the CF sending an address
        claimed message shall not receive a contending claim from another CF
        for at least 250 ms.
      
      As stated in "4.4.3.2 - NAME management (NM) message":
        1) A commanding CF can
           d) request that a CF with a specified NAME transmit the address-
              claimed message with its current NAME.
        2) A target CF shall
           d) send an address-claimed message in response to a request for a
              matching NAME
      
      Taking the above arguments into account, the 250 ms wait is requested
      only during network initialization.
      
      Do not restart the timer on AC message if both the NAME and the address
      match and so if the address has already been claimed (timer has expired)
      or the AC message has been sent to resolve the contention with another
      CF (timer is still running).
      
      Signed-off-by: default avatarDevid Antonio Filoni <devid.filoni@egluetechnologies.com>
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20221125170418.34575-1-devid.filoni@egluetechnologies.com
      
      
      Fixes: 9d71dd0c ("can: add support of SAE J1939 protocol")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c86e6d30
  13. Feb 09, 2023
  14. Dec 07, 2022
  15. Nov 07, 2022
Loading