1. 07 Dec, 2023 7 commits
    • Daniel Danzberger's avatar
      net: dsa: microchip: move ksz_chip_id enum to platform include · d16f1096
      Daniel Danzberger authored
      With the ksz_chip_id enums moved to the platform include file for ksz
      switches, platform code that instantiates a device can now use these to
      set ksz_platform_data::chip_id.
      Signed-off-by: default avatarDaniel Danzberger <dd@embedd.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d16f1096
    • Vladimir Oltean's avatar
      net: dsa: microchip: properly support platform_data probing · 3bc05faf
      Vladimir Oltean authored
      The ksz driver has bits and pieces of platform_data probing support, but
      it doesn't work.
      
      The conventional thing to do is to have an encapsulating structure for
      struct dsa_chip_data that gets put into dev->platform_data. This driver
      expects a struct ksz_platform_data, but that doesn't contain a struct
      dsa_chip_data as first element, which will obviously not work with
      dsa_switch_probe() -> dsa_switch_parse().
      
      Pointing dev->platform_data to a struct dsa_chip_data directly is in
      principle possible, but that doesn't work either. The driver has
      ksz_switch_detect() to read the device ID from hardware, followed by
      ksz_check_device_id() to compare it against a predetermined expected
      value. This protects against early errors in the SPI/I2C communication.
      With platform_data, the mechanism in ksz_check_device_id() doesn't work
      and even leads to NULL pointer dereferences, since of_device_get_match_data()
      doesn't work in that probe path.
      
      So obviously, the platform_data support is actually missing, and the
      existing handling of struct ksz_platform_data is bogus. Complete the
      support by adding a struct dsa_chip_data as first element, and fixing up
      ksz_check_device_id() to pick up the platform_data instead of the
      unavailable of_device_get_match_data().
      
      The early dev->chip_id assignment from ksz_switch_register() is also
      bogus, because ksz_switch_detect() sets it to an initial value. So
      remove it.
      
      Also, ksz_platform_data :: enabled_ports isn't used anywhere, delete it.
      
      Link: https://lore.kernel.org/netdev/20231204154315.3906267-1-dd@embedd.com/Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDaniel Danzberger <dd@embedd.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3bc05faf
    • David S. Miller's avatar
      Merge branch 'dsa-microchip-rmii-reference' · d5449d59
      David S. Miller authored
      Ante Knezic says:
      
      ====================
      net: dsa: microchip: enable setting rmii reference
      
      KSZ88X3 devices can select between internal and external RMII reference clock.
      This patch series introduces new device tree property for setting reference
      clock to internal.
      
      ---
      V5:
        - move rmii-clk-internal to be a port device tree property.
      V4:
        - remove rmii_clk_internal from ksz_device, as its not needed any more
        - move rmii clk config as well as ksz8795_cpu_interface_select to
          ksz8_config_cpu_port
      V3:
        - move ksz_cfg from global switch config to port config as suggested by Vladimir
          Oltean
        - reverse patch order as suggested by Vladimir Oltean
        - adapt dt schema as suggested by Conor Dooley
      V2:
        - don't rely on default register settings - enforce set/clear property as
          suggested by Andrew Lunn
        - enforce dt schema as suggested by Conor Dooley
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d5449d59
    • Ante Knezic's avatar
      net: dsa: microchip: add property to select internal RMII reference clock · 9f19a4eb
      Ante Knezic authored
      Microchip KSZ8863/KSZ8873 have the ability to select between internal
      and external RMII reference clock. By default, reference clock
      needs to be provided via REFCLKI_3 pin. If required, device can be
      setup to provide RMII clock internally so that REFCLKI_3 pin can be
      left unconnected.
      Add a new "microchip,rmii-clk-internal" property which will set
      RMII clock reference to internal. If property is not set, reference
      clock needs to be provided externally.
      
      While at it, move the ksz8795_cpu_interface_select() to
      ksz8_config_cpu_port() to get a cleaner call path for cpu port.
      Signed-off-by: default avatarAnte Knezic <ante.knezic@helmholz.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9f19a4eb
    • Ante Knezic's avatar
      dt-bindings: net: microchip,ksz: document microchip,rmii-clk-internal · 8e3bfaab
      Ante Knezic authored
      Add documentation for selecting reference rmii clock on KSZ88X3 devices
      Signed-off-by: default avatarAnte Knezic <ante.knezic@helmholz.de>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8e3bfaab
    • Johannes Berg's avatar
      net: rtnetlink: remove local list in __linkwatch_run_queue() · b8dbbbc5
      Johannes Berg authored
      Due to linkwatch_forget_dev() (and perhaps others?) checking for
      list_empty(&dev->link_watch_list), we must have all manipulations
      of even the local on-stack list 'wrk' here under spinlock, since
      even that list can be reached otherwise via dev->link_watch_list.
      
      This is already the case, but makes this a bit counter-intuitive,
      often local lists are used to _not_ have to use locking for their
      local use.
      
      Remove the local list as it doesn't seem to serve any purpose.
      While at it, move a variable declaration into the loop using it.
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Link: https://lore.kernel.org/r/20231205170011.56576dcc1727.I698b72219d9f6ce789bd209b8f6dffd0ca32a8f2@changeidSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b8dbbbc5
    • Eric Dumazet's avatar
      ipv6: add debug checks in fib6_info_release() · 5a08d006
      Eric Dumazet authored
      Some elusive syzbot reports are hinting to fib6_info_release(),
      with a potential dangling f6i->gc_link anchor.
      
      Add debug checks so that syzbot can catch the issue earlier eventually.
      
      BUG: KASAN: slab-use-after-free in __hlist_del include/linux/list.h:990 [inline]
      BUG: KASAN: slab-use-after-free in hlist_del_init include/linux/list.h:1016 [inline]
      BUG: KASAN: slab-use-after-free in fib6_clean_expires_locked include/net/ip6_fib.h:533 [inline]
      BUG: KASAN: slab-use-after-free in fib6_purge_rt+0x986/0x9c0 net/ipv6/ip6_fib.c:1064
      Write of size 8 at addr ffff88802805a840 by task syz-executor.1/10057
      
      CPU: 1 PID: 10057 Comm: syz-executor.1 Not tainted 6.7.0-rc2-syzkaller-00029-g9b6de136 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
      print_address_description mm/kasan/report.c:364 [inline]
      print_report+0xc4/0x620 mm/kasan/report.c:475
      kasan_report+0xda/0x110 mm/kasan/report.c:588
      __hlist_del include/linux/list.h:990 [inline]
      hlist_del_init include/linux/list.h:1016 [inline]
      fib6_clean_expires_locked include/net/ip6_fib.h:533 [inline]
      fib6_purge_rt+0x986/0x9c0 net/ipv6/ip6_fib.c:1064
      fib6_del_route net/ipv6/ip6_fib.c:1993 [inline]
      fib6_del+0xa7a/0x1750 net/ipv6/ip6_fib.c:2038
      __ip6_del_rt net/ipv6/route.c:3866 [inline]
      ip6_del_rt+0xf7/0x200 net/ipv6/route.c:3881
      ndisc_router_discovery+0x295b/0x3560 net/ipv6/ndisc.c:1372
      ndisc_rcv+0x3de/0x5f0 net/ipv6/ndisc.c:1856
      icmpv6_rcv+0x1470/0x19c0 net/ipv6/icmp.c:979
      ip6_protocol_deliver_rcu+0x170/0x13e0 net/ipv6/ip6_input.c:438
      ip6_input_finish+0x14f/0x2f0 net/ipv6/ip6_input.c:483
      NF_HOOK include/linux/netfilter.h:314 [inline]
      NF_HOOK include/linux/netfilter.h:308 [inline]
      ip6_input+0xa1/0xc0 net/ipv6/ip6_input.c:492
      ip6_mc_input+0x48b/0xf40 net/ipv6/ip6_input.c:586
      dst_input include/net/dst.h:461 [inline]
      ip6_rcv_finish net/ipv6/ip6_input.c:79 [inline]
      NF_HOOK include/linux/netfilter.h:314 [inline]
      NF_HOOK include/linux/netfilter.h:308 [inline]
      ipv6_rcv+0x24e/0x380 net/ipv6/ip6_input.c:310
      __netif_receive_skb_one_core+0x115/0x180 net/core/dev.c:5529
      __netif_receive_skb+0x1f/0x1b0 net/core/dev.c:5643
      netif_receive_skb_internal net/core/dev.c:5729 [inline]
      netif_receive_skb+0x133/0x700 net/core/dev.c:5788
      tun_rx_batched+0x429/0x780 drivers/net/tun.c:1579
      tun_get_user+0x29e3/0x3bc0 drivers/net/tun.c:2002
      tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048
      call_write_iter include/linux/fs.h:2020 [inline]
      new_sync_write fs/read_write.c:491 [inline]
      vfs_write+0x64f/0xdf0 fs/read_write.c:584
      ksys_write+0x12f/0x250 fs/read_write.c:637
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      RIP: 0033:0x7f38e387b82f
      Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 b9 80 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 0c 81 02 00 48
      RSP: 002b:00007f38e45c9090 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 00007f38e399bf80 RCX: 00007f38e387b82f
      RDX: 00000000000003b6 RSI: 0000000020000680 RDI: 00000000000000c8
      RBP: 00007f38e38c847a R08: 0000000000000000 R09: 0000000000000000
      R10: 00000000000003b6 R11: 0000000000000293 R12: 0000000000000000
      R13: 000000000000000b R14: 00007f38e399bf80 R15: 00007f38e3abfa48
      </TASK>
      
      Allocated by task 10044:
      kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
      kasan_set_track+0x25/0x30 mm/kasan/common.c:52
      ____kasan_kmalloc mm/kasan/common.c:374 [inline]
      __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383
      kasan_kmalloc include/linux/kasan.h:198 [inline]
      __do_kmalloc_node mm/slab_common.c:1007 [inline]
      __kmalloc+0x59/0x90 mm/slab_common.c:1020
      kmalloc include/linux/slab.h:604 [inline]
      kzalloc include/linux/slab.h:721 [inline]
      fib6_info_alloc+0x40/0x160 net/ipv6/ip6_fib.c:155
      ip6_route_info_create+0x337/0x1e70 net/ipv6/route.c:3749
      ip6_route_add+0x26/0x150 net/ipv6/route.c:3843
      rt6_add_route_info+0x2e7/0x4b0 net/ipv6/route.c:4316
      rt6_route_rcv+0x76c/0xbf0 net/ipv6/route.c:985
      ndisc_router_discovery+0x138b/0x3560 net/ipv6/ndisc.c:1529
      ndisc_rcv+0x3de/0x5f0 net/ipv6/ndisc.c:1856
      icmpv6_rcv+0x1470/0x19c0 net/ipv6/icmp.c:979
      ip6_protocol_deliver_rcu+0x170/0x13e0 net/ipv6/ip6_input.c:438
      ip6_input_finish+0x14f/0x2f0 net/ipv6/ip6_input.c:483
      NF_HOOK include/linux/netfilter.h:314 [inline]
      NF_HOOK include/linux/netfilter.h:308 [inline]
      ip6_input+0xa1/0xc0 net/ipv6/ip6_input.c:492
      ip6_mc_input+0x48b/0xf40 net/ipv6/ip6_input.c:586
      dst_input include/net/dst.h:461 [inline]
      ip6_rcv_finish net/ipv6/ip6_input.c:79 [inline]
      NF_HOOK include/linux/netfilter.h:314 [inline]
      NF_HOOK include/linux/netfilter.h:308 [inline]
      ipv6_rcv+0x24e/0x380 net/ipv6/ip6_input.c:310
      __netif_receive_skb_one_core+0x115/0x180 net/core/dev.c:5529
      __netif_receive_skb+0x1f/0x1b0 net/core/dev.c:5643
      netif_receive_skb_internal net/core/dev.c:5729 [inline]
      netif_receive_skb+0x133/0x700 net/core/dev.c:5788
      tun_rx_batched+0x429/0x780 drivers/net/tun.c:1579
      tun_get_user+0x29e3/0x3bc0 drivers/net/tun.c:2002
      tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048
      call_write_iter include/linux/fs.h:2020 [inline]
      new_sync_write fs/read_write.c:491 [inline]
      vfs_write+0x64f/0xdf0 fs/read_write.c:584
      ksys_write+0x12f/0x250 fs/read_write.c:637
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Freed by task 5123:
      kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
      kasan_set_track+0x25/0x30 mm/kasan/common.c:52
      kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
      ____kasan_slab_free mm/kasan/common.c:236 [inline]
      ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200
      kasan_slab_free include/linux/kasan.h:164 [inline]
      slab_free_hook mm/slub.c:1800 [inline]
      slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
      slab_free mm/slub.c:3809 [inline]
      __kmem_cache_free+0xc0/0x180 mm/slub.c:3822
      rcu_do_batch kernel/rcu/tree.c:2158 [inline]
      rcu_core+0x819/0x1680 kernel/rcu/tree.c:2431
      __do_softirq+0x21a/0x8de kernel/softirq.c:553
      
      Last potentially related work creation:
      kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
      __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
      __call_rcu_common.constprop.0+0x9a/0x7a0 kernel/rcu/tree.c:2681
      fib6_info_release include/net/ip6_fib.h:332 [inline]
      fib6_info_release include/net/ip6_fib.h:329 [inline]
      rt6_route_rcv+0xa4e/0xbf0 net/ipv6/route.c:997
      ndisc_router_discovery+0x138b/0x3560 net/ipv6/ndisc.c:1529
      ndisc_rcv+0x3de/0x5f0 net/ipv6/ndisc.c:1856
      icmpv6_rcv+0x1470/0x19c0 net/ipv6/icmp.c:979
      ip6_protocol_deliver_rcu+0x170/0x13e0 net/ipv6/ip6_input.c:438
      ip6_input_finish+0x14f/0x2f0 net/ipv6/ip6_input.c:483
      NF_HOOK include/linux/netfilter.h:314 [inline]
      NF_HOOK include/linux/netfilter.h:308 [inline]
      ip6_input+0xa1/0xc0 net/ipv6/ip6_input.c:492
      ip6_mc_input+0x48b/0xf40 net/ipv6/ip6_input.c:586
      dst_input include/net/dst.h:461 [inline]
      ip6_rcv_finish net/ipv6/ip6_input.c:79 [inline]
      NF_HOOK include/linux/netfilter.h:314 [inline]
      NF_HOOK include/linux/netfilter.h:308 [inline]
      ipv6_rcv+0x24e/0x380 net/ipv6/ip6_input.c:310
      __netif_receive_skb_one_core+0x115/0x180 net/core/dev.c:5529
      __netif_receive_skb+0x1f/0x1b0 net/core/dev.c:5643
      netif_receive_skb_internal net/core/dev.c:5729 [inline]
      netif_receive_skb+0x133/0x700 net/core/dev.c:5788
      tun_rx_batched+0x429/0x780 drivers/net/tun.c:1579
      tun_get_user+0x29e3/0x3bc0 drivers/net/tun.c:2002
      tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048
      call_write_iter include/linux/fs.h:2020 [inline]
      new_sync_write fs/read_write.c:491 [inline]
      vfs_write+0x64f/0xdf0 fs/read_write.c:584
      ksys_write+0x12f/0x250 fs/read_write.c:637
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Second to last potentially related work creation:
      kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
      __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
      insert_work+0x38/0x230 kernel/workqueue.c:1647
      __queue_work+0xcdc/0x11f0 kernel/workqueue.c:1803
      call_timer_fn+0x193/0x590 kernel/time/timer.c:1700
      expire_timers kernel/time/timer.c:1746 [inline]
      __run_timers+0x585/0xb20 kernel/time/timer.c:2022
      run_timer_softirq+0x58/0xd0 kernel/time/timer.c:2035
      __do_softirq+0x21a/0x8de kernel/softirq.c:553
      
      The buggy address belongs to the object at ffff88802805a800
      which belongs to the cache kmalloc-512 of size 512
      The buggy address is located 64 bytes inside of
      freed 512-byte region [ffff88802805a800, ffff88802805aa00)
      
      The buggy address belongs to the physical page:
      page:ffffea0000a01600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x28058
      head:ffffea0000a01600 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
      page_type: 0xffffffff()
      raw: 00fff00000000840 ffff888013041c80 ffffea0001e02600 dead000000000002
      raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 18706, tgid 18699 (syz-executor.2), ts 999991973280, free_ts 996884464281
      set_page_owner include/linux/page_owner.h:31 [inline]
      post_alloc_hook+0x2d0/0x350 mm/page_alloc.c:1537
      prep_new_page mm/page_alloc.c:1544 [inline]
      get_page_from_freelist+0xa25/0x36d0 mm/page_alloc.c:3312
      __alloc_pages+0x22e/0x2420 mm/page_alloc.c:4568
      alloc_pages_mpol+0x258/0x5f0 mm/mempolicy.c:2133
      alloc_slab_page mm/slub.c:1870 [inline]
      allocate_slab mm/slub.c:2017 [inline]
      new_slab+0x283/0x3c0 mm/slub.c:2070
      ___slab_alloc+0x979/0x1500 mm/slub.c:3223
      __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
      __slab_alloc_node mm/slub.c:3375 [inline]
      slab_alloc_node mm/slub.c:3468 [inline]
      __kmem_cache_alloc_node+0x131/0x310 mm/slub.c:3517
      __do_kmalloc_node mm/slab_common.c:1006 [inline]
      __kmalloc+0x49/0x90 mm/slab_common.c:1020
      kmalloc include/linux/slab.h:604 [inline]
      kzalloc include/linux/slab.h:721 [inline]
      copy_splice_read+0x1ac/0x8f0 fs/splice.c:338
      vfs_splice_read fs/splice.c:992 [inline]
      vfs_splice_read+0x2ea/0x3b0 fs/splice.c:962
      splice_direct_to_actor+0x2a5/0xa30 fs/splice.c:1069
      do_splice_direct+0x1af/0x280 fs/splice.c:1194
      do_sendfile+0xb3e/0x1310 fs/read_write.c:1254
      __do_sys_sendfile64 fs/read_write.c:1322 [inline]
      __se_sys_sendfile64 fs/read_write.c:1308 [inline]
      __x64_sys_sendfile64+0x1d6/0x220 fs/read_write.c:1308
      do_syscall_x64 arch/x86/entry/common.c:51 [inline]
      do_syscall_64+0x40/0x110 arch/x86/entry/common.c:82
      page last free stack trace:
      reset_page_owner include/linux/page_owner.h:24 [inline]
      free_pages_prepare mm/page_alloc.c:1137 [inline]
      free_unref_page_prepare+0x4fa/0xaa0 mm/page_alloc.c:2347
      free_unref_page_list+0xe6/0xb40 mm/page_alloc.c:2533
      release_pages+0x32a/0x14f0 mm/swap.c:1042
      tlb_batch_pages_flush+0x9a/0x190 mm/mmu_gather.c:98
      tlb_flush_mmu_free mm/mmu_gather.c:293 [inline]
      tlb_flush_mmu mm/mmu_gather.c:300 [inline]
      tlb_finish_mmu+0x14b/0x6f0 mm/mmu_gather.c:392
      exit_mmap+0x38b/0xa70 mm/mmap.c:3321
      __mmput+0x12a/0x4d0 kernel/fork.c:1349
      mmput+0x62/0x70 kernel/fork.c:1371
      exit_mm kernel/exit.c:567 [inline]
      do_exit+0x9ad/0x2ae0 kernel/exit.c:858
      do_group_exit+0xd4/0x2a0 kernel/exit.c:1021
      get_signal+0x23be/0x2790 kernel/signal.c:2904
      arch_do_signal_or_restart+0x90/0x7f0 arch/x86/kernel/signal.c:309
      exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
      exit_to_user_mode_prepare+0x121/0x240 kernel/entry/common.c:204
      irqentry_exit_to_user_mode+0xa/0x40 kernel/entry/common.c:309
      asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:645
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20231205173250.2982846-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      5a08d006
  2. 06 Dec, 2023 29 commits
  3. 05 Dec, 2023 4 commits