Skip to content
  1. Jul 17, 2023
  2. Jul 15, 2023
    • Jakub Kicinski's avatar
      Merge branch 'net-fix-kernel-doc-problems-in-include-net' · 0dd1805f
      Jakub Kicinski authored
      
      
      Randy Dunlap says:
      
      ====================
      net: fix kernel-doc problems in include/net/
      
      Fix many (but not all) kernel-doc warnings in include/net/.
      
       [PATCH v2 net 1/9] net: bonding: remove kernel-doc comment marker
       [PATCH v2 net 2/9] net: cfg802154: fix kernel-doc notation warnings
       [PATCH v2 net 3/9] codel: fix kernel-doc notation warnings
       [PATCH v2 net 4/9] devlink: fix kernel-doc notation warnings
       [PATCH v2 net 5/9] inet: frags: remove kernel-doc comment marker
       [PATCH v2 net 6/9] net: llc: fix kernel-doc notation warnings
       [PATCH v2 net 7/9] net: NSH: fix kernel-doc notation warning
       [PATCH v2 net 8/9] pie: fix kernel-doc notation warning
       [PATCH v2 net 9/9] rsi: remove kernel-doc comment marker
      ====================
      
      Link: https://lore.kernel.org/r/20230714045127.18752-1-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      0dd1805f
    • Randy Dunlap's avatar
      rsi: remove kernel-doc comment marker · 04be3c95
      Randy Dunlap authored
      Change an errant kernel-doc comment marker (/**) to a regular
      comment to prevent a kernel-doc warning.
      
      rsi_91x.h:3: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
       * Copyright (c) 2017 Redpine Signals Inc.
      
      Fixes: 4c10d56a
      
       ("rsi: add header file rsi_91x")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
      Cc: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
      Acked-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20230714045127.18752-10-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      04be3c95
    • Randy Dunlap's avatar
      pie: fix kernel-doc notation warning · d1cca974
      Randy Dunlap authored
      Spell a struct member's name correctly to prevent a kernel-doc
      warning.
      
      pie.h:38: warning: Function parameter or member 'tupdate' not described in 'pie_params'
      
      Fixes: b42a3d7c
      
       ("pie: improve comments and commenting style")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Leslie Monis <lesliemonis@gmail.com>
      Cc: "Mohit P. Tahiliani" <tahiliani@nitk.edu.in>
      Cc: Gautam Ramakrishnan <gautamramk@gmail.com>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Link: https://lore.kernel.org/r/20230714045127.18752-9-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d1cca974
    • Randy Dunlap's avatar
      net: NSH: fix kernel-doc notation warning · d1533d72
      Randy Dunlap authored
      Use the struct member's name and the correct format to prevent a
      kernel-doc warning.
      
      nsh.h:200: warning: Function parameter or member 'context' not described in 'nsh_md1_ctx'
      
      Fixes: 1f0b7744
      
       ("net: add NSH header structures and helpers")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Jiri Benc <jbenc@redhat.com>
      Link: https://lore.kernel.org/r/20230714045127.18752-8-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d1533d72
    • Randy Dunlap's avatar
      net: llc: fix kernel-doc notation warnings · 201a0883
      Randy Dunlap authored
      Use the corrent function parameter name or format to prevent
      kernel-doc warnings.
      Add 2 function parameter descriptions to prevent kernel-doc warnings.
      
      llc_pdu.h:278: warning: Function parameter or member 'da' not described in 'llc_pdu_decode_da'
      llc_pdu.h:278: warning: Excess function parameter 'sa' description in 'llc_pdu_decode_da'
      llc_pdu.h:330: warning: Function parameter or member 'skb' not described in 'llc_pdu_init_as_test_cmd'
      llc_pdu.h:379: warning: Function parameter or member 'svcs_supported' not described in 'llc_pdu_init_as_xid_cmd'
      llc_pdu.h:379: warning: Function parameter or member 'rx_window' not described in 'llc_pdu_init_as_xid_cmd'
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Link: https://lore.kernel.org/r/20230714045127.18752-7-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      201a0883
    • Randy Dunlap's avatar
      inet: frags: eliminate kernel-doc warning · d20909a0
      Randy Dunlap authored
      Modify the anonymous enum kernel-doc content so that it doesn't cause
      a kernel-doc warning.
      
      inet_frag.h:33: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
      
      Fixes: 1ab1934e
      
       ("inet: frags: enum the flag definitions and add descriptions")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Nikolay Aleksandrov <razor@blackwall.org>
      Link: https://lore.kernel.org/r/20230714045127.18752-6-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d20909a0
    • Randy Dunlap's avatar
      devlink: fix kernel-doc notation warnings · 839f55c5
      Randy Dunlap authored
      Spell function or struct member names correctly.
      Use ':' instead of '-' for struct member entries.
      Mark one field as private in kernel-doc.
      Add a few entries that were missing.
      Fix a typo.
      
      These changes prevent kernel-doc warnings:
      
      devlink.h:252: warning: Function parameter or member 'field_id' not described in 'devlink_dpipe_match'
      devlink.h:267: warning: Function parameter or member 'field_id' not described in 'devlink_dpipe_action'
      devlink.h:310: warning: Function parameter or member 'match_values_count' not described in 'devlink_dpipe_entry'
      devlink.h:355: warning: Function parameter or member 'list' not described in 'devlink_dpipe_table'
      devlink.h:374: warning: Function parameter or member 'actions_dump' not described in 'devlink_dpipe_table_ops'
      devlink.h:374: warning: Function parameter or member 'matches_dump' not described in 'devlink_dpipe_table_ops'
      devlink.h:374: warning: Function parameter or member 'entries_dump' not described in 'devlink_dpipe_table_ops'
      devlink.h:374: warning: Function parameter or member 'counters_set_update' not described in 'devlink_dpipe_table_ops'
      devlink.h:374: warning: Function parameter or member 'size_get' not described in 'devlink_dpipe_table_ops'
      devlink.h:384: warning: Function parameter or member 'headers' not described in 'devlink_dpipe_headers'
      devlink.h:384: warning: Function parameter or member 'headers_count' not described in 'devlink_dpipe_headers'
      devlink.h:398: warning: Function parameter or member 'unit' not described in 'devlink_resource_size_params'
      devlink.h:487: warning: Function parameter or member 'id' not described in 'devlink_param'
      devlink.h:645: warning: Function parameter or member 'overwrite_mask' not described in 'devlink_flash_update_params'
      
      Fixes: 1555d204 ("devlink: Support for pipeline debug (dpipe)")
      Fixes: d9f9b9a4 ("devlink: Add support for resource abstraction")
      Fixes: eabaef18 ("devlink: Add devlink_param register and unregister")
      Fixes: 5d5b4128
      
       ("devlink: introduce flash update overwrite mask")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: Moshe Shemesh <moshe@mellanox.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Link: https://lore.kernel.org/r/20230714045127.18752-5-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      839f55c5
    • Randy Dunlap's avatar
      codel: fix kernel-doc notation warnings · cfe57122
      Randy Dunlap authored
      Use '@' before the struct member names in kernel-doc notation
      to prevent kernel-doc warnings.
      
      codel.h:158: warning: Function parameter or member 'ecn_mark' not described in 'codel_stats'
      codel.h:158: warning: Function parameter or member 'ce_mark' not described in 'codel_stats'
      
      Fixes: 76e3cc12
      
       ("codel: Controlled Delay AQM")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: Dave Taht <dave.taht@bufferbloat.net>
      Link: https://lore.kernel.org/r/20230714045127.18752-4-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      cfe57122
    • Randy Dunlap's avatar
      net: cfg802154: fix kernel-doc notation warnings · a63e4044
      Randy Dunlap authored
      Add an enum heading to the kernel-doc comments to prevent
      kernel-doc warnings.
      
      cfg802154.h:174: warning: Cannot understand  * @WPAN_PHY_FLAG_TRANSMIT_POWER: Indicates that transceiver will support
       on line 174 - I thought it was a doc line
      
      cfg802154.h:192: warning: Enum value 'WPAN_PHY_FLAG_TXPOWER' not described in enum 'wpan_phy_flags'
      cfg802154.h:192: warning: Excess enum value 'WPAN_PHY_FLAG_TRANSMIT_POWER' description in 'wpan_phy_flags'
      
      Fixes: edea8f7c
      
       ("cfg802154: introduce wpan phy flags")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Alexander Aring <alex.aring@gmail.com>
      Cc: Stefan Schmidt <stefan@datenfreihafen.org>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Acked-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/r/20230714045127.18752-3-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a63e4044
    • Randy Dunlap's avatar
      net: bonding: remove kernel-doc comment marker · a66557c7
      Randy Dunlap authored
      Change an errant kernel-doc comment marker (/**) to a regular
      comment to prevent a kernel-doc warning.
      
      bonding.h:282: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
       * Returns NULL if the net_device does not belong to any of the bond's slaves
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Jay Vosburgh <j.vosburgh@gmail.com>
      Cc: Andy Gospodarek <andy@greyhouse.net>
      Link: https://lore.kernel.org/r/20230714045127.18752-2-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a66557c7
  3. Jul 14, 2023
    • Yan Zhai's avatar
      gso: fix dodgy bit handling for GSO_UDP_L4 · 98400367
      Yan Zhai authored
      Commit 1fd54773 ("udp: allow header check for dodgy GSO_UDP_L4
      packets.") checks DODGY bit for UDP, but for packets that can be fed
      directly to the device after gso_segs reset, it actually falls through
      to fragmentation:
      
      https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/
      
      This change restores the expected behavior of GSO_UDP_L4 packets.
      
      Fixes: 1fd54773
      
       ("udp: allow header check for dodgy GSO_UDP_L4 packets.")
      Suggested-by: default avatarWillem de Bruijn <willemdebruijn.kernel@gmail.com>
      Signed-off-by: default avatarYan Zhai <yan@cloudflare.com>
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      98400367
    • Wang Ming's avatar
      net: ethernet: Remove repeating expression · a822551c
      Wang Ming authored
      
      
      Identify issues that arise by using the tests/doublebitand.cocci
      semantic patch. Need to remove duplicate expression in if statement.
      
      Signed-off-by: default avatarWang Ming <machel@vivo.com>
      Reviewed-by: default avatarJiawen Wu <jiawenwu@trustnetic.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a822551c
    • Wang Ming's avatar
      bna: Remove error checking for debugfs_create_dir() · 4ad23d23
      Wang Ming authored
      
      
      It is expected that most callers should _ignore_ the errors return by
      debugfs_create_dir() in bnad_debugfs_init().
      
      Signed-off-by: default avatarWang Ming <machel@vivo.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4ad23d23
    • Daniel Golle's avatar
      net: ethernet: mtk_eth_soc: handle probe deferral · 1d6d537d
      Daniel Golle authored
      Move the call to of_get_ethdev_address to mtk_add_mac which is part of
      the probe function and can hence itself return -EPROBE_DEFER should
      of_get_ethdev_address return -EPROBE_DEFER. This allows us to entirely
      get rid of the mtk_init function.
      
      The problem of of_get_ethdev_address returning -EPROBE_DEFER surfaced
      in situations in which the NVMEM provider holding the MAC address has
      not yet be loaded at the time mtk_eth_soc is initially probed. In this
      case probing of mtk_eth_soc should be deferred instead of falling back
      to use a random MAC address, so once the NVMEM provider becomes
      available probing can be repeated.
      
      Fixes: 656e7052
      
       ("net-next: mediatek: add support for MT7623 ethernet")
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1d6d537d
    • Kuniyuki Iwashima's avatar
      bridge: Add extack warning when enabling STP in netns. · 56a16035
      Kuniyuki Iwashima authored
      When we create an L2 loop on a bridge in netns, we will see packets storm
      even if STP is enabled.
      
        # unshare -n
        # ip link add br0 type bridge
        # ip link add veth0 type veth peer name veth1
        # ip link set veth0 master br0 up
        # ip link set veth1 master br0 up
        # ip link set br0 type bridge stp_state 1
        # ip link set br0 up
        # sleep 30
        # ip -s link show br0
        2: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
            link/ether b6:61:98:1c:1c:b5 brd ff:ff:ff:ff:ff:ff
            RX: bytes  packets  errors  dropped missed  mcast
            956553768  12861249 0       0       0       12861249  <-. Keep
            TX: bytes  packets  errors  dropped carrier collsns     |  increasing
            1027834    11951    0       0       0       0         <-'   rapidly
      
      This is because llc_rcv() drops all packets in non-root netns and BPDU
      is dropped.
      
      Let's add extack warning when enabling STP in netns.
      
        # unshare -n
        # ip link add br0 type bridge
        # ip link set br0 type bridge stp_state 1
        Warning: bridge: STP does not work in non-root netns.
      
      Note this commit will be reverted later when we namespacify the whole LLC
      infra.
      
      Fixes: e730c155
      
       ("[NET]: Make packet reception network namespace safe")
      Suggested-by: default avatarHarry Coin <hcoin@quietfountain.com>
      Link: https://lore.kernel.org/netdev/0f531295-e289-022d-5add-5ceffa0df9bc@quietfountain.com/
      Suggested-by: default avatarIdo Schimmel <idosch@idosch.org>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Acked-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      56a16035
    • Tanmay Patil's avatar
      net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field() · b685f1a5
      Tanmay Patil authored
      CPSW ALE has 75 bit ALE entries which are stored within three 32 bit words.
      The cpsw_ale_get_field() and cpsw_ale_set_field() functions assume that the
      field will be strictly contained within one word. However, this is not
      guaranteed to be the case and it is possible for ALE field entries to span
      across up to two words at the most.
      
      Fix the methods to handle getting/setting fields spanning up to two words.
      
      Fixes: db82173f
      
       ("netdev: driver: ethernet: add cpsw address lookup engine support")
      Signed-off-by: default avatarTanmay Patil <t-patil@ti.com>
      [s-vadapalli@ti.com: rephrased commit message and added Fixes tag]
      Signed-off-by: default avatarSiddharth Vadapalli <s-vadapalli@ti.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b685f1a5
    • Mark Brown's avatar
      net: dsa: ar9331: Use explict flags for regmap single read/write · 9845217d
      Mark Brown authored
      
      
      The at9331 is only able to read or write a single register at once.  The
      driver has a custom regmap bus and chooses to tell the regmap core about
      this by reporting the maximum transfer sizes rather than the explicit
      flags that exist at the regmap level.  Since there are a number of
      problems with the raw transfer limits and the regmap level flags are
      better integrated anyway convert the driver to use the flags.
      
      No functional change.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9845217d
    • Alan Stern's avatar
      net: usbnet: Fix WARNING in usbnet_start_xmit/usb_submit_urb · 5e1627cb
      Alan Stern authored
      
      
      The syzbot fuzzer identified a problem in the usbnet driver:
      
      usb 1-1: BOGUS urb xfer, pipe 3 != type 1
      WARNING: CPU: 0 PID: 754 at drivers/usb/core/urb.c:504 usb_submit_urb+0xed6/0x1880 drivers/usb/core/urb.c:504
      Modules linked in:
      CPU: 0 PID: 754 Comm: kworker/0:2 Not tainted 6.4.0-rc7-syzkaller-00014-g692b7dc87ca6 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
      Workqueue: mld mld_ifc_work
      RIP: 0010:usb_submit_urb+0xed6/0x1880 drivers/usb/core/urb.c:504
      Code: 7c 24 18 e8 2c b4 5b fb 48 8b 7c 24 18 e8 42 07 f0 fe 41 89 d8 44 89 e1 4c 89 ea 48 89 c6 48 c7 c7 a0 c9 fc 8a e8 5a 6f 23 fb <0f> 0b e9 58 f8 ff ff e8 fe b3 5b fb 48 81 c5 c0 05 00 00 e9 84 f7
      RSP: 0018:ffffc9000463f568 EFLAGS: 00010086
      RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
      RDX: ffff88801eb28000 RSI: ffffffff814c03b7 RDI: 0000000000000001
      RBP: ffff8881443b7190 R08: 0000000000000001 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000003
      R13: ffff88802a77cb18 R14: 0000000000000003 R15: ffff888018262500
      FS:  0000000000000000(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000556a99c15a18 CR3: 0000000028c71000 CR4: 0000000000350ef0
      Call Trace:
       <TASK>
       usbnet_start_xmit+0xfe5/0x2190 drivers/net/usb/usbnet.c:1453
       __netdev_start_xmit include/linux/netdevice.h:4918 [inline]
       netdev_start_xmit include/linux/netdevice.h:4932 [inline]
       xmit_one net/core/dev.c:3578 [inline]
       dev_hard_start_xmit+0x187/0x700 net/core/dev.c:3594
      ...
      
      This bug is caused by the fact that usbnet trusts the bulk endpoint
      addresses its probe routine receives in the driver_info structure, and
      it does not check to see that these endpoints actually exist and have
      the expected type and directions.
      
      The fix is simply to add such a check.
      
      Reported-and-tested-by: default avatar <syzbot+63ee658b9a100ffadbe2@syzkaller.appspotmail.com>
      Closes: https://lore.kernel.org/linux-usb/000000000000a56e9105d0cec021@google.com/
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      CC: Oliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/ea152b6d-44df-4f8a-95c6-4db51143dcc1@rowland.harvard.edu
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      5e1627cb
    • Linus Walleij's avatar
      dsa: mv88e6xxx: Do a final check before timing out · 95ce158b
      Linus Walleij authored
      
      
      I get sporadic timeouts from the driver when using the
      MV88E6352. Reading the status again after the loop fixes the
      problem: the operation is successful but goes undetected.
      
      Some added prints show things like this:
      
      [   58.356209] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
          for switch, addr 1b reg 0b, mask 8000, val 0000, data c000
      [   58.367487] mv88e6085 mdio_mux-0.1:00: Timeout waiting for
          ATU op 4000, fid 0001
      (...)
      [   61.826293] mv88e6085 mdio_mux-0.1:00: Timeout while waiting
          for switch, addr 1c reg 18, mask 8000, val 0000, data 9860
      [   61.837560] mv88e6085 mdio_mux-0.1:00: Timeout waiting
          for PHY command 1860 to complete
      
      The reason is probably not the commands: I think those are
      mostly fine with the 50+50ms timeout, but the problem
      appears when OpenWrt brings up several interfaces in
      parallel on a system with 7 populated ports: if one of
      them take more than 50 ms and waits one or more of the
      others can get stuck on the mutex for the switch and then
      this can easily multiply.
      
      As we sleep and wait, the function loop needs a final
      check after exiting the loop if we were successful.
      
      Suggested-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Cc: Tobias Waldekranz <tobias@waldekranz.com>
      Fixes: 35da1dfd
      
       ("net: dsa: mv88e6xxx: Improve performance of busy bit polling")
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20230712223405.861899-1-linus.walleij@linaro.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      95ce158b
    • Linus Torvalds's avatar
      Merge tag 'net-6.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · b1983d42
      Linus Torvalds authored
      Pull networking fixes from Paolo Abeni:
       "Including fixes from netfilter, wireless and ebpf.
      
        Current release - regressions:
      
         - netfilter: conntrack: gre: don't set assured flag for clash entries
      
         - wifi: iwlwifi: remove 'use_tfh' config to fix crash
      
        Previous releases - regressions:
      
         - ipv6: fix a potential refcount underflow for idev
      
         - icmp6: ifix null-ptr-deref of ip6_null_entry->rt6i_idev in
           icmp6_dev()
      
         - bpf: fix max stack depth check for async callbacks
      
         - eth: mlx5e:
            - check for NOT_READY flag state after locking
            - fix page_pool page fragment tracking for XDP
      
         - eth: igc:
            - fix tx hang issue when QBV gate is closed
            - fix corner cases for TSN offload
      
         - eth: octeontx2-af: Move validation of ptp pointer before its usage
      
         - eth: ena: fix shift-out-of-bounds in exponential backoff
      
        Previous releases - always broken:
      
         - core: prevent skb corruption on frag list segmentation
      
         - sched:
            - cls_fw: fix improper refcount update leads to use-after-free
            - sch_qfq: account for stab overhead in qfq_enqueue
      
         - netfilter:
            - report use refcount overflow
            - prevent OOB access in nft_byteorder_eval
      
         - wifi: mt7921e: fix init command fail with enabled device
      
         - eth: ocelot: fix oversize frame dropping for preemptible TCs
      
         - eth: fec: recycle pages for transmitted XDP frames"
      
      * tag 'net-6.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (79 commits)
        selftests: tc-testing: add test for qfq with stab overhead
        net/sched: sch_qfq: account for stab overhead in qfq_enqueue
        selftests: tc-testing: add tests for qfq mtu sanity check
        net/sched: sch_qfq: reintroduce lmax bound check for MTU
        wifi: cfg80211: fix receiving mesh packets without RFC1042 header
        wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set()
        net: txgbe: fix eeprom calculation error
        net/sched: make psched_mtu() RTNL-less safe
        net: ena: fix shift-out-of-bounds in exponential backoff
        netdevsim: fix uninitialized data in nsim_dev_trap_fa_cookie_write()
        net/sched: flower: Ensure both minimum and maximum ports are specified
        MAINTAINERS: Add another mailing list for QUALCOMM ETHQOS ETHERNET DRIVER
        docs: netdev: update the URL of the status page
        wifi: iwlwifi: remove 'use_tfh' config to fix crash
        xdp: use trusted arguments in XDP hints kfuncs
        bpf: cpumap: Fix memory leak in cpu_map_update_elem
        wifi: airo: avoid uninitialized warning in airo_get_rate()
        octeontx2-pf: Add additional check for MCAM rules
        net: dsa: Removed unneeded of_node_put in felix_parse_ports_node
        net: fec: use netdev_err_once() instead of netdev_err()
        ...
      b1983d42
    • Linus Torvalds's avatar
      Merge tag 'trace-v6.5-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · ebc27aac
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
      
       - Fix some missing-prototype warnings
      
       - Fix user events struct args (did not include size of struct)
      
         When creating a user event, the "struct" keyword is to denote that
         the size of the field will be passed in. But the parsing failed to
         handle this case.
      
       - Add selftest to struct sizes for user events
      
       - Fix sample code for direct trampolines.
      
         The sample code for direct trampolines attached to handle_mm_fault().
         But the prototype changed and the direct trampoline sample code was
         not updated. Direct trampolines needs to have the arguments correct
         otherwise it can fail or crash the system.
      
       - Remove unused ftrace_regs_caller_ret() prototype.
      
       - Quiet false positive of FORTIFY_SOURCE
      
         Due to backward compatibility, the structure used to save stack
         traces in the kernel had a fixed size of 8. This structure is
         exported to user space via the tracing format file. A change was made
         to allow more than 8 functions to be recorded, and user space now
         uses the size field to know how many functions are actually in the
         stack.
      
         But the structure still has size of 8 (even though it points into the
         ring buffer that has the required amount allocated to hold a full
         stack.
      
         This was fine until the fortifier noticed that the
         memcpy(&entry->caller, stack, size) was greater than the 8 functions
         and would complain at runtime about it.
      
         Hide this by using a pointer to the stack location on the ring buffer
         instead of using the address of the entry structure caller field.
      
       - Fix a deadloop in reading trace_pipe that was caused by a mismatch
         between ring_buffer_empty() returning false which then asked to read
         the data, but the read code uses rb_num_of_entries() that returned
         zero, and causing a infinite "retry".
      
       - Fix a warning caused by not using all pages allocated to store ftrace
         functions, where this can happen if the linker inserts a bunch of
         "NULL" entries, causing the accounting of how many pages needed to be
         off.
      
       - Fix histogram synthetic event crashing when the start event is
         removed and the end event is still using a variable from it
      
       - Fix memory leak in freeing iter->temp in tracing_release_pipe()
      
      * tag 'trace-v6.5-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        tracing: Fix memory leak of iter->temp when reading trace_pipe
        tracing/histograms: Add histograms to hist_vars if they have referenced variables
        tracing: Stop FORTIFY_SOURCE complaining about stack trace caller
        ftrace: Fix possible warning on checking all pages used in ftrace_process_locs()
        ring-buffer: Fix deadloop issue on reading trace_pipe
        tracing: arm64: Avoid missing-prototype warnings
        selftests/user_events: Test struct size match cases
        tracing/user_events: Fix struct arg size match check
        x86/ftrace: Remove unsued extern declaration ftrace_regs_caller_ret()
        arm64: ftrace: Add direct call trampoline samples support
        samples: ftrace: Save required argument registers in sample trampolines
      ebc27aac
    • Linus Torvalds's avatar
      Merge tag 'for-linus-6.5-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 15999328
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
      
       - a cleanup of the Xen related ELF-notes
      
       - a fix for virtio handling in Xen dom0 when running Xen in a VM
      
      * tag 'for-linus-6.5-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        xen/virtio: Fix NULL deref when a bridge of PCI root bus has no parent
        x86/Xen: tidy xen-head.S
      15999328
    • Linus Torvalds's avatar
      Merge tag 'sh-for-v6.5-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/glaubitz/sh-linux · 9350cd01
      Linus Torvalds authored
      Pull sh fixes from John Paul Adrian Glaubitz:
       "The sh updates introduced multiple regressions.
      
        In particular, the change a8ac2961 ("sh: Avoid using IRQ0 on SH3
        and SH4") causes several boards to hang during boot due to incorrect
        IRQ numbers.
      
        Geert Uytterhoeven has contributed patches that handle the virq offset
        in the IRQ code for the dreamcast, highlander and r2d boards while
        Artur Rojek has contributed a patch which handles the virq offset for
        the hd64461 companion chip"
      
      * tag 'sh-for-v6.5-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/glaubitz/sh-linux:
        sh: hd64461: Handle virq offset for offchip IRQ base and HD64461 IRQ
        sh: mach-dreamcast: Handle virq offset in cascaded IRQ demux
        sh: mach-highlander: Handle virq offset in cascaded IRL demux
        sh: mach-r2d: Handle virq offset in cascaded IRL demux
      9350cd01
  4. Jul 13, 2023
    • Zheng Yejian's avatar
      tracing: Fix memory leak of iter->temp when reading trace_pipe · d5a82189
      Zheng Yejian authored
      kmemleak reports:
        unreferenced object 0xffff88814d14e200 (size 256):
          comm "cat", pid 336, jiffies 4294871818 (age 779.490s)
          hex dump (first 32 bytes):
            04 00 01 03 00 00 00 00 08 00 00 00 00 00 00 00  ................
            0c d8 c8 9b ff ff ff ff 04 5a ca 9b ff ff ff ff  .........Z......
          backtrace:
            [<ffffffff9bdff18f>] __kmalloc+0x4f/0x140
            [<ffffffff9bc9238b>] trace_find_next_entry+0xbb/0x1d0
            [<ffffffff9bc9caef>] trace_print_lat_context+0xaf/0x4e0
            [<ffffffff9bc94490>] print_trace_line+0x3e0/0x950
            [<ffffffff9bc95499>] tracing_read_pipe+0x2d9/0x5a0
            [<ffffffff9bf03a43>] vfs_read+0x143/0x520
            [<ffffffff9bf04c2d>] ksys_read+0xbd/0x160
            [<ffffffff9d0f0edf>] do_syscall_64+0x3f/0x90
            [<ffffffff9d2000aa>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      
      when reading file 'trace_pipe', 'iter->temp' is allocated or relocated
      in trace_find_next_entry() but not freed before 'trace_pipe' is closed.
      
      To fix it, free 'iter->temp' in tracing_release_pipe().
      
      Link: https://lore.kernel.org/linux-trace-kernel/20230713141435.1133021-1-zhengyejian1@huawei.com
      
      Cc: stable@vger.kernel.org
      Fixes: ff895103
      
       ("tracing: Save off entry when peeking at next entry")
      Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d5a82189
    • Paolo Abeni's avatar
      Merge branch 'net-sched-fixes-for-sch_qfq' · 9d23aac8
      Paolo Abeni authored
      
      
      Pedro Tammela says:
      
      ====================
      net/sched: fixes for sch_qfq
      
      Patch 1 fixes a regression introduced in 6.4 where the MTU size could be
      bigger than 'lmax'.
      
      Patch 3 fixes an issue where the code doesn't account for qdisc_pkt_len()
      returning a size bigger then 'lmax'.
      
      Patches 2 and 4 are selftests for the issues above.
      ====================
      
      Link: https://lore.kernel.org/r/20230711210103.597831-1-pctammela@mojatatu.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      9d23aac8
    • Pedro Tammela's avatar
      selftests: tc-testing: add test for qfq with stab overhead · 137f6219
      Pedro Tammela authored
      
      
      A packet with stab overhead greater than QFQ_MAX_LMAX should be dropped
      by the QFQ qdisc as it can't handle such lengths.
      
      Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Tested-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      137f6219
    • Pedro Tammela's avatar
      net/sched: sch_qfq: account for stab overhead in qfq_enqueue · 3e337087
      Pedro Tammela authored
      Lion says:
      -------
      In the QFQ scheduler a similar issue to CVE-2023-31436
      persists.
      
      Consider the following code in net/sched/sch_qfq.c:
      
      static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
                      struct sk_buff **to_free)
      {
           unsigned int len = qdisc_pkt_len(skb), gso_segs;
      
          // ...
      
           if (unlikely(cl->agg->lmax < len)) {
               pr_debug("qfq: increasing maxpkt from %u to %u for class %u",
                    cl->agg->lmax, len, cl->common.classid);
               err = qfq_change_agg(sch, cl, cl->agg->class_weight, len);
               if (err) {
                   cl->qstats.drops++;
                   return qdisc_drop(skb, sch, to_free);
               }
      
          // ...
      
           }
      
      Similarly to CVE-2023-31436, "lmax" is increased without any bounds
      checks according to the packet length "len". Usually this would not
      impose a problem because packet sizes are naturally limited.
      
      This is however not the actual packet length, rather the
      "qdisc_pkt_len(skb)" which might apply size transformations according to
      "struct qdisc_size_table" as created by "qdisc_get_stab()" in
      net/sched/sch_api.c if the TCA_STAB option was set when modifying the qdisc.
      
      A user may choose virtually any size using such a table.
      
      As a result the same issue as in CVE-2023-31436 can occur, allowing heap
      out-of-bounds read / writes in the kmalloc-8192 cache.
      -------
      
      We can create the issue with the following commands:
      
      tc qdisc add dev $DEV root handle 1: stab mtu 2048 tsize 512 mpu 0 \
      overhead 999999999 linklayer ethernet qfq
      tc class add dev $DEV parent 1: classid 1:1 htb rate 6mbit burst 15k
      tc filter add dev $DEV parent 1: matchall classid 1:1
      ping -I $DEV 1.1.1.2
      
      This is caused by incorrectly assuming that qdisc_pkt_len() returns a
      length within the QFQ_MIN_LMAX < len < QFQ_MAX_LMAX.
      
      Fixes: 462dbc91
      
       ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
      Reported-by: default avatarLion <nnamrec@gmail.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      3e337087
    • Pedro Tammela's avatar
      selftests: tc-testing: add tests for qfq mtu sanity check · c5a06fdc
      Pedro Tammela authored
      
      
      QFQ only supports a certain bound of MTU size so make sure
      we check for this requirement in the tests.
      
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Tested-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      c5a06fdc
    • Pedro Tammela's avatar
      net/sched: sch_qfq: reintroduce lmax bound check for MTU · 158810b2
      Pedro Tammela authored
      25369891 deletes a check for the case where no 'lmax' is
      specified which 30379334 previously fixed as 'lmax'
      could be set to the device's MTU without any bound checking
      for QFQ_LMAX_MIN and QFQ_LMAX_MAX. Therefore, reintroduce the check.
      
      Fixes: 25369891
      
       ("net/sched: sch_qfq: refactor parsing of netlink parameters")
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarPedro Tammela <pctammela@mojatatu.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      158810b2
    • Artur Rojek's avatar
      sh: hd64461: Handle virq offset for offchip IRQ base and HD64461 IRQ · 7c28a35e
      Artur Rojek authored
      A recent change to start counting SuperH IRQ #s from 16 breaks support
      for the Hitachi HD64461 companion chip.
      
      Move the offchip IRQ base and HD64461 IRQ # by 16 in order to
      accommodate for the new virq numbering rules.
      
      Fixes: a8ac2961
      
       ("sh: Avoid using IRQ0 on SH3 and SH4")
      Signed-off-by: default avatarArtur Rojek <contact@artur-rojek.eu>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/20230710233132.69734-1-contact@artur-rojek.eu
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      7c28a35e
    • Geert Uytterhoeven's avatar
      sh: mach-dreamcast: Handle virq offset in cascaded IRQ demux · 3d20f7a6
      Geert Uytterhoeven authored
      Take into account the virq offset when translating cascaded interrupts.
      
      Fixes: a8ac2961
      
       ("sh: Avoid using IRQ0 on SH3 and SH4")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/7d0cb246c9f1cd24bb1f637ec5cb67e799a4c3b8.1688908227.git.geert+renesas@glider.be
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      3d20f7a6
    • Geert Uytterhoeven's avatar
      sh: mach-highlander: Handle virq offset in cascaded IRL demux · a2601b8d
      Geert Uytterhoeven authored
      Take into account the virq offset when translating cascaded IRL
      interrupts.
      
      Fixes: a8ac2961
      
       ("sh: Avoid using IRQ0 on SH3 and SH4")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/4fcb0d08a2b372431c41e04312742dc9e41e1be4.1688908186.git.geert+renesas@glider.be
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      a2601b8d
    • Geert Uytterhoeven's avatar
      sh: mach-r2d: Handle virq offset in cascaded IRL demux · ab8aa4f0
      Geert Uytterhoeven authored
      When booting rts7751r2dplus_defconfig on QEMU, the system hangs due to
      an interrupt storm on IRQ 20.  IRQ 20 aka event 0x280 is a cascaded IRL
      interrupt, which maps to IRQ_VOYAGER, the interrupt used by the Silicon
      Motion SM501 multimedia companion chip.  As rts7751r2d_irq_demux() does
      not take into account the new virq offset, the interrupt is no longer
      translated, leading to an unhandled interrupt.
      
      Fix this by taking into account the virq offset when translating
      cascaded IRL interrupts.
      
      Fixes: a8ac2961
      
       ("sh: Avoid using IRQ0 on SH3 and SH4")
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Closes: https://lore.kernel.org/r/fbfea3ad-d327-4ad5-ac9c-648c7ca3fe1f@roeck-us.net
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Tested-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/2c99d5df41c40691f6c407b7b6a040d406bc81ac.1688901306.git.geert+renesas@glider.be
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      ab8aa4f0
    • Jakub Kicinski's avatar
      Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · b0b0ab6f
      Jakub Kicinski authored
      
      
      Alexei Starovoitov says:
      
      ====================
      pull-request: bpf 2023-07-12
      
      We've added 5 non-merge commits during the last 7 day(s) which contain
      a total of 7 files changed, 93 insertions(+), 28 deletions(-).
      
      The main changes are:
      
      1) Fix max stack depth check for async callbacks, from Kumar.
      
      2) Fix inconsistent JIT image generation, from Björn.
      
      3) Use trusted arguments in XDP hints kfuncs, from Larysa.
      
      4) Fix memory leak in cpu_map_update_elem, from Pu.
      
      * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
        xdp: use trusted arguments in XDP hints kfuncs
        bpf: cpumap: Fix memory leak in cpu_map_update_elem
        riscv, bpf: Fix inconsistent JIT image generation
        selftests/bpf: Add selftest for check_stack_max_depth bug
        bpf: Fix max stack depth check for async callbacks
      ====================
      
      Link: https://lore.kernel.org/r/20230712223045.40182-1-alexei.starovoitov@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b0b0ab6f
    • Felix Fietkau's avatar
      wifi: cfg80211: fix receiving mesh packets without RFC1042 header · fec3ebb5
      Felix Fietkau authored
      Fix ethernet header length field after stripping the mesh header
      
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/all/CT5GNZSK28AI.2K6M69OXM9RW5@syracuse/
      Fixes: 986e43b1
      
       ("wifi: mac80211: fix receiving A-MSDU frames on mesh interfaces")
      Reported-and-tested-by: default avatarNicolas Escande <nico.escande@gmail.com>
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Link: https://lore.kernel.org/r/20230711115052.68430-1-nbd@nbd.name
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fec3ebb5
    • Zhang Shurong's avatar
      wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set() · 4f4626cd
      Zhang Shurong authored
      If there is a failure during rtw89_fw_h2c_raw() rtw89_debug_priv_send_h2c
      should return negative error code instead of a positive value count.
      Fix this bug by returning correct error code.
      
      Fixes: e3ec7017
      
       ("rtw89: add Realtek 802.11ax driver")
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Acked-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Link: https://lore.kernel.org/r/tencent_AD09A61BC4DA92AD1EB0790F5C850E544D07@qq.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4f4626cd
    • Jiawen Wu's avatar
      net: txgbe: fix eeprom calculation error · aa846677
      Jiawen Wu authored
      For some device types like TXGBE_ID_XAUI, *checksum computed in
      txgbe_calc_eeprom_checksum() is larger than TXGBE_EEPROM_SUM. Remove the
      limit on the size of *checksum.
      
      Fixes: 049fe536 ("net: txgbe: Add operations to interact with firmware")
      Fixes: 5e2ea780
      
       ("net: txgbe: Fix unsigned comparison to zero in txgbe_calc_eeprom_checksum()")
      Signed-off-by: default avatarJiawen Wu <jiawenwu@trustnetic.com>
      Link: https://lore.kernel.org/r/20230711063414.3311-1-jiawenwu@trustnetic.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      aa846677
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of https://github.com/openrisc/linux · 0099852f
      Linus Torvalds authored
      Pull OpenRISC fix from Stafford Horne:
      
       - During the 6.4 cycle my fpu support work broke ABI compatibility in
         the sigcontext struct. This was noticed by musl libc developers after
         the release. This fix restores the ABI.
      
      * tag 'for-linus' of https://github.com/openrisc/linux:
        openrisc: Union fpcsr and oldmask in sigcontext to unbreak userspace ABI
      0099852f
    • Mohamed Khalfella's avatar
      tracing/histograms: Add histograms to hist_vars if they have referenced variables · 6018b585
      Mohamed Khalfella authored
      Hist triggers can have referenced variables without having direct
      variables fields. This can be the case if referenced variables are added
      for trigger actions. In this case the newly added references will not
      have field variables. Not taking such referenced variables into
      consideration can result in a bug where it would be possible to remove
      hist trigger with variables being refenced. This will result in a bug
      that is easily reproducable like so
      
      $ cd /sys/kernel/tracing
      $ echo 'synthetic_sys_enter char[] comm; long id' >> synthetic_events
      $ echo 'hist:keys=common_pid.execname,id.syscall:vals=hitcount:comm=common_pid.execname' >> events/raw_syscalls/sys_enter/trigger
      $ echo 'hist:keys=common_pid.execname,id.syscall:onmatch(raw_syscalls.sys_enter).synthetic_sys_enter($comm, id)' >> events/raw_syscalls/sys_enter/trigger
      $ echo '!hist:keys=common_pid.execname,id.syscall:vals=hitcount:comm=common_pid.execname' >> events/raw_syscalls/sys_enter/trigger
      
      [  100.263533] ==================================================================
      [  100.264634] BUG: KASAN: slab-use-after-free in resolve_var_refs+0xc7/0x180
      [  100.265520] Read of size 8 at addr ffff88810375d0f0 by task bash/439
      [  100.266320]
      [  100.266533] CPU: 2 PID: 439 Comm: bash Not tainted 6.5.0-rc1 #4
      [  100.267277] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-20220807_005459-localhost 04/01/2014
      [  100.268561] Call Trace:
      [  100.268902]  <TASK>
      [  100.269189]  dump_stack_lvl+0x4c/0x70
      [  100.269680]  print_report+0xc5/0x600
      [  100.270165]  ? resolve_var_refs+0xc7/0x180
      [  100.270697]  ? kasan_complete_mode_report_info+0x80/0x1f0
      [  100.271389]  ? resolve_var_refs+0xc7/0x180
      [  100.271913]  kasan_report+0xbd/0x100
      [  100.272380]  ? resolve_var_refs+0xc7/0x180
      [  100.272920]  __asan_load8+0x71/0xa0
      [  100.273377]  resolve_var_refs+0xc7/0x180
      [  100.273888]  event_hist_trigger+0x749/0x860
      [  100.274505]  ? kasan_save_stack+0x2a/0x50
      [  100.275024]  ? kasan_set_track+0x29/0x40
      [  100.275536]  ? __pfx_event_hist_trigger+0x10/0x10
      [  100.276138]  ? ksys_write+0xd1/0x170
      [  100.276607]  ? do_syscall_64+0x3c/0x90
      [  100.277099]  ? entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      [  100.277771]  ? destroy_hist_data+0x446/0x470
      [  100.278324]  ? event_hist_trigger_parse+0xa6c/0x3860
      [  100.278962]  ? __pfx_event_hist_trigger_parse+0x10/0x10
      [  100.279627]  ? __kasan_check_write+0x18/0x20
      [  100.280177]  ? mutex_unlock+0x85/0xd0
      [  100.280660]  ? __pfx_mutex_unlock+0x10/0x10
      [  100.281200]  ? kfree+0x7b/0x120
      [  100.281619]  ? ____kasan_slab_free+0x15d/0x1d0
      [  100.282197]  ? event_trigger_write+0xac/0x100
      [  100.282764]  ? __kasan_slab_free+0x16/0x20
      [  100.283293]  ? __kmem_cache_free+0x153/0x2f0
      [  100.283844]  ? sched_mm_cid_remote_clear+0xb1/0x250
      [  100.284550]  ? __pfx_sched_mm_cid_remote_clear+0x10/0x10
      [  100.285221]  ? event_trigger_write+0xbc/0x100
      [  100.285781]  ? __kasan_check_read+0x15/0x20
      [  100.286321]  ? __bitmap_weight+0x66/0xa0
      [  100.286833]  ? _find_next_bit+0x46/0xe0
      [  100.287334]  ? task_mm_cid_work+0x37f/0x450
      [  100.287872]  event_triggers_call+0x84/0x150
      [  100.288408]  trace_event_buffer_commit+0x339/0x430
      [  100.289073]  ? ring_buffer_event_data+0x3f/0x60
      [  100.292189]  trace_event_raw_event_sys_enter+0x8b/0xe0
      [  100.295434]  syscall_trace_enter.constprop.0+0x18f/0x1b0
      [  100.298653]  syscall_enter_from_user_mode+0x32/0x40
      [  100.301808]  do_syscall_64+0x1a/0x90
      [  100.304748]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      [  100.307775] RIP: 0033:0x7f686c75c1cb
      [  100.310617] Code: 73 01 c3 48 8b 0d 65 3c 10 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 21 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 35 3c 10 00 f7 d8 64 89 01 48
      [  100.317847] RSP: 002b:00007ffc60137a38 EFLAGS: 00000246 ORIG_RAX: 0000000000000021
      [  100.321200] RAX: ffffffffffffffda RBX: 000055f566469ea0 RCX: 00007f686c75c1cb
      [  100.324631] RDX: 0000000000000001 RSI: 0000000000000001 RDI: 000000000000000a
      [  100.328104] RBP: 00007ffc60137ac0 R08: 00007f686c818460 R09: 000000000000000a
      [  100.331509] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000009
      [  100.334992] R13: 0000000000000007 R14: 000000000000000a R15: 0000000000000007
      [  100.338381]  </TASK>
      
      We hit the bug because when second hist trigger has was created
      has_hist_vars() returned false because hist trigger did not have
      variables. As a result of that save_hist_vars() was not called to add
      the trigger to trace_array->hist_vars. Later on when we attempted to
      remove the first histogram find_any_var_ref() failed to detect it is
      being used because it did not find the second trigger in hist_vars list.
      
      With this change we wait until trigger actions are created so we can take
      into consideration if hist trigger has variable references. Also, now we
      check the return value of save_hist_vars() and fail trigger creation if
      save_hist_vars() fails.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20230712223021.636335-1-mkhalfella@purestorage.com
      
      Cc: stable@vger.kernel.org
      Fixes: 067fe038
      
       ("tracing: Add variable reference handling to hist triggers")
      Signed-off-by: default avatarMohamed Khalfella <mkhalfella@purestorage.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      6018b585