From: Greg Kroah-Hartman Date: Sun, 5 Dec 2021 13:22:33 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v4.4.294~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66c26652416961012caa5e54026abc1c2f30813c;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: i2c-cbus-gpio-set-atomic-transfer-callback.patch i2c-stm32f7-flush-tx-fifo-upon-transfer-errors.patch i2c-stm32f7-recover-the-bus-on-access-timeout.patch i2c-stm32f7-stop-dma-transfer-in-case-of-nack.patch natsemi-xtensa-fix-section-mismatch-warnings.patch net-mpls-fix-notifications-when-deleting-a-device.patch net-qlogic-qlcnic-fix-a-null-pointer-dereference-in-qlcnic_83xx_add_rings.patch siphash-use-_unaligned-version-by-default.patch --- diff --git a/queue-5.4/i2c-cbus-gpio-set-atomic-transfer-callback.patch b/queue-5.4/i2c-cbus-gpio-set-atomic-transfer-callback.patch new file mode 100644 index 00000000000..08287e2075f --- /dev/null +++ b/queue-5.4/i2c-cbus-gpio-set-atomic-transfer-callback.patch @@ -0,0 +1,43 @@ +From b12764695c3fcade145890b67f82f8b139174cc7 Mon Sep 17 00:00:00 2001 +From: Aaro Koskinen +Date: Sat, 27 Nov 2021 21:42:14 +0200 +Subject: i2c: cbus-gpio: set atomic transfer callback + +From: Aaro Koskinen + +commit b12764695c3fcade145890b67f82f8b139174cc7 upstream. + +CBUS transfers have always been atomic, but after commit 63b96983a5dd +("i2c: core: introduce callbacks for atomic transfers") we started to see +warnings during e.g. poweroff as the atomic callback is not explicitly set. +Fix that. + +Fixes the following WARNING seen during Nokia N810 power down: + +[ 786.570617] reboot: Power down +[ 786.573913] ------------[ cut here ]------------ +[ 786.578826] WARNING: CPU: 0 PID: 672 at drivers/i2c/i2c-core.h:40 i2c_smbus_xfer+0x100/0x110 +[ 786.587799] No atomic I2C transfer handler for 'i2c-2' + +Fixes: 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") +Signed-off-by: Aaro Koskinen +Signed-off-by: Wolfram Sang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/i2c/busses/i2c-cbus-gpio.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/drivers/i2c/busses/i2c-cbus-gpio.c ++++ b/drivers/i2c/busses/i2c-cbus-gpio.c +@@ -195,8 +195,9 @@ static u32 cbus_i2c_func(struct i2c_adap + } + + static const struct i2c_algorithm cbus_i2c_algo = { +- .smbus_xfer = cbus_i2c_smbus_xfer, +- .functionality = cbus_i2c_func, ++ .smbus_xfer = cbus_i2c_smbus_xfer, ++ .smbus_xfer_atomic = cbus_i2c_smbus_xfer, ++ .functionality = cbus_i2c_func, + }; + + static int cbus_i2c_remove(struct platform_device *pdev) diff --git a/queue-5.4/i2c-stm32f7-flush-tx-fifo-upon-transfer-errors.patch b/queue-5.4/i2c-stm32f7-flush-tx-fifo-upon-transfer-errors.patch new file mode 100644 index 00000000000..ef9d8cf2922 --- /dev/null +++ b/queue-5.4/i2c-stm32f7-flush-tx-fifo-upon-transfer-errors.patch @@ -0,0 +1,61 @@ +From 0c21d02ca469574d2082379db52d1a27b99eed0c Mon Sep 17 00:00:00 2001 +From: Alain Volmat +Date: Mon, 20 Sep 2021 17:21:29 +0200 +Subject: i2c: stm32f7: flush TX FIFO upon transfer errors + +From: Alain Volmat + +commit 0c21d02ca469574d2082379db52d1a27b99eed0c upstream. + +While handling an error during transfer (ex: NACK), it could +happen that the driver has already written data into TXDR +before the transfer get stopped. +This commit add TXDR Flush after end of transfer in case of error to +avoid sending a wrong data on any other slave upon next transfer. + +Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver") +Signed-off-by: Alain Volmat +Reviewed-by: Pierre-Yves MORDRET +Signed-off-by: Wolfram Sang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/i2c/busses/i2c-stm32f7.c | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +--- a/drivers/i2c/busses/i2c-stm32f7.c ++++ b/drivers/i2c/busses/i2c-stm32f7.c +@@ -1586,6 +1586,16 @@ static int stm32f7_i2c_xfer(struct i2c_a + time_left = wait_for_completion_timeout(&i2c_dev->complete, + i2c_dev->adap.timeout); + ret = f7_msg->result; ++ if (ret) { ++ /* ++ * It is possible that some unsent data have already been ++ * written into TXDR. To avoid sending old data in a ++ * further transfer, flush TXDR in case of any error ++ */ ++ writel_relaxed(STM32F7_I2C_ISR_TXE, ++ i2c_dev->base + STM32F7_I2C_ISR); ++ goto pm_free; ++ } + + if (!time_left) { + dev_dbg(i2c_dev->dev, "Access to slave 0x%x timed out\n", +@@ -1634,8 +1644,16 @@ static int stm32f7_i2c_smbus_xfer(struct + timeout = wait_for_completion_timeout(&i2c_dev->complete, + i2c_dev->adap.timeout); + ret = f7_msg->result; +- if (ret) ++ if (ret) { ++ /* ++ * It is possible that some unsent data have already been ++ * written into TXDR. To avoid sending old data in a ++ * further transfer, flush TXDR in case of any error ++ */ ++ writel_relaxed(STM32F7_I2C_ISR_TXE, ++ i2c_dev->base + STM32F7_I2C_ISR); + goto pm_free; ++ } + + if (!timeout) { + dev_dbg(dev, "Access to slave 0x%x timed out\n", f7_msg->addr); diff --git a/queue-5.4/i2c-stm32f7-recover-the-bus-on-access-timeout.patch b/queue-5.4/i2c-stm32f7-recover-the-bus-on-access-timeout.patch new file mode 100644 index 00000000000..c08e9171365 --- /dev/null +++ b/queue-5.4/i2c-stm32f7-recover-the-bus-on-access-timeout.patch @@ -0,0 +1,39 @@ +From b933d1faf8fa30d16171bcff404e39c41b2a7c84 Mon Sep 17 00:00:00 2001 +From: Alain Volmat +Date: Mon, 20 Sep 2021 17:21:30 +0200 +Subject: i2c: stm32f7: recover the bus on access timeout + +From: Alain Volmat + +commit b933d1faf8fa30d16171bcff404e39c41b2a7c84 upstream. + +When getting an access timeout, ensure that the bus is in a proper +state prior to returning the error. + +Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver") +Signed-off-by: Alain Volmat +Reviewed-by: Pierre-Yves MORDRET +Signed-off-by: Wolfram Sang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/i2c/busses/i2c-stm32f7.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/i2c/busses/i2c-stm32f7.c ++++ b/drivers/i2c/busses/i2c-stm32f7.c +@@ -1602,6 +1602,7 @@ static int stm32f7_i2c_xfer(struct i2c_a + i2c_dev->msg->addr); + if (i2c_dev->use_dma) + dmaengine_terminate_all(dma->chan_using); ++ stm32f7_i2c_wait_free_bus(i2c_dev); + ret = -ETIMEDOUT; + } + +@@ -1659,6 +1660,7 @@ static int stm32f7_i2c_smbus_xfer(struct + dev_dbg(dev, "Access to slave 0x%x timed out\n", f7_msg->addr); + if (i2c_dev->use_dma) + dmaengine_terminate_all(dma->chan_using); ++ stm32f7_i2c_wait_free_bus(i2c_dev); + ret = -ETIMEDOUT; + goto pm_free; + } diff --git a/queue-5.4/i2c-stm32f7-stop-dma-transfer-in-case-of-nack.patch b/queue-5.4/i2c-stm32f7-stop-dma-transfer-in-case-of-nack.patch new file mode 100644 index 00000000000..bf064a25c99 --- /dev/null +++ b/queue-5.4/i2c-stm32f7-stop-dma-transfer-in-case-of-nack.patch @@ -0,0 +1,63 @@ +From 31b90a95ccbbb4b628578ac17e3b3cc8eeacfe31 Mon Sep 17 00:00:00 2001 +From: Alain Volmat +Date: Mon, 20 Sep 2021 17:21:31 +0200 +Subject: i2c: stm32f7: stop dma transfer in case of NACK + +From: Alain Volmat + +commit 31b90a95ccbbb4b628578ac17e3b3cc8eeacfe31 upstream. + +In case of receiving a NACK, the dma transfer should be stopped +to avoid feeding data into the FIFO. +Also ensure to properly return the proper error code and avoid +waiting for the end of the dma completion in case of +error happening during the transmission. + +Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support") +Signed-off-by: Alain Volmat +Reviewed-by: Pierre-Yves MORDRET +Signed-off-by: Wolfram Sang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/i2c/busses/i2c-stm32f7.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/drivers/i2c/busses/i2c-stm32f7.c ++++ b/drivers/i2c/busses/i2c-stm32f7.c +@@ -1394,6 +1394,7 @@ static irqreturn_t stm32f7_i2c_isr_event + { + struct stm32f7_i2c_dev *i2c_dev = data; + struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg; ++ struct stm32_i2c_dma *dma = i2c_dev->dma; + void __iomem *base = i2c_dev->base; + u32 status, mask; + int ret = IRQ_HANDLED; +@@ -1418,6 +1419,10 @@ static irqreturn_t stm32f7_i2c_isr_event + if (status & STM32F7_I2C_ISR_NACKF) { + dev_dbg(i2c_dev->dev, "<%s>: Receive NACK\n", __func__); + writel_relaxed(STM32F7_I2C_ICR_NACKCF, base + STM32F7_I2C_ICR); ++ if (i2c_dev->use_dma) { ++ stm32f7_i2c_disable_dma_req(i2c_dev); ++ dmaengine_terminate_all(dma->chan_using); ++ } + f7_msg->result = -ENXIO; + } + +@@ -1433,7 +1438,7 @@ static irqreturn_t stm32f7_i2c_isr_event + /* Clear STOP flag */ + writel_relaxed(STM32F7_I2C_ICR_STOPCF, base + STM32F7_I2C_ICR); + +- if (i2c_dev->use_dma) { ++ if (i2c_dev->use_dma && !f7_msg->result) { + ret = IRQ_WAKE_THREAD; + } else { + i2c_dev->master_mode = false; +@@ -1446,7 +1451,7 @@ static irqreturn_t stm32f7_i2c_isr_event + if (f7_msg->stop) { + mask = STM32F7_I2C_CR2_STOP; + stm32f7_i2c_set_bits(base + STM32F7_I2C_CR2, mask); +- } else if (i2c_dev->use_dma) { ++ } else if (i2c_dev->use_dma && !f7_msg->result) { + ret = IRQ_WAKE_THREAD; + } else if (f7_msg->smbus) { + stm32f7_i2c_smbus_rep_start(i2c_dev); diff --git a/queue-5.4/natsemi-xtensa-fix-section-mismatch-warnings.patch b/queue-5.4/natsemi-xtensa-fix-section-mismatch-warnings.patch new file mode 100644 index 00000000000..6afe29eac09 --- /dev/null +++ b/queue-5.4/natsemi-xtensa-fix-section-mismatch-warnings.patch @@ -0,0 +1,51 @@ +From b0f38e15979fa8851e88e8aa371367f264e7b6e9 Mon Sep 17 00:00:00 2001 +From: Randy Dunlap +Date: Mon, 29 Nov 2021 22:39:47 -0800 +Subject: natsemi: xtensa: fix section mismatch warnings + +From: Randy Dunlap + +commit b0f38e15979fa8851e88e8aa371367f264e7b6e9 upstream. + +Fix section mismatch warnings in xtsonic. The first one appears to be +bogus and after fixing the second one, the first one is gone. + +WARNING: modpost: vmlinux.o(.text+0x529adc): Section mismatch in reference from the function sonic_get_stats() to the function .init.text:set_reset_devices() +The function sonic_get_stats() references +the function __init set_reset_devices(). +This is often because sonic_get_stats lacks a __init +annotation or the annotation of set_reset_devices is wrong. + +WARNING: modpost: vmlinux.o(.text+0x529b3b): Section mismatch in reference from the function xtsonic_probe() to the function .init.text:sonic_probe1() +The function xtsonic_probe() references +the function __init sonic_probe1(). +This is often because xtsonic_probe lacks a __init +annotation or the annotation of sonic_probe1 is wrong. + +Fixes: 74f2a5f0ef64 ("xtensa: Add support for the Sonic Ethernet device for the XT2000 board.") +Signed-off-by: Randy Dunlap +Reported-by: kernel test robot +Cc: Christophe JAILLET +Cc: Finn Thain +Cc: Chris Zankel +Cc: linux-xtensa@linux-xtensa.org +Cc: Thomas Bogendoerfer +Acked-by: Max Filippov +Link: https://lore.kernel.org/r/20211130063947.7529-1-rdunlap@infradead.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/natsemi/xtsonic.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/natsemi/xtsonic.c ++++ b/drivers/net/ethernet/natsemi/xtsonic.c +@@ -120,7 +120,7 @@ static const struct net_device_ops xtson + .ndo_set_mac_address = eth_mac_addr, + }; + +-static int __init sonic_probe1(struct net_device *dev) ++static int sonic_probe1(struct net_device *dev) + { + unsigned int silicon_revision; + struct sonic_local *lp = netdev_priv(dev); diff --git a/queue-5.4/net-mpls-fix-notifications-when-deleting-a-device.patch b/queue-5.4/net-mpls-fix-notifications-when-deleting-a-device.patch new file mode 100644 index 00000000000..87e2d019a06 --- /dev/null +++ b/queue-5.4/net-mpls-fix-notifications-when-deleting-a-device.patch @@ -0,0 +1,157 @@ +From 7d4741eacdefa5f0475431645b56baf00784df1f Mon Sep 17 00:00:00 2001 +From: Benjamin Poirier +Date: Mon, 29 Nov 2021 15:15:05 +0900 +Subject: net: mpls: Fix notifications when deleting a device + +From: Benjamin Poirier + +commit 7d4741eacdefa5f0475431645b56baf00784df1f upstream. + +There are various problems related to netlink notifications for mpls route +changes in response to interfaces being deleted: +* delete interface of only nexthop + DELROUTE notification is missing RTA_OIF attribute +* delete interface of non-last nexthop + NEWROUTE notification is missing entirely +* delete interface of last nexthop + DELROUTE notification is missing nexthop + +All of these problems stem from the fact that existing routes are modified +in-place before sending a notification. Restructure mpls_ifdown() to avoid +changing the route in the DELROUTE cases and to create a copy in the +NEWROUTE case. + +Fixes: f8efb73c97e2 ("mpls: multipath route support") +Signed-off-by: Benjamin Poirier +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/mpls/af_mpls.c | 68 ++++++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 52 insertions(+), 16 deletions(-) + +--- a/net/mpls/af_mpls.c ++++ b/net/mpls/af_mpls.c +@@ -1491,22 +1491,52 @@ static void mpls_dev_destroy_rcu(struct + kfree(mdev); + } + +-static void mpls_ifdown(struct net_device *dev, int event) ++static int mpls_ifdown(struct net_device *dev, int event) + { + struct mpls_route __rcu **platform_label; + struct net *net = dev_net(dev); +- u8 alive, deleted; + unsigned index; + + platform_label = rtnl_dereference(net->mpls.platform_label); + for (index = 0; index < net->mpls.platform_labels; index++) { + struct mpls_route *rt = rtnl_dereference(platform_label[index]); ++ bool nh_del = false; ++ u8 alive = 0; + + if (!rt) + continue; + +- alive = 0; +- deleted = 0; ++ if (event == NETDEV_UNREGISTER) { ++ u8 deleted = 0; ++ ++ for_nexthops(rt) { ++ struct net_device *nh_dev = ++ rtnl_dereference(nh->nh_dev); ++ ++ if (!nh_dev || nh_dev == dev) ++ deleted++; ++ if (nh_dev == dev) ++ nh_del = true; ++ } endfor_nexthops(rt); ++ ++ /* if there are no more nexthops, delete the route */ ++ if (deleted == rt->rt_nhn) { ++ mpls_route_update(net, index, NULL, NULL); ++ continue; ++ } ++ ++ if (nh_del) { ++ size_t size = sizeof(*rt) + rt->rt_nhn * ++ rt->rt_nh_size; ++ struct mpls_route *orig = rt; ++ ++ rt = kmalloc(size, GFP_KERNEL); ++ if (!rt) ++ return -ENOMEM; ++ memcpy(rt, orig, size); ++ } ++ } ++ + change_nexthops(rt) { + unsigned int nh_flags = nh->nh_flags; + +@@ -1530,16 +1560,15 @@ static void mpls_ifdown(struct net_devic + next: + if (!(nh_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN))) + alive++; +- if (!rtnl_dereference(nh->nh_dev)) +- deleted++; + } endfor_nexthops(rt); + + WRITE_ONCE(rt->rt_nhn_alive, alive); + +- /* if there are no more nexthops, delete the route */ +- if (event == NETDEV_UNREGISTER && deleted == rt->rt_nhn) +- mpls_route_update(net, index, NULL, NULL); ++ if (nh_del) ++ mpls_route_update(net, index, rt, NULL); + } ++ ++ return 0; + } + + static void mpls_ifup(struct net_device *dev, unsigned int flags) +@@ -1607,8 +1636,12 @@ static int mpls_dev_notify(struct notifi + return NOTIFY_OK; + + switch (event) { ++ int err; ++ + case NETDEV_DOWN: +- mpls_ifdown(dev, event); ++ err = mpls_ifdown(dev, event); ++ if (err) ++ return notifier_from_errno(err); + break; + case NETDEV_UP: + flags = dev_get_flags(dev); +@@ -1619,13 +1652,18 @@ static int mpls_dev_notify(struct notifi + break; + case NETDEV_CHANGE: + flags = dev_get_flags(dev); +- if (flags & (IFF_RUNNING | IFF_LOWER_UP)) ++ if (flags & (IFF_RUNNING | IFF_LOWER_UP)) { + mpls_ifup(dev, RTNH_F_DEAD | RTNH_F_LINKDOWN); +- else +- mpls_ifdown(dev, event); ++ } else { ++ err = mpls_ifdown(dev, event); ++ if (err) ++ return notifier_from_errno(err); ++ } + break; + case NETDEV_UNREGISTER: +- mpls_ifdown(dev, event); ++ err = mpls_ifdown(dev, event); ++ if (err) ++ return notifier_from_errno(err); + mdev = mpls_dev_get(dev); + if (mdev) { + mpls_dev_sysctl_unregister(dev, mdev); +@@ -1636,8 +1674,6 @@ static int mpls_dev_notify(struct notifi + case NETDEV_CHANGENAME: + mdev = mpls_dev_get(dev); + if (mdev) { +- int err; +- + mpls_dev_sysctl_unregister(dev, mdev); + err = mpls_dev_sysctl_register(dev, mdev); + if (err) diff --git a/queue-5.4/net-qlogic-qlcnic-fix-a-null-pointer-dereference-in-qlcnic_83xx_add_rings.patch b/queue-5.4/net-qlogic-qlcnic-fix-a-null-pointer-dereference-in-qlcnic_83xx_add_rings.patch new file mode 100644 index 00000000000..d729646e3b3 --- /dev/null +++ b/queue-5.4/net-qlogic-qlcnic-fix-a-null-pointer-dereference-in-qlcnic_83xx_add_rings.patch @@ -0,0 +1,59 @@ +From e2dabc4f7e7b60299c20a36d6a7b24ed9bf8e572 Mon Sep 17 00:00:00 2001 +From: Zhou Qingyang +Date: Tue, 30 Nov 2021 19:08:48 +0800 +Subject: net: qlogic: qlcnic: Fix a NULL pointer dereference in qlcnic_83xx_add_rings() + +From: Zhou Qingyang + +commit e2dabc4f7e7b60299c20a36d6a7b24ed9bf8e572 upstream. + +In qlcnic_83xx_add_rings(), the indirect function of +ahw->hw_ops->alloc_mbx_args will be called to allocate memory for +cmd.req.arg, and there is a dereference of it in qlcnic_83xx_add_rings(), +which could lead to a NULL pointer dereference on failure of the +indirect function like qlcnic_83xx_alloc_mbx_args(). + +Fix this bug by adding a check of alloc_mbx_args(), this patch +imitates the logic of mbx_cmd()'s failure handling. + +This bug was found by a static analyzer. The analysis employs +differential checking to identify inconsistent security operations +(e.g., checks or kfrees) between two code paths and confirms that the +inconsistent operations are not recovered in the current function or +the callers, so they constitute bugs. + +Note that, as a bug found by static analysis, it can be a false +positive or hard to trigger. Multiple researchers have cross-reviewed +the bug. + +Builds with CONFIG_QLCNIC=m show no new warnings, and our +static analyzer no longer warns about this code. + +Fixes: 7f9664525f9c ("qlcnic: 83xx memory map and HW access routine") +Signed-off-by: Zhou Qingyang +Link: https://lore.kernel.org/r/20211130110848.109026-1-zhou1615@umn.edu +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +@@ -1079,8 +1079,14 @@ static int qlcnic_83xx_add_rings(struct + sds_mbx_size = sizeof(struct qlcnic_sds_mbx); + context_id = recv_ctx->context_id; + num_sds = adapter->drv_sds_rings - QLCNIC_MAX_SDS_RINGS; +- ahw->hw_ops->alloc_mbx_args(&cmd, adapter, +- QLCNIC_CMD_ADD_RCV_RINGS); ++ err = ahw->hw_ops->alloc_mbx_args(&cmd, adapter, ++ QLCNIC_CMD_ADD_RCV_RINGS); ++ if (err) { ++ dev_err(&adapter->pdev->dev, ++ "Failed to alloc mbx args %d\n", err); ++ return err; ++ } ++ + cmd.req.arg[1] = 0 | (num_sds << 8) | (context_id << 16); + + /* set up status rings, mbx 2-81 */ diff --git a/queue-5.4/series b/queue-5.4/series index ab0b72833ff..e7c002960d6 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -29,3 +29,11 @@ s390-pci-move-pseudo-mmio-to-prevent-mio-overlap.patch fget-check-that-the-fd-still-exists-after-getting-a-ref-to-it.patch sata_fsl-fix-uaf-in-sata_fsl_port_stop-when-rmmod-sata_fsl.patch sata_fsl-fix-warning-in-remove_proc_entry-when-rmmod-sata_fsl.patch +i2c-stm32f7-flush-tx-fifo-upon-transfer-errors.patch +i2c-stm32f7-recover-the-bus-on-access-timeout.patch +i2c-stm32f7-stop-dma-transfer-in-case-of-nack.patch +i2c-cbus-gpio-set-atomic-transfer-callback.patch +natsemi-xtensa-fix-section-mismatch-warnings.patch +net-qlogic-qlcnic-fix-a-null-pointer-dereference-in-qlcnic_83xx_add_rings.patch +net-mpls-fix-notifications-when-deleting-a-device.patch +siphash-use-_unaligned-version-by-default.patch diff --git a/queue-5.4/siphash-use-_unaligned-version-by-default.patch b/queue-5.4/siphash-use-_unaligned-version-by-default.patch new file mode 100644 index 00000000000..2a07f2712a3 --- /dev/null +++ b/queue-5.4/siphash-use-_unaligned-version-by-default.patch @@ -0,0 +1,185 @@ +From f7e5b9bfa6c8820407b64eabc1f29c9a87e8993d Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Mon, 29 Nov 2021 10:39:29 -0500 +Subject: siphash: use _unaligned version by default + +From: Arnd Bergmann + +commit f7e5b9bfa6c8820407b64eabc1f29c9a87e8993d upstream. + +On ARM v6 and later, we define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +because the ordinary load/store instructions (ldr, ldrh, ldrb) can +tolerate any misalignment of the memory address. However, load/store +double and load/store multiple instructions (ldrd, ldm) may still only +be used on memory addresses that are 32-bit aligned, and so we have to +use the CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS macro with care, or we +may end up with a severe performance hit due to alignment traps that +require fixups by the kernel. Testing shows that this currently happens +with clang-13 but not gcc-11. In theory, any compiler version can +produce this bug or other problems, as we are dealing with undefined +behavior in C99 even on architectures that support this in hardware, +see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100363. + +Fortunately, the get_unaligned() accessors do the right thing: when +building for ARMv6 or later, the compiler will emit unaligned accesses +using the ordinary load/store instructions (but avoid the ones that +require 32-bit alignment). When building for older ARM, those accessors +will emit the appropriate sequence of ldrb/mov/orr instructions. And on +architectures that can truly tolerate any kind of misalignment, the +get_unaligned() accessors resolve to the leXX_to_cpup accessors that +operate on aligned addresses. + +Since the compiler will in fact emit ldrd or ldm instructions when +building this code for ARM v6 or later, the solution is to use the +unaligned accessors unconditionally on architectures where this is +known to be fast. The _aligned version of the hash function is +however still needed to get the best performance on architectures +that cannot do any unaligned access in hardware. + +This new version avoids the undefined behavior and should produce +the fastest hash on all architectures we support. + +Link: https://lore.kernel.org/linux-arm-kernel/20181008211554.5355-4-ard.biesheuvel@linaro.org/ +Link: https://lore.kernel.org/linux-crypto/CAK8P3a2KfmmGDbVHULWevB0hv71P2oi2ZCHEAqT=8dQfa0=cqQ@mail.gmail.com/ +Reported-by: Ard Biesheuvel +Fixes: 2c956a60778c ("siphash: add cryptographically secure PRF") +Signed-off-by: Arnd Bergmann +Reviewed-by: Jason A. Donenfeld +Acked-by: Ard Biesheuvel +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/siphash.h | 14 ++++---------- + lib/siphash.c | 12 ++++++------ + 2 files changed, 10 insertions(+), 16 deletions(-) + +--- a/include/linux/siphash.h ++++ b/include/linux/siphash.h +@@ -27,9 +27,7 @@ static inline bool siphash_key_is_zero(c + } + + u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key); +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key); +-#endif + + u64 siphash_1u64(const u64 a, const siphash_key_t *key); + u64 siphash_2u64(const u64 a, const u64 b, const siphash_key_t *key); +@@ -82,10 +80,9 @@ static inline u64 ___siphash_aligned(con + static inline u64 siphash(const void *data, size_t len, + const siphash_key_t *key) + { +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +- if (!IS_ALIGNED((unsigned long)data, SIPHASH_ALIGNMENT)) ++ if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || ++ !IS_ALIGNED((unsigned long)data, SIPHASH_ALIGNMENT)) + return __siphash_unaligned(data, len, key); +-#endif + return ___siphash_aligned(data, len, key); + } + +@@ -96,10 +93,8 @@ typedef struct { + + u32 __hsiphash_aligned(const void *data, size_t len, + const hsiphash_key_t *key); +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u32 __hsiphash_unaligned(const void *data, size_t len, + const hsiphash_key_t *key); +-#endif + + u32 hsiphash_1u32(const u32 a, const hsiphash_key_t *key); + u32 hsiphash_2u32(const u32 a, const u32 b, const hsiphash_key_t *key); +@@ -135,10 +130,9 @@ static inline u32 ___hsiphash_aligned(co + static inline u32 hsiphash(const void *data, size_t len, + const hsiphash_key_t *key) + { +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +- if (!IS_ALIGNED((unsigned long)data, HSIPHASH_ALIGNMENT)) ++ if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || ++ !IS_ALIGNED((unsigned long)data, HSIPHASH_ALIGNMENT)) + return __hsiphash_unaligned(data, len, key); +-#endif + return ___hsiphash_aligned(data, len, key); + } + +--- a/lib/siphash.c ++++ b/lib/siphash.c +@@ -49,6 +49,7 @@ + SIPROUND; \ + return (v0 ^ v1) ^ (v2 ^ v3); + ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key) + { + const u8 *end = data + len - (len % sizeof(u64)); +@@ -80,8 +81,8 @@ u64 __siphash_aligned(const void *data, + POSTAMBLE + } + EXPORT_SYMBOL(__siphash_aligned); ++#endif + +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key) + { + const u8 *end = data + len - (len % sizeof(u64)); +@@ -113,7 +114,6 @@ u64 __siphash_unaligned(const void *data + POSTAMBLE + } + EXPORT_SYMBOL(__siphash_unaligned); +-#endif + + /** + * siphash_1u64 - compute 64-bit siphash PRF value of a u64 +@@ -250,6 +250,7 @@ EXPORT_SYMBOL(siphash_3u32); + HSIPROUND; \ + return (v0 ^ v1) ^ (v2 ^ v3); + ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key) + { + const u8 *end = data + len - (len % sizeof(u64)); +@@ -280,8 +281,8 @@ u32 __hsiphash_aligned(const void *data, + HPOSTAMBLE + } + EXPORT_SYMBOL(__hsiphash_aligned); ++#endif + +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u32 __hsiphash_unaligned(const void *data, size_t len, + const hsiphash_key_t *key) + { +@@ -313,7 +314,6 @@ u32 __hsiphash_unaligned(const void *dat + HPOSTAMBLE + } + EXPORT_SYMBOL(__hsiphash_unaligned); +-#endif + + /** + * hsiphash_1u32 - compute 64-bit hsiphash PRF value of a u32 +@@ -418,6 +418,7 @@ EXPORT_SYMBOL(hsiphash_4u32); + HSIPROUND; \ + return v1 ^ v3; + ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key) + { + const u8 *end = data + len - (len % sizeof(u32)); +@@ -438,8 +439,8 @@ u32 __hsiphash_aligned(const void *data, + HPOSTAMBLE + } + EXPORT_SYMBOL(__hsiphash_aligned); ++#endif + +-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + u32 __hsiphash_unaligned(const void *data, size_t len, + const hsiphash_key_t *key) + { +@@ -461,7 +462,6 @@ u32 __hsiphash_unaligned(const void *dat + HPOSTAMBLE + } + EXPORT_SYMBOL(__hsiphash_unaligned); +-#endif + + /** + * hsiphash_1u32 - compute 32-bit hsiphash PRF value of a u32