]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 15:20:15 +0000 (16:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 15:20:15 +0000 (16:20 +0100)
added patches:
drm-virtio-use-kvmalloc-for-large-allocations.patch
dt-bindings-ethernet-controller-fix-fixed-link-specification.patch
dt-bindings-net-btusb-dt-fix-s-interrupt-name-interrupt-names.patch
i2c-i2c-qcom-geni-add-shutdown-callback-for-i2c.patch
mips-drop-32-bit-asm-string-functions.patch
net-ag71xx-remove-unnecessary-mtu-reservation.patch
net-bridge-use-switchdev-for-port-flags-set-through-sysfs-too.patch
net-fix-dev_ifsioc_locked-race-condition.patch

queue-5.4/drm-virtio-use-kvmalloc-for-large-allocations.patch [new file with mode: 0644]
queue-5.4/dt-bindings-ethernet-controller-fix-fixed-link-specification.patch [new file with mode: 0644]
queue-5.4/dt-bindings-net-btusb-dt-fix-s-interrupt-name-interrupt-names.patch [new file with mode: 0644]
queue-5.4/i2c-i2c-qcom-geni-add-shutdown-callback-for-i2c.patch [new file with mode: 0644]
queue-5.4/mips-drop-32-bit-asm-string-functions.patch [new file with mode: 0644]
queue-5.4/net-ag71xx-remove-unnecessary-mtu-reservation.patch [new file with mode: 0644]
queue-5.4/net-bridge-use-switchdev-for-port-flags-set-through-sysfs-too.patch [new file with mode: 0644]
queue-5.4/net-fix-dev_ifsioc_locked-race-condition.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/drm-virtio-use-kvmalloc-for-large-allocations.patch b/queue-5.4/drm-virtio-use-kvmalloc-for-large-allocations.patch
new file mode 100644 (file)
index 0000000..7df26b9
--- /dev/null
@@ -0,0 +1,38 @@
+From ea86f3defd55f141a44146e66cbf8ffb683d60da Mon Sep 17 00:00:00 2001
+From: Sergey Senozhatsky <senozhatsky@chromium.org>
+Date: Thu, 5 Nov 2020 10:47:44 +0900
+Subject: drm/virtio: use kvmalloc for large allocations
+
+From: Sergey Senozhatsky <senozhatsky@chromium.org>
+
+commit ea86f3defd55f141a44146e66cbf8ffb683d60da upstream.
+
+We observed that some of virtio_gpu_object_shmem_init() allocations
+can be rather costly - order 6 - which can be difficult to fulfill
+under memory pressure conditions. Switch to kvmalloc_array() in
+virtio_gpu_object_shmem_init() and let the kernel vmalloc the entries
+array.
+
+Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
+Link: http://patchwork.freedesktop.org/patch/msgid/20201105014744.1662226-1-senozhatsky@chromium.org
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+Signed-off-by: Doug Horn <doughorn@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/virtio/virtgpu_vq.c |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
+@@ -992,8 +992,9 @@ int virtio_gpu_object_attach(struct virt
+       }
+       /* gets freed when the ring has consumed it */
+-      ents = kmalloc_array(nents, sizeof(struct virtio_gpu_mem_entry),
+-                           GFP_KERNEL);
++      ents = kvmalloc_array(nents,
++                            sizeof(struct virtio_gpu_mem_entry),
++                            GFP_KERNEL);
+       if (!ents) {
+               DRM_ERROR("failed to allocate ent list\n");
+               return -ENOMEM;
diff --git a/queue-5.4/dt-bindings-ethernet-controller-fix-fixed-link-specification.patch b/queue-5.4/dt-bindings-ethernet-controller-fix-fixed-link-specification.patch
new file mode 100644 (file)
index 0000000..a295b72
--- /dev/null
@@ -0,0 +1,36 @@
+From 322322d15b9b912bc8710c367a95a7de62220a72 Mon Sep 17 00:00:00 2001
+From: Russell King <rmk+kernel@armlinux.org.uk>
+Date: Mon, 1 Feb 2021 10:02:20 +0000
+Subject: dt-bindings: ethernet-controller: fix fixed-link specification
+
+From: Russell King <rmk+kernel@armlinux.org.uk>
+
+commit 322322d15b9b912bc8710c367a95a7de62220a72 upstream.
+
+The original fixed-link.txt allowed a pause property for fixed link.
+This has been missed in the conversion to yaml format.
+
+Fixes: 9d3de3c58347 ("dt-bindings: net: Add YAML schemas for the generic Ethernet options")
+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Link: https://lore.kernel.org/r/E1l6W2G-0002Ga-0O@rmk-PC.armlinux.org.uk
+Signed-off-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Documentation/devicetree/bindings/net/ethernet-controller.yaml |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
++++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+@@ -190,6 +190,11 @@ properties:
+                 Indicates that full-duplex is used. When absent, half
+                 duplex is assumed.
++            pause:
++              $ref: /schemas/types.yaml#definitions/flag
++              description:
++                Indicates that pause should be enabled.
++
+             asym-pause:
+               $ref: /schemas/types.yaml#definitions/flag
+               description:
diff --git a/queue-5.4/dt-bindings-net-btusb-dt-fix-s-interrupt-name-interrupt-names.patch b/queue-5.4/dt-bindings-net-btusb-dt-fix-s-interrupt-name-interrupt-names.patch
new file mode 100644 (file)
index 0000000..9428327
--- /dev/null
@@ -0,0 +1,33 @@
+From f288988930e93857e0375bdf88bb670c312b82eb Mon Sep 17 00:00:00 2001
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+Date: Thu, 14 Jan 2021 14:13:33 +0100
+Subject: dt-bindings: net: btusb: DT fix s/interrupt-name/interrupt-names/
+
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+
+commit f288988930e93857e0375bdf88bb670c312b82eb upstream.
+
+The standard DT property name is "interrupt-names".
+
+Fixes: fd913ef7ce619467 ("Bluetooth: btusb: Add out-of-band wakeup support")
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Acked-by: Rob Herring <robh@kernel.org>
+Reviewed-by: Brian Norris <briannorris@chromium.org>
+Acked-by: Rajat Jain <rajatja@google.com>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Documentation/devicetree/bindings/net/btusb.txt |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/Documentation/devicetree/bindings/net/btusb.txt
++++ b/Documentation/devicetree/bindings/net/btusb.txt
+@@ -38,7 +38,7 @@ Following example uses irq pin number 3
+       compatible = "usb1286,204e";
+       reg = <1>;
+       interrupt-parent = <&gpio0>;
+-      interrupt-name = "wakeup";
++      interrupt-names = "wakeup";
+       interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+     };
+ };
diff --git a/queue-5.4/i2c-i2c-qcom-geni-add-shutdown-callback-for-i2c.patch b/queue-5.4/i2c-i2c-qcom-geni-add-shutdown-callback-for-i2c.patch
new file mode 100644 (file)
index 0000000..5763953
--- /dev/null
@@ -0,0 +1,84 @@
+From e0371298ddc51761be257698554ea507ac8bf831 Mon Sep 17 00:00:00 2001
+From: Roja Rani Yarubandi <rojay@codeaurora.org>
+Date: Fri, 8 Jan 2021 20:35:45 +0530
+Subject: i2c: i2c-qcom-geni: Add shutdown callback for i2c
+
+From: Roja Rani Yarubandi <rojay@codeaurora.org>
+
+commit e0371298ddc51761be257698554ea507ac8bf831 upstream.
+
+If the hardware is still accessing memory after SMMU translation
+is disabled (as part of smmu shutdown callback), then the
+IOVAs (I/O virtual address) which it was using will go on the bus
+as the physical addresses which will result in unknown crashes
+like NoC/interconnect errors.
+
+So, implement shutdown callback to i2c driver to stop on-going transfer
+and unmap DMA mappings during system "reboot" or "shutdown".
+
+Fixes: 37692de5d523 ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller")
+Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org>
+Reviewed-by: Akash Asthana <akashast@codeaurora.org>
+Signed-off-by: Wolfram Sang <wsa@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/i2c/busses/i2c-qcom-geni.c |   34 ++++++++++++++++++++++++++++++++++
+ 1 file changed, 34 insertions(+)
+
+--- a/drivers/i2c/busses/i2c-qcom-geni.c
++++ b/drivers/i2c/busses/i2c-qcom-geni.c
+@@ -377,6 +377,32 @@ static void geni_i2c_tx_msg_cleanup(stru
+       }
+ }
++static void geni_i2c_stop_xfer(struct geni_i2c_dev *gi2c)
++{
++      int ret;
++      u32 geni_status;
++      struct i2c_msg *cur;
++
++      /* Resume device, as runtime suspend can happen anytime during transfer */
++      ret = pm_runtime_get_sync(gi2c->se.dev);
++      if (ret < 0) {
++              dev_err(gi2c->se.dev, "Failed to resume device: %d\n", ret);
++              return;
++      }
++
++      geni_status = readl_relaxed(gi2c->se.base + SE_GENI_STATUS);
++      if (geni_status & M_GENI_CMD_ACTIVE) {
++              cur = gi2c->cur;
++              geni_i2c_abort_xfer(gi2c);
++              if (cur->flags & I2C_M_RD)
++                      geni_i2c_rx_msg_cleanup(gi2c, cur);
++              else
++                      geni_i2c_tx_msg_cleanup(gi2c, cur);
++      }
++
++      pm_runtime_put_sync_suspend(gi2c->se.dev);
++}
++
+ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
+                               u32 m_param)
+ {
+@@ -641,6 +667,13 @@ static int geni_i2c_remove(struct platfo
+       return 0;
+ }
++static void  geni_i2c_shutdown(struct platform_device *pdev)
++{
++      struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev);
++
++      geni_i2c_stop_xfer(gi2c);
++}
++
+ static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev)
+ {
+       int ret;
+@@ -701,6 +734,7 @@ MODULE_DEVICE_TABLE(of, geni_i2c_dt_matc
+ static struct platform_driver geni_i2c_driver = {
+       .probe  = geni_i2c_probe,
+       .remove = geni_i2c_remove,
++      .shutdown = geni_i2c_shutdown,
+       .driver = {
+               .name = "geni_i2c",
+               .pm = &geni_i2c_pm_ops,
diff --git a/queue-5.4/mips-drop-32-bit-asm-string-functions.patch b/queue-5.4/mips-drop-32-bit-asm-string-functions.patch
new file mode 100644 (file)
index 0000000..a09d2f7
--- /dev/null
@@ -0,0 +1,177 @@
+From 3c0be5849259b729580c23549330973a2dd513a2 Mon Sep 17 00:00:00 2001
+From: Paul Burton <paul.burton@mips.com>
+Date: Tue, 8 Oct 2019 19:46:01 +0000
+Subject: MIPS: Drop 32-bit asm string functions
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Paul Burton <paul.burton@mips.com>
+
+commit 3c0be5849259b729580c23549330973a2dd513a2 upstream.
+
+We have assembly implementations of strcpy(), strncpy(), strcmp() &
+strncmp() which:
+
+ - Are simple byte-at-a-time loops with no particular optimizations. As
+   a comment in the code describes, they're "rather naive".
+
+ - Offer no clear performance advantage over the generic C
+   implementations - in microbenchmarks performed by Alexander Lobakin
+   the asm functions sometimes win & sometimes lose, but generally not
+   by large margins in either direction.
+
+ - Don't support 64-bit kernels, where we already make use of the
+   generic C implementations.
+
+ - Tend to bloat kernel code size due to inlining.
+
+ - Don't support CONFIG_FORTIFY_SOURCE.
+
+ - Won't support nanoMIPS without rework.
+
+For all of these reasons, delete the asm implementations & make use of
+the generic C implementations for 32-bit kernels just like we already do
+for 64-bit kernels.
+
+Signed-off-by: Paul Burton <paul.burton@mips.com>
+URL: https://lore.kernel.org/linux-mips/a2a35f1cf58d6db19eb4af9b4ae21e35@dlink.ru/
+Cc: Alexander Lobakin <alobakin@dlink.ru>
+Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
+Cc: linux-mips@vger.kernel.org
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/mips/include/asm/string.h |  121 -----------------------------------------
+ 1 file changed, 121 deletions(-)
+
+--- a/arch/mips/include/asm/string.h
++++ b/arch/mips/include/asm/string.h
+@@ -10,127 +10,6 @@
+ #ifndef _ASM_STRING_H
+ #define _ASM_STRING_H
+-
+-/*
+- * Most of the inline functions are rather naive implementations so I just
+- * didn't bother updating them for 64-bit ...
+- */
+-#ifdef CONFIG_32BIT
+-
+-#ifndef IN_STRING_C
+-
+-#define __HAVE_ARCH_STRCPY
+-static __inline__ char *strcpy(char *__dest, __const__ char *__src)
+-{
+-  char *__xdest = __dest;
+-
+-  __asm__ __volatile__(
+-      ".set\tnoreorder\n\t"
+-      ".set\tnoat\n"
+-      "1:\tlbu\t$1,(%1)\n\t"
+-      "addiu\t%1,1\n\t"
+-      "sb\t$1,(%0)\n\t"
+-      "bnez\t$1,1b\n\t"
+-      "addiu\t%0,1\n\t"
+-      ".set\tat\n\t"
+-      ".set\treorder"
+-      : "=r" (__dest), "=r" (__src)
+-      : "0" (__dest), "1" (__src)
+-      : "memory");
+-
+-  return __xdest;
+-}
+-
+-#define __HAVE_ARCH_STRNCPY
+-static __inline__ char *strncpy(char *__dest, __const__ char *__src, size_t __n)
+-{
+-  char *__xdest = __dest;
+-
+-  if (__n == 0)
+-    return __xdest;
+-
+-  __asm__ __volatile__(
+-      ".set\tnoreorder\n\t"
+-      ".set\tnoat\n"
+-      "1:\tlbu\t$1,(%1)\n\t"
+-      "subu\t%2,1\n\t"
+-      "sb\t$1,(%0)\n\t"
+-      "beqz\t$1,2f\n\t"
+-      "addiu\t%0,1\n\t"
+-      "bnez\t%2,1b\n\t"
+-      "addiu\t%1,1\n"
+-      "2:\n\t"
+-      ".set\tat\n\t"
+-      ".set\treorder"
+-      : "=r" (__dest), "=r" (__src), "=r" (__n)
+-      : "0" (__dest), "1" (__src), "2" (__n)
+-      : "memory");
+-
+-  return __xdest;
+-}
+-
+-#define __HAVE_ARCH_STRCMP
+-static __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct)
+-{
+-  int __res;
+-
+-  __asm__ __volatile__(
+-      ".set\tnoreorder\n\t"
+-      ".set\tnoat\n\t"
+-      "lbu\t%2,(%0)\n"
+-      "1:\tlbu\t$1,(%1)\n\t"
+-      "addiu\t%0,1\n\t"
+-      "bne\t$1,%2,2f\n\t"
+-      "addiu\t%1,1\n\t"
+-      "bnez\t%2,1b\n\t"
+-      "lbu\t%2,(%0)\n\t"
+-#if defined(CONFIG_CPU_R3000)
+-      "nop\n\t"
+-#endif
+-      "move\t%2,$1\n"
+-      "2:\tsubu\t%2,$1\n"
+-      "3:\t.set\tat\n\t"
+-      ".set\treorder"
+-      : "=r" (__cs), "=r" (__ct), "=r" (__res)
+-      : "0" (__cs), "1" (__ct));
+-
+-  return __res;
+-}
+-
+-#endif /* !defined(IN_STRING_C) */
+-
+-#define __HAVE_ARCH_STRNCMP
+-static __inline__ int
+-strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count)
+-{
+-      int __res;
+-
+-      __asm__ __volatile__(
+-      ".set\tnoreorder\n\t"
+-      ".set\tnoat\n"
+-      "1:\tlbu\t%3,(%0)\n\t"
+-      "beqz\t%2,2f\n\t"
+-      "lbu\t$1,(%1)\n\t"
+-      "subu\t%2,1\n\t"
+-      "bne\t$1,%3,3f\n\t"
+-      "addiu\t%0,1\n\t"
+-      "bnez\t%3,1b\n\t"
+-      "addiu\t%1,1\n"
+-      "2:\n\t"
+-#if defined(CONFIG_CPU_R3000)
+-      "nop\n\t"
+-#endif
+-      "move\t%3,$1\n"
+-      "3:\tsubu\t%3,$1\n\t"
+-      ".set\tat\n\t"
+-      ".set\treorder"
+-      : "=r" (__cs), "=r" (__ct), "=r" (__count), "=r" (__res)
+-      : "0" (__cs), "1" (__ct), "2" (__count));
+-
+-      return __res;
+-}
+-#endif /* CONFIG_32BIT */
+-
+ #define __HAVE_ARCH_MEMSET
+ extern void *memset(void *__s, int __c, size_t __count);
diff --git a/queue-5.4/net-ag71xx-remove-unnecessary-mtu-reservation.patch b/queue-5.4/net-ag71xx-remove-unnecessary-mtu-reservation.patch
new file mode 100644 (file)
index 0000000..4c9ca76
--- /dev/null
@@ -0,0 +1,43 @@
+From 04b385f325080157ab1b5f8ce1b1de07ce0d9e27 Mon Sep 17 00:00:00 2001
+From: DENG Qingfang <dqfext@gmail.com>
+Date: Thu, 18 Feb 2021 11:45:14 +0800
+Subject: net: ag71xx: remove unnecessary MTU reservation
+
+From: DENG Qingfang <dqfext@gmail.com>
+
+commit 04b385f325080157ab1b5f8ce1b1de07ce0d9e27 upstream.
+
+2 bytes of the MTU are reserved for Atheros DSA tag, but DSA core
+has already handled that since commit dc0fe7d47f9f.
+Remove the unnecessary reservation.
+
+Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
+Signed-off-by: DENG Qingfang <dqfext@gmail.com>
+Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
+Link: https://lore.kernel.org/r/20210218034514.3421-1-dqfext@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/atheros/ag71xx.c |    4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+--- a/drivers/net/ethernet/atheros/ag71xx.c
++++ b/drivers/net/ethernet/atheros/ag71xx.c
+@@ -222,8 +222,6 @@
+ #define AG71XX_REG_RX_SM      0x01b0
+ #define AG71XX_REG_TX_SM      0x01b4
+-#define ETH_SWITCH_HEADER_LEN 2
+-
+ #define AG71XX_DEFAULT_MSG_ENABLE     \
+       (NETIF_MSG_DRV                  \
+       | NETIF_MSG_PROBE               \
+@@ -784,7 +782,7 @@ static void ag71xx_hw_setup(struct ag71x
+ static unsigned int ag71xx_max_frame_len(unsigned int mtu)
+ {
+-      return ETH_SWITCH_HEADER_LEN + ETH_HLEN + VLAN_HLEN + mtu + ETH_FCS_LEN;
++      return ETH_HLEN + VLAN_HLEN + mtu + ETH_FCS_LEN;
+ }
+ static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac)
diff --git a/queue-5.4/net-bridge-use-switchdev-for-port-flags-set-through-sysfs-too.patch b/queue-5.4/net-bridge-use-switchdev-for-port-flags-set-through-sysfs-too.patch
new file mode 100644 (file)
index 0000000..8b1e7d9
--- /dev/null
@@ -0,0 +1,52 @@
+From 8043c845b63a2dd88daf2d2d268a33e1872800f0 Mon Sep 17 00:00:00 2001
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+Date: Sun, 7 Feb 2021 21:47:33 +0200
+Subject: net: bridge: use switchdev for port flags set through sysfs too
+
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+
+commit 8043c845b63a2dd88daf2d2d268a33e1872800f0 upstream.
+
+Looking through patchwork I don't see that there was any consensus to
+use switchdev notifiers only in case of netlink provided port flags but
+not sysfs (as a sort of deprecation, punishment or anything like that),
+so we should probably keep the user interface consistent in terms of
+functionality.
+
+http://patchwork.ozlabs.org/project/netdev/patch/20170605092043.3523-3-jiri@resnulli.us/
+http://patchwork.ozlabs.org/project/netdev/patch/20170608064428.4785-3-jiri@resnulli.us/
+
+Fixes: 3922285d96e7 ("net: bridge: Add support for offloading port attributes")
+Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
+Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/bridge/br_sysfs_if.c |    9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+--- a/net/bridge/br_sysfs_if.c
++++ b/net/bridge/br_sysfs_if.c
+@@ -55,9 +55,8 @@ static BRPORT_ATTR(_name, 0644,                                      \
+ static int store_flag(struct net_bridge_port *p, unsigned long v,
+                     unsigned long mask)
+ {
+-      unsigned long flags;
+-
+-      flags = p->flags;
++      unsigned long flags = p->flags;
++      int err;
+       if (v)
+               flags |= mask;
+@@ -65,6 +64,10 @@ static int store_flag(struct net_bridge_
+               flags &= ~mask;
+       if (flags != p->flags) {
++              err = br_switchdev_set_port_flag(p, flags, mask);
++              if (err)
++                      return err;
++
+               p->flags = flags;
+               br_port_flags_change(p, mask);
+       }
diff --git a/queue-5.4/net-fix-dev_ifsioc_locked-race-condition.patch b/queue-5.4/net-fix-dev_ifsioc_locked-race-condition.patch
new file mode 100644 (file)
index 0000000..d0e10e5
--- /dev/null
@@ -0,0 +1,214 @@
+From 3b23a32a63219f51a5298bc55a65ecee866e79d0 Mon Sep 17 00:00:00 2001
+From: Cong Wang <cong.wang@bytedance.com>
+Date: Thu, 11 Feb 2021 11:34:10 -0800
+Subject: net: fix dev_ifsioc_locked() race condition
+
+From: Cong Wang <cong.wang@bytedance.com>
+
+commit 3b23a32a63219f51a5298bc55a65ecee866e79d0 upstream.
+
+dev_ifsioc_locked() is called with only RCU read lock, so when
+there is a parallel writer changing the mac address, it could
+get a partially updated mac address, as shown below:
+
+Thread 1                       Thread 2
+// eth_commit_mac_addr_change()
+memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+                               // dev_ifsioc_locked()
+                               memcpy(ifr->ifr_hwaddr.sa_data,
+                                       dev->dev_addr,...);
+
+Close this race condition by guarding them with a RW semaphore,
+like netdev_get_name(). We can not use seqlock here as it does not
+allow blocking. The writers already take RTNL anyway, so this does
+not affect the slow path. To avoid bothering existing
+dev_set_mac_address() callers in drivers, introduce a new wrapper
+just for user-facing callers on ioctl and rtnetlink paths.
+
+Note, bonding also changes slave mac addresses but that requires
+a separate patch due to the complexity of bonding code.
+
+Fixes: 3710becf8a58 ("net: RCU locking for simple ioctl()")
+Reported-by: "Gong, Sishuai" <sishuai@purdue.edu>
+Cc: Eric Dumazet <eric.dumazet@gmail.com>
+Cc: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Cong Wang <cong.wang@bytedance.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/tap.c         |    7 +++----
+ drivers/net/tun.c         |    4 ++--
+ include/linux/netdevice.h |    3 +++
+ net/core/dev.c            |   42 ++++++++++++++++++++++++++++++++++++++++++
+ net/core/dev_ioctl.c      |   20 +++++++-------------
+ net/core/rtnetlink.c      |    2 +-
+ 6 files changed, 58 insertions(+), 20 deletions(-)
+
+--- a/drivers/net/tap.c
++++ b/drivers/net/tap.c
+@@ -1095,10 +1095,9 @@ static long tap_ioctl(struct file *file,
+                       return -ENOLINK;
+               }
+               ret = 0;
+-              u = tap->dev->type;
++              dev_get_mac_address(&sa, dev_net(tap->dev), tap->dev->name);
+               if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) ||
+-                  copy_to_user(&ifr->ifr_hwaddr.sa_data, tap->dev->dev_addr, ETH_ALEN) ||
+-                  put_user(u, &ifr->ifr_hwaddr.sa_family))
++                  copy_to_user(&ifr->ifr_hwaddr, &sa, sizeof(sa)))
+                       ret = -EFAULT;
+               tap_put_tap_dev(tap);
+               rtnl_unlock();
+@@ -1113,7 +1112,7 @@ static long tap_ioctl(struct file *file,
+                       rtnl_unlock();
+                       return -ENOLINK;
+               }
+-              ret = dev_set_mac_address(tap->dev, &sa, NULL);
++              ret = dev_set_mac_address_user(tap->dev, &sa, NULL);
+               tap_put_tap_dev(tap);
+               rtnl_unlock();
+               return ret;
+--- a/drivers/net/tun.c
++++ b/drivers/net/tun.c
+@@ -3224,7 +3224,7 @@ static long __tun_chr_ioctl(struct file
+       case SIOCGIFHWADDR:
+               /* Get hw address */
+               memcpy(ifr.ifr_hwaddr.sa_data, tun->dev->dev_addr, ETH_ALEN);
+-              ifr.ifr_hwaddr.sa_family = tun->dev->type;
++              dev_get_mac_address(&ifr.ifr_hwaddr, net, tun->dev->name);
+               if (copy_to_user(argp, &ifr, ifreq_len))
+                       ret = -EFAULT;
+               break;
+@@ -3234,7 +3234,7 @@ static long __tun_chr_ioctl(struct file
+               tun_debug(KERN_DEBUG, tun, "set hw address: %pM\n",
+                         ifr.ifr_hwaddr.sa_data);
+-              ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr, NULL);
++              ret = dev_set_mac_address_user(tun->dev, &ifr.ifr_hwaddr, NULL);
+               break;
+       case TUNGETSNDBUF:
+--- a/include/linux/netdevice.h
++++ b/include/linux/netdevice.h
+@@ -3679,6 +3679,9 @@ int dev_pre_changeaddr_notify(struct net
+                             struct netlink_ext_ack *extack);
+ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
+                       struct netlink_ext_ack *extack);
++int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa,
++                           struct netlink_ext_ack *extack);
++int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name);
+ int dev_change_carrier(struct net_device *, bool new_carrier);
+ int dev_get_phys_port_id(struct net_device *dev,
+                        struct netdev_phys_item_id *ppid);
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -8144,6 +8144,48 @@ int dev_set_mac_address(struct net_devic
+ }
+ EXPORT_SYMBOL(dev_set_mac_address);
++static DECLARE_RWSEM(dev_addr_sem);
++
++int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa,
++                           struct netlink_ext_ack *extack)
++{
++      int ret;
++
++      down_write(&dev_addr_sem);
++      ret = dev_set_mac_address(dev, sa, extack);
++      up_write(&dev_addr_sem);
++      return ret;
++}
++EXPORT_SYMBOL(dev_set_mac_address_user);
++
++int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name)
++{
++      size_t size = sizeof(sa->sa_data);
++      struct net_device *dev;
++      int ret = 0;
++
++      down_read(&dev_addr_sem);
++      rcu_read_lock();
++
++      dev = dev_get_by_name_rcu(net, dev_name);
++      if (!dev) {
++              ret = -ENODEV;
++              goto unlock;
++      }
++      if (!dev->addr_len)
++              memset(sa->sa_data, 0, size);
++      else
++              memcpy(sa->sa_data, dev->dev_addr,
++                     min_t(size_t, size, dev->addr_len));
++      sa->sa_family = dev->type;
++
++unlock:
++      rcu_read_unlock();
++      up_read(&dev_addr_sem);
++      return ret;
++}
++EXPORT_SYMBOL(dev_get_mac_address);
++
+ /**
+  *    dev_change_carrier - Change device carrier
+  *    @dev: device
+--- a/net/core/dev_ioctl.c
++++ b/net/core/dev_ioctl.c
+@@ -122,17 +122,6 @@ static int dev_ifsioc_locked(struct net
+               ifr->ifr_mtu = dev->mtu;
+               return 0;
+-      case SIOCGIFHWADDR:
+-              if (!dev->addr_len)
+-                      memset(ifr->ifr_hwaddr.sa_data, 0,
+-                             sizeof(ifr->ifr_hwaddr.sa_data));
+-              else
+-                      memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
+-                             min(sizeof(ifr->ifr_hwaddr.sa_data),
+-                                 (size_t)dev->addr_len));
+-              ifr->ifr_hwaddr.sa_family = dev->type;
+-              return 0;
+-
+       case SIOCGIFSLAVE:
+               err = -EINVAL;
+               break;
+@@ -246,7 +235,7 @@ static int dev_ifsioc(struct net *net, s
+       case SIOCSIFHWADDR:
+               if (dev->addr_len > sizeof(struct sockaddr))
+                       return -EINVAL;
+-              return dev_set_mac_address(dev, &ifr->ifr_hwaddr, NULL);
++              return dev_set_mac_address_user(dev, &ifr->ifr_hwaddr, NULL);
+       case SIOCSIFHWBROADCAST:
+               if (ifr->ifr_hwaddr.sa_family != dev->type)
+@@ -396,6 +385,12 @@ int dev_ioctl(struct net *net, unsigned
+        */
+       switch (cmd) {
++      case SIOCGIFHWADDR:
++              dev_load(net, ifr->ifr_name);
++              ret = dev_get_mac_address(&ifr->ifr_hwaddr, net, ifr->ifr_name);
++              if (colon)
++                      *colon = ':';
++              return ret;
+       /*
+        *      These ioctl calls:
+        *      - can be done by all.
+@@ -405,7 +400,6 @@ int dev_ioctl(struct net *net, unsigned
+       case SIOCGIFFLAGS:
+       case SIOCGIFMETRIC:
+       case SIOCGIFMTU:
+-      case SIOCGIFHWADDR:
+       case SIOCGIFSLAVE:
+       case SIOCGIFMAP:
+       case SIOCGIFINDEX:
+--- a/net/core/rtnetlink.c
++++ b/net/core/rtnetlink.c
+@@ -2471,7 +2471,7 @@ static int do_setlink(const struct sk_bu
+               sa->sa_family = dev->type;
+               memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
+                      dev->addr_len);
+-              err = dev_set_mac_address(dev, sa, extack);
++              err = dev_set_mac_address_user(dev, sa, extack);
+               kfree(sa);
+               if (err)
+                       goto errout;
index 2c7a74257aa6f7086968cc41122147f21c6621d5..3095ec84358505c31a4d7ca84459c51f6baaaf88 100644 (file)
@@ -15,3 +15,11 @@ smackfs-restrict-bytes-count-in-smackfs-write-functions.patch
 net-fix-up-truesize-of-cloned-skb-in-skb_prepare_for_shift.patch
 nbd-handle-device-refs-for-destroy_on_disconnect-properly.patch
 mm-hugetlb.c-fix-unnecessary-address-expansion-of-pmd-sharing.patch
+net-bridge-use-switchdev-for-port-flags-set-through-sysfs-too.patch
+net-ag71xx-remove-unnecessary-mtu-reservation.patch
+net-fix-dev_ifsioc_locked-race-condition.patch
+dt-bindings-ethernet-controller-fix-fixed-link-specification.patch
+dt-bindings-net-btusb-dt-fix-s-interrupt-name-interrupt-names.patch
+i2c-i2c-qcom-geni-add-shutdown-callback-for-i2c.patch
+mips-drop-32-bit-asm-string-functions.patch
+drm-virtio-use-kvmalloc-for-large-allocations.patch