Skip to content
  1. Aug 02, 2023
  2. Aug 01, 2023
  3. Jul 31, 2023
    • Duoming Zhou's avatar
      net: usb: lan78xx: reorder cleanup operations to avoid UAF bugs · 1e7417c1
      Duoming Zhou authored
      The timer dev->stat_monitor can schedule the delayed work dev->wq and
      the delayed work dev->wq can also arm the dev->stat_monitor timer.
      
      When the device is detaching, the net_device will be deallocated. but
      the net_device private data could still be dereferenced in delayed work
      or timer handler. As a result, the UAF bugs will happen.
      
      One racy situation is shown below:
      
            (Thread 1)                 |      (Thread 2)
      lan78xx_stat_monitor()           |
       ...                             |  lan78xx_disconnect()
       lan78xx_defer_kevent()          |    ...
        ...                            |    cancel_delayed_work_sync(&dev->wq);
        schedule_delayed_work()        |    ...
        (wait some time)               |    free_netdev(net); //free net_device
        lan78xx_delayedwork()          |
        //use net_device private data  |
        dev-> //use                    |
      
      Although we use cancel_delayed_work_sync() to cancel the delayed work
      in lan78xx_disconnect(), it could still be scheduled in timer handler
      lan78xx_stat_monitor().
      
      Another racy situation is shown below:
      
            (Thread 1)                |      (Thread 2)
      lan78xx_delayedwork             |
       mod_timer()                    |  lan78xx_disconnect()
                                      |   cancel_delayed_work_sync()
       (wait some time)               |   if (timer_pending(&dev->stat_monitor))
                   	                |       del_timer_sync(&dev->stat_monitor);
       lan78xx_stat_monitor()         |   ...
        lan78xx_defer_kevent()        |   free_netdev(net); //free
         //use net_device private data|
         dev-> //use                  |
      
      Although we use del_timer_sync() to delete the timer, the function
      timer_pending() returns 0 when the timer is activated. As a result,
      the del_timer_sync() will not be executed and the timer could be
      re-armed.
      
      In order to mitigate this bug, We use timer_shutdown_sync() to shutdown
      the timer and then use cancel_delayed_work_sync() to cancel the delayed
      work. As a result, the net_device could be deallocated safely.
      
      What's more, the dev->flags is set to EVENT_DEV_DISCONNECT in
      lan78xx_disconnect(). But it could still be set to EVENT_STAT_UPDATE
      in lan78xx_stat_monitor(). So this patch put the set_bit() behind
      timer_shutdown_sync().
      
      Fixes: 77dfff5b
      
       ("lan78xx: Fix race condition in disconnect handling")
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1e7417c1
    • Rafał Miłecki's avatar
      dt-bindings: net: mediatek,net: fixup MAC binding · 8469c7f5
      Rafał Miłecki authored
      
      
      1. Use unevaluatedProperties
      It's needed to allow ethernet-controller.yaml properties work correctly.
      
      2. Drop unneeded phy-handle/phy-mode
      
      3. Don't require phy-handle
      Some SoCs may use fixed link.
      
      For in-kernel MT7621 DTS files this fixes following errors:
      arch/mips/boot/dts/ralink/mt7621-tplink-hc220-g5-v1.dtb: ethernet@1e100000: mac@0: 'fixed-link' does not match any of the regexes: 'pinctrl-[0-9]+'
              From schema: Documentation/devicetree/bindings/net/mediatek,net.yaml
      arch/mips/boot/dts/ralink/mt7621-tplink-hc220-g5-v1.dtb: ethernet@1e100000: mac@0: 'phy-handle' is a required property
              From schema: Documentation/devicetree/bindings/net/mediatek,net.yaml
      arch/mips/boot/dts/ralink/mt7621-tplink-hc220-g5-v1.dtb: ethernet@1e100000: mac@1: 'fixed-link' does not match any of the regexes: 'pinctrl-[0-9]+'
              From schema: Documentation/devicetree/bindings/net/mediatek,net.yaml
      arch/mips/boot/dts/ralink/mt7621-tplink-hc220-g5-v1.dtb: ethernet@1e100000: mac@1: 'phy-handle' is a required property
              From schema: Documentation/devicetree/bindings/net/mediatek,net.yaml
      
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8469c7f5
    • Kuniyuki Iwashima's avatar
      net/sched: taprio: Limit TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME to INT_MAX. · e7397184
      Kuniyuki Iwashima authored
      syzkaller found zero division error [0] in div_s64_rem() called from
      get_cycle_time_elapsed(), where sched->cycle_time is the divisor.
      
      We have tests in parse_taprio_schedule() so that cycle_time will never
      be 0, and actually cycle_time is not 0 in get_cycle_time_elapsed().
      
      The problem is that the types of divisor are different; cycle_time is
      s64, but the argument of div_s64_rem() is s32.
      
      syzkaller fed this input and 0x100000000 is cast to s32 to be 0.
      
        @TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME={0xc, 0x8, 0x100000000}
      
      We use s64 for cycle_time to cast it to ktime_t, so let's keep it and
      set max for cycle_time.
      
      While at it, we prevent overflow in setup_txtime() and add another
      test in parse_taprio_schedule() to check if cycle_time overflows.
      
      Also, we add a new tdc test case for this issue.
      
      [0]:
      divide error: 0000 [#1] PREEMPT SMP KASAN NOPTI
      CPU: 1 PID: 103 Comm: kworker/1:3 Not tainted 6.5.0-rc1-00330-g60cc1f7d0605 #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
      Workqueue: ipv6_addrconf addrconf_dad_work
      RIP: 0010:div_s64_rem include/linux/math64.h:42 [inline]
      RIP: 0010:get_cycle_time_elapsed net/sched/sch_taprio.c:223 [inline]
      RIP: 0010:find_entry_to_transmit+0x252/0x7e0 net/sched/sch_taprio.c:344
      Code: 3c 02 00 0f 85 5e 05 00 00 48 8b 4c 24 08 4d 8b bd 40 01 00 00 48 8b 7c 24 48 48 89 c8 4c 29 f8 48 63 f7 48 99 48 89 74 24 70 <48> f7 fe 48 29 d1 48 8d 04 0f 49 89 cc 48 89 44 24 20 49 8d 85 10
      RSP: 0018:ffffc90000acf260 EFLAGS: 00010206
      RAX: 177450e0347560cf RBX: 0000000000000000 RCX: 177450e0347560cf
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000100000000
      RBP: 0000000000000056 R08: 0000000000000000 R09: ffffed10020a0934
      R10: ffff8880105049a7 R11: ffff88806cf3a520 R12: ffff888010504800
      R13: ffff88800c00d800 R14: ffff8880105049a0 R15: 0000000000000000
      FS:  0000000000000000(0000) GS:ffff88806cf00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f0edf84f0e8 CR3: 000000000d73c002 CR4: 0000000000770ee0
      PKRU: 55555554
      Call Trace:
       <TASK>
       get_packet_txtime net/sched/sch_taprio.c:508 [inline]
       taprio_enqueue_one+0x900/0xff0 net/sched/sch_taprio.c:577
       taprio_enqueue+0x378/0xae0 net/sched/sch_taprio.c:658
       dev_qdisc_enqueue+0x46/0x170 net/core/dev.c:3732
       __dev_xmit_skb net/core/dev.c:3821 [inline]
       __dev_queue_xmit+0x1b2f/0x3000 net/core/dev.c:4169
       dev_queue_xmit include/linux/netdevice.h:3088 [inline]
       neigh_resolve_output net/core/neighbour.c:1552 [inline]
       neigh_resolve_output+0x4a7/0x780 net/core/neighbour.c:1532
       neigh_output include/net/neighbour.h:544 [inline]
       ip6_finish_output2+0x924/0x17d0 net/ipv6/ip6_output.c:135
       __ip6_finish_output+0x620/0xaa0 net/ipv6/ip6_output.c:196
       ip6_finish_output net/ipv6/ip6_output.c:207 [inline]
       NF_HOOK_COND include/linux/netfilter.h:292 [inline]
       ip6_output+0x206/0x410 net/ipv6/ip6_output.c:228
       dst_output include/net/dst.h:458 [inline]
       NF_HOOK.constprop.0+0xea/0x260 include/linux/netfilter.h:303
       ndisc_send_skb+0x872/0xe80 net/ipv6/ndisc.c:508
       ndisc_send_ns+0xb5/0x130 net/ipv6/ndisc.c:666
       addrconf_dad_work+0xc14/0x13f0 net/ipv6/addrconf.c:4175
       process_one_work+0x92c/0x13a0 kernel/workqueue.c:2597
       worker_thread+0x60f/0x1240 kernel/workqueue.c:2748
       kthread+0x2fe/0x3f0 kernel/kthread.c:389
       ret_from_fork+0x2c/0x50 arch/x86/entry/entry_64.S:308
       </TASK>
      Modules linked in:
      
      Fixes: 4cfd5779
      
       ("taprio: Add support for txtime-assist mode")
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Co-developed-by: default avatarEric Dumazet <edumazet@google.com>
      Co-developed-by: default avatarPedro Tammela <pctammela@mojatatu.com>
      Acked-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e7397184
  4. Jul 30, 2023
  5. Jul 29, 2023
    • Thierry Reding's avatar
      net: stmmac: tegra: Properly allocate clock bulk data · a0b1b205
      Thierry Reding authored
      The clock data is an array of struct clk_bulk_data, so make sure to
      allocate enough memory.
      
      Fixes: d8ca1137
      
       ("net: stmmac: tegra: Add MGBE support")
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a0b1b205
    • Chengfeng Ye's avatar
      mISDN: hfcpci: Fix potential deadlock on &hc->lock · 56c6be35
      Chengfeng Ye authored
      As &hc->lock is acquired by both timer _hfcpci_softirq() and hardirq
      hfcpci_int(), the timer should disable irq before lock acquisition
      otherwise deadlock could happen if the timmer is preemtped by the hadr irq.
      
      Possible deadlock scenario:
      hfcpci_softirq() (timer)
          -> _hfcpci_softirq()
          -> spin_lock(&hc->lock);
              <irq interruption>
              -> hfcpci_int()
              -> spin_lock(&hc->lock); (deadlock here)
      
      This flaw was found by an experimental static analysis tool I am developing
      for irq-related deadlock.
      
      The tentative patch fixes the potential deadlock by spin_lock_irq()
      in timer.
      
      Fixes: b36b654a
      
       ("mISDN: Create /sys/class/mISDN")
      Signed-off-by: default avatarChengfeng Ye <dg573847474@gmail.com>
      Link: https://lore.kernel.org/r/20230727085619.7419-1-dg573847474@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      56c6be35
    • Jamal Hadi Salim's avatar
      net: sched: cls_u32: Fix match key mis-addressing · e68409db
      Jamal Hadi Salim authored
      
      
      A match entry is uniquely identified with an "address" or "path" in the
      form of: hashtable ID(12b):bucketid(8b):nodeid(12b).
      
      When creating table match entries all of hash table id, bucket id and
      node (match entry id) are needed to be either specified by the user or
      reasonable in-kernel defaults are used. The in-kernel default for a table id is
      0x800(omnipresent root table); for bucketid it is 0x0. Prior to this fix there
      was none for a nodeid i.e. the code assumed that the user passed the correct
      nodeid and if the user passes a nodeid of 0 (as Mingi Cho did) then that is what
      was used. But nodeid of 0 is reserved for identifying the table. This is not
      a problem until we dump. The dump code notices that the nodeid is zero and
      assumes it is referencing a table and therefore references table struct
      tc_u_hnode instead of what was created i.e match entry struct tc_u_knode.
      
      Ming does an equivalent of:
      tc filter add dev dummy0 parent 10: prio 1 handle 0x1000 \
      protocol ip u32 match ip src 10.0.0.1/32 classid 10:1 action ok
      
      Essentially specifying a table id 0, bucketid 1 and nodeid of zero
      Tableid 0 is remapped to the default of 0x800.
      Bucketid 1 is ignored and defaults to 0x00.
      Nodeid was assumed to be what Ming passed - 0x000
      
      dumping before fix shows:
      ~$ tc filter ls dev dummy0 parent 10:
      filter protocol ip pref 1 u32 chain 0
      filter protocol ip pref 1 u32 chain 0 fh 800: ht divisor 1
      filter protocol ip pref 1 u32 chain 0 fh 800: ht divisor -30591
      
      Note that the last line reports a table instead of a match entry
      (you can tell this because it says "ht divisor...").
      As a result of reporting the wrong data type (misinterpretting of struct
      tc_u_knode as being struct tc_u_hnode) the divisor is reported with value
      of -30591. Ming identified this as part of the heap address
      (physmap_base is 0xffff8880 (-30591 - 1)).
      
      The fix is to ensure that when table entry matches are added and no
      nodeid is specified (i.e nodeid == 0) then we get the next available
      nodeid from the table's pool.
      
      After the fix, this is what the dump shows:
      $ tc filter ls dev dummy0 parent 10:
      filter protocol ip pref 1 u32 chain 0
      filter protocol ip pref 1 u32 chain 0 fh 800: ht divisor 1
      filter protocol ip pref 1 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 10:1 not_in_hw
        match 0a000001/ffffffff at 12
      	action order 1: gact action pass
      	 random type none pass val 0
      	 index 1 ref 1 bind 1
      
      Reported-by: default avatarMingi Cho <mgcho.minic@gmail.com>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Link: https://lore.kernel.org/r/20230726135151.416917-1-jhs@mojatatu.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e68409db
  6. Jul 28, 2023
    • Eugen Hristev's avatar
      dt-bindings: net: rockchip-dwmac: fix {tx|rx}-delay defaults/range in schema · 5416d792
      Eugen Hristev authored
      The range and the defaults are specified in the description instead of
      being specified in the schema.
      Fix it by adding the default value in the `default` field and specifying
      the range as `minimum` and `maximum`.
      
      Fixes: b331b8ef
      
       ("dt-bindings: net: convert rockchip-dwmac to json-schema")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@collabora.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5416d792
    • Jakub Kicinski's avatar
      Merge tag 'mlx5-fixes-2023-07-26' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux · 4a082260
      Jakub Kicinski authored
      Saeed Mahameed says:
      
      ====================
      mlx5 fixes 2023-07-26
      
      This series provides bug fixes to mlx5 driver.
      
      * tag 'mlx5-fixes-2023-07-26' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux:
        net/mlx5: Unregister devlink params in case interface is down
        net/mlx5: DR, Fix peer domain namespace setting
        net/mlx5: fs_chains: Fix ft prio if ignore_flow_level is not supported
        net/mlx5e: kTLS, Fix protection domain in use syndrome when devlink reload
        net/mlx5: Bridge, set debugfs access right to root-only
        net/mlx5e: xsk: Fix crash on regular rq reactivation
        net/mlx5e: xsk: Fix invalid buffer access for legacy rq
        net/mlx5e: Move representor neigh cleanup to profile cleanup_tx
        net/mlx5e: Fix crash moving to switchdev mode when ntuple offload is set
        net/mlx5e: Don't hold encap tbl lock if there is no encap action
        net/mlx5: Honor user input for migratable port fn attr
        net/mlx5e: fix return value check in mlx5e_ipsec_remove_trailer()
        net/mlx5: fix potential memory leak in mlx5e_init_rep_rx
        net/mlx5: DR, fix memory leak in mlx5dr_cmd_create_reformat_ctx
        net/mlx5e: fix double free in macsec_fs_tx_create_crypto_table_groups
      ====================
      
      Link: https://lore.kernel.org/r/20230726213206.47022-1-saeed@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4a082260
    • Yuanjun Gong's avatar
      net: dsa: fix value check in bcm_sf2_sw_probe() · dadc5b86
      Yuanjun Gong authored
      in bcm_sf2_sw_probe(), check the return value of clk_prepare_enable()
      and return the error code if clk_prepare_enable() returns an
      unexpected value.
      
      Fixes: e9ec5c3b
      
       ("net: dsa: bcm_sf2: request and handle clocks")
      Signed-off-by: default avatarYuanjun Gong <ruc_gongyuanjun@163.com>
      Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Link: https://lore.kernel.org/r/20230726170506.16547-1-ruc_gongyuanjun@163.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      dadc5b86
    • Eric Dumazet's avatar
      net: flower: fix stack-out-of-bounds in fl_set_key_cfm() · 4d50e500
      Eric Dumazet authored
      Typical misuse of
      
      	nla_parse_nested(array, XXX_MAX, ...);
      
      array must be declared as
      
      	struct nlattr *array[XXX_MAX + 1];
      
      v2: Based on feedbacks from Ido Schimmel and Zahari Doychev,
      I also changed TCA_FLOWER_KEY_CFM_OPT_MAX and cfm_opt_policy
      definitions.
      
      syzbot reported:
      
      BUG: KASAN: stack-out-of-bounds in __nla_validate_parse+0x136/0x2bd0 lib/nlattr.c:588
      Write of size 32 at addr ffffc90003a0ee20 by task syz-executor296/5014
      
      CPU: 0 PID: 5014 Comm: syz-executor296 Not tainted 6.5.0-rc2-syzkaller-00307-gd192f5382581 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
      print_address_description mm/kasan/report.c:364 [inline]
      print_report+0x163/0x540 mm/kasan/report.c:475
      kasan_report+0x175/0x1b0 mm/kasan/report.c:588
      kasan_check_range+0x27e/0x290 mm/kasan/generic.c:187
      __asan_memset+0x23/0x40 mm/kasan/shadow.c:84
      __nla_validate_parse+0x136/0x2bd0 lib/nlattr.c:588
      __nla_parse+0x40/0x50 lib/nlattr.c:700
      nla_parse_nested include/net/netlink.h:1262 [inline]
      fl_set_key_cfm+0x1e3/0x440 net/sched/cls_flower.c:1718
      fl_set_key+0x2168/0x6620 net/sched/cls_flower.c:1884
      fl_tmplt_create+0x1fe/0x510 net/sched/cls_flower.c:2666
      tc_chain_tmplt_add net/sched/cls_api.c:2959 [inline]
      tc_ctl_chain+0x131d/0x1ac0 net/sched/cls_api.c:3068
      rtnetlink_rcv_msg+0x82b/0xf50 net/core/rtnetlink.c:6424
      netlink_rcv_skb+0x1df/0x430 net/netlink/af_netlink.c:2549
      netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
      netlink_unicast+0x7c3/0x990 net/netlink/af_netlink.c:1365
      netlink_sendmsg+0xa2a/0xd60 net/netlink/af_netlink.c:1914
      sock_sendmsg_nosec net/socket.c:725 [inline]
      sock_sendmsg net/socket.c:748 [inline]
      ____sys_sendmsg+0x592/0x890 net/socket.c:2494
      ___sys_sendmsg net/socket.c:2548 [inline]
      __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2577
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f54c6150759
      Code: 48 83 c4 28 c3 e8 d7 19 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffe06c30578 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f54c619902d RCX: 00007f54c6150759
      RDX: 0000000000000000 RSI: 0000000020000280 RDI: 0000000000000003
      RBP: 00007ffe06c30590 R08: 0000000000000000 R09: 00007ffe06c305f0
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f54c61c35f0
      R13: 00007ffe06c30778 R14: 0000000000000001 R15: 0000000000000001
      </TASK>
      
      The buggy address belongs to stack of task syz-executor296/5014
      and is located at offset 32 in frame:
      fl_set_key_cfm+0x0/0x440 net/sched/cls_flower.c:374
      
      This frame has 1 object:
      [32, 56) 'nla_cfm_opt'
      
      The buggy address belongs to the virtual mapping at
      [ffffc90003a08000, ffffc90003a11000) created by:
      copy_process+0x5c8/0x4290 kernel/fork.c:2330
      
      Fixes: 7cfffd5f
      
       ("net: flower: add support for matching cfm fields")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Simon Horman <simon.horman@corigine.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarZahari Doychev <zdoychev@maxlinear.com>
      Link: https://lore.kernel.org/r/20230726145815.943910-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4d50e500
    • Jakub Kicinski's avatar
      MAINTAINERS: stmmac: retire Giuseppe Cavallaro · fa467226
      Jakub Kicinski authored
      
      
      I tried to get stmmac maintainers to be more active by agreeing with
      them off-list on a review rotation. I pinged Peppe 3 times over 2 weeks
      during his "shift month", no reviews are flowing.
      
      All the contributions are much appreciated! But stmmac is quite
      active, we need participating maintainers :(
      
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230726151120.1649474-1-kuba@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fa467226
    • Russell King (Oracle)'s avatar
      net: dsa: fix older DSA drivers using phylink · 9945c1fb
      Russell King (Oracle) authored
      
      
      Older DSA drivers that do not provide an dsa_ops adjust_link method end
      up using phylink. Unfortunately, a recent phylink change that requires
      its supported_interfaces bitmap to be filled breaks these drivers
      because the bitmap remains empty.
      
      Rather than fixing each driver individually, fix it in the core code so
      we have a sensible set of defaults.
      
      Reported-by: default avatarSergei Antonov <saproj@gmail.com>
      Fixes: de5c9bf4
      
       ("net: phylink: require supported_interfaces to be filled")
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Tested-by: Vladimir Oltean <olteanv@gmail.com> # dsa_loop
      Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Link: https://lore.kernel.org/r/E1qOflM-001AEz-D3@rmk-PC.armlinux.org.uk
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      9945c1fb
    • Lin Ma's avatar
      rtnetlink: let rtnl_bridge_setlink checks IFLA_BRIDGE_MODE length · d73ef2d6
      Lin Ma authored
      There are totally 9 ndo_bridge_setlink handlers in the current kernel,
      which are 1) bnxt_bridge_setlink, 2) be_ndo_bridge_setlink 3)
      i40e_ndo_bridge_setlink 4) ice_bridge_setlink 5)
      ixgbe_ndo_bridge_setlink 6) mlx5e_bridge_setlink 7)
      nfp_net_bridge_setlink 8) qeth_l2_bridge_setlink 9) br_setlink.
      
      By investigating the code, we find that 1-7 parse and use nlattr
      IFLA_BRIDGE_MODE but 3 and 4 forget to do the nla_len check. This can
      lead to an out-of-attribute read and allow a malformed nlattr (e.g.,
      length 0) to be viewed as a 2 byte integer.
      
      To avoid such issues, also for other ndo_bridge_setlink handlers in the
      future. This patch adds the nla_len check in rtnl_bridge_setlink and
      does an early error return if length mismatches. To make it works, the
      break is removed from the parsing for IFLA_BRIDGE_FLAGS to make sure
      this nla_for_each_nested iterates every attribute.
      
      Fixes: b1edc14a ("ice: Implement ice_bridge_getlink and ice_bridge_setlink")
      Fixes: 51616018
      
       ("i40e: Add support for getlink, setlink ndo ops")
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
      Acked-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
      Reviewed-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Link: https://lore.kernel.org/r/20230726075314.1059224-1-linma@zju.edu.cn
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d73ef2d6
    • Linus Torvalds's avatar
      Merge tag 'net-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · 57012c57
      Linus Torvalds authored
      Pull networking fixes from Paolo Abeni:
       "Including fixes from can, netfilter.
      
        Current release - regressions:
      
         - core: fix splice_to_socket() for O_NONBLOCK socket
      
         - af_unix: fix fortify_panic() in unix_bind_bsd().
      
         - can: raw: fix lockdep issue in raw_release()
      
        Previous releases - regressions:
      
         - tcp: reduce chance of collisions in inet6_hashfn().
      
         - netfilter: skip immediate deactivate in _PREPARE_ERROR
      
         - tipc: stop tipc crypto on failure in tipc_node_create
      
         - eth: igc: fix kernel panic during ndo_tx_timeout callback
      
         - eth: iavf: fix potential deadlock on allocation failure
      
        Previous releases - always broken:
      
         - ipv6: fix bug where deleting a mngtmpaddr can create a new
           temporary address
      
         - eth: ice: fix memory management in ice_ethtool_fdir.c
      
         - eth: hns3: fix the imp capability bit cannot exceed 32 bits issue
      
         - eth: vxlan: calculate correct header length for GPE
      
         - eth: stmmac: apply redundant write work around on 4.xx too"
      
      * tag 'net-6.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (49 commits)
        tipc: stop tipc crypto on failure in tipc_node_create
        af_unix: Terminate sun_path when bind()ing pathname socket.
        tipc: check return value of pskb_trim()
        benet: fix return value check in be_lancer_xmit_workarounds()
        virtio-net: fix race between set queues and probe
        net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
        splice, net: Fix splice_to_socket() for O_NONBLOCK socket
        net: fec: tx processing does not call XDP APIs if budget is 0
        mptcp: more accurate NL event generation
        selftests: mptcp: join: only check for ip6tables if needed
        tools: ynl-gen: fix parse multi-attr enum attribute
        tools: ynl-gen: fix enum index in _decode_enum(..)
        netfilter: nf_tables: disallow rule addition to bound chain via NFTA_RULE_CHAIN_ID
        netfilter: nf_tables: skip immediate deactivate in _PREPARE_ERROR
        netfilter: nft_set_rbtree: fix overlap expiration walk
        igc: Fix Kernel Panic during ndo_tx_timeout callback
        net: dsa: qca8k: fix mdb add/del case with 0 VID
        net: dsa: qca8k: fix broken search_and_del
        net: dsa: qca8k: fix search_and_insert wrong handling of new rule
        net: dsa: qca8k: enable use_single_write for qca8xxx
        ...
      57012c57