From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87635C19F28 for ; Wed, 27 Jul 2022 17:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238204AbiG0R0d (ORCPT ); Wed, 27 Jul 2022 13:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbiG0RZV (ORCPT ); Wed, 27 Jul 2022 13:25:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792215FADA; Wed, 27 Jul 2022 09:46:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F99561560; Wed, 27 Jul 2022 16:46:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D911C433D7; Wed, 27 Jul 2022 16:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940396; bh=xmzjyxsesrVir23dMT/MhOAnIeNp3qCflA/JyTIZJGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=su/mHB16+LhuZSLjnzWkdASyESTrW3PDnCN8j51ob/8pbcqB5QNs1qCzwTCw1xTdx Y2o2CaO7mbDYeO8ckJPTgudZHA2Co4HBXStU/NHvB5Pb0WKllIdH0c147Rc7fnutSp Ekp3aFTge+Hf7TYzRO7YKJ0kuUWAxi97guY/bv1c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Linus Walleij Subject: [PATCH 5.18 001/158] pinctrl: armada-37xx: use raw spinlocks for regmap to avoid invalid wait context Date: Wed, 27 Jul 2022 18:11:05 +0200 Message-Id: <20220727161021.487449726@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean commit 4546760619cfa9b718fe2059ceb07101cf9ff61e upstream. The irqchip->irq_set_type method is called by __irq_set_trigger() under the desc->lock raw spinlock. The armada-37xx implementation, armada_37xx_irq_set_type(), uses an MMIO regmap created by of_syscon_register(), which uses plain spinlocks (the kind that are sleepable on RT). Therefore, this is an invalid locking scheme for which we get a kernel splat stating just that ("[ BUG: Invalid wait context ]"), because the context in which the plain spinlock may sleep is atomic due to the raw spinlock. We need to go raw spinlocks all the way. Make this driver create its own MMIO regmap, with use_raw_spinlock=3Dtrue, and stop relying on syscon to provide it. This patch depends on commit 67021f25d952 ("regmap: teach regmap to use raw spinlocks if requested in the config"). Cc: # 5.15+ Fixes: 2f227605394b ("pinctrl: armada-37xx: Add irqchip support") Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220716233745.1704677-3-vladimir.oltean@nx= p.com Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 27 +++++++++++++++++++++--= ---- 1 file changed, 21 insertions(+), 6 deletions(-) --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -1121,25 +1121,40 @@ static const struct of_device_id armada_ { }, }; =20 +static const struct regmap_config armada_37xx_pinctrl_regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, + .use_raw_spinlock =3D true, +}; + static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev) { struct armada_37xx_pinctrl *info; struct device *dev =3D &pdev->dev; - struct device_node *np =3D dev->of_node; struct regmap *regmap; + void __iomem *base; int ret; =20 + base =3D devm_platform_get_and_ioremap_resource(pdev, 0, NULL); + if (IS_ERR(base)) { + dev_err(dev, "failed to ioremap base address: %pe\n", base); + return PTR_ERR(base); + } + + regmap =3D devm_regmap_init_mmio(dev, base, + &armada_37xx_pinctrl_regmap_config); + if (IS_ERR(regmap)) { + dev_err(dev, "failed to create regmap: %pe\n", regmap); + return PTR_ERR(regmap); + } + info =3D devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; =20 info->dev =3D dev; - - regmap =3D syscon_node_to_regmap(np); - if (IS_ERR(regmap)) - return dev_err_probe(dev, PTR_ERR(regmap), "cannot get regmap\n"); info->regmap =3D regmap; - info->data =3D of_device_get_match_data(dev); =20 ret =3D armada_37xx_pinctrl_register(pdev, info); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADE0FC04A68 for ; Wed, 27 Jul 2022 17:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242143AbiG0R2T (ORCPT ); Wed, 27 Jul 2022 13:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241485AbiG0R1b (ORCPT ); Wed, 27 Jul 2022 13:27:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE6D7E83A; Wed, 27 Jul 2022 09:47:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0B2D3B821BE; Wed, 27 Jul 2022 16:47:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B4AEC4347C; Wed, 27 Jul 2022 16:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940427; bh=0RyaagzoJehFp4OnNWJ66rEEeBYyrXWn1vmn7EOA0OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tarvzgdnSPN+IuyxGGw1diutkYg8QYBqeWCkCKisVwB1d2aQ+SJsQvJ09zGmv4l4W 3YetAl2jCtEE+xwU5Lz+dxqwWaC5hTN8FkOAIY99pr+UVahJ3afkYq4VG0MnTqs28r 3End9/+zn55CH/RTRyCKokr5KWRBvEGIknJibEnw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabien Dessenne , Linus Walleij Subject: [PATCH 5.18 002/158] pinctrl: stm32: fix optional IRQ support to gpios Date: Wed, 27 Jul 2022 18:11:06 +0200 Message-Id: <20220727161021.529993485@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Fabien Dessenne commit a1d4ef1adf8bbd302067534ead671a94759687ed upstream. To act as an interrupt controller, a gpio bank relies on the "interrupt-parent" of the pin controller. When this optional "interrupt-parent" misses, do not create any IRQ domain. This fixes a "NULL pointer in stm32_gpio_domain_alloc()" kernel crash when the interrupt-parent =3D property is not declared in the Device Tree. Fixes: 0eb9f683336d ("pinctrl: Add IRQ support to STM32 gpios") Signed-off-by: Fabien Dessenne Link: https://lore.kernel.org/r/20220627142350.742973-1-fabien.dessenne@fos= s.st.com Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/stm32/pinctrl-stm32.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1299,15 +1299,17 @@ static int stm32_gpiolib_register_bank(s bank->bank_ioport_nr =3D bank_ioport_nr; spin_lock_init(&bank->lock); =20 - /* create irq hierarchical domain */ - bank->fwnode =3D of_node_to_fwnode(np); + if (pctl->domain) { + /* create irq hierarchical domain */ + bank->fwnode =3D of_node_to_fwnode(np); + + bank->domain =3D irq_domain_create_hierarchy(pctl->domain, 0, STM32_GPIO= _IRQ_LINE, + bank->fwnode, &stm32_gpio_domain_ops, + bank); =20 - bank->domain =3D irq_domain_create_hierarchy(pctl->domain, 0, - STM32_GPIO_IRQ_LINE, bank->fwnode, - &stm32_gpio_domain_ops, bank); - - if (!bank->domain) - return -ENODEV; + if (!bank->domain) + return -ENODEV; + } =20 err =3D gpiochip_add_data(&bank->gpio_chip, bank); if (err) { @@ -1466,6 +1468,8 @@ int stm32_pctl_probe(struct platform_dev pctl->domain =3D stm32_pctrl_get_irq_domain(np); if (IS_ERR(pctl->domain)) return PTR_ERR(pctl->domain); + if (!pctl->domain) + dev_warn(dev, "pinctrl without interrupt support\n"); =20 /* hwspinlock is optional */ hwlock_id =3D of_hwspin_lock_get_id(pdev->dev.of_node, 0); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FA9CC04A68 for ; Wed, 27 Jul 2022 17:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241677AbiG0RcP (ORCPT ); Wed, 27 Jul 2022 13:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242519AbiG0R3t (ORCPT ); Wed, 27 Jul 2022 13:29:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B99A80F77; Wed, 27 Jul 2022 09:47:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3402360D3B; Wed, 27 Jul 2022 16:47:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35E4EC433C1; Wed, 27 Jul 2022 16:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940457; bh=V57nnVM33eJ0YzjDgclMIxQPLhibnX+EzUHblugqnqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yu+iESx9JagbICZikEjMS3LSJPCJhzcOkTMkP+94hMGmJ66LOxSvzcckXcQXH5RgC bP75kzWNCavVa/tTmPT36xzpQSFip6m0uUTsBnV3zi08xrgC3hmFbx2kOg9oQKgLES HUfLJGPT68O2R+hCshYF6mNzX59XcKn+4kM2f5Y4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Dooks , Bin Meng , Palmer Dabbelt Subject: [PATCH 5.18 003/158] riscv: add as-options for modules with assembly compontents Date: Wed, 27 Jul 2022 18:11:07 +0200 Message-Id: <20220727161021.578776695@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ben Dooks commit c1f6eff304e4dfa4558b6a8c6b2d26a91db6c998 upstream. When trying to load modules built for RISC-V which include assembly files the kernel loader errors with "unexpected relocation type 'R_RISCV_ALIGN'" due to R_RISCV_ALIGN relocations being generated by the assembler. The R_RISCV_ALIGN relocations can be removed at the expense of code space by adding -mno-relax to gcc and as. In commit 7a8e7da42250138 ("RISC-V: Fixes to module loading") -mno-relax is added to the build variable KBUILD_CFLAGS_MODULE. See [1] for more info. The issue is that when kbuild builds a .S file, it invokes gcc with the -mno-relax flag, but this is not being passed through to the assembler. Adding -Wa,-mno-relax to KBUILD_AFLAGS_MODULE ensures that the assembler is invoked correctly. This may have now been fixed in gcc[2] and this addition should not stop newer gcc and as from working. [1] https://github.com/riscv/riscv-elf-psabi-doc/issues/183 [2] https://github.com/gcc-mirror/gcc/commit/3b0a7d624e64eeb81e4d5e8c62c46d= 86ef521857 Signed-off-by: Ben Dooks Reviewed-by: Bin Meng Link: https://lore.kernel.org/r/20220529152200.609809-1-ben.dooks@codethink= .co.uk Fixes: ab1ef68e5401 ("RISC-V: Add sections of PLT and GOT for kernel module= ") Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/riscv/Makefile | 1 + 1 file changed, 1 insertion(+) --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -73,6 +73,7 @@ ifeq ($(CONFIG_PERF_EVENTS),y) endif =20 KBUILD_CFLAGS_MODULE +=3D $(call cc-option,-mno-relax) +KBUILD_AFLAGS_MODULE +=3D $(call as-option,-Wa$(comma)-mno-relax) =20 # GCC versions that support the "-mstrict-align" option default to allowing # unaligned accesses. While unaligned accesses are explicitly allowed in = the From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B0CC04A68 for ; Wed, 27 Jul 2022 17:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242371AbiG0Rb4 (ORCPT ); Wed, 27 Jul 2022 13:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242333AbiG0R30 (ORCPT ); Wed, 27 Jul 2022 13:29:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18427FE7B; Wed, 27 Jul 2022 09:47:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D9A3FB821BA; Wed, 27 Jul 2022 16:47:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D167C433B5; Wed, 27 Jul 2022 16:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940460; bh=u+VHCb/+dwB55XLu8E0kajWD5E5d65pkG7VtzbRaIRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GE7aASv8ZGhw1lCBZKwAVzcEGc2fIFe7UfWBhQe6cU8w0A8OkluKetPdfyNGKk7rX adJKssi1Ed0Tk9gOuXTXOJx6oyHQjOv3Vw/2k0cQFjogi1+oP3L/jqaQQ5LpFYMYtc eAsPyqFoVDwCOS1ZD7gKZQt4UzNI0GAnUdmWWrCU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Amit Cohen , Nicolas Dichtel , David Ahern , "David S. Miller" Subject: [PATCH 5.18 004/158] mlxsw: spectrum_router: Fix IPv4 nexthop gateway indication Date: Wed, 27 Jul 2022 18:11:08 +0200 Message-Id: <20220727161021.619318517@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ido Schimmel commit e5ec6a2513383fe2ecc2ee3b5f51d97acbbcd4d8 upstream. mlxsw needs to distinguish nexthops with a gateway from connected nexthops in order to write the former to the adjacency table of the device. The check used to rely on the fact that nexthops with a gateway have a 'link' scope whereas connected nexthops have a 'host' scope. This is no longer correct after commit 747c14307214 ("ip: fix dflt addr selection for connected nexthop"). Fix that by instead checking the address family of the gateway IP. This is a more direct way and also consistent with the IPv6 counterpart in mlxsw_sp_rt6_is_gateway(). Cc: stable@vger.kernel.org Fixes: 747c14307214 ("ip: fix dflt addr selection for connected nexthop") Fixes: 597cfe4fc339 ("nexthop: Add support for IPv4 nexthops") Signed-off-by: Ido Schimmel Reviewed-by: Amit Cohen Reviewed-by: Nicolas Dichtel Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -5387,7 +5387,7 @@ static bool mlxsw_sp_fi_is_gateway(const { const struct fib_nh *nh =3D fib_info_nh(fi, 0); =20 - return nh->fib_nh_scope =3D=3D RT_SCOPE_LINK || + return nh->fib_nh_gw_family || mlxsw_sp_nexthop4_ipip_type(mlxsw_sp, nh, NULL); } From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10CBEC04A68 for ; Wed, 27 Jul 2022 17:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242375AbiG0RcB (ORCPT ); Wed, 27 Jul 2022 13:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242385AbiG0R3c (ORCPT ); Wed, 27 Jul 2022 13:29:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0284952DF1; Wed, 27 Jul 2022 09:47:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9BB6AB821D2; Wed, 27 Jul 2022 16:47:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D755CC433C1; Wed, 27 Jul 2022 16:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940463; bh=m+MdzK3zbrk88iLvCTtfSb2ljfBx9asE8hnGNYWG9Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2JK6MAeOhwkgIY0tOMHTLZBQlj1PRjnwgK2ViqiarigWGi6tcxuukdRYbo+TNobeq aUkaW43FryG7esEp2sKFCel0ltigDeO74GEDJeMHgtSAj7uoGLerALcph7y+j9O7GD HSypBxcT2lognDBFNip7E9ytmJh7icNhqb2eTmos= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Snowberg , Mimi Zohar , John Haxby , Linus Torvalds Subject: [PATCH 5.18 005/158] lockdown: Fix kexec lockdown bypass with ima policy Date: Wed, 27 Jul 2022 18:11:09 +0200 Message-Id: <20220727161021.663655785@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Snowberg commit 543ce63b664e2c2f9533d089a4664b559c3e6b5b upstream. The lockdown LSM is primarily used in conjunction with UEFI Secure Boot. This LSM may also be used on machines without UEFI. It can also be enabled when UEFI Secure Boot is disabled. One of lockdown's features is to prevent kexec from loading untrusted kernels. Lockdown can be enabled through a bootparam or after the kernel has booted through securityfs. If IMA appraisal is used with the "ima_appraise=3Dlog" boot param, lockdown can be defeated with kexec on any machine when Secure Boot is disabled or unavailable. IMA prevents setting "ima_appraise=3Dlog" from the boot param when Secure Boot is enabled, but this does not cover cases where lockdown is used without Secure Boot. To defeat lockdown, boot without Secure Boot and add ima_appraise=3Dlog to the kernel command line; then: $ echo "integrity" > /sys/kernel/security/lockdown $ echo "appraise func=3DKEXEC_KERNEL_CHECK appraise_type=3Dimasig" > \ /sys/kernel/security/ima/policy $ kexec -ls unsigned-kernel Add a call to verify ima appraisal is set to "enforce" whenever lockdown is enabled. This fixes CVE-2022-21505. Cc: stable@vger.kernel.org Fixes: 29d3c1c8dfe7 ("kexec: Allow kexec_file() with appropriate IMA policy= when locked down") Signed-off-by: Eric Snowberg Acked-by: Mimi Zohar Reviewed-by: John Haxby Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- security/integrity/ima/ima_policy.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -2181,6 +2181,10 @@ bool ima_appraise_signature(enum kernel_ if (id >=3D READING_MAX_ID) return false; =20 + if (id =3D=3D READING_KEXEC_IMAGE && !(ima_appraise & IMA_APPRAISE_ENFORC= E) + && security_locked_down(LOCKDOWN_KEXEC)) + return false; + func =3D read_idmap[id] ?: FILE_CHECK; =20 rcu_read_lock(); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D5C0C04A68 for ; Wed, 27 Jul 2022 17:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242175AbiG0RcY (ORCPT ); Wed, 27 Jul 2022 13:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242585AbiG0RaE (ORCPT ); Wed, 27 Jul 2022 13:30:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38485246C; Wed, 27 Jul 2022 09:48:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A23C600BE; Wed, 27 Jul 2022 16:47:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9943BC433C1; Wed, 27 Jul 2022 16:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940466; bh=LDTAR5XNGEs6IbAPArum+Jk2Iiza2SC3BANq8xb76xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1xOISjigE5jYPoVqbVcfrKCqkAX90p8HZbZ7BURSqVTFhkzCPSkkPIHJ2w7ff6GfZ 42bCXcO9jeuwaJn3JlRnDOe22e7z50I8qRofunRbhEFuhJarXzu6+eVuKgW0aog1zI SssQrerLwXWUlms3+D0yPYHHvyRj0Dfi53/3tuso= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yegor Yefremov , Arnd Bergmann , Tony Lindgren , Adrian Hunter , Ulf Hansson Subject: [PATCH 5.18 006/158] mmc: sdhci-omap: Fix a lockdep warning for PM runtime init Date: Wed, 27 Jul 2022 18:11:10 +0200 Message-Id: <20220727161021.703512831@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tony Lindgren commit 51189eb9ddc88851edc42f539a0f9862fd0630c2 upstream. We need runtime PM enabled early in probe before sdhci_setup_host() for sdhci_omap_set_capabilities(). But on the first runtime resume we must not call sdhci_runtime_resume_host() as sdhci_setup_host() has not been called yet. Let's check for an initialized controller like we already do for context restore to fix a lockdep warning. Fixes: f433e8aac6b9 ("mmc: sdhci-omap: Implement PM runtime functions") Reported-by: Yegor Yefremov Suggested-by: Arnd Bergmann Signed-off-by: Tony Lindgren Acked-by: Adrian Hunter Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220622051215.34063-1-tony@atomide.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/mmc/host/sdhci-omap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/drivers/mmc/host/sdhci-omap.c +++ b/drivers/mmc/host/sdhci-omap.c @@ -1303,8 +1303,9 @@ static int sdhci_omap_probe(struct platf /* * omap_device_pm_domain has callbacks to enable the main * functional clock, interface clock and also configure the - * SYSCONFIG register of omap devices. The callback will be invoked - * as part of pm_runtime_get_sync. + * SYSCONFIG register to clear any boot loader set voltage + * capabilities before calling sdhci_setup_host(). The + * callback will be invoked as part of pm_runtime_get_sync. */ pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, 50); @@ -1446,7 +1447,8 @@ static int __maybe_unused sdhci_omap_run struct sdhci_pltfm_host *pltfm_host =3D sdhci_priv(host); struct sdhci_omap_host *omap_host =3D sdhci_pltfm_priv(pltfm_host); =20 - sdhci_runtime_suspend_host(host); + if (omap_host->con !=3D -EINVAL) + sdhci_runtime_suspend_host(host); =20 sdhci_omap_context_save(omap_host); =20 @@ -1463,10 +1465,10 @@ static int __maybe_unused sdhci_omap_run =20 pinctrl_pm_select_default_state(dev); =20 - if (omap_host->con !=3D -EINVAL) + if (omap_host->con !=3D -EINVAL) { sdhci_omap_context_restore(omap_host); - - sdhci_runtime_resume_host(host, 0); + sdhci_runtime_resume_host(host, 0); + } =20 return 0; } From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 622EDC04A68 for ; Wed, 27 Jul 2022 17:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241218AbiG0RcH (ORCPT ); Wed, 27 Jul 2022 13:32:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242421AbiG0R3h (ORCPT ); Wed, 27 Jul 2022 13:29:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E43352DF3; Wed, 27 Jul 2022 09:47:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6927761556; Wed, 27 Jul 2022 16:47:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7085FC433C1; Wed, 27 Jul 2022 16:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940468; bh=MZS7xM2P/QhUfUhlJ/ZyYiAd7ucFRqtt4/MMoU+Odgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLesKRth8yXu9ox0rZf4LulVDyhFZhmdfDV8rNTP5XPBfZGqyDsXjCx1+kJc0H56S B+vI5SNaFN0nickEmLd4NCk5PxyUgnQCZkcfdxquXcjbm0Za0pKiS90faiq7Pk5S0V hD3DWzcss1R1LnWzdyXH0E/PPvmsNU6f2OOqew4k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sascha Hauer , Han Xu , =?UTF-8?q?Tomasz=20Mo=C5=84?= , Richard Weinberger Subject: [PATCH 5.18 007/158] mtd: rawnand: gpmi: Set WAIT_FOR_READY timeout based on program/erase times Date: Wed, 27 Jul 2022 18:11:11 +0200 Message-Id: <20220727161021.734636052@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sascha Hauer commit 0fddf9ad06fd9f439f137139861556671673e31c upstream. 06781a5026350 Fixes the calculation of the DEVICE_BUSY_TIMEOUT register value from busy_timeout_cycles. busy_timeout_cycles is calculated wrong though: It is calculated based on the maximum page read time, but the timeout is also used for page write and block erase operations which require orders of magnitude bigger timeouts. Fix this by calculating busy_timeout_cycles from the maximum of tBERS_max and tPROG_max. This is for now the easiest and most obvious way to fix the driver. There's room for improvements though: The NAND_OP_WAITRDY_INSTR tells us the desired timeout for the current operation, so we could program the timeout dynamically for each operation instead of setting a fixed timeout. Also we could wire up the interrupt handler to actually detect and forward timeouts occurred when waiting for the chip being ready. As a sidenote I verified that the change in 06781a5026350 is really correct. I wired up the interrupt handler in my tree and measured the time between starting the operation and the timeout interrupt handler coming in. The time increases 41us with each step in the timeout register which corresponds to 4096 clock cycles with the 99MHz clock that I have. Fixes: 06781a5026350 ("mtd: rawnand: gpmi: Fix setting busy timeout setting= ") Fixes: b1206122069aa ("mtd: rawniand: gpmi: use core timings instead of an = empirical derivation") Cc: stable@vger.kernel.org Signed-off-by: Sascha Hauer Acked-by: Han Xu Tested-by: Tomasz Mo=C5=84 Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -655,9 +655,10 @@ static int gpmi_nfc_compute_timings(stru unsigned int tRP_ps; bool use_half_period; int sample_delay_ps, sample_delay_factor; - u16 busy_timeout_cycles; + unsigned int busy_timeout_cycles; u8 wrn_dly_sel; unsigned long clk_rate, min_rate; + u64 busy_timeout_ps; =20 if (sdr->tRC_min >=3D 30000) { /* ONFI non-EDO modes [0-3] */ @@ -690,7 +691,8 @@ static int gpmi_nfc_compute_timings(stru addr_setup_cycles =3D TO_CYCLES(sdr->tALS_min, period_ps); data_setup_cycles =3D TO_CYCLES(sdr->tDS_min, period_ps); data_hold_cycles =3D TO_CYCLES(sdr->tDH_min, period_ps); - busy_timeout_cycles =3D TO_CYCLES(sdr->tWB_max + sdr->tR_max, period_ps); + busy_timeout_ps =3D max(sdr->tBERS_max, sdr->tPROG_max); + busy_timeout_cycles =3D TO_CYCLES(busy_timeout_ps, period_ps); =20 hw->timing0 =3D BF_GPMI_TIMING0_ADDRESS_SETUP(addr_setup_cycles) | BF_GPMI_TIMING0_DATA_HOLD(data_hold_cycles) | From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E20AC04A68 for ; Wed, 27 Jul 2022 17:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242252AbiG0Rcg (ORCPT ); Wed, 27 Jul 2022 13:32:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242251AbiG0Ra3 (ORCPT ); Wed, 27 Jul 2022 13:30:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD74F81B2F; Wed, 27 Jul 2022 09:48:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2871261479; Wed, 27 Jul 2022 16:47:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36C2AC433C1; Wed, 27 Jul 2022 16:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940471; bh=9tCpcYupvaxeRANDUq8GCP66gANHEGG8QwCZcmAUZjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=biiGTC1kaQnp34+WnNnKB/EyJmK9nJodVUdoso4tFv8yZ7hR0U6eGhzs5G/AmM2xn DPfNO6J38mi1h4PDbuXC3aaQonOQq+2KQSeoA7LJIy3JP0ntqiNdRd+yCsotOZJygR y0AbqkIjjzEdsMJlXN0qpuNSuap+kefc5B/Qh8oA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Dmitry Osipenko Subject: [PATCH 5.18 008/158] drm/ttm: fix locking in vmap/vunmap TTM GEM helpers Date: Wed, 27 Jul 2022 18:11:12 +0200 Message-Id: <20220727161021.764692072@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian K=C3=B6nig commit dbd0da2453c694f2f74651834d90fb280b57f151 upstream. I've stumbled over this while reviewing patches for DMA-buf and it looks like we completely messed the locking up here. In general most TTM function should only be called while holding the appropriate BO resv lock. Without this we could break the internal buffer object state here. Only compile tested! Signed-off-by: Christian K=C3=B6nig Fixes: 43676605f890 ("drm/ttm: Add vmap/vunmap to TTM and TTM GEM helpers") Cc: stable@vger.kernel.org Reviewed-by: Dmitry Osipenko Link: https://patchwork.freedesktop.org/patch/msgid/20220715111533.467012-1= -christian.koenig@amd.com Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpu/drm/drm_gem_ttm_helper.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/drm_gem_ttm_helper.c +++ b/drivers/gpu/drm/drm_gem_ttm_helper.c @@ -64,8 +64,13 @@ int drm_gem_ttm_vmap(struct drm_gem_obje struct iosys_map *map) { struct ttm_buffer_object *bo =3D drm_gem_ttm_of_gem(gem); + int ret; =20 - return ttm_bo_vmap(bo, map); + dma_resv_lock(gem->resv, NULL); + ret =3D ttm_bo_vmap(bo, map); + dma_resv_unlock(gem->resv); + + return ret; } EXPORT_SYMBOL(drm_gem_ttm_vmap); =20 @@ -82,7 +87,9 @@ void drm_gem_ttm_vunmap(struct drm_gem_o { struct ttm_buffer_object *bo =3D drm_gem_ttm_of_gem(gem); =20 + dma_resv_lock(gem->resv, NULL); ttm_bo_vunmap(bo, map); + dma_resv_unlock(gem->resv); } EXPORT_SYMBOL(drm_gem_ttm_vunmap); =20 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E2E8C04A68 for ; Wed, 27 Jul 2022 17:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242107AbiG0RcL (ORCPT ); Wed, 27 Jul 2022 13:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242506AbiG0R3s (ORCPT ); Wed, 27 Jul 2022 13:29:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0447E80F67; Wed, 27 Jul 2022 09:47:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 86E06B821D4; Wed, 27 Jul 2022 16:47:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E61D3C433D7; Wed, 27 Jul 2022 16:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940474; bh=RfQQQrVVHg+qrqR7Zwd2k658vR9G4P25h5UQdUhcilY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yc/pcTOqvirDRV+o8Gw10yLDExgi5PNEwUvRsXhCNKZ8I9DJ7z76qga+AwJD7bf9C lh9M/j39TH0zz6EFqwQ7QDGQcd4UI9qaxC6m7MYlndPnVYbtumq35FvXJz/Q3V+deF 1rg5HWW5j3kgkHlz26FCN/dUJVeTLm9yVZF3Vhuc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Kazlauskas , Solomon Chiu , Stylon Wang , Harry Wentland , Alex Deucher Subject: [PATCH 5.18 009/158] drm/amd/display: Fix new dmub notification enabling in DM Date: Wed, 27 Jul 2022 18:11:13 +0200 Message-Id: <20220727161021.801746226@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Stylon Wang commit 2d4bd81fea1ad6ebba543bd6da3ef5179d130e6a upstream. [Why] Changes from "Fix for dmub outbox notification enable" need to land in DM or DMUB outbox notification would be disabled. [How] Enable outbox notification only after interrupt are enabled and IRQ handlers registered. Any pending notification will be sent by DMUB once outbox notification is enabled. Fixes: ed7208706448 ("drm/amd/display: Fix for dmub outbox notification ena= ble") Reviewed-by: Nicholas Kazlauskas Acked-by: Solomon Chiu Signed-off-by: Stylon Wang Acked-by: Harry Wentland Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 27 +++++++++++++++--= ----- 1 file changed, 19 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1670,7 +1670,7 @@ static int amdgpu_dm_init(struct amdgpu_ #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY) adev->dm.crc_rd_wrk =3D amdgpu_dm_crtc_secure_display_create_work(); #endif - if (dc_enable_dmub_notifications(adev->dm.dc)) { + if (dc_is_dmub_outbox_supported(adev->dm.dc)) { init_completion(&adev->dm.dmub_aux_transfer_done); adev->dm.dmub_notify =3D kzalloc(sizeof(struct dmub_notification), GFP_K= ERNEL); if (!adev->dm.dmub_notify) { @@ -1708,6 +1708,13 @@ static int amdgpu_dm_init(struct amdgpu_ goto error; } =20 + /* Enable outbox notification only after IRQ handlers are registered and = DMUB is alive. + * It is expected that DMUB will resend any pending notifications at this= point, for + * example HPD from DPIA. + */ + if (dc_is_dmub_outbox_supported(adev->dm.dc)) + dc_enable_dmub_outbox(adev->dm.dc); + /* create fake encoders for MST */ dm_dp_create_fake_mst_encoders(adev); =20 @@ -2701,9 +2708,6 @@ static int dm_resume(void *handle) */ link_enc_cfg_copy(adev->dm.dc->current_state, dc_state); =20 - if (dc_enable_dmub_notifications(adev->dm.dc)) - amdgpu_dm_outbox_init(adev); - r =3D dm_dmub_hw_init(adev); if (r) DRM_ERROR("DMUB interface failed to initialize: status=3D%d\n", r); @@ -2721,6 +2725,11 @@ static int dm_resume(void *handle) } } =20 + if (dc_is_dmub_outbox_supported(adev->dm.dc)) { + amdgpu_dm_outbox_init(adev); + dc_enable_dmub_outbox(adev->dm.dc); + } + WARN_ON(!dc_commit_state(dm->dc, dc_state)); =20 dm_gpureset_commit_state(dm->cached_dc_state, dm); @@ -2742,13 +2751,15 @@ static int dm_resume(void *handle) /* TODO: Remove dc_state->dccg, use dc->dccg directly. */ dc_resource_state_construct(dm->dc, dm_state->context); =20 - /* Re-enable outbox interrupts for DPIA. */ - if (dc_enable_dmub_notifications(adev->dm.dc)) - amdgpu_dm_outbox_init(adev); - /* Before powering on DC we need to re-initialize DMUB. */ dm_dmub_hw_resume(adev); =20 + /* Re-enable outbox interrupts for DPIA. */ + if (dc_is_dmub_outbox_supported(adev->dm.dc)) { + amdgpu_dm_outbox_init(adev); + dc_enable_dmub_outbox(adev->dm.dc); + } + /* power on hardware */ dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D5E8C19F2B for ; Wed, 27 Jul 2022 17:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242056AbiG0R0n (ORCPT ); Wed, 27 Jul 2022 13:26:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241961AbiG0RZ3 (ORCPT ); Wed, 27 Jul 2022 13:25:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E31B7D7A5; Wed, 27 Jul 2022 09:46:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E1420B821A6; Wed, 27 Jul 2022 16:46:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D9EAC433B5; Wed, 27 Jul 2022 16:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940399; bh=GhYgZIgGTDUbTK6LWYbZValzjDD+lImexv1IGjxCoo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcahtjh209Ui9ATS61UTeX1/MCJNXN7Ecs8jgPzXFUohoE27CG/AmmyEXxXKc5p2x cj9BCqZiqp8Q5ZnttlerQEtyaTeMw7DHLvp0qb+/2l9kjmKkDX/NeY+qiHb0CUmwza XXuigjrmwT0g7/SrMGR5dNFj/ViTFBLwvTKPgudY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Andrey Grodzovsky Subject: [PATCH 5.18 010/158] drm/scheduler: Dont kill jobs in interrupt context Date: Wed, 27 Jul 2022 18:11:14 +0200 Message-Id: <20220727161021.852697362@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dmitry Osipenko commit 9b04369b060fd4885f728b7a4ab4851ffb1abb64 upstream. Interrupt context can't sleep. Drivers like Panfrost and MSM are taking mutex when job is released, and thus, that code can sleep. This results into "BUG: scheduling while atomic" if locks are contented while job is freed. There is no good reason for releasing scheduler's jobs in IRQ context, hence use normal context to fix the trouble. Cc: stable@vger.kernel.org Fixes: 542cff7893a3 ("drm/sched: Avoid lockdep spalt on killing a processes= ") Signed-off-by: Dmitry Osipenko Signed-off-by: Andrey Grodzovsky Link: https://patchwork.freedesktop.org/patch/msgid/20220411221536.283312-1= -dmitry.osipenko@collabora.com Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpu/drm/scheduler/sched_entity.c | 6 +++--- include/drm/gpu_scheduler.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -190,7 +190,7 @@ long drm_sched_entity_flush(struct drm_s } EXPORT_SYMBOL(drm_sched_entity_flush); =20 -static void drm_sched_entity_kill_jobs_irq_work(struct irq_work *wrk) +static void drm_sched_entity_kill_jobs_work(struct work_struct *wrk) { struct drm_sched_job *job =3D container_of(wrk, typeof(*job), work); =20 @@ -207,8 +207,8 @@ static void drm_sched_entity_kill_jobs_c struct drm_sched_job *job =3D container_of(cb, struct drm_sched_job, finish_cb); =20 - init_irq_work(&job->work, drm_sched_entity_kill_jobs_irq_work); - irq_work_queue(&job->work); + INIT_WORK(&job->work, drm_sched_entity_kill_jobs_work); + schedule_work(&job->work); } =20 static struct dma_fence * --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include =20 #define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000) =20 @@ -294,7 +294,7 @@ struct drm_sched_job { */ union { struct dma_fence_cb finish_cb; - struct irq_work work; + struct work_struct work; }; =20 uint64_t id; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AB0EC04A68 for ; Wed, 27 Jul 2022 17:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237871AbiG0R0o (ORCPT ); Wed, 27 Jul 2022 13:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242077AbiG0RZu (ORCPT ); Wed, 27 Jul 2022 13:25:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B8727D7B3; Wed, 27 Jul 2022 09:46:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FF5B60DDB; Wed, 27 Jul 2022 16:46:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C0DDC433D6; Wed, 27 Jul 2022 16:46:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940402; bh=bBnTDkDz7hQo4y2s7JN6+Uc7JMmsoDTjkSc05ifzYHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ye89JMGW7HMtNdMPjyC7EUBWPBt41jUDbFaBwGFvW+ScZzUrjmmt1QbtWCnBDjjM/ p5BhtrfDxakSO5FGswxmh5iD3XWLhyFIcDg+lh1Zz8KAcHCc53mxtZWh4628FY8aBv aljKRivY2pKFE9caOpPkWyMRyg9gAdlq/4TTna6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jose Alonso , "David S. Miller" Subject: [PATCH 5.18 011/158] net: usb: ax88179_178a needs FLAG_SEND_ZLP Date: Wed, 27 Jul 2022 18:11:15 +0200 Message-Id: <20220727161021.894847844@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jose Alonso commit 36a15e1cb134c0395261ba1940762703f778438c upstream. The extra byte inserted by usbnet.c when (length % dev->maxpacket =3D=3D 0) is causing problems to device. This patch sets FLAG_SEND_ZLP to avoid this. Tested with: 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet Problems observed: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1) Using ssh/sshfs. The remote sshd daemon can abort with the message: "message authentication code incorrect" This happens because the tcp message sent is corrupted during the USB "Bulk out". The device calculate the tcp checksum and send a valid tcp message to the remote sshd. Then the encryption detects the error and aborts. 2) NETDEV WATCHDOG: ... (ax88179_178a): transmit queue 0 timed out 3) Stop normal work without any log message. The "Bulk in" continue receiving packets normally. The host sends "Bulk out" and the device responds with -ECONNRESET. (The netusb.c code tx_complete ignore -ECONNRESET) Under normal conditions these errors take days to happen and in intense usage take hours. A test with ping gives packet loss, showing that something is wrong: ping -4 -s 462 {destination} # 462 =3D 512 - 42 - 8 Not all packets fail. My guess is that the device tries to find another packet starting at the extra byte and will fail or not depending on the next bytes (old buffer content). =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Signed-off-by: Jose Alonso Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/usb/ax88179_178a.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -1801,7 +1801,7 @@ static const struct driver_info ax88179_ .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1814,7 +1814,7 @@ static const struct driver_info ax88178a .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1827,7 +1827,7 @@ static const struct driver_info cypress_ .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1840,7 +1840,7 @@ static const struct driver_info dlink_du .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1853,7 +1853,7 @@ static const struct driver_info sitecom_ .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1866,7 +1866,7 @@ static const struct driver_info samsung_ .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1879,7 +1879,7 @@ static const struct driver_info lenovo_i .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1892,7 +1892,7 @@ static const struct driver_info belkin_i .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1905,7 +1905,7 @@ static const struct driver_info toshiba_ .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1918,7 +1918,7 @@ static const struct driver_info mct_info .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1931,7 +1931,7 @@ static const struct driver_info at_umc20 .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1944,7 +1944,7 @@ static const struct driver_info at_umc20 .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; @@ -1957,7 +1957,7 @@ static const struct driver_info at_umc20 .link_reset =3D ax88179_link_reset, .reset =3D ax88179_reset, .stop =3D ax88179_stop, - .flags =3D FLAG_ETHER | FLAG_FRAMING_AX, + .flags =3D FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, .rx_fixup =3D ax88179_rx_fixup, .tx_fixup =3D ax88179_tx_fixup, }; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FDC3C04A68 for ; Wed, 27 Jul 2022 17:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233236AbiG0R2D (ORCPT ); Wed, 27 Jul 2022 13:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242107AbiG0R1U (ORCPT ); Wed, 27 Jul 2022 13:27:20 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E86D17E818; Wed, 27 Jul 2022 09:47:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1ADFCCE2309; Wed, 27 Jul 2022 16:46:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4696C433D7; Wed, 27 Jul 2022 16:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940405; bh=mb30FYcBdEncl0eHesCKo8U5r22CzeF8EimsaD5en9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nBA0L/gTujS2tAX10TIe8VyRWGNxMT50yaHoweYQFzbqyM+HZOHXz33TDnhgH/eP9 VRumeA4cYEeiHcWzsHC6IeZq4FaJEEr1Htgjr0V0zn6z9KuDO6Dro78jQ6ZYdbHsQn kJtR7+f2N5mlH+7ezVxbWE/q0QKVR9OfvcYuwaW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , Manivannan Sadhasivam , Manivannan Sadhasivam , Fabio Porcedda Subject: [PATCH 5.18 012/158] bus: mhi: host: pci_generic: add Telit FN980 v1 hardware revision Date: Wed, 27 Jul 2022 18:11:16 +0200 Message-Id: <20220727161021.943545353@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Daniele Palmas commit a96ef8b504efb2ad445dfb6d54f9488c3ddf23d2 upstream. Add Telit FN980 v1 hardware revision: 01:00.0 Unassigned class [ff00]: Qualcomm Device [17cb:0306] Subsystem: Device [1c5d:2000] Signed-off-by: Daniele Palmas Reviewed-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20220427072648.17635-1-dnlplm@gmail.com [mani: Added "host" to the subject] Signed-off-by: Manivannan Sadhasivam Signed-off-by: Fabio Porcedda Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/bus/mhi/host/pci_generic.c | 38 ++++++++++++++++++++++++++++++++= +++++ 1 file changed, 38 insertions(+) --- a/drivers/bus/mhi/host/pci_generic.c +++ b/drivers/bus/mhi/host/pci_generic.c @@ -446,10 +446,48 @@ static const struct mhi_pci_dev_info mhi .sideband_wake =3D false, }; =20 +static const struct mhi_channel_config mhi_telit_fn980_hw_v1_channels[] = =3D { + MHI_CHANNEL_CONFIG_UL(14, "QMI", 32, 0), + MHI_CHANNEL_CONFIG_DL(15, "QMI", 32, 0), + MHI_CHANNEL_CONFIG_UL(20, "IPCR", 16, 0), + MHI_CHANNEL_CONFIG_DL_AUTOQUEUE(21, "IPCR", 16, 0), + MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0", 128, 1), + MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0", 128, 2), +}; + +static struct mhi_event_config mhi_telit_fn980_hw_v1_events[] =3D { + MHI_EVENT_CONFIG_CTRL(0, 128), + MHI_EVENT_CONFIG_HW_DATA(1, 1024, 100), + MHI_EVENT_CONFIG_HW_DATA(2, 2048, 101) +}; + +static struct mhi_controller_config modem_telit_fn980_hw_v1_config =3D { + .max_channels =3D 128, + .timeout_ms =3D 20000, + .num_channels =3D ARRAY_SIZE(mhi_telit_fn980_hw_v1_channels), + .ch_cfg =3D mhi_telit_fn980_hw_v1_channels, + .num_events =3D ARRAY_SIZE(mhi_telit_fn980_hw_v1_events), + .event_cfg =3D mhi_telit_fn980_hw_v1_events, +}; + +static const struct mhi_pci_dev_info mhi_telit_fn980_hw_v1_info =3D { + .name =3D "telit-fn980-hwv1", + .fw =3D "qcom/sdx55m/sbl1.mbn", + .edl =3D "qcom/sdx55m/edl.mbn", + .config =3D &modem_telit_fn980_hw_v1_config, + .bar_num =3D MHI_PCI_DEFAULT_BAR_NUM, + .dma_data_width =3D 32, + .mru_default =3D 32768, + .sideband_wake =3D false, +}; + static const struct pci_device_id mhi_pci_id_table[] =3D { /* EM919x (sdx55), use the same vid:pid as qcom-sdx55m */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0306, 0x18d7, 0x0200), .driver_data =3D (kernel_ulong_t) &mhi_sierra_em919x_info }, + /* Telit FN980 hardware revision v1 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0306, 0x1C5D, 0x2000), + .driver_data =3D (kernel_ulong_t) &mhi_telit_fn980_hw_v1_info }, { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0306), .driver_data =3D (kernel_ulong_t) &mhi_qcom_sdx55_info }, { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0304), From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEA22C19F28 for ; Wed, 27 Jul 2022 17:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233386AbiG0R1s (ORCPT ); Wed, 27 Jul 2022 13:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbiG0R1S (ORCPT ); Wed, 27 Jul 2022 13:27:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C20F7E80E; Wed, 27 Jul 2022 09:47:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AEB9260D3B; Wed, 27 Jul 2022 16:46:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF0C7C433D7; Wed, 27 Jul 2022 16:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940408; bh=BZLp5uwG5GWcYyxKYOPodzLCyM2oeGeRA1HANZnEyF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Th/OWrE8JjFiMwZHctJR4hYu/17ONN17WP2Nxp4xcr6MMLL8UHsV+ezUNRcofFK6x 8iI1BISMdcN7KZAQmMu8OOc22kAjtvkjonOtZ3wi+DLA/StwQzQBH8wAp1CEOnbrGf H+N0+NlRTuEtQbOOw5s5iewZUNY1DX8jWF7uN6qI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniele Palmas , Manivannan Sadhasivam , Manivannan Sadhasivam , Fabio Porcedda Subject: [PATCH 5.18 013/158] bus: mhi: host: pci_generic: add Telit FN990 Date: Wed, 27 Jul 2022 18:11:17 +0200 Message-Id: <20220727161021.984004086@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Daniele Palmas commit 77fc41204734042861210b9d05338c9b8360affb upstream. Add Telit FN990: 01:00.0 Unassigned class [ff00]: Qualcomm Device 0308 Subsystem: Device 1c5d:2010 Signed-off-by: Daniele Palmas Reviewed-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20220502112036.443618-1-dnlplm@gmail.com [mani: Added "host" to the subject] Signed-off-by: Manivannan Sadhasivam Signed-off-by: Fabio Porcedda Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/bus/mhi/host/pci_generic.c | 41 ++++++++++++++++++++++++++++++++= +++++ 1 file changed, 41 insertions(+) --- a/drivers/bus/mhi/host/pci_generic.c +++ b/drivers/bus/mhi/host/pci_generic.c @@ -481,6 +481,44 @@ static const struct mhi_pci_dev_info mhi .sideband_wake =3D false, }; =20 +static const struct mhi_channel_config mhi_telit_fn990_channels[] =3D { + MHI_CHANNEL_CONFIG_UL_SBL(2, "SAHARA", 32, 0), + MHI_CHANNEL_CONFIG_DL_SBL(3, "SAHARA", 32, 0), + MHI_CHANNEL_CONFIG_UL(4, "DIAG", 64, 1), + MHI_CHANNEL_CONFIG_DL(5, "DIAG", 64, 1), + MHI_CHANNEL_CONFIG_UL(12, "MBIM", 32, 0), + MHI_CHANNEL_CONFIG_DL(13, "MBIM", 32, 0), + MHI_CHANNEL_CONFIG_UL(32, "DUN", 32, 0), + MHI_CHANNEL_CONFIG_DL(33, "DUN", 32, 0), + MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0_MBIM", 128, 2), + MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0_MBIM", 128, 3), +}; + +static struct mhi_event_config mhi_telit_fn990_events[] =3D { + MHI_EVENT_CONFIG_CTRL(0, 128), + MHI_EVENT_CONFIG_DATA(1, 128), + MHI_EVENT_CONFIG_HW_DATA(2, 1024, 100), + MHI_EVENT_CONFIG_HW_DATA(3, 2048, 101) +}; + +static const struct mhi_controller_config modem_telit_fn990_config =3D { + .max_channels =3D 128, + .timeout_ms =3D 20000, + .num_channels =3D ARRAY_SIZE(mhi_telit_fn990_channels), + .ch_cfg =3D mhi_telit_fn990_channels, + .num_events =3D ARRAY_SIZE(mhi_telit_fn990_events), + .event_cfg =3D mhi_telit_fn990_events, +}; + +static const struct mhi_pci_dev_info mhi_telit_fn990_info =3D { + .name =3D "telit-fn990", + .config =3D &modem_telit_fn990_config, + .bar_num =3D MHI_PCI_DEFAULT_BAR_NUM, + .dma_data_width =3D 32, + .sideband_wake =3D false, + .mru_default =3D 32768, +}; + static const struct pci_device_id mhi_pci_id_table[] =3D { /* EM919x (sdx55), use the same vid:pid as qcom-sdx55m */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0306, 0x18d7, 0x0200), @@ -492,6 +530,9 @@ static const struct pci_device_id mhi_pc .driver_data =3D (kernel_ulong_t) &mhi_qcom_sdx55_info }, { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0304), .driver_data =3D (kernel_ulong_t) &mhi_qcom_sdx24_info }, + /* Telit FN990 */ + { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0308, 0x1c5d, 0x2010), + .driver_data =3D (kernel_ulong_t) &mhi_telit_fn990_info }, { PCI_DEVICE(0x1eac, 0x1001), /* EM120R-GL (sdx24) */ .driver_data =3D (kernel_ulong_t) &mhi_quectel_em1xx_info }, { PCI_DEVICE(0x1eac, 0x1002), /* EM160R-GL (sdx24) */ From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F23AAC19F2B for ; Wed, 27 Jul 2022 17:27:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbiG0R1Y (ORCPT ); Wed, 27 Jul 2022 13:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242117AbiG0R07 (ORCPT ); Wed, 27 Jul 2022 13:26:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 090905FAE6; Wed, 27 Jul 2022 09:46:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1C6B3B821AC; Wed, 27 Jul 2022 16:46:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FF9DC433D7; Wed, 27 Jul 2022 16:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940410; bh=ZhxdM7jcjpWARpoyc/iCo1myCVH6FRG8l2e//X3LXSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VcYfgtcN+1Ek6uiyg0NNpnUbvoYLZ14G/S025CTm6TWxkyXxs8H/QxWL4XqiH0NKQ r5nZUyeZC2Y7yrunX0Oy08rmofcoyvb6zz3iJtAl/u9XXYGhO7o2f/qRuS29+zgW4M h7XnPfpD85X0LEf203+99f5A13+e40ZJVkqc4XHk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jeffrey Hugo , Dexuan Cui , Wei Liu , Carl Vanderlip Subject: [PATCH 5.18 014/158] PCI: hv: Fix multi-MSI to allow more than one MSI vector Date: Wed, 27 Jul 2022 18:11:18 +0200 Message-Id: <20220727161022.034016477@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jeffrey Hugo [ upstream change 08e61e861a0e47e5e1a3fb78406afd6b0cea6b6d ] If the allocation of multiple MSI vectors for multi-MSI fails in the core PCI framework, the framework will retry the allocation as a single MSI vector, assuming that meets the min_vecs specified by the requesting driver. Hyper-V advertises that multi-MSI is supported, but reuses the VECTOR domain to implement that for x86. The VECTOR domain does not support multi-MSI, so the alloc will always fail and fallback to a single MSI allocation. In short, Hyper-V advertises a capability it does not implement. Hyper-V can support multi-MSI because it coordinates with the hypervisor to map the MSIs in the IOMMU's interrupt remapper, which is something the VECTOR domain does not have. Therefore the fix is simple - copy what the x86 IOMMU drivers (AMD/Intel-IR) do by removing X86_IRQ_ALLOC_CONTIGUOUS_VECTORS after calling the VECTOR domain's pci_msi_prepare(). Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft = Hyper-V VMs") Signed-off-by: Jeffrey Hugo Reviewed-by: Dexuan Cui Link: https://lore.kernel.org/r/1649856981-14649-1-git-send-email-quic_jhug= o@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pci/controller/pci-hyperv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -614,7 +614,16 @@ static void hv_set_msi_entry_from_desc(u static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *info) { - return pci_msi_prepare(domain, dev, nvec, info); + int ret =3D pci_msi_prepare(domain, dev, nvec, info); + + /* + * By using the interrupt remapper in the hypervisor IOMMU, contiguous + * CPU vectors is not needed for multi-MSI + */ + if (info->type =3D=3D X86_IRQ_ALLOC_TYPE_PCI_MSI) + info->flags &=3D ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; + + return ret; } =20 /** From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E693C04A68 for ; Wed, 27 Jul 2022 17:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237910AbiG0R2n (ORCPT ); Wed, 27 Jul 2022 13:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242163AbiG0R1g (ORCPT ); Wed, 27 Jul 2022 13:27:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 794F152474; Wed, 27 Jul 2022 09:47:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2AEE761557; Wed, 27 Jul 2022 16:46:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38285C433B5; Wed, 27 Jul 2022 16:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940413; bh=+3Pj8ZvBdsOpEI4vxaUMxo337gIqMh//unFM5xke8xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CedvuP2GBM1shW+DfjMzWKDIkudkfUlm829r+anZuhXpIYGaK0/kZM8IxEdhxwxZk eS+xbZW0uxy9TxshDaa+DcuJ4/rjgalIXsdsQcWB38ldA/CybIsKFbx+f5wToUpHjz N30M902YUN0wuRkHpS475b3ORPO7zmw/JCCQ3KiY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jeffrey Hugo , Michael Kelley , Wei Liu , Carl Vanderlip Subject: [PATCH 5.18 015/158] PCI: hv: Fix hv_arch_irq_unmask() for multi-MSI Date: Wed, 27 Jul 2022 18:11:19 +0200 Message-Id: <20220727161022.084869974@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jeffrey Hugo [ upstream change 455880dfe292a2bdd3b4ad6a107299fce610e64b ] In the multi-MSI case, hv_arch_irq_unmask() will only operate on the first MSI of the N allocated. This is because only the first msi_desc is cached and it is shared by all the MSIs of the multi-MSI block. This means that hv_arch_irq_unmask() gets the correct address, but the wrong data (always 0). This can break MSIs. Lets assume MSI0 is vector 34 on CPU0, and MSI1 is vector 33 on CPU0. hv_arch_irq_unmask() is called on MSI0. It uses a hypercall to configure the MSI address and data (0) to vector 34 of CPU0. This is correct. Then hv_arch_irq_unmask is called on MSI1. It uses another hypercall to configure the MSI address and data (0) to vector 33 of CPU0. This is wrong, and results in both MSI0 and MSI1 being routed to vector 33. Linux will observe extra instances of MSI1 and no instances of MSI0 despite the endpoint device behaving correctly. For the multi-MSI case, we need unique address and data info for each MSI, but the cached msi_desc does not provide that. However, that information can be gotten from the int_desc cached in the chip_data by compose_msi_msg(). Fix the multi-MSI case to use that cached information instead. Since hv_set_msi_entry_from_desc() is no longer applicable, remove it. Signed-off-by: Jeffrey Hugo Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/1651068453-29588-1-git-send-email-quic_jhug= o@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pci/controller/pci-hyperv.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -604,13 +604,6 @@ static unsigned int hv_msi_get_int_vecto return cfg->vector; } =20 -static void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry, - struct msi_desc *msi_desc) -{ - msi_entry->address.as_uint32 =3D msi_desc->msg.address_lo; - msi_entry->data.as_uint32 =3D msi_desc->msg.data; -} - static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *info) { @@ -640,6 +633,7 @@ static void hv_arch_irq_unmask(struct ir { struct msi_desc *msi_desc =3D irq_data_get_msi_desc(data); struct hv_retarget_device_interrupt *params; + struct tran_int_desc *int_desc; struct hv_pcibus_device *hbus; struct cpumask *dest; cpumask_var_t tmp; @@ -654,6 +648,7 @@ static void hv_arch_irq_unmask(struct ir pdev =3D msi_desc_to_pci_dev(msi_desc); pbus =3D pdev->bus; hbus =3D container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); + int_desc =3D data->chip_data; =20 spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); =20 @@ -661,7 +656,8 @@ static void hv_arch_irq_unmask(struct ir memset(params, 0, sizeof(*params)); params->partition_id =3D HV_PARTITION_ID_SELF; params->int_entry.source =3D HV_INTERRUPT_SOURCE_MSI; - hv_set_msi_entry_from_desc(¶ms->int_entry.msi_entry, msi_desc); + params->int_entry.msi_entry.address.as_uint32 =3D int_desc->address & 0xf= fffffff; + params->int_entry.msi_entry.data.as_uint32 =3D int_desc->data; params->device_id =3D (hbus->hdev->dev_instance.b[5] << 24) | (hbus->hdev->dev_instance.b[4] << 16) | (hbus->hdev->dev_instance.b[7] << 8) | From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4402CC19F2B for ; Wed, 27 Jul 2022 17:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242245AbiG0Ram (ORCPT ); Wed, 27 Jul 2022 13:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbiG0R1o (ORCPT ); Wed, 27 Jul 2022 13:27:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC48F7F52D; Wed, 27 Jul 2022 09:47:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A211DB821BA; Wed, 27 Jul 2022 16:46:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05CC2C433D6; Wed, 27 Jul 2022 16:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940416; bh=exQanQQCCW8xmYNuSUTKN1XUpk6IthBjCfK9gdDG8wM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZeHY4fpgwVTZraM2iIsfIA3I2dtf5WVFtnPCFNRMsMzCvDsu8J+DvGW1BN9i91BnG /lg/BOwIQbVGZJtjmB8MVcabQObSl14tWqXQ06lM+BnXlYBNgDvCyOJqGtGtf3ShIL tqleJ5vVRCAA2p0Hiius2B3pDRJ2eXGfRbjfQFOE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jeffrey Hugo , Dexuan Cui , Michael Kelley , Wei Liu , Carl Vanderlip Subject: [PATCH 5.18 016/158] PCI: hv: Reuse existing IRTE allocation in compose_msi_msg() Date: Wed, 27 Jul 2022 18:11:20 +0200 Message-Id: <20220727161022.117305587@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jeffrey Hugo [ upstream change b4b77778ecc5bfbd4e77de1b2fd5c1dd3c655f1f ] Currently if compose_msi_msg() is called multiple times, it will free any previous IRTE allocation, and generate a new allocation. While nothing prevents this from occurring, it is extraneous when Linux could just reuse the existing allocation and avoid a bunch of overhead. However, when future IRTE allocations operate on blocks of MSIs instead of a single line, freeing the allocation will impact all of the lines. This could cause an issue where an allocation of N MSIs occurs, then some of the lines are retargeted, and finally the allocation is freed/reallocated. The freeing of the allocation removes all of the configuration for the entire block, which requires all the lines to be retargeted, which might not happen since some lines might already be unmasked/active. Signed-off-by: Jeffrey Hugo Reviewed-by: Dexuan Cui Tested-by: Dexuan Cui Tested-by: Michael Kelley Link: https://lore.kernel.org/r/1652282582-21595-1-git-send-email-quic_jhug= o@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pci/controller/pci-hyperv.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1700,6 +1700,15 @@ static void hv_compose_msi_msg(struct ir u32 size; int ret; =20 + /* Reuse the previous allocation */ + if (data->chip_data) { + int_desc =3D data->chip_data; + msg->address_hi =3D int_desc->address >> 32; + msg->address_lo =3D int_desc->address & 0xffffffff; + msg->data =3D int_desc->data; + return; + } + pdev =3D msi_desc_to_pci_dev(irq_data_get_msi_desc(data)); dest =3D irq_data_get_effective_affinity_mask(data); pbus =3D pdev->bus; @@ -1709,13 +1718,6 @@ static void hv_compose_msi_msg(struct ir if (!hpdev) goto return_null_message; =20 - /* Free any previous message that might have already been composed. */ - if (data->chip_data) { - int_desc =3D data->chip_data; - data->chip_data =3D NULL; - hv_int_desc_free(hpdev, int_desc); - } - int_desc =3D kzalloc(sizeof(*int_desc), GFP_ATOMIC); if (!int_desc) goto drop_reference; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BB2CC04A68 for ; Wed, 27 Jul 2022 17:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242277AbiG0RbB (ORCPT ); Wed, 27 Jul 2022 13:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242137AbiG0R1t (ORCPT ); Wed, 27 Jul 2022 13:27:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89D47E82F; Wed, 27 Jul 2022 09:47:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8212DB821D5; Wed, 27 Jul 2022 16:47:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD1BDC433C1; Wed, 27 Jul 2022 16:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940419; bh=QGVr2ZyyoQ561rkrPsxvQAu8+NGwK0pg+cyAp/UQSVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J5XkWCJD40NOv6Z98q0C/lgEtQ8ZHz744rCzWajFKIuXQp9j5as7rJOlJSQCdPCBE 0kTiN8Pif8kWGLaGRIYmsu+EfCOgz9IRA4CSD5D8qopGN+Epfw9pU7UZy+TjFpLdsm diajinQtiRkuEOqjM+xZD4ko239xAX1Gvn71iJ/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Dexuan Cui , Jeffrey Hugo , Michael Kelley , Wei Liu , Carl Vanderlip Subject: [PATCH 5.18 017/158] PCI: hv: Fix interrupt mapping for multi-MSI Date: Wed, 27 Jul 2022 18:11:21 +0200 Message-Id: <20220727161022.166458774@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jeffrey Hugo [ upstream change a2bad844a67b1c7740bda63e87453baf63c3a7f7 ] According to Dexuan, the hypervisor folks beleive that multi-msi allocations are not correct. compose_msi_msg() will allocate multi-msi one by one. However, multi-msi is a block of related MSIs, with alignment requirements. In order for the hypervisor to allocate properly aligned and consecutive entries in the IOMMU Interrupt Remapping Table, there should be a single mapping request that requests all of the multi-msi vectors in one shot. Dexuan suggests detecting the multi-msi case and composing a single request related to the first MSI. Then for the other MSIs in the same block, use the cached information. This appears to be viable, so do it. Suggested-by: Dexuan Cui Signed-off-by: Jeffrey Hugo Reviewed-by: Dexuan Cui Tested-by: Michael Kelley Link: https://lore.kernel.org/r/1652282599-21643-1-git-send-email-quic_jhug= o@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pci/controller/pci-hyperv.c | 60 ++++++++++++++++++++++++++++++-= ----- 1 file changed, 50 insertions(+), 10 deletions(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1518,6 +1518,10 @@ static void hv_int_desc_free(struct hv_p u8 buffer[sizeof(struct pci_delete_interrupt)]; } ctxt; =20 + if (!int_desc->vector_count) { + kfree(int_desc); + return; + } memset(&ctxt, 0, sizeof(ctxt)); int_pkt =3D (struct pci_delete_interrupt *)&ctxt.pkt.message; int_pkt->message_type.type =3D @@ -1602,12 +1606,12 @@ static void hv_pci_compose_compl(void *c =20 static u32 hv_compose_msi_req_v1( struct pci_create_interrupt *int_pkt, struct cpumask *affinity, - u32 slot, u8 vector) + u32 slot, u8 vector, u8 vector_count) { int_pkt->message_type.type =3D PCI_CREATE_INTERRUPT_MESSAGE; int_pkt->wslot.slot =3D slot; int_pkt->int_desc.vector =3D vector; - int_pkt->int_desc.vector_count =3D 1; + int_pkt->int_desc.vector_count =3D vector_count; int_pkt->int_desc.delivery_mode =3D DELIVERY_MODE; =20 /* @@ -1630,14 +1634,14 @@ static int hv_compose_msi_req_get_cpu(st =20 static u32 hv_compose_msi_req_v2( struct pci_create_interrupt2 *int_pkt, struct cpumask *affinity, - u32 slot, u8 vector) + u32 slot, u8 vector, u8 vector_count) { int cpu; =20 int_pkt->message_type.type =3D PCI_CREATE_INTERRUPT_MESSAGE2; int_pkt->wslot.slot =3D slot; int_pkt->int_desc.vector =3D vector; - int_pkt->int_desc.vector_count =3D 1; + int_pkt->int_desc.vector_count =3D vector_count; int_pkt->int_desc.delivery_mode =3D DELIVERY_MODE; cpu =3D hv_compose_msi_req_get_cpu(affinity); int_pkt->int_desc.processor_array[0] =3D @@ -1649,7 +1653,7 @@ static u32 hv_compose_msi_req_v2( =20 static u32 hv_compose_msi_req_v3( struct pci_create_interrupt3 *int_pkt, struct cpumask *affinity, - u32 slot, u32 vector) + u32 slot, u32 vector, u8 vector_count) { int cpu; =20 @@ -1657,7 +1661,7 @@ static u32 hv_compose_msi_req_v3( int_pkt->wslot.slot =3D slot; int_pkt->int_desc.vector =3D vector; int_pkt->int_desc.reserved =3D 0; - int_pkt->int_desc.vector_count =3D 1; + int_pkt->int_desc.vector_count =3D vector_count; int_pkt->int_desc.delivery_mode =3D DELIVERY_MODE; cpu =3D hv_compose_msi_req_get_cpu(affinity); int_pkt->int_desc.processor_array[0] =3D @@ -1688,6 +1692,8 @@ static void hv_compose_msi_msg(struct ir struct cpumask *dest; struct compose_comp_ctxt comp; struct tran_int_desc *int_desc; + struct msi_desc *msi_desc; + u8 vector, vector_count; struct { struct pci_packet pci_pkt; union { @@ -1709,7 +1715,8 @@ static void hv_compose_msi_msg(struct ir return; } =20 - pdev =3D msi_desc_to_pci_dev(irq_data_get_msi_desc(data)); + msi_desc =3D irq_data_get_msi_desc(data); + pdev =3D msi_desc_to_pci_dev(msi_desc); dest =3D irq_data_get_effective_affinity_mask(data); pbus =3D pdev->bus; hbus =3D container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); @@ -1722,6 +1729,36 @@ static void hv_compose_msi_msg(struct ir if (!int_desc) goto drop_reference; =20 + if (!msi_desc->pci.msi_attrib.is_msix && msi_desc->nvec_used > 1) { + /* + * If this is not the first MSI of Multi MSI, we already have + * a mapping. Can exit early. + */ + if (msi_desc->irq !=3D data->irq) { + data->chip_data =3D int_desc; + int_desc->address =3D msi_desc->msg.address_lo | + (u64)msi_desc->msg.address_hi << 32; + int_desc->data =3D msi_desc->msg.data + + (data->irq - msi_desc->irq); + msg->address_hi =3D msi_desc->msg.address_hi; + msg->address_lo =3D msi_desc->msg.address_lo; + msg->data =3D int_desc->data; + put_pcichild(hpdev); + return; + } + /* + * The vector we select here is a dummy value. The correct + * value gets sent to the hypervisor in unmask(). This needs + * to be aligned with the count, and also not zero. Multi-msi + * is powers of 2 up to 32, so 32 will always work here. + */ + vector =3D 32; + vector_count =3D msi_desc->nvec_used; + } else { + vector =3D hv_msi_get_int_vector(data); + vector_count =3D 1; + } + memset(&ctxt, 0, sizeof(ctxt)); init_completion(&comp.comp_pkt.host_event); ctxt.pci_pkt.completion_func =3D hv_pci_compose_compl; @@ -1732,7 +1769,8 @@ static void hv_compose_msi_msg(struct ir size =3D hv_compose_msi_req_v1(&ctxt.int_pkts.v1, dest, hpdev->desc.win_slot.slot, - hv_msi_get_int_vector(data)); + vector, + vector_count); break; =20 case PCI_PROTOCOL_VERSION_1_2: @@ -1740,14 +1778,16 @@ static void hv_compose_msi_msg(struct ir size =3D hv_compose_msi_req_v2(&ctxt.int_pkts.v2, dest, hpdev->desc.win_slot.slot, - hv_msi_get_int_vector(data)); + vector, + vector_count); break; =20 case PCI_PROTOCOL_VERSION_1_4: size =3D hv_compose_msi_req_v3(&ctxt.int_pkts.v3, dest, hpdev->desc.win_slot.slot, - hv_msi_get_int_vector(data)); + vector, + vector_count); break; =20 default: From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 874FAC19F2B for ; Wed, 27 Jul 2022 17:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242346AbiG0RbZ (ORCPT ); Wed, 27 Jul 2022 13:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242162AbiG0R2b (ORCPT ); Wed, 27 Jul 2022 13:28:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04BF17FE68; Wed, 27 Jul 2022 09:47:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 87C4C615FE; Wed, 27 Jul 2022 16:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98241C433C1; Wed, 27 Jul 2022 16:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940422; bh=zl8nkHP5kUCeFYDnIhWo5vo26zKl4GVTupTw4VrhxM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmi5f8O5XxZtNcIXWJVgsXHaXnkyeCVV/qGG9cT74X/kPk39pEtyFpR8KIuRx/BFY 9Nx1fDu8hnSE9mZMlLVObbzgEux63iudi8qBExDVi/D1kUAUmDcMzHshbM3V/joliK E6fJG7I7OSpvST6N2mrlqc8VTKMDwfGUTI4pzOkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hayes Wang , Jakub Kicinski Subject: [PATCH 5.18 018/158] r8152: fix a WOL issue Date: Wed, 27 Jul 2022 18:11:22 +0200 Message-Id: <20220727161022.205844893@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hayes Wang commit cdf0b86b250fd3c1c3e120c86583ea510c52e4ce upstream. This fixes that the platform is waked by an unexpected packet. The size and range of FIFO is different when the device enters S3 state, so it is necessary to correct some settings when suspending. Regardless of jumbo frame, set RMS to 1522 and MTPS to MTPS_DEFAULT. Besides, enable MCU_BORW_EN to update the method of calculating the pointer of data. Then, the hardware could get the correct data. Fixes: 195aae321c82 ("r8152: support new chips") Signed-off-by: Hayes Wang Link: https://lore.kernel.org/r/20220718082120.10957-391-nic_swsd@realtek.c= om Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/usb/r8152.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -32,7 +32,7 @@ #define NETNEXT_VERSION "12" =20 /* Information for net */ -#define NET_VERSION "12" +#define NET_VERSION "13" =20 #define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION #define DRIVER_AUTHOR "Realtek linux nic maintainers " @@ -5915,7 +5915,8 @@ static void r8153_enter_oob(struct r8152 =20 wait_oob_link_list_ready(tp); =20 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, mtu_to_size(tp->netdev->mtu)); + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, 1522); + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT); =20 switch (tp->version) { case RTL_VER_03: @@ -5951,6 +5952,10 @@ static void r8153_enter_oob(struct r8152 ocp_data |=3D NOW_IS_OOB | DIS_MCU_CLROOB; ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); =20 + ocp_data =3D ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); + ocp_data |=3D MCU_BORW_EN; + ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); + rxdy_gated_en(tp, false); =20 ocp_data =3D ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); @@ -6553,6 +6558,9 @@ static void rtl8156_down(struct r8152 *t rtl_disable(tp); rtl_reset_bmu(tp); =20 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, 1522); + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_DEFAULT); + /* Clear teredo wake event. bit[15:8] is the teredo wakeup * type. Set it to zero. bits[7:0] are the W1C bits about * the events. Set them to all 1 to clear them. @@ -6563,6 +6571,10 @@ static void rtl8156_down(struct r8152 *t ocp_data |=3D NOW_IS_OOB; ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); =20 + ocp_data =3D ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); + ocp_data |=3D MCU_BORW_EN; + ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); + rtl_rx_vlan_en(tp, true); rxdy_gated_en(tp, false); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18D86C19F28 for ; Wed, 27 Jul 2022 17:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbiG0Rbb (ORCPT ); Wed, 27 Jul 2022 13:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242262AbiG0R3L (ORCPT ); Wed, 27 Jul 2022 13:29:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B4B80482; Wed, 27 Jul 2022 09:47:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 326DDB821AC; Wed, 27 Jul 2022 16:47:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F67C43143; Wed, 27 Jul 2022 16:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940424; bh=1+iurOaVQp3iZhPQt/kTqOFCUdJRGjD5/lCZjsj38Bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g4C3oHKJl15uK0ale3EDo5JIoPv9yt88mpNHPQrwbtHpmEhtvV17jR5QxacDK880Z W8152uXmiEODArCg1naS83jFqBq4pMJBEijr9KrQpJi9WQmBPTRv1JekOcOtU5v7NQ SOsnqdyCP7iHOsI3Zbf1IZzuRp01QUlZgmH2ebIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" Subject: [PATCH 5.18 019/158] ip: Fix data-races around sysctl_ip_default_ttl. Date: Wed, 27 Jul 2022 18:11:23 +0200 Message-Id: <20220727161022.246265876@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima commit 8281b7ec5c56b71cb2cc5a1728b41607be66959c upstream. While reading sysctl_ip_default_ttl, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/netronome/nfp/flower/action.c | 2 +- include/net/route.h | 2 +- net/ipv4/ip_sockglue.c | 2 +- net/ipv4/netfilter/nf_reject_ipv4.c | 4 ++-- net/ipv4/proc.c | 2 +- net/netfilter/nf_synproxy_core.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -473,7 +473,7 @@ nfp_fl_set_tun(struct nfp_app *app, stru set_tun->ttl =3D ip4_dst_hoplimit(&rt->dst); ip_rt_put(rt); } else { - set_tun->ttl =3D net->ipv4.sysctl_ip_default_ttl; + set_tun->ttl =3D READ_ONCE(net->ipv4.sysctl_ip_default_ttl); } } =20 --- a/include/net/route.h +++ b/include/net/route.h @@ -361,7 +361,7 @@ static inline int ip4_dst_hoplimit(const struct net *net =3D dev_net(dst->dev); =20 if (hoplimit =3D=3D 0) - hoplimit =3D net->ipv4.sysctl_ip_default_ttl; + hoplimit =3D READ_ONCE(net->ipv4.sysctl_ip_default_ttl); return hoplimit; } =20 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1606,7 +1606,7 @@ static int do_ip_getsockopt(struct sock { struct net *net =3D sock_net(sk); val =3D (inet->uc_ttl =3D=3D -1 ? - net->ipv4.sysctl_ip_default_ttl : + READ_ONCE(net->ipv4.sysctl_ip_default_ttl) : inet->uc_ttl); break; } --- a/net/ipv4/netfilter/nf_reject_ipv4.c +++ b/net/ipv4/netfilter/nf_reject_ipv4.c @@ -62,7 +62,7 @@ struct sk_buff *nf_reject_skb_v4_tcp_res =20 skb_reserve(nskb, LL_MAX_HEADER); niph =3D nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP, - net->ipv4.sysctl_ip_default_ttl); + READ_ONCE(net->ipv4.sysctl_ip_default_ttl)); nf_reject_ip_tcphdr_put(nskb, oldskb, oth); niph->tot_len =3D htons(nskb->len); ip_send_check(niph); @@ -115,7 +115,7 @@ struct sk_buff *nf_reject_skb_v4_unreach =20 skb_reserve(nskb, LL_MAX_HEADER); niph =3D nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP, - net->ipv4.sysctl_ip_default_ttl); + READ_ONCE(net->ipv4.sysctl_ip_default_ttl)); =20 skb_reset_transport_header(nskb); icmph =3D skb_put_zero(nskb, sizeof(struct icmphdr)); --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -387,7 +387,7 @@ static int snmp_seq_show_ipstats(struct =20 seq_printf(seq, "\nIp: %d %d", IPV4_DEVCONF_ALL(net, FORWARDING) ? 1 : 2, - net->ipv4.sysctl_ip_default_ttl); + READ_ONCE(net->ipv4.sysctl_ip_default_ttl)); =20 BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) !=3D 0); snmp_get_cpu_field64_batch(buff64, snmp4_ipstats_list, --- a/net/netfilter/nf_synproxy_core.c +++ b/net/netfilter/nf_synproxy_core.c @@ -405,7 +405,7 @@ synproxy_build_ip(struct net *net, struc iph->tos =3D 0; iph->id =3D 0; iph->frag_off =3D htons(IP_DF); - iph->ttl =3D net->ipv4.sysctl_ip_default_ttl; + iph->ttl =3D READ_ONCE(net->ipv4.sysctl_ip_default_ttl); iph->protocol =3D IPPROTO_TCP; iph->check =3D 0; iph->saddr =3D saddr; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB55EC04A68 for ; Wed, 27 Jul 2022 17:28:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234620AbiG0R2k (ORCPT ); Wed, 27 Jul 2022 13:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242154AbiG0R1e (ORCPT ); Wed, 27 Jul 2022 13:27:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348007E33D; Wed, 27 Jul 2022 09:47:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 36B98B821A6; Wed, 27 Jul 2022 16:47:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42809C433B5; Wed, 27 Jul 2022 16:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940430; bh=LDe2d3/aX99mWMtN2t4AG9MQrz+qUjNJhrrFYgdFu9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T727YET9OyVzP8mWKT3iXrnmsftbGFWTt442y0FsUNSg8fBbPVT+oN/dicx04blkY Y1j0B1otmvE26qYrbibT2pf3ZIl5OaSFPTRzdYAFZE0WheE+TOl4PNTncUFuKgrrQO chC2f1hL06dxnwqfjRu7JegJMQJy2++Lz+1U+R9A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Steffen Klassert , Sasha Levin Subject: [PATCH 5.18 020/158] xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in xfrm_bundle_lookup() Date: Wed, 27 Jul 2022 18:11:24 +0200 Message-Id: <20220727161022.277422268@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua [ Upstream commit f85daf0e725358be78dfd208dea5fd665d8cb901 ] xfrm_policy_lookup() will call xfrm_pol_hold_rcu() to get a refcount of pols[0]. This refcount can be dropped in xfrm_expand_policies() when xfrm_expand_policies() return error. pols[0]'s refcount is balanced in here. But xfrm_bundle_lookup() will also call xfrm_pols_put() with num_pols =3D=3D 1 to drop this refcount when xfrm_expand_policies() return error. This patch also fix an illegal address access. pols[0] will save a error point when xfrm_policy_lookup fails. This lead to xfrm_pols_put to resolve an illegal address in xfrm_bundle_lookup's error path. Fix these by setting num_pols =3D 0 in xfrm_expand_policies()'s error path. Fixes: 80c802f3073e ("xfrm: cache bundles instead of policies for outgoing = flows") Signed-off-by: Hangyu Hua Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/xfrm/xfrm_policy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index f1876ea61fdc..f1a0bab920a5 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2678,8 +2678,10 @@ static int xfrm_expand_policies(const struct flowi *= fl, u16 family, *num_xfrms =3D 0; return 0; } - if (IS_ERR(pols[0])) + if (IS_ERR(pols[0])) { + *num_pols =3D 0; return PTR_ERR(pols[0]); + } =20 *num_xfrms =3D pols[0]->xfrm_nr; =20 @@ -2694,6 +2696,7 @@ static int xfrm_expand_policies(const struct flowi *f= l, u16 family, if (pols[1]) { if (IS_ERR(pols[1])) { xfrm_pols_put(pols, *num_pols); + *num_pols =3D 0; return PTR_ERR(pols[1]); } (*num_pols)++; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CED7C04A68 for ; Wed, 27 Jul 2022 17:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242216AbiG0R2y (ORCPT ); Wed, 27 Jul 2022 13:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242161AbiG0R1g (ORCPT ); Wed, 27 Jul 2022 13:27:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995347F505; Wed, 27 Jul 2022 09:47:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2BB4261629; Wed, 27 Jul 2022 16:47:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 383F3C43470; Wed, 27 Jul 2022 16:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940433; bh=Q8YPi+BWUHDf7BRhBTc9sgcZya0rrya2AxGzyzuI8cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Z62Sc+jts5d1p0abCRXG/YSFS3zQ2s+TGFIcowUx+P0JryYwdx43hRn2OHMbyZbM sMS6wVAKL00WPYY663SDoAJe0Rqkb2LrOOqaG/Y5cPQcpTvkBfTih9540bkUw/eg8J TEPxXe4Mo4vMvzcrpvbK4uupy72B43NuKPbcpHl8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gao Chao , Linus Walleij , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.18 021/158] power: supply: ab8500_fg: add missing destroy_workqueue in ab8500_fg_probe Date: Wed, 27 Jul 2022 18:11:25 +0200 Message-Id: <20220727161022.316867058@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Gao Chao [ Upstream commit 0f5de2f0532229752d923c769a5b202ae437523b ] In ab8500_fg_probe, misses destroy_workqueue in error path, this patch fixes that. Fixes: 010ddb813f35 ("power: supply: ab8500_fg: Allocate wq in probe") Signed-off-by: Gao Chao Reviewed-by: Linus Walleij Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/power/supply/ab8500_fg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500= _fg.c index ec8a404d71b4..4339fa9ff009 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3148,6 +3148,7 @@ static int ab8500_fg_probe(struct platform_device *pd= ev) ret =3D ab8500_fg_init_hw_registers(di); if (ret) { dev_err(dev, "failed to initialize registers\n"); + destroy_workqueue(di->fg_wq); return ret; } =20 @@ -3159,6 +3160,7 @@ static int ab8500_fg_probe(struct platform_device *pd= ev) di->fg_psy =3D devm_power_supply_register(dev, &ab8500_fg_desc, &psy_cfg); if (IS_ERR(di->fg_psy)) { dev_err(dev, "failed to register FG psy\n"); + destroy_workqueue(di->fg_wq); return PTR_ERR(di->fg_psy); } =20 @@ -3174,8 +3176,10 @@ static int ab8500_fg_probe(struct platform_device *p= dev) /* Register primary interrupt handlers */ for (i =3D 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) { irq =3D platform_get_irq_byname(pdev, ab8500_fg_irq[i].name); - if (irq < 0) + if (irq < 0) { + destroy_workqueue(di->fg_wq); return irq; + } =20 ret =3D devm_request_threaded_irq(dev, irq, NULL, ab8500_fg_irq[i].isr, @@ -3185,6 +3189,7 @@ static int ab8500_fg_probe(struct platform_device *pd= ev) if (ret !=3D 0) { dev_err(dev, "failed to request %s IRQ %d: %d\n", ab8500_fg_irq[i].name, irq, ret); + destroy_workqueue(di->fg_wq); return ret; } dev_dbg(dev, "Requested %s IRQ %d: %d\n", @@ -3200,6 +3205,7 @@ static int ab8500_fg_probe(struct platform_device *pd= ev) ret =3D ab8500_fg_sysfs_init(di); if (ret) { dev_err(dev, "failed to create sysfs entry\n"); + destroy_workqueue(di->fg_wq); return ret; } =20 @@ -3207,6 +3213,7 @@ static int ab8500_fg_probe(struct platform_device *pd= ev) if (ret) { dev_err(dev, "failed to create FG psy\n"); ab8500_fg_sysfs_exit(di); + destroy_workqueue(di->fg_wq); return ret; } =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E01E9C04A68 for ; Wed, 27 Jul 2022 17:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiG0RcE (ORCPT ); Wed, 27 Jul 2022 13:32:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242393AbiG0R3d (ORCPT ); Wed, 27 Jul 2022 13:29:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A16080526; Wed, 27 Jul 2022 09:47:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9B0E5B8200D; Wed, 27 Jul 2022 16:47:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0532EC433C1; Wed, 27 Jul 2022 16:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940437; bh=jsF4LpQm777PxNt5/h+cNChfYSEvUrbp0KZNEszQamk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bo2Sp00JN+is7LRQH5e9eoHXZkOYSizB84pnapgJX/YvStm4+7Et1K4wpMpKxf2d2 Lk0LNMGI0BOb0f14ORtinW3MI5MvTDp/DaVrLXB8PGxvENutMbEKZwqrz87bAZuHk2 38FFLWE3G52RYawIPx8yvkfx7bLHw0mag7XekTvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Linus Walleij , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.18 022/158] power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe Date: Wed, 27 Jul 2022 18:11:26 +0200 Message-Id: <20220727161022.356820953@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miaoqian Lin [ Upstream commit 80192eff64eee9b3bc0594a47381937b94b9d65a ] of_find_matching_node_and_match() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. Fixes: 0e545f57b708 ("power: reset: driver for the Versatile syscon reboot") Signed-off-by: Miaoqian Lin Reviewed-by: Linus Walleij Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/power/reset/arm-versatile-reboot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/reset/arm-versatile-reboot.c b/drivers/power/res= et/arm-versatile-reboot.c index 08d0a07b58ef..c7624d7611a7 100644 --- a/drivers/power/reset/arm-versatile-reboot.c +++ b/drivers/power/reset/arm-versatile-reboot.c @@ -146,6 +146,7 @@ static int __init versatile_reboot_probe(void) versatile_reboot_type =3D (enum versatile_reboot)reboot_id->data; =20 syscon_regmap =3D syscon_node_to_regmap(np); + of_node_put(np); if (IS_ERR(syscon_regmap)) return PTR_ERR(syscon_regmap); =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1FDAC04A68 for ; Wed, 27 Jul 2022 17:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbiG0Rat (ORCPT ); Wed, 27 Jul 2022 13:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242120AbiG0R1r (ORCPT ); Wed, 27 Jul 2022 13:27:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 073267F53E; Wed, 27 Jul 2022 09:47:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 142C5614DE; Wed, 27 Jul 2022 16:47:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E517CC43150; Wed, 27 Jul 2022 16:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940440; bh=gWy067auv1cIDDz1ieWzLMz4GbK/yZ0iwF/UgHgWv7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m4EMfRj5i2SklB7VYp4LtmPwtca++mWbvqNjyFn3YUUXbIKffroT5WzpE1keElOvj 7wemqKyLm16HC66jJyjOzdYwNBHy/HvwfzCL5FN8VlhK7pqnDgMYae1KWt8Mx5AJA3 W3luGrszD/obwtYGOWkd82jMDdrs4TZdVq3EXX7c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mustafa Ismail , Shiraz Saleem , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.18 023/158] RDMA/irdma: Do not advertise 1GB page size for x722 Date: Wed, 27 Jul 2022 18:11:27 +0200 Message-Id: <20220727161022.406069939@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mustafa Ismail [ Upstream commit 5e8afb8792f3b6ae7ccf700f8c19225382636401 ] x722 does not support 1GB page size but the irdma driver incorrectly advertises 1GB page size support for x722 device to ib_core to compute the best page size to use on this MR. This could lead to incorrect start offsets computed by hardware on the MR. Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs") Signed-off-by: Mustafa Ismail Signed-off-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/infiniband/hw/irdma/i40iw_hw.c | 1 + drivers/infiniband/hw/irdma/icrdma_hw.c | 1 + drivers/infiniband/hw/irdma/irdma.h | 1 + drivers/infiniband/hw/irdma/verbs.c | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/irdma/i40iw_hw.c b/drivers/infiniband/hw= /irdma/i40iw_hw.c index e46fc110004d..50299f58b6b3 100644 --- a/drivers/infiniband/hw/irdma/i40iw_hw.c +++ b/drivers/infiniband/hw/irdma/i40iw_hw.c @@ -201,6 +201,7 @@ void i40iw_init_hw(struct irdma_sc_dev *dev) dev->hw_attrs.uk_attrs.max_hw_read_sges =3D I40IW_MAX_SGE_RD; dev->hw_attrs.max_hw_device_pages =3D I40IW_MAX_PUSH_PAGE_COUNT; dev->hw_attrs.uk_attrs.max_hw_inline =3D I40IW_MAX_INLINE_DATA_SIZE; + dev->hw_attrs.page_size_cap =3D SZ_4K | SZ_2M; dev->hw_attrs.max_hw_ird =3D I40IW_MAX_IRD_SIZE; dev->hw_attrs.max_hw_ord =3D I40IW_MAX_ORD_SIZE; dev->hw_attrs.max_hw_wqes =3D I40IW_MAX_WQ_ENTRIES; diff --git a/drivers/infiniband/hw/irdma/icrdma_hw.c b/drivers/infiniband/h= w/irdma/icrdma_hw.c index cf53b17510cd..5986fd906308 100644 --- a/drivers/infiniband/hw/irdma/icrdma_hw.c +++ b/drivers/infiniband/hw/irdma/icrdma_hw.c @@ -139,6 +139,7 @@ void icrdma_init_hw(struct irdma_sc_dev *dev) dev->cqp_db =3D dev->hw_regs[IRDMA_CQPDB]; dev->cq_ack_db =3D dev->hw_regs[IRDMA_CQACK]; dev->irq_ops =3D &icrdma_irq_ops; + dev->hw_attrs.page_size_cap =3D SZ_4K | SZ_2M | SZ_1G; dev->hw_attrs.max_hw_ird =3D ICRDMA_MAX_IRD_SIZE; dev->hw_attrs.max_hw_ord =3D ICRDMA_MAX_ORD_SIZE; dev->hw_attrs.max_stat_inst =3D ICRDMA_MAX_STATS_COUNT; diff --git a/drivers/infiniband/hw/irdma/irdma.h b/drivers/infiniband/hw/ir= dma/irdma.h index 46c12334c735..4789e85d717b 100644 --- a/drivers/infiniband/hw/irdma/irdma.h +++ b/drivers/infiniband/hw/irdma/irdma.h @@ -127,6 +127,7 @@ struct irdma_hw_attrs { u64 max_hw_outbound_msg_size; u64 max_hw_inbound_msg_size; u64 max_mr_size; + u64 page_size_cap; u32 min_hw_qp_id; u32 min_hw_aeq_size; u32 max_hw_aeq_size; diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/ir= dma/verbs.c index 52f3e88f8569..6daa149dcbda 100644 --- a/drivers/infiniband/hw/irdma/verbs.c +++ b/drivers/infiniband/hw/irdma/verbs.c @@ -30,7 +30,7 @@ static int irdma_query_device(struct ib_device *ibdev, props->vendor_part_id =3D pcidev->device; =20 props->hw_ver =3D rf->pcidev->revision; - props->page_size_cap =3D SZ_4K | SZ_2M | SZ_1G; + props->page_size_cap =3D hw_attrs->page_size_cap; props->max_mr_size =3D hw_attrs->max_mr_size; props->max_qp =3D rf->max_qp - rf->used_qps; props->max_qp_wr =3D hw_attrs->max_qp_wr; @@ -2764,7 +2764,7 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *= pd, u64 start, u64 len, =20 if (req.reg_type =3D=3D IRDMA_MEMREG_TYPE_MEM) { iwmr->page_size =3D ib_umem_find_best_pgsz(region, - SZ_4K | SZ_2M | SZ_1G, + iwdev->rf->sc_dev.hw_attrs.page_size_cap, virt); if (unlikely(!iwmr->page_size)) { kfree(iwmr); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E85EC19F28 for ; Wed, 27 Jul 2022 17:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242329AbiG0RbF (ORCPT ); Wed, 27 Jul 2022 13:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241977AbiG0R21 (ORCPT ); Wed, 27 Jul 2022 13:28:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854717FE51; Wed, 27 Jul 2022 09:47:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DDDDC60DDB; Wed, 27 Jul 2022 16:47:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E662BC433D6; Wed, 27 Jul 2022 16:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940443; bh=wNWaaf9ZVTOkTXZushfipplNyncTlNCML5XFMyU0joc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxpKXnzCYhPCkpwESwpX41NT6KQS6sjKYyfjQaUrHMB2j7xEU1n8Mi7rFq975TqKT /vuY7zDh4L8auHj8YCUlmdsf7WDnMNBZMSChDNdVmv6UXV1R0O6hzmvbPXb5j+eYxc JRNd6aNHQ36Z09gk0SLpeP+RHmWq4cDr/nviVUhY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mustafa Ismail , Shiraz Saleem , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.18 024/158] RDMA/irdma: Fix sleep from invalid context BUG Date: Wed, 27 Jul 2022 18:11:28 +0200 Message-Id: <20220727161022.437017263@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mustafa Ismail [ Upstream commit cc0315564d6eec91c716d314b743321be24c70b3 ] Taking the qos_mutex to process RoCEv2 QP's on netdev events causes a kernel splat. Fix this by removing the handling for RoCEv2 in irdma_cm_teardown_connections that uses the mutex. This handling is only needed for iWARP to avoid having connections established while the link is down or having connections remain functional after the IP address is removed. BUG: sleeping function called from invalid context at kernel/locking/mute= x. Call Trace: kernel: dump_stack+0x66/0x90 kernel: ___might_sleep.cold.92+0x8d/0x9a kernel: mutex_lock+0x1c/0x40 kernel: irdma_cm_teardown_connections+0x28e/0x4d0 [irdma] kernel: ? check_preempt_curr+0x7a/0x90 kernel: ? select_idle_sibling+0x22/0x3c0 kernel: ? select_task_rq_fair+0x94c/0xc90 kernel: ? irdma_exec_cqp_cmd+0xc27/0x17c0 [irdma] kernel: ? __wake_up_common+0x7a/0x190 kernel: irdma_if_notify+0x3cc/0x450 [irdma] kernel: ? sched_clock_cpu+0xc/0xb0 kernel: irdma_inet6addr_event+0xc6/0x150 [irdma] Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager") Signed-off-by: Mustafa Ismail Signed-off-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/infiniband/hw/irdma/cm.c | 50 -------------------------------- 1 file changed, 50 deletions(-) diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma= /cm.c index 638bf4a1ed94..646fa8677490 100644 --- a/drivers/infiniband/hw/irdma/cm.c +++ b/drivers/infiniband/hw/irdma/cm.c @@ -4231,10 +4231,6 @@ void irdma_cm_teardown_connections(struct irdma_devi= ce *iwdev, u32 *ipaddr, struct irdma_cm_node *cm_node; struct list_head teardown_list; struct ib_qp_attr attr; - struct irdma_sc_vsi *vsi =3D &iwdev->vsi; - struct irdma_sc_qp *sc_qp; - struct irdma_qp *qp; - int i; =20 INIT_LIST_HEAD(&teardown_list); =20 @@ -4251,52 +4247,6 @@ void irdma_cm_teardown_connections(struct irdma_devi= ce *iwdev, u32 *ipaddr, irdma_cm_disconn(cm_node->iwqp); irdma_rem_ref_cm_node(cm_node); } - if (!iwdev->roce_mode) - return; - - INIT_LIST_HEAD(&teardown_list); - for (i =3D 0; i < IRDMA_MAX_USER_PRIORITY; i++) { - mutex_lock(&vsi->qos[i].qos_mutex); - list_for_each_safe (list_node, list_core_temp, - &vsi->qos[i].qplist) { - u32 qp_ip[4]; - - sc_qp =3D container_of(list_node, struct irdma_sc_qp, - list); - if (sc_qp->qp_uk.qp_type !=3D IRDMA_QP_TYPE_ROCE_RC) - continue; - - qp =3D sc_qp->qp_uk.back_qp; - if (!disconnect_all) { - if (nfo->ipv4) - qp_ip[0] =3D qp->udp_info.local_ipaddr[3]; - else - memcpy(qp_ip, - &qp->udp_info.local_ipaddr[0], - sizeof(qp_ip)); - } - - if (disconnect_all || - (nfo->vlan_id =3D=3D (qp->udp_info.vlan_tag & VLAN_VID_MASK) && - !memcmp(qp_ip, ipaddr, nfo->ipv4 ? 4 : 16))) { - spin_lock(&iwdev->rf->qptable_lock); - if (iwdev->rf->qp_table[sc_qp->qp_uk.qp_id]) { - irdma_qp_add_ref(&qp->ibqp); - list_add(&qp->teardown_entry, - &teardown_list); - } - spin_unlock(&iwdev->rf->qptable_lock); - } - } - mutex_unlock(&vsi->qos[i].qos_mutex); - } - - list_for_each_safe (list_node, list_core_temp, &teardown_list) { - qp =3D container_of(list_node, struct irdma_qp, teardown_entry); - attr.qp_state =3D IB_QPS_ERR; - irdma_modify_qp_roce(&qp->ibqp, &attr, IB_QP_STATE, NULL); - irdma_qp_rem_ref(&qp->ibqp); - } } =20 /** --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D592FC04A68 for ; Wed, 27 Jul 2022 17:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242324AbiG0RbQ (ORCPT ); Wed, 27 Jul 2022 13:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242147AbiG0R23 (ORCPT ); Wed, 27 Jul 2022 13:28:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC587FE4C; Wed, 27 Jul 2022 09:47:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9ED9600BE; Wed, 27 Jul 2022 16:47:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B26EAC433C1; Wed, 27 Jul 2022 16:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940446; bh=9daQcHA1ca8CTNZjEp82Tejpl/6LJe3wwlznXAHn6+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wnyI0QosExcNM9PmwHBAcrmtaD3SZX56kOFnei6l6d1xDfvd433+QjfutA2CHL/Bm hd4prnm7OS979GZBFYmM/ZlCk9LJ4LUTrXR1pK3+bZkOTp8+Aoqo37GKpzVdnwMpdk tu12AMHjGUsNmUCLUVDTSnNKPq01CTplDxBnF/qQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Sergio Paracuellos , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 025/158] pinctrl: ralink: rename MT7628(an) functions to MT76X8 Date: Wed, 27 Jul 2022 18:11:29 +0200 Message-Id: <20220727161022.476750720@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ar=C4=B1n=C3=A7 =C3=9CNAL [ Upstream commit 150438c86f55989632005b92c94f4aa2ec562ed6 ] The functions that include "MT7628(an)" are for MT7628 and MT7688 SoCs. Rename them to MT76X8 to refer to both of the SoCs. Signed-off-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Reviewed-by: Sergio Paracuellos Acked-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20220414173916.5552-2-arinc.unal@arinc9.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/ralink/pinctrl-mt7620.c | 218 ++++++++++++------------ 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/drivers/pinctrl/ralink/pinctrl-mt7620.c b/drivers/pinctrl/rali= nk/pinctrl-mt7620.c index 6853b5b8b0fe..d3f9feec1f74 100644 --- a/drivers/pinctrl/ralink/pinctrl-mt7620.c +++ b/drivers/pinctrl/ralink/pinctrl-mt7620.c @@ -112,260 +112,260 @@ static struct rt2880_pmx_group mt7620a_pinmux_data[= ] =3D { { 0 } }; =20 -static struct rt2880_pmx_func pwm1_grp_mt7628[] =3D { +static struct rt2880_pmx_func pwm1_grp_mt76x8[] =3D { FUNC("sdxc d6", 3, 19, 1), FUNC("utif", 2, 19, 1), FUNC("gpio", 1, 19, 1), FUNC("pwm1", 0, 19, 1), }; =20 -static struct rt2880_pmx_func pwm0_grp_mt7628[] =3D { +static struct rt2880_pmx_func pwm0_grp_mt76x8[] =3D { FUNC("sdxc d7", 3, 18, 1), FUNC("utif", 2, 18, 1), FUNC("gpio", 1, 18, 1), FUNC("pwm0", 0, 18, 1), }; =20 -static struct rt2880_pmx_func uart2_grp_mt7628[] =3D { +static struct rt2880_pmx_func uart2_grp_mt76x8[] =3D { FUNC("sdxc d5 d4", 3, 20, 2), FUNC("pwm", 2, 20, 2), FUNC("gpio", 1, 20, 2), FUNC("uart2", 0, 20, 2), }; =20 -static struct rt2880_pmx_func uart1_grp_mt7628[] =3D { +static struct rt2880_pmx_func uart1_grp_mt76x8[] =3D { FUNC("sw_r", 3, 45, 2), FUNC("pwm", 2, 45, 2), FUNC("gpio", 1, 45, 2), FUNC("uart1", 0, 45, 2), }; =20 -static struct rt2880_pmx_func i2c_grp_mt7628[] =3D { +static struct rt2880_pmx_func i2c_grp_mt76x8[] =3D { FUNC("-", 3, 4, 2), FUNC("debug", 2, 4, 2), FUNC("gpio", 1, 4, 2), FUNC("i2c", 0, 4, 2), }; =20 -static struct rt2880_pmx_func refclk_grp_mt7628[] =3D { FUNC("refclk", 0, = 37, 1) }; -static struct rt2880_pmx_func perst_grp_mt7628[] =3D { FUNC("perst", 0, 36= , 1) }; -static struct rt2880_pmx_func wdt_grp_mt7628[] =3D { FUNC("wdt", 0, 38, 1)= }; -static struct rt2880_pmx_func spi_grp_mt7628[] =3D { FUNC("spi", 0, 7, 4) = }; +static struct rt2880_pmx_func refclk_grp_mt76x8[] =3D { FUNC("refclk", 0, = 37, 1) }; +static struct rt2880_pmx_func perst_grp_mt76x8[] =3D { FUNC("perst", 0, 36= , 1) }; +static struct rt2880_pmx_func wdt_grp_mt76x8[] =3D { FUNC("wdt", 0, 38, 1)= }; +static struct rt2880_pmx_func spi_grp_mt76x8[] =3D { FUNC("spi", 0, 7, 4) = }; =20 -static struct rt2880_pmx_func sd_mode_grp_mt7628[] =3D { +static struct rt2880_pmx_func sd_mode_grp_mt76x8[] =3D { FUNC("jtag", 3, 22, 8), FUNC("utif", 2, 22, 8), FUNC("gpio", 1, 22, 8), FUNC("sdxc", 0, 22, 8), }; =20 -static struct rt2880_pmx_func uart0_grp_mt7628[] =3D { +static struct rt2880_pmx_func uart0_grp_mt76x8[] =3D { FUNC("-", 3, 12, 2), FUNC("-", 2, 12, 2), FUNC("gpio", 1, 12, 2), FUNC("uart0", 0, 12, 2), }; =20 -static struct rt2880_pmx_func i2s_grp_mt7628[] =3D { +static struct rt2880_pmx_func i2s_grp_mt76x8[] =3D { FUNC("antenna", 3, 0, 4), FUNC("pcm", 2, 0, 4), FUNC("gpio", 1, 0, 4), FUNC("i2s", 0, 0, 4), }; =20 -static struct rt2880_pmx_func spi_cs1_grp_mt7628[] =3D { +static struct rt2880_pmx_func spi_cs1_grp_mt76x8[] =3D { FUNC("-", 3, 6, 1), FUNC("refclk", 2, 6, 1), FUNC("gpio", 1, 6, 1), FUNC("spi cs1", 0, 6, 1), }; =20 -static struct rt2880_pmx_func spis_grp_mt7628[] =3D { +static struct rt2880_pmx_func spis_grp_mt76x8[] =3D { FUNC("pwm_uart2", 3, 14, 4), FUNC("utif", 2, 14, 4), FUNC("gpio", 1, 14, 4), FUNC("spis", 0, 14, 4), }; =20 -static struct rt2880_pmx_func gpio_grp_mt7628[] =3D { +static struct rt2880_pmx_func gpio_grp_mt76x8[] =3D { FUNC("pcie", 3, 11, 1), FUNC("refclk", 2, 11, 1), FUNC("gpio", 1, 11, 1), FUNC("gpio", 0, 11, 1), }; =20 -static struct rt2880_pmx_func p4led_kn_grp_mt7628[] =3D { +static struct rt2880_pmx_func p4led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 30, 1), FUNC("utif", 2, 30, 1), FUNC("gpio", 1, 30, 1), FUNC("p4led_kn", 0, 30, 1), }; =20 -static struct rt2880_pmx_func p3led_kn_grp_mt7628[] =3D { +static struct rt2880_pmx_func p3led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 31, 1), FUNC("utif", 2, 31, 1), FUNC("gpio", 1, 31, 1), FUNC("p3led_kn", 0, 31, 1), }; =20 -static struct rt2880_pmx_func p2led_kn_grp_mt7628[] =3D { +static struct rt2880_pmx_func p2led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 32, 1), FUNC("utif", 2, 32, 1), FUNC("gpio", 1, 32, 1), FUNC("p2led_kn", 0, 32, 1), }; =20 -static struct rt2880_pmx_func p1led_kn_grp_mt7628[] =3D { +static struct rt2880_pmx_func p1led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 33, 1), FUNC("utif", 2, 33, 1), FUNC("gpio", 1, 33, 1), FUNC("p1led_kn", 0, 33, 1), }; =20 -static struct rt2880_pmx_func p0led_kn_grp_mt7628[] =3D { +static struct rt2880_pmx_func p0led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 34, 1), FUNC("rsvd", 2, 34, 1), FUNC("gpio", 1, 34, 1), FUNC("p0led_kn", 0, 34, 1), }; =20 -static struct rt2880_pmx_func wled_kn_grp_mt7628[] =3D { +static struct rt2880_pmx_func wled_kn_grp_mt76x8[] =3D { FUNC("rsvd", 3, 35, 1), FUNC("rsvd", 2, 35, 1), FUNC("gpio", 1, 35, 1), FUNC("wled_kn", 0, 35, 1), }; =20 -static struct rt2880_pmx_func p4led_an_grp_mt7628[] =3D { +static struct rt2880_pmx_func p4led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 39, 1), FUNC("utif", 2, 39, 1), FUNC("gpio", 1, 39, 1), FUNC("p4led_an", 0, 39, 1), }; =20 -static struct rt2880_pmx_func p3led_an_grp_mt7628[] =3D { +static struct rt2880_pmx_func p3led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 40, 1), FUNC("utif", 2, 40, 1), FUNC("gpio", 1, 40, 1), FUNC("p3led_an", 0, 40, 1), }; =20 -static struct rt2880_pmx_func p2led_an_grp_mt7628[] =3D { +static struct rt2880_pmx_func p2led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 41, 1), FUNC("utif", 2, 41, 1), FUNC("gpio", 1, 41, 1), FUNC("p2led_an", 0, 41, 1), }; =20 -static struct rt2880_pmx_func p1led_an_grp_mt7628[] =3D { +static struct rt2880_pmx_func p1led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 42, 1), FUNC("utif", 2, 42, 1), FUNC("gpio", 1, 42, 1), FUNC("p1led_an", 0, 42, 1), }; =20 -static struct rt2880_pmx_func p0led_an_grp_mt7628[] =3D { +static struct rt2880_pmx_func p0led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 43, 1), FUNC("rsvd", 2, 43, 1), FUNC("gpio", 1, 43, 1), FUNC("p0led_an", 0, 43, 1), }; =20 -static struct rt2880_pmx_func wled_an_grp_mt7628[] =3D { +static struct rt2880_pmx_func wled_an_grp_mt76x8[] =3D { FUNC("rsvd", 3, 44, 1), FUNC("rsvd", 2, 44, 1), FUNC("gpio", 1, 44, 1), FUNC("wled_an", 0, 44, 1), }; =20 -#define MT7628_GPIO_MODE_MASK 0x3 - -#define MT7628_GPIO_MODE_P4LED_KN 58 -#define MT7628_GPIO_MODE_P3LED_KN 56 -#define MT7628_GPIO_MODE_P2LED_KN 54 -#define MT7628_GPIO_MODE_P1LED_KN 52 -#define MT7628_GPIO_MODE_P0LED_KN 50 -#define MT7628_GPIO_MODE_WLED_KN 48 -#define MT7628_GPIO_MODE_P4LED_AN 42 -#define MT7628_GPIO_MODE_P3LED_AN 40 -#define MT7628_GPIO_MODE_P2LED_AN 38 -#define MT7628_GPIO_MODE_P1LED_AN 36 -#define MT7628_GPIO_MODE_P0LED_AN 34 -#define MT7628_GPIO_MODE_WLED_AN 32 -#define MT7628_GPIO_MODE_PWM1 30 -#define MT7628_GPIO_MODE_PWM0 28 -#define MT7628_GPIO_MODE_UART2 26 -#define MT7628_GPIO_MODE_UART1 24 -#define MT7628_GPIO_MODE_I2C 20 -#define MT7628_GPIO_MODE_REFCLK 18 -#define MT7628_GPIO_MODE_PERST 16 -#define MT7628_GPIO_MODE_WDT 14 -#define MT7628_GPIO_MODE_SPI 12 -#define MT7628_GPIO_MODE_SDMODE 10 -#define MT7628_GPIO_MODE_UART0 8 -#define MT7628_GPIO_MODE_I2S 6 -#define MT7628_GPIO_MODE_CS1 4 -#define MT7628_GPIO_MODE_SPIS 2 -#define MT7628_GPIO_MODE_GPIO 0 - -static struct rt2880_pmx_group mt7628an_pinmux_data[] =3D { - GRP_G("pwm1", pwm1_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_PWM1), - GRP_G("pwm0", pwm0_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_PWM0), - GRP_G("uart2", uart2_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_UART2), - GRP_G("uart1", uart1_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_UART1), - GRP_G("i2c", i2c_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_I2C), - GRP("refclk", refclk_grp_mt7628, 1, MT7628_GPIO_MODE_REFCLK), - GRP("perst", perst_grp_mt7628, 1, MT7628_GPIO_MODE_PERST), - GRP("wdt", wdt_grp_mt7628, 1, MT7628_GPIO_MODE_WDT), - GRP("spi", spi_grp_mt7628, 1, MT7628_GPIO_MODE_SPI), - GRP_G("sdmode", sd_mode_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_SDMODE), - GRP_G("uart0", uart0_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_UART0), - GRP_G("i2s", i2s_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_I2S), - GRP_G("spi cs1", spi_cs1_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_CS1), - GRP_G("spis", spis_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_SPIS), - GRP_G("gpio", gpio_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_GPIO), - GRP_G("wled_an", wled_an_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_WLED_AN), - GRP_G("p0led_an", p0led_an_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P0LED_AN), - GRP_G("p1led_an", p1led_an_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P1LED_AN), - GRP_G("p2led_an", p2led_an_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P2LED_AN), - GRP_G("p3led_an", p3led_an_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P3LED_AN), - GRP_G("p4led_an", p4led_an_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P4LED_AN), - GRP_G("wled_kn", wled_kn_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_WLED_KN), - GRP_G("p0led_kn", p0led_kn_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P0LED_KN), - GRP_G("p1led_kn", p1led_kn_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P1LED_KN), - GRP_G("p2led_kn", p2led_kn_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P2LED_KN), - GRP_G("p3led_kn", p3led_kn_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P3LED_KN), - GRP_G("p4led_kn", p4led_kn_grp_mt7628, MT7628_GPIO_MODE_MASK, - 1, MT7628_GPIO_MODE_P4LED_KN), +#define MT76X8_GPIO_MODE_MASK 0x3 + +#define MT76X8_GPIO_MODE_P4LED_KN 58 +#define MT76X8_GPIO_MODE_P3LED_KN 56 +#define MT76X8_GPIO_MODE_P2LED_KN 54 +#define MT76X8_GPIO_MODE_P1LED_KN 52 +#define MT76X8_GPIO_MODE_P0LED_KN 50 +#define MT76X8_GPIO_MODE_WLED_KN 48 +#define MT76X8_GPIO_MODE_P4LED_AN 42 +#define MT76X8_GPIO_MODE_P3LED_AN 40 +#define MT76X8_GPIO_MODE_P2LED_AN 38 +#define MT76X8_GPIO_MODE_P1LED_AN 36 +#define MT76X8_GPIO_MODE_P0LED_AN 34 +#define MT76X8_GPIO_MODE_WLED_AN 32 +#define MT76X8_GPIO_MODE_PWM1 30 +#define MT76X8_GPIO_MODE_PWM0 28 +#define MT76X8_GPIO_MODE_UART2 26 +#define MT76X8_GPIO_MODE_UART1 24 +#define MT76X8_GPIO_MODE_I2C 20 +#define MT76X8_GPIO_MODE_REFCLK 18 +#define MT76X8_GPIO_MODE_PERST 16 +#define MT76X8_GPIO_MODE_WDT 14 +#define MT76X8_GPIO_MODE_SPI 12 +#define MT76X8_GPIO_MODE_SDMODE 10 +#define MT76X8_GPIO_MODE_UART0 8 +#define MT76X8_GPIO_MODE_I2S 6 +#define MT76X8_GPIO_MODE_CS1 4 +#define MT76X8_GPIO_MODE_SPIS 2 +#define MT76X8_GPIO_MODE_GPIO 0 + +static struct rt2880_pmx_group mt76x8_pinmux_data[] =3D { + GRP_G("pwm1", pwm1_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_PWM1), + GRP_G("pwm0", pwm0_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_PWM0), + GRP_G("uart2", uart2_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_UART2), + GRP_G("uart1", uart1_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_UART1), + GRP_G("i2c", i2c_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_I2C), + GRP("refclk", refclk_grp_mt76x8, 1, MT76X8_GPIO_MODE_REFCLK), + GRP("perst", perst_grp_mt76x8, 1, MT76X8_GPIO_MODE_PERST), + GRP("wdt", wdt_grp_mt76x8, 1, MT76X8_GPIO_MODE_WDT), + GRP("spi", spi_grp_mt76x8, 1, MT76X8_GPIO_MODE_SPI), + GRP_G("sdmode", sd_mode_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_SDMODE), + GRP_G("uart0", uart0_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_UART0), + GRP_G("i2s", i2s_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_I2S), + GRP_G("spi cs1", spi_cs1_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_CS1), + GRP_G("spis", spis_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_SPIS), + GRP_G("gpio", gpio_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_GPIO), + GRP_G("wled_an", wled_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_WLED_AN), + GRP_G("p0led_an", p0led_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P0LED_AN), + GRP_G("p1led_an", p1led_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P1LED_AN), + GRP_G("p2led_an", p2led_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P2LED_AN), + GRP_G("p3led_an", p3led_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P3LED_AN), + GRP_G("p4led_an", p4led_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P4LED_AN), + GRP_G("wled_kn", wled_kn_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_WLED_KN), + GRP_G("p0led_kn", p0led_kn_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P0LED_KN), + GRP_G("p1led_kn", p1led_kn_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P1LED_KN), + GRP_G("p2led_kn", p2led_kn_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P2LED_KN), + GRP_G("p3led_kn", p3led_kn_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P3LED_KN), + GRP_G("p4led_kn", p4led_kn_grp_mt76x8, MT76X8_GPIO_MODE_MASK, + 1, MT76X8_GPIO_MODE_P4LED_KN), { 0 } }; =20 static int mt7620_pinmux_probe(struct platform_device *pdev) { if (is_mt76x8()) - return rt2880_pinmux_init(pdev, mt7628an_pinmux_data); + return rt2880_pinmux_init(pdev, mt76x8_pinmux_data); else return rt2880_pinmux_init(pdev, mt7620a_pinmux_data); } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF723C04A68 for ; Wed, 27 Jul 2022 17:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233960AbiG0Rbs (ORCPT ); Wed, 27 Jul 2022 13:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242319AbiG0R3Z (ORCPT ); Wed, 27 Jul 2022 13:29:25 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 374BC8049A; Wed, 27 Jul 2022 09:47:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1F433CE2314; Wed, 27 Jul 2022 16:47:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89130C433D6; Wed, 27 Jul 2022 16:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940449; bh=7+QOaPl6X2wUo779kjghaLkfqQGV8c0zdFf9/rbyZD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abxOHBOiUBJ/613wUJsP7Bri0EBzh3zuK0jzre6WqX0MxvjVBskYAI8a5iqsa6IvU //9dFOlgmwHdWnPdTVFic8g0RrOsyV/45Z8loIYTSa2UvDxntbPnhR9BsBDzeGv/Fr lcVSTz/QBaqeZjpdXryCohZ2haAYvB9TdkHtkM4Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Sergio Paracuellos , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 026/158] pinctrl: ralink: rename pinctrl-rt2880 to pinctrl-ralink Date: Wed, 27 Jul 2022 18:11:30 +0200 Message-Id: <20220727161022.518238346@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ar=C4=B1n=C3=A7 =C3=9CNAL [ Upstream commit 6b3dd85b0bdec1a8308fa5dcbafcd5d55b5f3608 ] pinctrl-rt2880.c and pinmux.h make up the Ralink pinctrl driver. Rename pinctrl-rt2880.c to pinctrl-ralink.c. Rename pinmux.h to pinctrl-ralink.h. Fix references to it. Rename functions that include "rt2880" to "ralink". Remove PINCTRL_RT2880 symbol and make the existing PINCTRL_RALINK symbol compile pinctrl-ralink.c. Change the bool to "Ralink pinctrl driver". Signed-off-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Reviewed-by: Sergio Paracuellos Acked-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20220414173916.5552-3-arinc.unal@arinc9.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/ralink/Kconfig | 16 ++-- drivers/pinctrl/ralink/Makefile | 2 +- drivers/pinctrl/ralink/pinctrl-mt7620.c | 92 +++++++++---------- drivers/pinctrl/ralink/pinctrl-mt7621.c | 30 +++--- .../{pinctrl-rt2880.c =3D> pinctrl-ralink.c} | 90 +++++++++--------- .../ralink/{pinmux.h =3D> pinctrl-ralink.h} | 16 ++-- drivers/pinctrl/ralink/pinctrl-rt288x.c | 20 ++-- drivers/pinctrl/ralink/pinctrl-rt305x.c | 44 ++++----- drivers/pinctrl/ralink/pinctrl-rt3883.c | 28 +++--- 9 files changed, 167 insertions(+), 171 deletions(-) rename drivers/pinctrl/ralink/{pinctrl-rt2880.c =3D> pinctrl-ralink.c} (73= %) rename drivers/pinctrl/ralink/{pinmux.h =3D> pinctrl-ralink.h} (75%) diff --git a/drivers/pinctrl/ralink/Kconfig b/drivers/pinctrl/ralink/Kconfig index a76ee3deb8c3..d0f0a8f2b9b7 100644 --- a/drivers/pinctrl/ralink/Kconfig +++ b/drivers/pinctrl/ralink/Kconfig @@ -3,37 +3,33 @@ menu "Ralink pinctrl drivers" depends on RALINK =20 config PINCTRL_RALINK - bool "Ralink pin control support" - default y if RALINK - -config PINCTRL_RT2880 - bool "RT2880 pinctrl driver for RALINK/Mediatek SOCs" + bool "Ralink pinctrl driver" select PINMUX select GENERIC_PINCONF =20 config PINCTRL_MT7620 bool "mt7620 pinctrl driver for RALINK/Mediatek SOCs" depends on RALINK && SOC_MT7620 - select PINCTRL_RT2880 + select PINCTRL_RALINK =20 config PINCTRL_MT7621 bool "mt7621 pinctrl driver for RALINK/Mediatek SOCs" depends on RALINK && SOC_MT7621 - select PINCTRL_RT2880 + select PINCTRL_RALINK =20 config PINCTRL_RT288X bool "RT288X pinctrl driver for RALINK/Mediatek SOCs" depends on RALINK && SOC_RT288X - select PINCTRL_RT2880 + select PINCTRL_RALINK =20 config PINCTRL_RT305X bool "RT305X pinctrl driver for RALINK/Mediatek SOCs" depends on RALINK && SOC_RT305X - select PINCTRL_RT2880 + select PINCTRL_RALINK =20 config PINCTRL_RT3883 bool "RT3883 pinctrl driver for RALINK/Mediatek SOCs" depends on RALINK && SOC_RT3883 - select PINCTRL_RT2880 + select PINCTRL_RALINK =20 endmenu diff --git a/drivers/pinctrl/ralink/Makefile b/drivers/pinctrl/ralink/Makef= ile index a15610206ced..2c1323b74e96 100644 --- a/drivers/pinctrl/ralink/Makefile +++ b/drivers/pinctrl/ralink/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_PINCTRL_RT2880) +=3D pinctrl-rt2880.o +obj-$(CONFIG_PINCTRL_RALINK) +=3D pinctrl-ralink.o =20 obj-$(CONFIG_PINCTRL_MT7620) +=3D pinctrl-mt7620.o obj-$(CONFIG_PINCTRL_MT7621) +=3D pinctrl-mt7621.o diff --git a/drivers/pinctrl/ralink/pinctrl-mt7620.c b/drivers/pinctrl/rali= nk/pinctrl-mt7620.c index d3f9feec1f74..51b863d85c51 100644 --- a/drivers/pinctrl/ralink/pinctrl-mt7620.c +++ b/drivers/pinctrl/ralink/pinctrl-mt7620.c @@ -5,7 +5,7 @@ #include #include #include -#include "pinmux.h" +#include "pinctrl-ralink.h" =20 #define MT7620_GPIO_MODE_UART0_SHIFT 2 #define MT7620_GPIO_MODE_UART0_MASK 0x7 @@ -54,20 +54,20 @@ #define MT7620_GPIO_MODE_EPHY 15 #define MT7620_GPIO_MODE_PA 20 =20 -static struct rt2880_pmx_func i2c_grp[] =3D { FUNC("i2c", 0, 1, 2) }; -static struct rt2880_pmx_func spi_grp[] =3D { FUNC("spi", 0, 3, 4) }; -static struct rt2880_pmx_func uartlite_grp[] =3D { FUNC("uartlite", 0, 15,= 2) }; -static struct rt2880_pmx_func mdio_grp[] =3D { +static struct ralink_pmx_func i2c_grp[] =3D { FUNC("i2c", 0, 1, 2) }; +static struct ralink_pmx_func spi_grp[] =3D { FUNC("spi", 0, 3, 4) }; +static struct ralink_pmx_func uartlite_grp[] =3D { FUNC("uartlite", 0, 15,= 2) }; +static struct ralink_pmx_func mdio_grp[] =3D { FUNC("mdio", MT7620_GPIO_MODE_MDIO, 22, 2), FUNC("refclk", MT7620_GPIO_MODE_MDIO_REFCLK, 22, 2), }; -static struct rt2880_pmx_func rgmii1_grp[] =3D { FUNC("rgmii1", 0, 24, 12)= }; -static struct rt2880_pmx_func refclk_grp[] =3D { FUNC("spi refclk", 0, 37,= 3) }; -static struct rt2880_pmx_func ephy_grp[] =3D { FUNC("ephy", 0, 40, 5) }; -static struct rt2880_pmx_func rgmii2_grp[] =3D { FUNC("rgmii2", 0, 60, 12)= }; -static struct rt2880_pmx_func wled_grp[] =3D { FUNC("wled", 0, 72, 1) }; -static struct rt2880_pmx_func pa_grp[] =3D { FUNC("pa", 0, 18, 4) }; -static struct rt2880_pmx_func uartf_grp[] =3D { +static struct ralink_pmx_func rgmii1_grp[] =3D { FUNC("rgmii1", 0, 24, 12)= }; +static struct ralink_pmx_func refclk_grp[] =3D { FUNC("spi refclk", 0, 37,= 3) }; +static struct ralink_pmx_func ephy_grp[] =3D { FUNC("ephy", 0, 40, 5) }; +static struct ralink_pmx_func rgmii2_grp[] =3D { FUNC("rgmii2", 0, 60, 12)= }; +static struct ralink_pmx_func wled_grp[] =3D { FUNC("wled", 0, 72, 1) }; +static struct ralink_pmx_func pa_grp[] =3D { FUNC("pa", 0, 18, 4) }; +static struct ralink_pmx_func uartf_grp[] =3D { FUNC("uartf", MT7620_GPIO_MODE_UARTF, 7, 8), FUNC("pcm uartf", MT7620_GPIO_MODE_PCM_UARTF, 7, 8), FUNC("pcm i2s", MT7620_GPIO_MODE_PCM_I2S, 7, 8), @@ -76,20 +76,20 @@ static struct rt2880_pmx_func uartf_grp[] =3D { FUNC("gpio uartf", MT7620_GPIO_MODE_GPIO_UARTF, 7, 4), FUNC("gpio i2s", MT7620_GPIO_MODE_GPIO_I2S, 7, 4), }; -static struct rt2880_pmx_func wdt_grp[] =3D { +static struct ralink_pmx_func wdt_grp[] =3D { FUNC("wdt rst", 0, 17, 1), FUNC("wdt refclk", 0, 17, 1), }; -static struct rt2880_pmx_func pcie_rst_grp[] =3D { +static struct ralink_pmx_func pcie_rst_grp[] =3D { FUNC("pcie rst", MT7620_GPIO_MODE_PCIE_RST, 36, 1), FUNC("pcie refclk", MT7620_GPIO_MODE_PCIE_REF, 36, 1) }; -static struct rt2880_pmx_func nd_sd_grp[] =3D { +static struct ralink_pmx_func nd_sd_grp[] =3D { FUNC("nand", MT7620_GPIO_MODE_NAND, 45, 15), FUNC("sd", MT7620_GPIO_MODE_SD, 47, 13) }; =20 -static struct rt2880_pmx_group mt7620a_pinmux_data[] =3D { +static struct ralink_pmx_group mt7620a_pinmux_data[] =3D { GRP("i2c", i2c_grp, 1, MT7620_GPIO_MODE_I2C), GRP("uartf", uartf_grp, MT7620_GPIO_MODE_UART0_MASK, MT7620_GPIO_MODE_UART0_SHIFT), @@ -112,166 +112,166 @@ static struct rt2880_pmx_group mt7620a_pinmux_data[= ] =3D { { 0 } }; =20 -static struct rt2880_pmx_func pwm1_grp_mt76x8[] =3D { +static struct ralink_pmx_func pwm1_grp_mt76x8[] =3D { FUNC("sdxc d6", 3, 19, 1), FUNC("utif", 2, 19, 1), FUNC("gpio", 1, 19, 1), FUNC("pwm1", 0, 19, 1), }; =20 -static struct rt2880_pmx_func pwm0_grp_mt76x8[] =3D { +static struct ralink_pmx_func pwm0_grp_mt76x8[] =3D { FUNC("sdxc d7", 3, 18, 1), FUNC("utif", 2, 18, 1), FUNC("gpio", 1, 18, 1), FUNC("pwm0", 0, 18, 1), }; =20 -static struct rt2880_pmx_func uart2_grp_mt76x8[] =3D { +static struct ralink_pmx_func uart2_grp_mt76x8[] =3D { FUNC("sdxc d5 d4", 3, 20, 2), FUNC("pwm", 2, 20, 2), FUNC("gpio", 1, 20, 2), FUNC("uart2", 0, 20, 2), }; =20 -static struct rt2880_pmx_func uart1_grp_mt76x8[] =3D { +static struct ralink_pmx_func uart1_grp_mt76x8[] =3D { FUNC("sw_r", 3, 45, 2), FUNC("pwm", 2, 45, 2), FUNC("gpio", 1, 45, 2), FUNC("uart1", 0, 45, 2), }; =20 -static struct rt2880_pmx_func i2c_grp_mt76x8[] =3D { +static struct ralink_pmx_func i2c_grp_mt76x8[] =3D { FUNC("-", 3, 4, 2), FUNC("debug", 2, 4, 2), FUNC("gpio", 1, 4, 2), FUNC("i2c", 0, 4, 2), }; =20 -static struct rt2880_pmx_func refclk_grp_mt76x8[] =3D { FUNC("refclk", 0, = 37, 1) }; -static struct rt2880_pmx_func perst_grp_mt76x8[] =3D { FUNC("perst", 0, 36= , 1) }; -static struct rt2880_pmx_func wdt_grp_mt76x8[] =3D { FUNC("wdt", 0, 38, 1)= }; -static struct rt2880_pmx_func spi_grp_mt76x8[] =3D { FUNC("spi", 0, 7, 4) = }; +static struct ralink_pmx_func refclk_grp_mt76x8[] =3D { FUNC("refclk", 0, = 37, 1) }; +static struct ralink_pmx_func perst_grp_mt76x8[] =3D { FUNC("perst", 0, 36= , 1) }; +static struct ralink_pmx_func wdt_grp_mt76x8[] =3D { FUNC("wdt", 0, 38, 1)= }; +static struct ralink_pmx_func spi_grp_mt76x8[] =3D { FUNC("spi", 0, 7, 4) = }; =20 -static struct rt2880_pmx_func sd_mode_grp_mt76x8[] =3D { +static struct ralink_pmx_func sd_mode_grp_mt76x8[] =3D { FUNC("jtag", 3, 22, 8), FUNC("utif", 2, 22, 8), FUNC("gpio", 1, 22, 8), FUNC("sdxc", 0, 22, 8), }; =20 -static struct rt2880_pmx_func uart0_grp_mt76x8[] =3D { +static struct ralink_pmx_func uart0_grp_mt76x8[] =3D { FUNC("-", 3, 12, 2), FUNC("-", 2, 12, 2), FUNC("gpio", 1, 12, 2), FUNC("uart0", 0, 12, 2), }; =20 -static struct rt2880_pmx_func i2s_grp_mt76x8[] =3D { +static struct ralink_pmx_func i2s_grp_mt76x8[] =3D { FUNC("antenna", 3, 0, 4), FUNC("pcm", 2, 0, 4), FUNC("gpio", 1, 0, 4), FUNC("i2s", 0, 0, 4), }; =20 -static struct rt2880_pmx_func spi_cs1_grp_mt76x8[] =3D { +static struct ralink_pmx_func spi_cs1_grp_mt76x8[] =3D { FUNC("-", 3, 6, 1), FUNC("refclk", 2, 6, 1), FUNC("gpio", 1, 6, 1), FUNC("spi cs1", 0, 6, 1), }; =20 -static struct rt2880_pmx_func spis_grp_mt76x8[] =3D { +static struct ralink_pmx_func spis_grp_mt76x8[] =3D { FUNC("pwm_uart2", 3, 14, 4), FUNC("utif", 2, 14, 4), FUNC("gpio", 1, 14, 4), FUNC("spis", 0, 14, 4), }; =20 -static struct rt2880_pmx_func gpio_grp_mt76x8[] =3D { +static struct ralink_pmx_func gpio_grp_mt76x8[] =3D { FUNC("pcie", 3, 11, 1), FUNC("refclk", 2, 11, 1), FUNC("gpio", 1, 11, 1), FUNC("gpio", 0, 11, 1), }; =20 -static struct rt2880_pmx_func p4led_kn_grp_mt76x8[] =3D { +static struct ralink_pmx_func p4led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 30, 1), FUNC("utif", 2, 30, 1), FUNC("gpio", 1, 30, 1), FUNC("p4led_kn", 0, 30, 1), }; =20 -static struct rt2880_pmx_func p3led_kn_grp_mt76x8[] =3D { +static struct ralink_pmx_func p3led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 31, 1), FUNC("utif", 2, 31, 1), FUNC("gpio", 1, 31, 1), FUNC("p3led_kn", 0, 31, 1), }; =20 -static struct rt2880_pmx_func p2led_kn_grp_mt76x8[] =3D { +static struct ralink_pmx_func p2led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 32, 1), FUNC("utif", 2, 32, 1), FUNC("gpio", 1, 32, 1), FUNC("p2led_kn", 0, 32, 1), }; =20 -static struct rt2880_pmx_func p1led_kn_grp_mt76x8[] =3D { +static struct ralink_pmx_func p1led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 33, 1), FUNC("utif", 2, 33, 1), FUNC("gpio", 1, 33, 1), FUNC("p1led_kn", 0, 33, 1), }; =20 -static struct rt2880_pmx_func p0led_kn_grp_mt76x8[] =3D { +static struct ralink_pmx_func p0led_kn_grp_mt76x8[] =3D { FUNC("jtag", 3, 34, 1), FUNC("rsvd", 2, 34, 1), FUNC("gpio", 1, 34, 1), FUNC("p0led_kn", 0, 34, 1), }; =20 -static struct rt2880_pmx_func wled_kn_grp_mt76x8[] =3D { +static struct ralink_pmx_func wled_kn_grp_mt76x8[] =3D { FUNC("rsvd", 3, 35, 1), FUNC("rsvd", 2, 35, 1), FUNC("gpio", 1, 35, 1), FUNC("wled_kn", 0, 35, 1), }; =20 -static struct rt2880_pmx_func p4led_an_grp_mt76x8[] =3D { +static struct ralink_pmx_func p4led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 39, 1), FUNC("utif", 2, 39, 1), FUNC("gpio", 1, 39, 1), FUNC("p4led_an", 0, 39, 1), }; =20 -static struct rt2880_pmx_func p3led_an_grp_mt76x8[] =3D { +static struct ralink_pmx_func p3led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 40, 1), FUNC("utif", 2, 40, 1), FUNC("gpio", 1, 40, 1), FUNC("p3led_an", 0, 40, 1), }; =20 -static struct rt2880_pmx_func p2led_an_grp_mt76x8[] =3D { +static struct ralink_pmx_func p2led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 41, 1), FUNC("utif", 2, 41, 1), FUNC("gpio", 1, 41, 1), FUNC("p2led_an", 0, 41, 1), }; =20 -static struct rt2880_pmx_func p1led_an_grp_mt76x8[] =3D { +static struct ralink_pmx_func p1led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 42, 1), FUNC("utif", 2, 42, 1), FUNC("gpio", 1, 42, 1), FUNC("p1led_an", 0, 42, 1), }; =20 -static struct rt2880_pmx_func p0led_an_grp_mt76x8[] =3D { +static struct ralink_pmx_func p0led_an_grp_mt76x8[] =3D { FUNC("jtag", 3, 43, 1), FUNC("rsvd", 2, 43, 1), FUNC("gpio", 1, 43, 1), FUNC("p0led_an", 0, 43, 1), }; =20 -static struct rt2880_pmx_func wled_an_grp_mt76x8[] =3D { +static struct ralink_pmx_func wled_an_grp_mt76x8[] =3D { FUNC("rsvd", 3, 44, 1), FUNC("rsvd", 2, 44, 1), FUNC("gpio", 1, 44, 1), @@ -308,7 +308,7 @@ static struct rt2880_pmx_func wled_an_grp_mt76x8[] =3D { #define MT76X8_GPIO_MODE_SPIS 2 #define MT76X8_GPIO_MODE_GPIO 0 =20 -static struct rt2880_pmx_group mt76x8_pinmux_data[] =3D { +static struct ralink_pmx_group mt76x8_pinmux_data[] =3D { GRP_G("pwm1", pwm1_grp_mt76x8, MT76X8_GPIO_MODE_MASK, 1, MT76X8_GPIO_MODE_PWM1), GRP_G("pwm0", pwm0_grp_mt76x8, MT76X8_GPIO_MODE_MASK, @@ -365,9 +365,9 @@ static struct rt2880_pmx_group mt76x8_pinmux_data[] =3D= { static int mt7620_pinmux_probe(struct platform_device *pdev) { if (is_mt76x8()) - return rt2880_pinmux_init(pdev, mt76x8_pinmux_data); + return ralink_pinmux_init(pdev, mt76x8_pinmux_data); else - return rt2880_pinmux_init(pdev, mt7620a_pinmux_data); + return ralink_pinmux_init(pdev, mt7620a_pinmux_data); } =20 static const struct of_device_id mt7620_pinmux_match[] =3D { diff --git a/drivers/pinctrl/ralink/pinctrl-mt7621.c b/drivers/pinctrl/rali= nk/pinctrl-mt7621.c index 7d96144c474e..14b89cb43d4c 100644 --- a/drivers/pinctrl/ralink/pinctrl-mt7621.c +++ b/drivers/pinctrl/ralink/pinctrl-mt7621.c @@ -3,7 +3,7 @@ #include #include #include -#include "pinmux.h" +#include "pinctrl-ralink.h" =20 #define MT7621_GPIO_MODE_UART1 1 #define MT7621_GPIO_MODE_I2C 2 @@ -34,40 +34,40 @@ #define MT7621_GPIO_MODE_SDHCI_SHIFT 18 #define MT7621_GPIO_MODE_SDHCI_GPIO 1 =20 -static struct rt2880_pmx_func uart1_grp[] =3D { FUNC("uart1", 0, 1, 2) }; -static struct rt2880_pmx_func i2c_grp[] =3D { FUNC("i2c", 0, 3, 2) }; -static struct rt2880_pmx_func uart3_grp[] =3D { +static struct ralink_pmx_func uart1_grp[] =3D { FUNC("uart1", 0, 1, 2) }; +static struct ralink_pmx_func i2c_grp[] =3D { FUNC("i2c", 0, 3, 2) }; +static struct ralink_pmx_func uart3_grp[] =3D { FUNC("uart3", 0, 5, 4), FUNC("i2s", 2, 5, 4), FUNC("spdif3", 3, 5, 4), }; -static struct rt2880_pmx_func uart2_grp[] =3D { +static struct ralink_pmx_func uart2_grp[] =3D { FUNC("uart2", 0, 9, 4), FUNC("pcm", 2, 9, 4), FUNC("spdif2", 3, 9, 4), }; -static struct rt2880_pmx_func jtag_grp[] =3D { FUNC("jtag", 0, 13, 5) }; -static struct rt2880_pmx_func wdt_grp[] =3D { +static struct ralink_pmx_func jtag_grp[] =3D { FUNC("jtag", 0, 13, 5) }; +static struct ralink_pmx_func wdt_grp[] =3D { FUNC("wdt rst", 0, 18, 1), FUNC("wdt refclk", 2, 18, 1), }; -static struct rt2880_pmx_func pcie_rst_grp[] =3D { +static struct ralink_pmx_func pcie_rst_grp[] =3D { FUNC("pcie rst", MT7621_GPIO_MODE_PCIE_RST, 19, 1), FUNC("pcie refclk", MT7621_GPIO_MODE_PCIE_REF, 19, 1) }; -static struct rt2880_pmx_func mdio_grp[] =3D { FUNC("mdio", 0, 20, 2) }; -static struct rt2880_pmx_func rgmii2_grp[] =3D { FUNC("rgmii2", 0, 22, 12)= }; -static struct rt2880_pmx_func spi_grp[] =3D { +static struct ralink_pmx_func mdio_grp[] =3D { FUNC("mdio", 0, 20, 2) }; +static struct ralink_pmx_func rgmii2_grp[] =3D { FUNC("rgmii2", 0, 22, 12)= }; +static struct ralink_pmx_func spi_grp[] =3D { FUNC("spi", 0, 34, 7), FUNC("nand1", 2, 34, 7), }; -static struct rt2880_pmx_func sdhci_grp[] =3D { +static struct ralink_pmx_func sdhci_grp[] =3D { FUNC("sdhci", 0, 41, 8), FUNC("nand2", 2, 41, 8), }; -static struct rt2880_pmx_func rgmii1_grp[] =3D { FUNC("rgmii1", 0, 49, 12)= }; +static struct ralink_pmx_func rgmii1_grp[] =3D { FUNC("rgmii1", 0, 49, 12)= }; =20 -static struct rt2880_pmx_group mt7621_pinmux_data[] =3D { +static struct ralink_pmx_group mt7621_pinmux_data[] =3D { GRP("uart1", uart1_grp, 1, MT7621_GPIO_MODE_UART1), GRP("i2c", i2c_grp, 1, MT7621_GPIO_MODE_I2C), GRP_G("uart3", uart3_grp, MT7621_GPIO_MODE_UART3_MASK, @@ -92,7 +92,7 @@ static struct rt2880_pmx_group mt7621_pinmux_data[] =3D { =20 static int mt7621_pinmux_probe(struct platform_device *pdev) { - return rt2880_pinmux_init(pdev, mt7621_pinmux_data); + return ralink_pinmux_init(pdev, mt7621_pinmux_data); } =20 static const struct of_device_id mt7621_pinmux_match[] =3D { diff --git a/drivers/pinctrl/ralink/pinctrl-rt2880.c b/drivers/pinctrl/rali= nk/pinctrl-ralink.c similarity index 73% rename from drivers/pinctrl/ralink/pinctrl-rt2880.c rename to drivers/pinctrl/ralink/pinctrl-ralink.c index 96fc06d1b8b9..841f23f55c95 100644 --- a/drivers/pinctrl/ralink/pinctrl-rt2880.c +++ b/drivers/pinctrl/ralink/pinctrl-ralink.c @@ -19,23 +19,23 @@ #include #include =20 -#include "pinmux.h" +#include "pinctrl-ralink.h" #include "../core.h" #include "../pinctrl-utils.h" =20 #define SYSC_REG_GPIO_MODE 0x60 #define SYSC_REG_GPIO_MODE2 0x64 =20 -struct rt2880_priv { +struct ralink_priv { struct device *dev; =20 struct pinctrl_pin_desc *pads; struct pinctrl_desc *desc; =20 - struct rt2880_pmx_func **func; + struct ralink_pmx_func **func; int func_count; =20 - struct rt2880_pmx_group *groups; + struct ralink_pmx_group *groups; const char **group_names; int group_count; =20 @@ -43,27 +43,27 @@ struct rt2880_priv { int max_pins; }; =20 -static int rt2880_get_group_count(struct pinctrl_dev *pctrldev) +static int ralink_get_group_count(struct pinctrl_dev *pctrldev) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 return p->group_count; } =20 -static const char *rt2880_get_group_name(struct pinctrl_dev *pctrldev, +static const char *ralink_get_group_name(struct pinctrl_dev *pctrldev, unsigned int group) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 return (group >=3D p->group_count) ? NULL : p->group_names[group]; } =20 -static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev, +static int ralink_get_group_pins(struct pinctrl_dev *pctrldev, unsigned int group, const unsigned int **pins, unsigned int *num_pins) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 if (group >=3D p->group_count) return -EINVAL; @@ -74,35 +74,35 @@ static int rt2880_get_group_pins(struct pinctrl_dev *pc= trldev, return 0; } =20 -static const struct pinctrl_ops rt2880_pctrl_ops =3D { - .get_groups_count =3D rt2880_get_group_count, - .get_group_name =3D rt2880_get_group_name, - .get_group_pins =3D rt2880_get_group_pins, +static const struct pinctrl_ops ralink_pctrl_ops =3D { + .get_groups_count =3D ralink_get_group_count, + .get_group_name =3D ralink_get_group_name, + .get_group_pins =3D ralink_get_group_pins, .dt_node_to_map =3D pinconf_generic_dt_node_to_map_all, .dt_free_map =3D pinconf_generic_dt_free_map, }; =20 -static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev) +static int ralink_pmx_func_count(struct pinctrl_dev *pctrldev) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 return p->func_count; } =20 -static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev, +static const char *ralink_pmx_func_name(struct pinctrl_dev *pctrldev, unsigned int func) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 return p->func[func]->name; } =20 -static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev, +static int ralink_pmx_group_get_groups(struct pinctrl_dev *pctrldev, unsigned int func, const char * const **groups, unsigned int * const num_groups) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 if (p->func[func]->group_count =3D=3D 1) *groups =3D &p->group_names[p->func[func]->groups[0]]; @@ -114,10 +114,10 @@ static int rt2880_pmx_group_get_groups(struct pinctrl= _dev *pctrldev, return 0; } =20 -static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, +static int ralink_pmx_group_enable(struct pinctrl_dev *pctrldev, unsigned int func, unsigned int group) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); u32 mode =3D 0; u32 reg =3D SYSC_REG_GPIO_MODE; int i; @@ -158,11 +158,11 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev= *pctrldev, return 0; } =20 -static int rt2880_pmx_group_gpio_request_enable(struct pinctrl_dev *pctrld= ev, +static int ralink_pmx_group_gpio_request_enable(struct pinctrl_dev *pctrld= ev, struct pinctrl_gpio_range *range, unsigned int pin) { - struct rt2880_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); + struct ralink_priv *p =3D pinctrl_dev_get_drvdata(pctrldev); =20 if (!p->gpio[pin]) { dev_err(p->dev, "pin %d is not set to gpio mux\n", pin); @@ -172,28 +172,28 @@ static int rt2880_pmx_group_gpio_request_enable(struc= t pinctrl_dev *pctrldev, return 0; } =20 -static const struct pinmux_ops rt2880_pmx_group_ops =3D { - .get_functions_count =3D rt2880_pmx_func_count, - .get_function_name =3D rt2880_pmx_func_name, - .get_function_groups =3D rt2880_pmx_group_get_groups, - .set_mux =3D rt2880_pmx_group_enable, - .gpio_request_enable =3D rt2880_pmx_group_gpio_request_enable, +static const struct pinmux_ops ralink_pmx_group_ops =3D { + .get_functions_count =3D ralink_pmx_func_count, + .get_function_name =3D ralink_pmx_func_name, + .get_function_groups =3D ralink_pmx_group_get_groups, + .set_mux =3D ralink_pmx_group_enable, + .gpio_request_enable =3D ralink_pmx_group_gpio_request_enable, }; =20 -static struct pinctrl_desc rt2880_pctrl_desc =3D { +static struct pinctrl_desc ralink_pctrl_desc =3D { .owner =3D THIS_MODULE, - .name =3D "rt2880-pinmux", - .pctlops =3D &rt2880_pctrl_ops, - .pmxops =3D &rt2880_pmx_group_ops, + .name =3D "ralink-pinmux", + .pctlops =3D &ralink_pctrl_ops, + .pmxops =3D &ralink_pmx_group_ops, }; =20 -static struct rt2880_pmx_func gpio_func =3D { +static struct ralink_pmx_func gpio_func =3D { .name =3D "gpio", }; =20 -static int rt2880_pinmux_index(struct rt2880_priv *p) +static int ralink_pinmux_index(struct ralink_priv *p) { - struct rt2880_pmx_group *mux =3D p->groups; + struct ralink_pmx_group *mux =3D p->groups; int i, j, c =3D 0; =20 /* count the mux functions */ @@ -248,7 +248,7 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) return 0; } =20 -static int rt2880_pinmux_pins(struct rt2880_priv *p) +static int ralink_pinmux_pins(struct ralink_priv *p) { int i, j; =20 @@ -311,10 +311,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) return 0; } =20 -int rt2880_pinmux_init(struct platform_device *pdev, - struct rt2880_pmx_group *data) +int ralink_pinmux_init(struct platform_device *pdev, + struct ralink_pmx_group *data) { - struct rt2880_priv *p; + struct ralink_priv *p; struct pinctrl_dev *dev; int err; =20 @@ -322,23 +322,23 @@ int rt2880_pinmux_init(struct platform_device *pdev, return -ENOTSUPP; =20 /* setup the private data */ - p =3D devm_kzalloc(&pdev->dev, sizeof(struct rt2880_priv), GFP_KERNEL); + p =3D devm_kzalloc(&pdev->dev, sizeof(struct ralink_priv), GFP_KERNEL); if (!p) return -ENOMEM; =20 p->dev =3D &pdev->dev; - p->desc =3D &rt2880_pctrl_desc; + p->desc =3D &ralink_pctrl_desc; p->groups =3D data; platform_set_drvdata(pdev, p); =20 /* init the device */ - err =3D rt2880_pinmux_index(p); + err =3D ralink_pinmux_index(p); if (err) { dev_err(&pdev->dev, "failed to load index\n"); return err; } =20 - err =3D rt2880_pinmux_pins(p); + err =3D ralink_pinmux_pins(p); if (err) { dev_err(&pdev->dev, "failed to load pins\n"); return err; diff --git a/drivers/pinctrl/ralink/pinmux.h b/drivers/pinctrl/ralink/pinct= rl-ralink.h similarity index 75% rename from drivers/pinctrl/ralink/pinmux.h rename to drivers/pinctrl/ralink/pinctrl-ralink.h index 0046abe3bcc7..134969409585 100644 --- a/drivers/pinctrl/ralink/pinmux.h +++ b/drivers/pinctrl/ralink/pinctrl-ralink.h @@ -3,8 +3,8 @@ * Copyright (C) 2012 John Crispin */ =20 -#ifndef _RT288X_PINMUX_H__ -#define _RT288X_PINMUX_H__ +#ifndef _PINCTRL_RALINK_H__ +#define _PINCTRL_RALINK_H__ =20 #define FUNC(name, value, pin_first, pin_count) \ { name, value, pin_first, pin_count } @@ -19,9 +19,9 @@ .func =3D _func, .gpio =3D _gpio, \ .func_count =3D ARRAY_SIZE(_func) } =20 -struct rt2880_pmx_group; +struct ralink_pmx_group; =20 -struct rt2880_pmx_func { +struct ralink_pmx_func { const char *name; const char value; =20 @@ -35,7 +35,7 @@ struct rt2880_pmx_func { int enabled; }; =20 -struct rt2880_pmx_group { +struct ralink_pmx_group { const char *name; int enabled; =20 @@ -43,11 +43,11 @@ struct rt2880_pmx_group { const char mask; const char gpio; =20 - struct rt2880_pmx_func *func; + struct ralink_pmx_func *func; int func_count; }; =20 -int rt2880_pinmux_init(struct platform_device *pdev, - struct rt2880_pmx_group *data); +int ralink_pinmux_init(struct platform_device *pdev, + struct ralink_pmx_group *data); =20 #endif diff --git a/drivers/pinctrl/ralink/pinctrl-rt288x.c b/drivers/pinctrl/rali= nk/pinctrl-rt288x.c index 0744aebbace5..40c45140ff8a 100644 --- a/drivers/pinctrl/ralink/pinctrl-rt288x.c +++ b/drivers/pinctrl/ralink/pinctrl-rt288x.c @@ -4,7 +4,7 @@ #include #include #include -#include "pinmux.h" +#include "pinctrl-ralink.h" =20 #define RT2880_GPIO_MODE_I2C BIT(0) #define RT2880_GPIO_MODE_UART0 BIT(1) @@ -15,15 +15,15 @@ #define RT2880_GPIO_MODE_SDRAM BIT(6) #define RT2880_GPIO_MODE_PCI BIT(7) =20 -static struct rt2880_pmx_func i2c_func[] =3D { FUNC("i2c", 0, 1, 2) }; -static struct rt2880_pmx_func spi_func[] =3D { FUNC("spi", 0, 3, 4) }; -static struct rt2880_pmx_func uartlite_func[] =3D { FUNC("uartlite", 0, 7,= 8) }; -static struct rt2880_pmx_func jtag_func[] =3D { FUNC("jtag", 0, 17, 5) }; -static struct rt2880_pmx_func mdio_func[] =3D { FUNC("mdio", 0, 22, 2) }; -static struct rt2880_pmx_func sdram_func[] =3D { FUNC("sdram", 0, 24, 16) = }; -static struct rt2880_pmx_func pci_func[] =3D { FUNC("pci", 0, 40, 32) }; +static struct ralink_pmx_func i2c_func[] =3D { FUNC("i2c", 0, 1, 2) }; +static struct ralink_pmx_func spi_func[] =3D { FUNC("spi", 0, 3, 4) }; +static struct ralink_pmx_func uartlite_func[] =3D { FUNC("uartlite", 0, 7,= 8) }; +static struct ralink_pmx_func jtag_func[] =3D { FUNC("jtag", 0, 17, 5) }; +static struct ralink_pmx_func mdio_func[] =3D { FUNC("mdio", 0, 22, 2) }; +static struct ralink_pmx_func sdram_func[] =3D { FUNC("sdram", 0, 24, 16) = }; +static struct ralink_pmx_func pci_func[] =3D { FUNC("pci", 0, 40, 32) }; =20 -static struct rt2880_pmx_group rt2880_pinmux_data_act[] =3D { +static struct ralink_pmx_group rt2880_pinmux_data_act[] =3D { GRP("i2c", i2c_func, 1, RT2880_GPIO_MODE_I2C), GRP("spi", spi_func, 1, RT2880_GPIO_MODE_SPI), GRP("uartlite", uartlite_func, 1, RT2880_GPIO_MODE_UART0), @@ -36,7 +36,7 @@ static struct rt2880_pmx_group rt2880_pinmux_data_act[] = =3D { =20 static int rt288x_pinmux_probe(struct platform_device *pdev) { - return rt2880_pinmux_init(pdev, rt2880_pinmux_data_act); + return ralink_pinmux_init(pdev, rt2880_pinmux_data_act); } =20 static const struct of_device_id rt288x_pinmux_match[] =3D { diff --git a/drivers/pinctrl/ralink/pinctrl-rt305x.c b/drivers/pinctrl/rali= nk/pinctrl-rt305x.c index 5d8fa156c003..25527ca1ccaa 100644 --- a/drivers/pinctrl/ralink/pinctrl-rt305x.c +++ b/drivers/pinctrl/ralink/pinctrl-rt305x.c @@ -5,7 +5,7 @@ #include #include #include -#include "pinmux.h" +#include "pinctrl-ralink.h" =20 #define RT305X_GPIO_MODE_UART0_SHIFT 2 #define RT305X_GPIO_MODE_UART0_MASK 0x7 @@ -31,9 +31,9 @@ #define RT3352_GPIO_MODE_LNA 18 #define RT3352_GPIO_MODE_PA 20 =20 -static struct rt2880_pmx_func i2c_func[] =3D { FUNC("i2c", 0, 1, 2) }; -static struct rt2880_pmx_func spi_func[] =3D { FUNC("spi", 0, 3, 4) }; -static struct rt2880_pmx_func uartf_func[] =3D { +static struct ralink_pmx_func i2c_func[] =3D { FUNC("i2c", 0, 1, 2) }; +static struct ralink_pmx_func spi_func[] =3D { FUNC("spi", 0, 3, 4) }; +static struct ralink_pmx_func uartf_func[] =3D { FUNC("uartf", RT305X_GPIO_MODE_UARTF, 7, 8), FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 8), FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 8), @@ -42,28 +42,28 @@ static struct rt2880_pmx_func uartf_func[] =3D { FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4), FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4), }; -static struct rt2880_pmx_func uartlite_func[] =3D { FUNC("uartlite", 0, 15= , 2) }; -static struct rt2880_pmx_func jtag_func[] =3D { FUNC("jtag", 0, 17, 5) }; -static struct rt2880_pmx_func mdio_func[] =3D { FUNC("mdio", 0, 22, 2) }; -static struct rt2880_pmx_func rt5350_led_func[] =3D { FUNC("led", 0, 22, 5= ) }; -static struct rt2880_pmx_func rt5350_cs1_func[] =3D { +static struct ralink_pmx_func uartlite_func[] =3D { FUNC("uartlite", 0, 15= , 2) }; +static struct ralink_pmx_func jtag_func[] =3D { FUNC("jtag", 0, 17, 5) }; +static struct ralink_pmx_func mdio_func[] =3D { FUNC("mdio", 0, 22, 2) }; +static struct ralink_pmx_func rt5350_led_func[] =3D { FUNC("led", 0, 22, 5= ) }; +static struct ralink_pmx_func rt5350_cs1_func[] =3D { FUNC("spi_cs1", 0, 27, 1), FUNC("wdg_cs1", 1, 27, 1), }; -static struct rt2880_pmx_func sdram_func[] =3D { FUNC("sdram", 0, 24, 16) = }; -static struct rt2880_pmx_func rt3352_rgmii_func[] =3D { +static struct ralink_pmx_func sdram_func[] =3D { FUNC("sdram", 0, 24, 16) = }; +static struct ralink_pmx_func rt3352_rgmii_func[] =3D { FUNC("rgmii", 0, 24, 12) }; -static struct rt2880_pmx_func rgmii_func[] =3D { FUNC("rgmii", 0, 40, 12) = }; -static struct rt2880_pmx_func rt3352_lna_func[] =3D { FUNC("lna", 0, 36, 2= ) }; -static struct rt2880_pmx_func rt3352_pa_func[] =3D { FUNC("pa", 0, 38, 2) = }; -static struct rt2880_pmx_func rt3352_led_func[] =3D { FUNC("led", 0, 40, 5= ) }; -static struct rt2880_pmx_func rt3352_cs1_func[] =3D { +static struct ralink_pmx_func rgmii_func[] =3D { FUNC("rgmii", 0, 40, 12) = }; +static struct ralink_pmx_func rt3352_lna_func[] =3D { FUNC("lna", 0, 36, 2= ) }; +static struct ralink_pmx_func rt3352_pa_func[] =3D { FUNC("pa", 0, 38, 2) = }; +static struct ralink_pmx_func rt3352_led_func[] =3D { FUNC("led", 0, 40, 5= ) }; +static struct ralink_pmx_func rt3352_cs1_func[] =3D { FUNC("spi_cs1", 0, 45, 1), FUNC("wdg_cs1", 1, 45, 1), }; =20 -static struct rt2880_pmx_group rt3050_pinmux_data[] =3D { +static struct ralink_pmx_group rt3050_pinmux_data[] =3D { GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C), GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI), GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK, @@ -76,7 +76,7 @@ static struct rt2880_pmx_group rt3050_pinmux_data[] =3D { { 0 } }; =20 -static struct rt2880_pmx_group rt3352_pinmux_data[] =3D { +static struct ralink_pmx_group rt3352_pinmux_data[] =3D { GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C), GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI), GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK, @@ -92,7 +92,7 @@ static struct rt2880_pmx_group rt3352_pinmux_data[] =3D { { 0 } }; =20 -static struct rt2880_pmx_group rt5350_pinmux_data[] =3D { +static struct ralink_pmx_group rt5350_pinmux_data[] =3D { GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C), GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI), GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK, @@ -107,11 +107,11 @@ static struct rt2880_pmx_group rt5350_pinmux_data[] = =3D { static int rt305x_pinmux_probe(struct platform_device *pdev) { if (soc_is_rt5350()) - return rt2880_pinmux_init(pdev, rt5350_pinmux_data); + return ralink_pinmux_init(pdev, rt5350_pinmux_data); else if (soc_is_rt305x() || soc_is_rt3350()) - return rt2880_pinmux_init(pdev, rt3050_pinmux_data); + return ralink_pinmux_init(pdev, rt3050_pinmux_data); else if (soc_is_rt3352()) - return rt2880_pinmux_init(pdev, rt3352_pinmux_data); + return ralink_pinmux_init(pdev, rt3352_pinmux_data); else return -EINVAL; } diff --git a/drivers/pinctrl/ralink/pinctrl-rt3883.c b/drivers/pinctrl/rali= nk/pinctrl-rt3883.c index 3e0e1b4caa64..0b8674dbe188 100644 --- a/drivers/pinctrl/ralink/pinctrl-rt3883.c +++ b/drivers/pinctrl/ralink/pinctrl-rt3883.c @@ -3,7 +3,7 @@ #include #include #include -#include "pinmux.h" +#include "pinctrl-ralink.h" =20 #define RT3883_GPIO_MODE_UART0_SHIFT 2 #define RT3883_GPIO_MODE_UART0_MASK 0x7 @@ -39,9 +39,9 @@ #define RT3883_GPIO_MODE_LNA_G_GPIO 0x3 #define RT3883_GPIO_MODE_LNA_G _RT3883_GPIO_MODE_LNA_G(RT3883_GPIO_MODE_L= NA_G_MASK) =20 -static struct rt2880_pmx_func i2c_func[] =3D { FUNC("i2c", 0, 1, 2) }; -static struct rt2880_pmx_func spi_func[] =3D { FUNC("spi", 0, 3, 4) }; -static struct rt2880_pmx_func uartf_func[] =3D { +static struct ralink_pmx_func i2c_func[] =3D { FUNC("i2c", 0, 1, 2) }; +static struct ralink_pmx_func spi_func[] =3D { FUNC("spi", 0, 3, 4) }; +static struct ralink_pmx_func uartf_func[] =3D { FUNC("uartf", RT3883_GPIO_MODE_UARTF, 7, 8), FUNC("pcm uartf", RT3883_GPIO_MODE_PCM_UARTF, 7, 8), FUNC("pcm i2s", RT3883_GPIO_MODE_PCM_I2S, 7, 8), @@ -50,21 +50,21 @@ static struct rt2880_pmx_func uartf_func[] =3D { FUNC("gpio uartf", RT3883_GPIO_MODE_GPIO_UARTF, 7, 4), FUNC("gpio i2s", RT3883_GPIO_MODE_GPIO_I2S, 7, 4), }; -static struct rt2880_pmx_func uartlite_func[] =3D { FUNC("uartlite", 0, 15= , 2) }; -static struct rt2880_pmx_func jtag_func[] =3D { FUNC("jtag", 0, 17, 5) }; -static struct rt2880_pmx_func mdio_func[] =3D { FUNC("mdio", 0, 22, 2) }; -static struct rt2880_pmx_func lna_a_func[] =3D { FUNC("lna a", 0, 32, 3) }; -static struct rt2880_pmx_func lna_g_func[] =3D { FUNC("lna g", 0, 35, 3) }; -static struct rt2880_pmx_func pci_func[] =3D { +static struct ralink_pmx_func uartlite_func[] =3D { FUNC("uartlite", 0, 15= , 2) }; +static struct ralink_pmx_func jtag_func[] =3D { FUNC("jtag", 0, 17, 5) }; +static struct ralink_pmx_func mdio_func[] =3D { FUNC("mdio", 0, 22, 2) }; +static struct ralink_pmx_func lna_a_func[] =3D { FUNC("lna a", 0, 32, 3) }; +static struct ralink_pmx_func lna_g_func[] =3D { FUNC("lna g", 0, 35, 3) }; +static struct ralink_pmx_func pci_func[] =3D { FUNC("pci-dev", 0, 40, 32), FUNC("pci-host2", 1, 40, 32), FUNC("pci-host1", 2, 40, 32), FUNC("pci-fnc", 3, 40, 32) }; -static struct rt2880_pmx_func ge1_func[] =3D { FUNC("ge1", 0, 72, 12) }; -static struct rt2880_pmx_func ge2_func[] =3D { FUNC("ge2", 0, 84, 12) }; +static struct ralink_pmx_func ge1_func[] =3D { FUNC("ge1", 0, 72, 12) }; +static struct ralink_pmx_func ge2_func[] =3D { FUNC("ge2", 0, 84, 12) }; =20 -static struct rt2880_pmx_group rt3883_pinmux_data[] =3D { +static struct ralink_pmx_group rt3883_pinmux_data[] =3D { GRP("i2c", i2c_func, 1, RT3883_GPIO_MODE_I2C), GRP("spi", spi_func, 1, RT3883_GPIO_MODE_SPI), GRP("uartf", uartf_func, RT3883_GPIO_MODE_UART0_MASK, @@ -83,7 +83,7 @@ static struct rt2880_pmx_group rt3883_pinmux_data[] =3D { =20 static int rt3883_pinmux_probe(struct platform_device *pdev) { - return rt2880_pinmux_init(pdev, rt3883_pinmux_data); + return ralink_pinmux_init(pdev, rt3883_pinmux_data); } =20 static const struct of_device_id rt3883_pinmux_match[] =3D { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73450C04A68 for ; Wed, 27 Jul 2022 17:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242353AbiG0Rbf (ORCPT ); Wed, 27 Jul 2022 13:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242292AbiG0R3U (ORCPT ); Wed, 27 Jul 2022 13:29:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD0E452466; Wed, 27 Jul 2022 09:47:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2CA2BB821BE; Wed, 27 Jul 2022 16:47:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DABAC433B5; Wed, 27 Jul 2022 16:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940451; bh=lBNpbwAz4MluJai4tIGarwcVNMTQu6FMGiQvNRLpuZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZPJas7Xc6Q1PvAd0fM11cDDCVP0138e0v4HrfAg/UOLgbwbWH1Ew3gAXHjLeiXQg +CqxrDgeY1UMSCC81vl93UUxGxKBbgG089+ilNUxpuLV8jQN1zEdPwrpRomOAVSgdd MMfrFvq/2gnvyEt8ePd/2ujaOaC0CFTbREPsWGmo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hacash Robot , William Dean , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 027/158] pinctrl: ralink: Check for null return of devm_kcalloc Date: Wed, 27 Jul 2022 18:11:31 +0200 Message-Id: <20220727161022.566725196@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: William Dean [ Upstream commit c3b821e8e406d5650e587b7ac624ac24e9b780a8 ] Because of the possible failure of the allocation, data->domains might be NULL pointer and will cause the dereference of the NULL pointer later. Therefore, it might be better to check it and directly return -ENOMEM without releasing data manually if fails, because the comment of the devm_kmalloc() says "Memory allocated with this function is automatically freed on driver detach.". Fixes: a86854d0c599b ("treewide: devm_kzalloc() -> devm_kcalloc()") Reported-by: Hacash Robot Signed-off-by: William Dean Link: https://lore.kernel.org/r/20220710154922.2610876-1-williamsukatube@16= 3.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/ralink/pinctrl-ralink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/ralink/pinctrl-ralink.c b/drivers/pinctrl/rali= nk/pinctrl-ralink.c index 841f23f55c95..3a8268a43d74 100644 --- a/drivers/pinctrl/ralink/pinctrl-ralink.c +++ b/drivers/pinctrl/ralink/pinctrl-ralink.c @@ -266,6 +266,8 @@ static int ralink_pinmux_pins(struct ralink_priv *p) p->func[i]->pin_count, sizeof(int), GFP_KERNEL); + if (!p->func[i]->pins) + return -ENOMEM; for (j =3D 0; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] =3D p->func[i]->pin_first + j; =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05201C19F2B for ; Wed, 27 Jul 2022 17:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242354AbiG0Rbx (ORCPT ); Wed, 27 Jul 2022 13:31:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242313AbiG0R3Y (ORCPT ); Wed, 27 Jul 2022 13:29:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A45A52470; Wed, 27 Jul 2022 09:47:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3833B821C5; Wed, 27 Jul 2022 16:47:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4403FC43470; Wed, 27 Jul 2022 16:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940454; bh=EEAxF3Db0LOQhyP5PX4UY1J0DpmdkZYOZ7FetD1luY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoW3JrIcaJUGlVIDKRXVdWG6TYrY3fhUIhsZSyH2kN9Fh6T2VSalNj8/EGA+3FVmR HLqSn13+GsCSDT01J9ngoXMbeLoyKUhih3UJoc0z79/57hrOxTcSaDV6uC9J6k7PU9 hotDGvttvvF4eiv3bD1py7y0+xYCR4yYFgKOI0Wo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hacash Robot , William Dean , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 028/158] pinctrl: sunplus: Add check for kcalloc Date: Wed, 27 Jul 2022 18:11:32 +0200 Message-Id: <20220727161022.598871762@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: William Dean [ Upstream commit acf50233fc979b566e3b87d329191dcd01e2a72c ] As the potential failure of the kcalloc(), it should be better to check it in order to avoid the dereference of the NULL pointer. Fixes: aa74c44be19c8 ("pinctrl: Add driver for Sunplus SP7021") Reported-by: Hacash Robot Signed-off-by: William Dean Link: https://lore.kernel.org/r/20220710154822.2610801-1-williamsukatube@16= 3.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/sunplus/sppctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/spp= ctl.c index 3ba47040ac42..2b3335ab56c6 100644 --- a/drivers/pinctrl/sunplus/sppctl.c +++ b/drivers/pinctrl/sunplus/sppctl.c @@ -871,6 +871,9 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pc= tldev, struct device_node } =20 *map =3D kcalloc(*num_maps + nmG, sizeof(**map), GFP_KERNEL); + if (*map =3D=3D NULL) + return -ENOMEM; + for (i =3D 0; i < (*num_maps); i++) { dt_pin =3D be32_to_cpu(list[i]); pin_num =3D FIELD_GET(GENMASK(31, 24), dt_pin); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FE4AC19F2B for ; Wed, 27 Jul 2022 17:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240203AbiG0RgS (ORCPT ); Wed, 27 Jul 2022 13:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242691AbiG0Rer (ORCPT ); Wed, 27 Jul 2022 13:34:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C8B8322E; Wed, 27 Jul 2022 09:49:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 68D56B821BA; Wed, 27 Jul 2022 16:49:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4D62C433D7; Wed, 27 Jul 2022 16:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940568; bh=UfdR8alEtr+J6C83yGSrEMxB5kYXnNaWCvzjtgVLPQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PBp9GBgSN2ahNX9Xm+SsMMjpp4qpMQcdZP9eV/7x6uwwdg/9PxOQyx1u3XKhkEkbF Ikc0BbYs8+IdlnryJMuyprXGf5zs29vyYgrMVSuJxrCXwg/hMq5f8lwHRzrfmr0x/T Mmpi9H5Gm6imNhYxTyD1fpHBhsOEDh7eUkZwD5lk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Jihong , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.18 029/158] perf/core: Fix data race between perf_event_set_output() and perf_mmap_close() Date: Wed, 27 Jul 2022 18:11:33 +0200 Message-Id: <20220727161022.646512129@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra [ Upstream commit 68e3c69803dada336893640110cb87221bb01dcf ] Yang Jihing reported a race between perf_event_set_output() and perf_mmap_close(): CPU1 CPU2 perf_mmap_close(e2) if (atomic_dec_and_test(&e2->rb->mmap_count)) // 1 - > 0 detach_rest =3D true ioctl(e1, IOC_SET_OUTPUT, e2) perf_event_set_output(e1, e2) ... list_for_each_entry_rcu(e, &e2->rb->event_list, rb_entry) ring_buffer_attach(e, NULL); // e1 isn't yet added and // therefore not detached ring_buffer_attach(e1, e2->rb) list_add_rcu(&e1->rb_entry, &e2->rb->event_list) After this; e1 is attached to an unmapped rb and a subsequent perf_mmap() will loop forever more: again: mutex_lock(&e->mmap_mutex); if (event->rb) { ... if (!atomic_inc_not_zero(&e->rb->mmap_count)) { ... mutex_unlock(&e->mmap_mutex); goto again; } } The loop in perf_mmap_close() holds e2->mmap_mutex, while the attach in perf_event_set_output() holds e1->mmap_mutex. As such there is no serialization to avoid this race. Change perf_event_set_output() to take both e1->mmap_mutex and e2->mmap_mutex to alleviate that problem. Additionally, have the loop in perf_mmap() detach the rb directly, this avoids having to wait for the concurrent perf_mmap_close() to get around to doing it to make progress. Fixes: 9bb5d40cd93c ("perf: Fix mmap() accounting hole") Reported-by: Yang Jihong Signed-off-by: Peter Zijlstra (Intel) Tested-by: Yang Jihong Link: https://lkml.kernel.org/r/YsQ3jm2GR38SW7uD@worktop.programming.kicks-= ass.net Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- kernel/events/core.c | 45 ++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 950b25c3f210..82238406f5f5 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6254,10 +6254,10 @@ static int perf_mmap(struct file *file, struct vm_a= rea_struct *vma) =20 if (!atomic_inc_not_zero(&event->rb->mmap_count)) { /* - * Raced against perf_mmap_close() through - * perf_event_set_output(). Try again, hope for better - * luck. + * Raced against perf_mmap_close(); remove the + * event and try again. */ + ring_buffer_attach(event, NULL); mutex_unlock(&event->mmap_mutex); goto again; } @@ -11826,14 +11826,25 @@ static int perf_copy_attr(struct perf_event_attr = __user *uattr, goto out; } =20 +static void mutex_lock_double(struct mutex *a, struct mutex *b) +{ + if (b < a) + swap(a, b); + + mutex_lock(a); + mutex_lock_nested(b, SINGLE_DEPTH_NESTING); +} + static int perf_event_set_output(struct perf_event *event, struct perf_event *output_= event) { struct perf_buffer *rb =3D NULL; int ret =3D -EINVAL; =20 - if (!output_event) + if (!output_event) { + mutex_lock(&event->mmap_mutex); goto set; + } =20 /* don't allow circular references */ if (event =3D=3D output_event) @@ -11871,8 +11882,15 @@ perf_event_set_output(struct perf_event *event, st= ruct perf_event *output_event) event->pmu !=3D output_event->pmu) goto out; =20 + /* + * Hold both mmap_mutex to serialize against perf_mmap_close(). Since + * output_event is already on rb->event_list, and the list iteration + * restarts after every removal, it is guaranteed this new event is + * observed *OR* if output_event is already removed, it's guaranteed we + * observe !rb->mmap_count. + */ + mutex_lock_double(&event->mmap_mutex, &output_event->mmap_mutex); set: - mutex_lock(&event->mmap_mutex); /* Can't redirect output if we've got an active mmap() */ if (atomic_read(&event->mmap_count)) goto unlock; @@ -11882,6 +11900,12 @@ perf_event_set_output(struct perf_event *event, st= ruct perf_event *output_event) rb =3D ring_buffer_get(output_event); if (!rb) goto unlock; + + /* did we race against perf_mmap_close() */ + if (!atomic_read(&rb->mmap_count)) { + ring_buffer_put(rb); + goto unlock; + } } =20 ring_buffer_attach(event, rb); @@ -11889,20 +11913,13 @@ perf_event_set_output(struct perf_event *event, s= truct perf_event *output_event) ret =3D 0; unlock: mutex_unlock(&event->mmap_mutex); + if (output_event) + mutex_unlock(&output_event->mmap_mutex); =20 out: return ret; } =20 -static void mutex_lock_double(struct mutex *a, struct mutex *b) -{ - if (b < a) - swap(a, b); - - mutex_lock(a); - mutex_lock_nested(b, SINGLE_DEPTH_NESTING); -} - static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id) { bool nmi_safe =3D false; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0E43C04A68 for ; Wed, 27 Jul 2022 17:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242131AbiG0RcV (ORCPT ); Wed, 27 Jul 2022 13:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242579AbiG0RaD (ORCPT ); Wed, 27 Jul 2022 13:30:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 535276053A; Wed, 27 Jul 2022 09:48:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6728DB8200D; Wed, 27 Jul 2022 16:48:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4666C433C1; Wed, 27 Jul 2022 16:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940480; bh=IQkqiL557D1Uy1xhbqyt5NvKMoYWp8sG7TSbNKRSI+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+hMuQ9TNbTIDITilDPY+XqLMDu1AIQ0TufPVEXvDXOAqEmkCTWlKQoNXR8GpX83p c/2SbBKbJiwikF/LqrXEdumFyELwHFxlXe2ngg1VLILu0rfUBwxfQ/DxAf2LZttuIN Q/dgXkJ3DIE+IKDSjAN8xL9aCtGOEOZGiD/vLl1w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dima Ruinskiy , Sasha Neftin , "Chia-Lin Kao (AceLan)" , Naama Meir , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 030/158] e1000e: Enable GPT clock before sending message to CSME Date: Wed, 27 Jul 2022 18:11:34 +0200 Message-Id: <20220727161022.686155057@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sasha Neftin [ Upstream commit b49feacbeffc7635cc6692cbcc6a1eae2c17da6f ] On corporate (CSME) ADL systems, the Ethernet Controller may stop working ("HW unit hang") after exiting from the s0ix state. The reason is that CSME misses the message sent by the host. Enabling the dynamic GPT clock solves this problem. This clock is cleared upon HW initialization. Fixes: 3e55d231716e ("e1000e: Add handshake with the CSME to support S0ix") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=3D214821 Reviewed-by: Dima Ruinskiy Signed-off-by: Sasha Neftin Tested-by: Chia-Lin Kao (AceLan) Tested-by: Naama Meir Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ether= net/intel/e1000e/netdev.c index fa06f68c8c80..c64102b29862 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6494,6 +6494,10 @@ static void e1000e_s0ix_exit_flow(struct e1000_adapt= er *adapter) =20 if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID && hw->mac.type >=3D e1000_pch_adp) { + /* Keep the GPT clock enabled for CSME */ + mac_data =3D er32(FEXTNVM); + mac_data |=3D BIT(3); + ew32(FEXTNVM, mac_data); /* Request ME unconfigure the device from S0ix */ mac_data =3D er32(H2ME); mac_data &=3D ~E1000_H2ME_START_DPG; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 517BDC19F2B for ; Wed, 27 Jul 2022 17:35:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242461AbiG0ReL (ORCPT ); Wed, 27 Jul 2022 13:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238422AbiG0Rde (ORCPT ); Wed, 27 Jul 2022 13:33:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23FC38244D; Wed, 27 Jul 2022 09:48:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E993B61684; Wed, 27 Jul 2022 16:48:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3156C433B5; Wed, 27 Jul 2022 16:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940510; bh=HExVcHZTruUUfXUkliReJ0ROIBKXM0SO1OOV/4zgfhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dau8xouMusYxpIPi18cvf+npgLLFIZHtQWyNLDJQqF9WepZT8Ozg7SIjLNpZSDl02 Co9YZ9dU+HvjJO5DO8sOh8OggFdEPAfS0X7FcJCui/mn/8Jc2lDkgDRjjB/PtCMDQV Q5QiiNNcL2uPXmE8wKEjZaWdxynbB4cKm5Ifqmkw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sasha Neftin , Naama Meir , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 031/158] Revert "e1000e: Fix possible HW unit hang after an s0ix exit" Date: Wed, 27 Jul 2022 18:11:35 +0200 Message-Id: <20220727161022.727044176@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sasha Neftin [ Upstream commit 6cfa45361d3eac31ba67d7d0bbef547151450106 ] This reverts commit 1866aa0d0d6492bc2f8d22d0df49abaccf50cddd. Commit 1866aa0d0d64 ("e1000e: Fix possible HW unit hang after an s0ix exit") was a workaround for CSME problem to handle messages comes via H2ME mailbox. This problem has been fixed by patch "e1000e: Enable the GPT clock before sending message to the CSME". Fixes: 3e55d231716e ("e1000e: Add handshake with the CSME to support S0ix") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=3D214821 Signed-off-by: Sasha Neftin Tested-by: Naama Meir Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/e1000e/hw.h | 1 - drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ---- drivers/net/ethernet/intel/e1000e/ich8lan.h | 1 - drivers/net/ethernet/intel/e1000e/netdev.c | 26 --------------------- 4 files changed, 32 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/= intel/e1000e/hw.h index 13382df2f2ef..bcf680e83811 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -630,7 +630,6 @@ struct e1000_phy_info { bool disable_polarity_correction; bool is_mdix; bool polarity_correction; - bool reset_disable; bool speed_downgraded; bool autoneg_wait_to_complete; }; diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethe= rnet/intel/e1000e/ich8lan.c index e6c8e6d5234f..9466f65a6da7 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2050,10 +2050,6 @@ static s32 e1000_check_reset_block_ich8lan(struct e1= 000_hw *hw) bool blocked =3D false; int i =3D 0; =20 - /* Check the PHY (LCD) reset flag */ - if (hw->phy.reset_disable) - return true; - while ((blocked =3D !(er32(FWSM) & E1000_ICH_FWSM_RSPCIPHY)) && (i++ < 30)) usleep_range(10000, 11000); diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.h b/drivers/net/ethe= rnet/intel/e1000e/ich8lan.h index 638a3ddd7ada..2504b11c3169 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.h +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h @@ -271,7 +271,6 @@ #define I217_CGFREG_ENABLE_MTA_RESET 0x0002 #define I217_MEMPWR PHY_REG(772, 26) #define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010 -#define I217_MEMPWR_MOEM 0x1000 =20 /* Receive Address Initial CRC Calculation */ #define E1000_PCH_RAICC(_n) (0x05F50 + ((_n) * 4)) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ether= net/intel/e1000e/netdev.c index c64102b29862..f1729940e46c 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6991,21 +6991,8 @@ static __maybe_unused int e1000e_pm_suspend(struct d= evice *dev) struct net_device *netdev =3D pci_get_drvdata(to_pci_dev(dev)); struct e1000_adapter *adapter =3D netdev_priv(netdev); struct pci_dev *pdev =3D to_pci_dev(dev); - struct e1000_hw *hw =3D &adapter->hw; - u16 phy_data; int rc; =20 - if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID && - hw->mac.type >=3D e1000_pch_adp) { - /* Mask OEM Bits / Gig Disable / Restart AN (772_26[12] =3D 1) */ - e1e_rphy(hw, I217_MEMPWR, &phy_data); - phy_data |=3D I217_MEMPWR_MOEM; - e1e_wphy(hw, I217_MEMPWR, phy_data); - - /* Disable LCD reset */ - hw->phy.reset_disable =3D true; - } - e1000e_flush_lpic(pdev); =20 e1000e_pm_freeze(dev); @@ -7027,8 +7014,6 @@ static __maybe_unused int e1000e_pm_resume(struct dev= ice *dev) struct net_device *netdev =3D pci_get_drvdata(to_pci_dev(dev)); struct e1000_adapter *adapter =3D netdev_priv(netdev); struct pci_dev *pdev =3D to_pci_dev(dev); - struct e1000_hw *hw =3D &adapter->hw; - u16 phy_data; int rc; =20 /* Introduce S0ix implementation */ @@ -7039,17 +7024,6 @@ static __maybe_unused int e1000e_pm_resume(struct de= vice *dev) if (rc) return rc; =20 - if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID && - hw->mac.type >=3D e1000_pch_adp) { - /* Unmask OEM Bits / Gig Disable / Restart AN 772_26[12] =3D 0 */ - e1e_rphy(hw, I217_MEMPWR, &phy_data); - phy_data &=3D ~I217_MEMPWR_MOEM; - e1e_wphy(hw, I217_MEMPWR, phy_data); - - /* Enable LCD reset */ - hw->phy.reset_disable =3D false; - } - return e1000e_pm_thaw(dev); } =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07670C04A68 for ; Wed, 27 Jul 2022 17:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242453AbiG0Rfo (ORCPT ); Wed, 27 Jul 2022 13:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242460AbiG0ReL (ORCPT ); Wed, 27 Jul 2022 13:34:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF4F4E85B; Wed, 27 Jul 2022 09:49:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BECB1B821D2; Wed, 27 Jul 2022 16:49:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F2A2C433C1; Wed, 27 Jul 2022 16:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940540; bh=IZNnPTniXjTLUs78BbccaslE5cuZUNEFv5XO4brCuo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RkXQxKcvwrHh5crTqq+z+tzZShKcFOnUkTR9G7EEXPA3yqkeaXx2Fp5CkeWvctwsg 9Y8mVLyyYGYBUHO+rBwnVlcDdNjpM6e1p7V4IPPZKb5a9/1/5grZIrZ4vGjr3Cg8sS Cj6df+kaW6mxgcnXFO+2l2nOh059Aovs1cUrKg2M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lennert Buytenhek , Naama Meir , Sasha Neftin , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 032/158] igc: Reinstate IGC_REMOVED logic and implement it properly Date: Wed, 27 Jul 2022 18:11:36 +0200 Message-Id: <20220727161022.772710635@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lennert Buytenhek [ Upstream commit 7c1ddcee5311f3315096217881d2dbe47cc683f9 ] The initially merged version of the igc driver code (via commit 146740f9abc4, "igc: Add support for PF") contained the following IGC_REMOVED checks in the igc_rd32/wr32() MMIO accessors: u32 igc_rd32(struct igc_hw *hw, u32 reg) { u8 __iomem *hw_addr =3D READ_ONCE(hw->hw_addr); u32 value =3D 0; if (IGC_REMOVED(hw_addr)) return ~value; value =3D readl(&hw_addr[reg]); /* reads should not return all F's */ if (!(~value) && (!reg || !(~readl(hw_addr)))) hw->hw_addr =3D NULL; return value; } And: #define wr32(reg, val) \ do { \ u8 __iomem *hw_addr =3D READ_ONCE((hw)->hw_addr); \ if (!IGC_REMOVED(hw_addr)) \ writel((val), &hw_addr[(reg)]); \ } while (0) E.g. igb has similar checks in its MMIO accessors, and has a similar macro E1000_REMOVED, which is implemented as follows: #define E1000_REMOVED(h) unlikely(!(h)) These checks serve to detect and take note of an 0xffffffff MMIO read return from the device, which can be caused by a PCIe link flap or some other kind of PCI bus error, and to avoid performing MMIO reads and writes from that point onwards. However, the IGC_REMOVED macro was not originally implemented: #ifndef IGC_REMOVED #define IGC_REMOVED(a) (0) #endif /* IGC_REMOVED */ This led to the IGC_REMOVED logic to be removed entirely in a subsequent commit (commit 3c215fb18e70, "igc: remove IGC_REMOVED function"), with the rationale that such checks matter only for virtualization and that igc does not support virtualization -- but a PCIe device can become detached even without virtualization being in use, and without proper checks, a PCIe bus error affecting an igc adapter will lead to various NULL pointer dereferences, as the first access after the error will set hw->hw_addr to NULL, and subsequent accesses will blindly dereference this now-NULL pointer. This patch reinstates the IGC_REMOVED checks in igc_rd32/wr32(), and implements IGC_REMOVED the way it is done for igb, by checking for the unlikely() case of hw_addr being NULL. This change prevents the oopses seen when a PCIe link flap occurs on an igc adapter. Fixes: 146740f9abc4 ("igc: Add support for PF") Signed-off-by: Lennert Buytenhek Tested-by: Naama Meir Acked-by: Sasha Neftin Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/igc/igc_main.c | 3 +++ drivers/net/ethernet/intel/igc/igc_regs.h | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethern= et/intel/igc/igc_main.c index 74b2c590ed5d..38e46e9ba8bb 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6171,6 +6171,9 @@ u32 igc_rd32(struct igc_hw *hw, u32 reg) u8 __iomem *hw_addr =3D READ_ONCE(hw->hw_addr); u32 value =3D 0; =20 + if (IGC_REMOVED(hw_addr)) + return ~value; + value =3D readl(&hw_addr[reg]); =20 /* reads should not return all F's */ diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h b/drivers/net/ethern= et/intel/igc/igc_regs.h index e197a33d93a0..026c3b65fc37 100644 --- a/drivers/net/ethernet/intel/igc/igc_regs.h +++ b/drivers/net/ethernet/intel/igc/igc_regs.h @@ -306,7 +306,8 @@ u32 igc_rd32(struct igc_hw *hw, u32 reg); #define wr32(reg, val) \ do { \ u8 __iomem *hw_addr =3D READ_ONCE((hw)->hw_addr); \ - writel((val), &hw_addr[(reg)]); \ + if (!IGC_REMOVED(hw_addr)) \ + writel((val), &hw_addr[(reg)]); \ } while (0) =20 #define rd32(reg) (igc_rd32(hw, reg)) @@ -318,4 +319,6 @@ do { \ =20 #define array_rd32(reg, offset) (igc_rd32(hw, (reg) + ((offset) << 2))) =20 +#define IGC_REMOVED(h) unlikely(!(h)) + #endif --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1ABBC04A68 for ; Wed, 27 Jul 2022 17:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242470AbiG0Rfy (ORCPT ); Wed, 27 Jul 2022 13:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242535AbiG0ReU (ORCPT ); Wed, 27 Jul 2022 13:34:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 375EF8320C; Wed, 27 Jul 2022 09:49:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AACB2B821AC; Wed, 27 Jul 2022 16:49:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 192C3C433C1; Wed, 27 Jul 2022 16:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940551; bh=7fTa14/lKPNdhwduF4hY9eR8NwdSBaT24ZZOvhjIwqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GN8/5Wi4vSjhqqBJ6d8rROiINhZg5X8hqiyXGUD2xOqz8WwkilzJrgR3SJG/vyzfu PaGXi6oxli86hgEA6U5SukbJD3SaLMuT7JyhrfO9X0bh8Fy8nvB12rNDtdhElJskKj QmVdmjdwoqJIaCUmi8y9BmlIN9k/cLkIv7IEukno= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 033/158] ip: Fix data-races around sysctl_ip_no_pmtu_disc. Date: Wed, 27 Jul 2022 18:11:37 +0200 Message-Id: <20220727161022.812447163@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 0968d2a441bf6afb551fd99e60fa65ed67068963 ] While reading sysctl_ip_no_pmtu_disc, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/af_inet.c | 2 +- net/ipv4/icmp.c | 2 +- net/ipv6/af_inet6.c | 2 +- net/xfrm/xfrm_state.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 98bc180563d1..8c0a22a5b36c 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -335,7 +335,7 @@ static int inet_create(struct net *net, struct socket *= sock, int protocol, inet->hdrincl =3D 1; } =20 - if (net->ipv4.sysctl_ip_no_pmtu_disc) + if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) inet->pmtudisc =3D IP_PMTUDISC_DONT; else inet->pmtudisc =3D IP_PMTUDISC_WANT; diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index c13ceda9ce5d..d8cfa6241c04 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -878,7 +878,7 @@ static bool icmp_unreach(struct sk_buff *skb) * values please see * Documentation/networking/ip-sysctl.rst */ - switch (net->ipv4.sysctl_ip_no_pmtu_disc) { + switch (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) { default: net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n", &iph->daddr); diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 7d7b7523d126..ef1e6545d869 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -226,7 +226,7 @@ static int inet6_create(struct net *net, struct socket = *sock, int protocol, RCU_INIT_POINTER(inet->mc_list, NULL); inet->rcv_tos =3D 0; =20 - if (net->ipv4.sysctl_ip_no_pmtu_disc) + if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) inet->pmtudisc =3D IP_PMTUDISC_DONT; else inet->pmtudisc =3D IP_PMTUDISC_WANT; diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index b749935152ba..b4ce16a934a2 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2620,7 +2620,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init= _replay, bool offload) int err; =20 if (family =3D=3D AF_INET && - xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc) + READ_ONCE(xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc)) x->props.flags |=3D XFRM_STATE_NOPMTUDISC; =20 err =3D -EPROTONOSUPPORT; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9029EC04A68 for ; Wed, 27 Jul 2022 17:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241604AbiG0RgX (ORCPT ); Wed, 27 Jul 2022 13:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242700AbiG0Res (ORCPT ); Wed, 27 Jul 2022 13:34:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCFE83235; Wed, 27 Jul 2022 09:49:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B988F61479; Wed, 27 Jul 2022 16:49:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C95F7C433C1; Wed, 27 Jul 2022 16:49:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940554; bh=dN4tTBOH5BS+WNPJLd/h4yzH04AAcMpyxHoqSYwowYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tT02GkyRSNLuWFziK0ra6cuOT+HVa7YEl3jSeRfi1Kutq4X3RjLUEM/w5fjqNT3Qd bJ7aUfKrLc7KAu1f2kkyMU4RJwNNOYNzbo/IS2wbQUXg/XGfFMAOmUg4DokP4ocK4n ZZnfQJg3lUwWEAzKGHjiCIwuSl9XWEMAOv0AF+iM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 034/158] ip: Fix data-races around sysctl_ip_fwd_use_pmtu. Date: Wed, 27 Jul 2022 18:11:38 +0200 Message-Id: <20220727161022.845221234@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 60c158dc7b1f0558f6cadd5b50d0386da0000d50 ] While reading sysctl_ip_fwd_use_pmtu, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: f87c10a8aa1e ("ipv4: introduce ip_dst_mtu_maybe_forward and protect = forwarding path against pmtu spoofing") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/ip.h | 2 +- net/ipv4/route.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 26fffda78cca..05fe313f72fa 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -446,7 +446,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(con= st struct dst_entry *dst, struct net *net =3D dev_net(dst->dev); unsigned int mtu; =20 - if (net->ipv4.sysctl_ip_fwd_use_pmtu || + if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) || ip_mtu_locked(dst) || !forwarding) { mtu =3D rt->rt_pmtu; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index ed01063d8f30..8363e575c455 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1397,7 +1397,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __= be32 daddr) struct fib_info *fi =3D res->fi; u32 mtu =3D 0; =20 - if (dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu || + if (READ_ONCE(dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu) || fi->fib_metrics->metrics[RTAX_LOCK - 1] & (1 << RTAX_MTU)) mtu =3D fi->fib_mtu; =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C607FC19F2B for ; Wed, 27 Jul 2022 17:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241772AbiG0Rgb (ORCPT ); Wed, 27 Jul 2022 13:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242714AbiG0Reu (ORCPT ); Wed, 27 Jul 2022 13:34:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 288CA8323E; Wed, 27 Jul 2022 09:49:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 75383616F8; Wed, 27 Jul 2022 16:49:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DEB9C433D6; Wed, 27 Jul 2022 16:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940556; bh=T5yfefPrB78U2aMaH4vQc94rncf1A/Cn1oL91elqos4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yWGknymzdfGBNh3j+YEmN4VufwASSGSPO93LsANKyk3ksIelkwIoaKKABw9+Hio3/ lUw9MKnp8f0GWxlLQw+WampX4yf495kgUx/tXH8jeKhdgF5SFiyhs07Y1sL3liQviW 84qjkVyNT2Bjw0PKO6jQj7MIWYmwz5C3fFZCSsJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 035/158] ip: Fix data-races around sysctl_ip_fwd_update_priority. Date: Wed, 27 Jul 2022 18:11:39 +0200 Message-Id: <20220727161022.885758786@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 7bf9e18d9a5e99e3c83482973557e9f047b051e7 ] While reading sysctl_ip_fwd_update_priority, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 432e05d32892 ("net: ipv4: Control SKB reprioritization after forward= ing") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++- net/ipv4/ip_forward.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/driver= s/net/ethernet/mellanox/mlxsw/spectrum_router.c index 5ec9bc321566..994bd2e14e55 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -10462,13 +10462,14 @@ static int mlxsw_sp_dscp_init(struct mlxsw_sp *ml= xsw_sp) static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) { struct net *net =3D mlxsw_sp_net(mlxsw_sp); - bool usp =3D net->ipv4.sysctl_ip_fwd_update_priority; char rgcr_pl[MLXSW_REG_RGCR_LEN]; u64 max_rifs; + bool usp; =20 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_RIFS)) return -EIO; max_rifs =3D MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); + usp =3D READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority); =20 mlxsw_reg_rgcr_pack(rgcr_pl, true, true); mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, max_rifs); diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c index 92ba3350274b..03bb7c51b618 100644 --- a/net/ipv4/ip_forward.c +++ b/net/ipv4/ip_forward.c @@ -151,7 +151,7 @@ int ip_forward(struct sk_buff *skb) !skb_sec_path(skb)) ip_rt_send_redirect(skb); =20 - if (net->ipv4.sysctl_ip_fwd_update_priority) + if (READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority)) skb->priority =3D rt_tos2priority(iph->tos); =20 return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 732A5C04A68 for ; Wed, 27 Jul 2022 17:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242558AbiG0Rgi (ORCPT ); Wed, 27 Jul 2022 13:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242732AbiG0Rew (ORCPT ); Wed, 27 Jul 2022 13:34:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78A3983F07; Wed, 27 Jul 2022 09:49:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C7AA1B821D2; Wed, 27 Jul 2022 16:49:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3456AC433D6; Wed, 27 Jul 2022 16:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940559; bh=yO/lDs1tzTNDuRJk8SFnUSVSSqM3pggkSXFLZ0ov0Aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIgdBk4ijfd3LABkUzBuiwoJIxSh83iEqKsCSHkJ4+bTh0xaBVDr6fcJ986yqIqDZ AuYRotU+tOmhjQSMs92rY0V+q+Bcb3RMT53HdSt9p9jKc1nI5RW2H5kXAZD3uHzxNG At7vletW1LWxGbCS4/hF2dDE6jGEYgSP7MNKGTH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 036/158] ip: Fix data-races around sysctl_ip_nonlocal_bind. Date: Wed, 27 Jul 2022 18:11:40 +0200 Message-Id: <20220727161022.924691668@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 289d3b21fb0bfc94c4e98f10635bba1824e5f83c ] While reading sysctl_ip_nonlocal_bind, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/inet_sock.h | 2 +- net/sctp/protocol.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index 48e4c59d85e2..2f6b715acc15 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -373,7 +373,7 @@ static inline bool inet_get_convert_csum(struct sock *s= k) static inline bool inet_can_nonlocal_bind(struct net *net, struct inet_sock *inet) { - return net->ipv4.sysctl_ip_nonlocal_bind || + return READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind) || inet->freebind || inet->transparent; } =20 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 35928fefae33..1a094b087d88 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -358,7 +358,7 @@ static int sctp_v4_available(union sctp_addr *addr, str= uct sctp_sock *sp) if (addr->v4.sin_addr.s_addr !=3D htonl(INADDR_ANY) && ret !=3D RTN_LOCAL && !sp->inet.freebind && - !net->ipv4.sysctl_ip_nonlocal_bind) + !READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind)) return 0; =20 if (ipv6_only_sock(sctp_opt2sk(sp))) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF064C04A68 for ; Wed, 27 Jul 2022 17:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242498AbiG0RgD (ORCPT ); Wed, 27 Jul 2022 13:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242615AbiG0Red (ORCPT ); Wed, 27 Jul 2022 13:34:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B7B82F94; Wed, 27 Jul 2022 09:49:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C3501B821AC; Wed, 27 Jul 2022 16:49:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DCE3C433C1; Wed, 27 Jul 2022 16:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940562; bh=ajiG2rl1RLkX8O8OZOPgAuzDpLkhQSUhjhx2O/QgZDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yaVq7aWwzY+PCct4vOLD95L2iqjfzgp8w+TZGsyy0PJIiC+lSLnx0Dy7n+eRCinCT 3MthOVlNk/EuEZ0kfpXlN2+ntD8q2CFtHDR9qF+Cv/GaCZMfP8mXjSya/U9S1Ks8ol /YPwg7GPi4iAKyDgdFyjI8uOUwdYfefypKmwHcIY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 037/158] ip: Fix a data-race around sysctl_ip_autobind_reuse. Date: Wed, 27 Jul 2022 18:11:41 +0200 Message-Id: <20220727161022.956770263@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 0db232765887d9807df8bcb7b6f29b2871539eab ] While reading sysctl_ip_autobind_reuse, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 4b01a9674231 ("tcp: bind(0) remove the SO_REUSEADDR restriction when= ephemeral ports are exhausted.") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_connection_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_soc= k.c index 1e5b53c2bb26..dfb5a2d7ad85 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -259,7 +259,7 @@ inet_csk_find_open_port(struct sock *sk, struct inet_bi= nd_bucket **tb_ret, int * goto other_half_scan; } =20 - if (net->ipv4.sysctl_ip_autobind_reuse && !relax) { + if (READ_ONCE(net->ipv4.sysctl_ip_autobind_reuse) && !relax) { /* We still have a chance to connect to different destinations */ relax =3D true; goto ports_exhausted; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A0C5C19F28 for ; Wed, 27 Jul 2022 17:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237457AbiG0RgH (ORCPT ); Wed, 27 Jul 2022 13:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242654AbiG0Rek (ORCPT ); Wed, 27 Jul 2022 13:34:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A1238321D; Wed, 27 Jul 2022 09:49:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E45CC616FF; Wed, 27 Jul 2022 16:49:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6045C433C1; Wed, 27 Jul 2022 16:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940565; bh=grI3TtxyBN+CVhA9VjS4IQUU/Bu18uoVSuQlV5oauoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zoY5nh8sogbIe+XxVe2ZCKW5HWFEIL630A+SZ0LIue4Hd5kmx36P/hqHBHY8EYokH B8PnD041l74HmCwqoS+0kHn6YIs2NwzbPZEW8bX44f3Cm0XMkhg/iZbNmf7CYUlXfJ b65gmxHs+0Vr66v88Xae5/qBCiwbjpS5OtimzRfs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 038/158] ip: Fix a data-race around sysctl_fwmark_reflect. Date: Wed, 27 Jul 2022 18:11:42 +0200 Message-Id: <20220727161022.998435138@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 85d0b4dbd74b95cc492b1f4e34497d3f894f5d9a ] While reading sysctl_fwmark_reflect, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: e110861f8609 ("net: add a sysctl to reflect the fwmark on replies") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/ip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/ip.h b/include/net/ip.h index 05fe313f72fa..4a15b6bcb4b8 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -384,7 +384,7 @@ void ipfrag_init(void); void ip_static_sysctl_init(void); =20 #define IP4_REPLY_MARK(net, mark) \ - ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0) + (READ_ONCE((net)->ipv4.sysctl_fwmark_reflect) ? (mark) : 0) =20 static inline bool ip_is_fragment(const struct iphdr *iph) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF4E8C04A68 for ; Wed, 27 Jul 2022 17:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242408AbiG0Rc1 (ORCPT ); Wed, 27 Jul 2022 13:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242591AbiG0RaF (ORCPT ); Wed, 27 Jul 2022 13:30:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68D852441; Wed, 27 Jul 2022 09:48:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E17760DDB; Wed, 27 Jul 2022 16:48:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79977C433D7; Wed, 27 Jul 2022 16:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940482; bh=5eRz3WFU8EPC45Oedg//mJwlMSW4YQq7xFg16rfQVrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wc4SGfFDfiZfsJVUUffRu0ZgkrBw+J+CklvO7Rrc2bC6QptjBcS6TRQoxVcqZqwdu DELYfntwksiTQlTiRiZ4BF/YA//JHOqqYx27XpN4KYKJMZisllTumIlUaLBBg7DdHF l/nVMQuj5UySgKd1of0N/ARywmMV2kKsNAg2oJKo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 039/158] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept. Date: Wed, 27 Jul 2022 18:11:43 +0200 Message-Id: <20220727161023.040288482@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 1a0008f9df59451d0a17806c1ee1a19857032fa8 ] While reading sysctl_tcp_fwmark_accept, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 84f39b08d786 ("net: support marking accepting TCP sockets") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/inet_sock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index 2f6b715acc15..d3cf5871289b 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -107,7 +107,8 @@ static inline struct inet_request_sock *inet_rsk(const = struct request_sock *sk) =20 static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff = *skb) { - if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept) + if (!sk->sk_mark && + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)) return skb->mark; =20 return sk->sk_mark; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CDF0C04A68 for ; Wed, 27 Jul 2022 17:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242258AbiG0Rcc (ORCPT ); Wed, 27 Jul 2022 13:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241250AbiG0RaL (ORCPT ); Wed, 27 Jul 2022 13:30:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB2981B07; Wed, 27 Jul 2022 09:48:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BEB80B821D2; Wed, 27 Jul 2022 16:48:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B39AC433C1; Wed, 27 Jul 2022 16:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940485; bh=t4+PmeHplRjYmog1XkVipDtST+ACitslT3Asytvp7/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d4730nk26hUk1HGU7B3IzxFhetti+hwhf48n+oHJIdu25J0UyE9CYR16sdFrKYvz7 +3kgwdUhFwrij2zqzjEXXCa3eKbTcZo1UoiAB01Yt2RPh6WLLIiZpxEbVOKTl8tnr8 DSxgTnFn7dSGIAK9rERa8ivYb6kI32lr9kzOTVbY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 040/158] tcp: sk->sk_bound_dev_if once in inet_request_bound_dev_if() Date: Wed, 27 Jul 2022 18:11:44 +0200 Message-Id: <20220727161023.090802081@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit fdb5fd7f736ec7ae9fb36d2842ea6d9ebc4e7269 ] inet_request_bound_dev_if() reads sk->sk_bound_dev_if twice while listener socket is not locked. Another cpu could change this field under us. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/inet_sock.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index d3cf5871289b..b29108f0973a 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -117,14 +117,15 @@ static inline u32 inet_request_mark(const struct sock= *sk, struct sk_buff *skb) static inline int inet_request_bound_dev_if(const struct sock *sk, struct sk_buff *skb) { + int bound_dev_if =3D READ_ONCE(sk->sk_bound_dev_if); #ifdef CONFIG_NET_L3_MASTER_DEV struct net *net =3D sock_net(sk); =20 - if (!sk->sk_bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept) + if (!bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept) return l3mdev_master_ifindex_by_index(net, skb->skb_iif); #endif =20 - return sk->sk_bound_dev_if; + return bound_dev_if; } =20 static inline int inet_sk_bound_l3mdev(const struct sock *sk) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25D8BC04A68 for ; Wed, 27 Jul 2022 17:33:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242264AbiG0RdM (ORCPT ); Wed, 27 Jul 2022 13:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242103AbiG0Rcl (ORCPT ); Wed, 27 Jul 2022 13:32:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 120A5820F8; Wed, 27 Jul 2022 09:48:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0032761560; Wed, 27 Jul 2022 16:48:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C71CDC43141; Wed, 27 Jul 2022 16:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940488; bh=um3XuKFXmrTfyH4G12SgpbWVKKQtJMOjq/GSVIWvn1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZSm8yZcDb8LkZnnAbwHf4llsJK5OuxAfCBbYQStQOxC13CnaEmEAia3mioizpf2yc 4jwlRboCBOR1fbEa+oaORJMg9q8+GG1QJ60uYmFBH0cl2pImwdhZ1Ap3RrtgEuGI0f QOyVVy0W3o7OwszN0IrJez2kG1g6aGwijcwLHH/o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 041/158] tcp: Fix data-races around sysctl_tcp_l3mdev_accept. Date: Wed, 27 Jul 2022 18:11:45 +0200 Message-Id: <20220727161023.130892625@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 08a75f10679470552a3a443f9aefd1399604d31d ] While reading sysctl_tcp_l3mdev_accept, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 6dd9a14e92e5 ("net: Allow accepted sockets to be bound to l3mdev dom= ain") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/inet_hashtables.h | 2 +- include/net/inet_sock.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 98e1ec1a14f0..749bb1e46087 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -207,7 +207,7 @@ static inline bool inet_sk_bound_dev_eq(struct net *net= , int bound_dev_if, int dif, int sdif) { #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) - return inet_bound_dev_eq(!!net->ipv4.sysctl_tcp_l3mdev_accept, + return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept), bound_dev_if, dif, sdif); #else return inet_bound_dev_eq(true, bound_dev_if, dif, sdif); diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index b29108f0973a..6395f6b9a5d2 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -121,7 +121,7 @@ static inline int inet_request_bound_dev_if(const struc= t sock *sk, #ifdef CONFIG_NET_L3_MASTER_DEV struct net *net =3D sock_net(sk); =20 - if (!bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept) + if (!bound_dev_if && READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept)) return l3mdev_master_ifindex_by_index(net, skb->skb_iif); #endif =20 @@ -133,7 +133,7 @@ static inline int inet_sk_bound_l3mdev(const struct soc= k *sk) #ifdef CONFIG_NET_L3_MASTER_DEV struct net *net =3D sock_net(sk); =20 - if (!net->ipv4.sysctl_tcp_l3mdev_accept) + if (!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept)) return l3mdev_master_ifindex_by_index(net, sk->sk_bound_dev_if); #endif --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E91E5C04A68 for ; Wed, 27 Jul 2022 17:33:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242016AbiG0Rd2 (ORCPT ); Wed, 27 Jul 2022 13:33:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242099AbiG0Rcs (ORCPT ); Wed, 27 Jul 2022 13:32:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A5A52E6C; Wed, 27 Jul 2022 09:48:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 65AFD61557; Wed, 27 Jul 2022 16:48:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7293EC433D6; Wed, 27 Jul 2022 16:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940490; bh=CQOsgGC5WOqF5/c/4Wao2Ym8lS5LaiCU03klsncrZ8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fMCeIWP7hN5BJI5CrJSyaC3E+I5Yf6eGtP408AEeI0hRWfTZgXsAo6XjhUGzm31Fj Iylwz7CLsd/Q3obb4ATKQ3CcWhARDV82xZxslhLCdtaEQfKfrXUsnX1xTV4Q6ysW4A MSECK0pXIsEESWjvNfPYRXgYYLnudTxHWKUIJxEc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 042/158] tcp: Fix data-races around sysctl_tcp_mtu_probing. Date: Wed, 27 Jul 2022 18:11:46 +0200 Message-Id: <20220727161023.180007282@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit f47d00e077e7d61baf69e46dde3210c886360207 ] While reading sysctl_tcp_mtu_probing, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 5d424d5a674f ("[TCP]: MTU probing") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 2 +- net/ipv4/tcp_timer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 34249469e361..f0f2e1aea8c7 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1760,7 +1760,7 @@ void tcp_mtup_init(struct sock *sk) struct inet_connection_sock *icsk =3D inet_csk(sk); struct net *net =3D sock_net(sk); =20 - icsk->icsk_mtup.enabled =3D net->ipv4.sysctl_tcp_mtu_probing > 1; + icsk->icsk_mtup.enabled =3D READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) >= 1; icsk->icsk_mtup.search_high =3D tp->rx_opt.mss_clamp + sizeof(struct tcph= dr) + icsk->icsk_af_ops->net_header_len; icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_ba= se_mss); diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 20cf4a98c69d..98bb00e29e1e 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -163,7 +163,7 @@ static void tcp_mtu_probing(struct inet_connection_sock= *icsk, struct sock *sk) int mss; =20 /* Black hole detection */ - if (!net->ipv4.sysctl_tcp_mtu_probing) + if (!READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing)) return; =20 if (!icsk->icsk_mtup.enabled) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5307C19F28 for ; Wed, 27 Jul 2022 17:33:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237877AbiG0Rdd (ORCPT ); Wed, 27 Jul 2022 13:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238095AbiG0Rcy (ORCPT ); Wed, 27 Jul 2022 13:32:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5A286069B; Wed, 27 Jul 2022 09:48:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9A7BB821D4; Wed, 27 Jul 2022 16:48:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 306DEC433D7; Wed, 27 Jul 2022 16:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940493; bh=u1KkQ6uV2RajP/q84Jl74ERIu68q0kXV9S4tdwjI0vw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iK8+rmweduWZUz2bctG/xukkSdQtdigox7yila63mQMmwEgVg9+4kI7a7cF70EImd RDHNZpeEF+3qA3LYkLus6OohS6byw08y9F3HNaQC2Z8T98NYiNZ1YzZJTK5s1gyopP 5wVjJlgAfdRM8rNq0zrlfGMUHGVa0k1Wn0EJVcZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 043/158] tcp: Fix data-races around sysctl_tcp_base_mss. Date: Wed, 27 Jul 2022 18:11:47 +0200 Message-Id: <20220727161023.221030141@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 88d78bc097cd8ebc6541e93316c9d9bf651b13e8 ] While reading sysctl_tcp_base_mss, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 5d424d5a674f ("[TCP]: MTU probing") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 2 +- net/ipv4/tcp_timer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index f0f2e1aea8c7..66b35cb893c1 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1763,7 +1763,7 @@ void tcp_mtup_init(struct sock *sk) icsk->icsk_mtup.enabled =3D READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) >= 1; icsk->icsk_mtup.search_high =3D tp->rx_opt.mss_clamp + sizeof(struct tcph= dr) + icsk->icsk_af_ops->net_header_len; - icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_ba= se_mss); + icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, READ_ONCE(net->ipv4.sys= ctl_tcp_base_mss)); icsk->icsk_mtup.probe_size =3D 0; if (icsk->icsk_mtup.enabled) icsk->icsk_mtup.probe_timestamp =3D tcp_jiffies32; diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 98bb00e29e1e..04063c7e33ba 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -171,7 +171,7 @@ static void tcp_mtu_probing(struct inet_connection_sock= *icsk, struct sock *sk) icsk->icsk_mtup.probe_timestamp =3D tcp_jiffies32; } else { mss =3D tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; - mss =3D min(net->ipv4.sysctl_tcp_base_mss, mss); + mss =3D min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss); mss =3D max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor); mss =3D max(mss, net->ipv4.sysctl_tcp_min_snd_mss); icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, mss); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BE18C04A68 for ; Wed, 27 Jul 2022 17:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242352AbiG0Rcr (ORCPT ); Wed, 27 Jul 2022 13:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242162AbiG0Rbb (ORCPT ); Wed, 27 Jul 2022 13:31:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11A0C81B03; Wed, 27 Jul 2022 09:48:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8AA9FB821BE; Wed, 27 Jul 2022 16:48:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F18FBC433D6; Wed, 27 Jul 2022 16:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940496; bh=ZaDrSyoHPMmnrgYBGNLyz0WEwo3VzQrsMANzf9xmc1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=traebQUIj+edVCqaTCD/YbyKT422t4SW+0FND6pWTeRdS+/5xFR9uF1fU+iBWNvgf nToOc/vMaG0dDvkWv5QIuk5QoJBd8/D6yTXEIOzLf/txs8OtZuELmUpYZsHouxL52F xvQl4SBoJcR3fAUm6R9t20ldejkMJ6XXACFX0fsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 044/158] tcp: Fix data-races around sysctl_tcp_min_snd_mss. Date: Wed, 27 Jul 2022 18:11:48 +0200 Message-Id: <20220727161023.261025196@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 78eb166cdefcc3221c8c7c1e2d514e91a2eb5014 ] While reading sysctl_tcp_min_snd_mss, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 5f3e2bf008c2 ("tcp: add tcp_min_snd_mss sysctl") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 3 ++- net/ipv4/tcp_timer.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 66b35cb893c1..da31119f9463 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1717,7 +1717,8 @@ static inline int __tcp_mtu_to_mss(struct sock *sk, i= nt pmtu) mss_now -=3D icsk->icsk_ext_hdr_len; =20 /* Then reserve room for full set of TCP options and 8 bytes of data */ - mss_now =3D max(mss_now, sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss); + mss_now =3D max(mss_now, + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss)); return mss_now; } =20 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 04063c7e33ba..39107bb730b0 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -173,7 +173,7 @@ static void tcp_mtu_probing(struct inet_connection_sock= *icsk, struct sock *sk) mss =3D tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; mss =3D min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss); mss =3D max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor); - mss =3D max(mss, net->ipv4.sysctl_tcp_min_snd_mss); + mss =3D max(mss, READ_ONCE(net->ipv4.sysctl_tcp_min_snd_mss)); icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, mss); } tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A01BC04A68 for ; Wed, 27 Jul 2022 17:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241795AbiG0Rdh (ORCPT ); Wed, 27 Jul 2022 13:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242420AbiG0RdI (ORCPT ); Wed, 27 Jul 2022 13:33:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 937274E84F; Wed, 27 Jul 2022 09:48:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 41828B821D6; Wed, 27 Jul 2022 16:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E5D9C433D7; Wed, 27 Jul 2022 16:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940499; bh=5aJJgCNUDtk8qpGPzgPquBcPXcbJrkVDOJVjGB4GzcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SuCg2QheXT9v5lVlSDujKIJoUACwLOPNjoox/TWisj/LsNzqEkNXd9sDZCYotTiVq 0HGrKul1IbfcPSZVYE9HjrJlMUFuBG8r2pvwgpblBQLBsZ2nUQfO5kaD8qy+NbJdSO JZ4jGpfeJYHmRTFNBSAlBGUhrGiely36gC9Br0LU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 045/158] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor. Date: Wed, 27 Jul 2022 18:11:49 +0200 Message-Id: <20220727161023.311369466@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 8e92d4423615a5257d0d871fc067aa561f597deb ] While reading sysctl_tcp_mtu_probe_floor, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: c04b79b6cfd7 ("tcp: add new tcp_mtu_probe_floor sysctl") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 39107bb730b0..4f3b9ab222b6 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -172,7 +172,7 @@ static void tcp_mtu_probing(struct inet_connection_sock= *icsk, struct sock *sk) } else { mss =3D tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; mss =3D min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss); - mss =3D max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor); + mss =3D max(mss, READ_ONCE(net->ipv4.sysctl_tcp_mtu_probe_floor)); mss =3D max(mss, READ_ONCE(net->ipv4.sysctl_tcp_min_snd_mss)); icsk->icsk_mtup.search_low =3D tcp_mss_to_mtu(sk, mss); } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EA9BC04A68 for ; Wed, 27 Jul 2022 17:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242411AbiG0Rc7 (ORCPT ); Wed, 27 Jul 2022 13:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242407AbiG0RcY (ORCPT ); Wed, 27 Jul 2022 13:32:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 863C7820E1; Wed, 27 Jul 2022 09:48:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 165F3B821AC; Wed, 27 Jul 2022 16:48:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E514C433C1; Wed, 27 Jul 2022 16:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940501; bh=NMLDzPEZRn3UbTEBGdezvIFEOBlX/dTbsSYnaT92B+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1RV9hBH/Vsz0TCYtLWryN5+Ch25KrT3JFQpMEw0sg4lEpV29wKt97+rKPE4WDIX0I U4zE3AQdIGT0QrExCy6nuQwoVMF6RqCaWP7cr8eWhXzD4DDTHfX9tChyTcrfRDmxan J9wXJUcBdk3VkQR3ZfElDBR9ZfDK+y4YiWdRxuoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 046/158] tcp: Fix a data-race around sysctl_tcp_probe_threshold. Date: Wed, 27 Jul 2022 18:11:50 +0200 Message-Id: <20220727161023.357911180@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 92c0aa4175474483d6cf373314343d4e624e882a ] While reading sysctl_tcp_probe_threshold, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 6b58e0a5f32d ("ipv4: Use binary search to choose tcp PMTU probe_size= ") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index da31119f9463..4057da397087 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2365,7 +2365,7 @@ static int tcp_mtu_probe(struct sock *sk) * probing process by not resetting search range to its orignal. */ if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high) || - interval < net->ipv4.sysctl_tcp_probe_threshold) { + interval < READ_ONCE(net->ipv4.sysctl_tcp_probe_threshold)) { /* Check whether enough time has elaplased for * another round of probing. */ --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9E14C19F2B for ; Wed, 27 Jul 2022 17:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242223AbiG0RdJ (ORCPT ); Wed, 27 Jul 2022 13:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242423AbiG0Rca (ORCPT ); Wed, 27 Jul 2022 13:32:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957C4820F1; Wed, 27 Jul 2022 09:48:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 265F060D3B; Wed, 27 Jul 2022 16:48:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FED2C433C1; Wed, 27 Jul 2022 16:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940504; bh=v2APZq3y8LHDyYfiUlRZJGE/FAqvnm2e0gheW9YgKQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D4rMva6ciKjDo6AdDisX9sgmJextTZ3NjmfjPCrsG8WiZsmZtluCmxZLhwO5eXH4q xlDtRpXqaKKDDLtDH44CmrggtYK+5fNeKmENxQ8QbNaZnM//ZG+O+tr0oRrRhNS1QH qigqguc1WnVCkK8vGrGJA6jlmfbRDQWUdGLVK0DA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 047/158] tcp: Fix a data-race around sysctl_tcp_probe_interval. Date: Wed, 27 Jul 2022 18:11:51 +0200 Message-Id: <20220727161023.405587826@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 2a85388f1d94a9f8b5a529118a2c5eaa0520d85c ] While reading sysctl_tcp_probe_interval, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 05cbc0db03e8 ("ipv4: Create probe timer for tcp PMTU as per RFC4821") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 4057da397087..99a2f4518e2e 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2281,7 +2281,7 @@ static inline void tcp_mtu_check_reprobe(struct sock = *sk) u32 interval; s32 delta; =20 - interval =3D net->ipv4.sysctl_tcp_probe_interval; + interval =3D READ_ONCE(net->ipv4.sysctl_tcp_probe_interval); delta =3D tcp_jiffies32 - icsk->icsk_mtup.probe_timestamp; if (unlikely(delta >=3D interval * HZ)) { int mss =3D tcp_current_mss(sk); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C34C19F2C for ; Wed, 27 Jul 2022 17:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241257AbiG0RfN (ORCPT ); Wed, 27 Jul 2022 13:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242415AbiG0Rde (ORCPT ); Wed, 27 Jul 2022 13:33:34 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B61606B4; Wed, 27 Jul 2022 09:48:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 2F717CE2311; Wed, 27 Jul 2022 16:48:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F11BFC433D6; Wed, 27 Jul 2022 16:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940507; bh=1cPJDOWf1YZmUIflLvJDJ9vPMZP8ZvGzCyuRVCTr26Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/gPtgBfNAWOmSgNrfOPZ1XA2qbCmSAxSX54k5hEknqlasH1nYvUA/YcUwxxTCova ibWcDtbsGPAGbLi87BCzMZKReAK4Ub946H4iXddyi/J6ovDeSrZa8uIS0SUrDnDePJ 84Is/8nMAreXN8je4+069/iD+2u1I5Lr+A/wtOsM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Biao Huang , Matthias Brugger , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 048/158] stmmac: dwmac-mediatek: fix clock issue Date: Wed, 27 Jul 2022 18:11:52 +0200 Message-Id: <20220727161023.445815090@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Biao Huang [ Upstream commit fa4b3ca60e8011d3046765b3de8d3f1ffc53af28 ] The pm_runtime takes care of the clock handling in current stmmac drivers, and dwmac-mediatek implement the mediatek_dwmac_clks_config() as the callback for pm_runtime. Then, stripping duplicated clocks handling in old init()/exit() to fix clock issue in suspend/resume test. As to clocks in probe/remove, vendor need symmetric handling to ensure clocks balance. Test pass, including suspend/resume and ko insertion/remove. Fixes: 3186bdad97d5 ("stmmac: dwmac-mediatek: add platform level clocks man= agement") Signed-off-by: Biao Huang Reviewed-by: Matthias Brugger Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../ethernet/stmicro/stmmac/dwmac-mediatek.c | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac-mediatek.c index 6ff88df58767..ca8ab290013c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c @@ -576,32 +576,7 @@ static int mediatek_dwmac_init(struct platform_device = *pdev, void *priv) } } =20 - ret =3D clk_bulk_prepare_enable(variant->num_clks, plat->clks); - if (ret) { - dev_err(plat->dev, "failed to enable clks, err =3D %d\n", ret); - return ret; - } - - ret =3D clk_prepare_enable(plat->rmii_internal_clk); - if (ret) { - dev_err(plat->dev, "failed to enable rmii internal clk, err =3D %d\n", r= et); - goto err_clk; - } - return 0; - -err_clk: - clk_bulk_disable_unprepare(variant->num_clks, plat->clks); - return ret; -} - -static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv) -{ - struct mediatek_dwmac_plat_data *plat =3D priv; - const struct mediatek_dwmac_variant *variant =3D plat->variant; - - clk_disable_unprepare(plat->rmii_internal_clk); - clk_bulk_disable_unprepare(variant->num_clks, plat->clks); } =20 static int mediatek_dwmac_clks_config(void *priv, bool enabled) @@ -643,7 +618,6 @@ static int mediatek_dwmac_common_data(struct platform_d= evice *pdev, plat->addr64 =3D priv_plat->variant->dma_bit_mask; plat->bsp_priv =3D priv_plat; plat->init =3D mediatek_dwmac_init; - plat->exit =3D mediatek_dwmac_exit; plat->clks_config =3D mediatek_dwmac_clks_config; if (priv_plat->variant->dwmac_fix_mac_speed) plat->fix_mac_speed =3D priv_plat->variant->dwmac_fix_mac_speed; @@ -712,13 +686,32 @@ static int mediatek_dwmac_probe(struct platform_devic= e *pdev) mediatek_dwmac_common_data(pdev, plat_dat, priv_plat); mediatek_dwmac_init(pdev, priv_plat); =20 + ret =3D mediatek_dwmac_clks_config(priv_plat, true); + if (ret) + return ret; + ret =3D stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) { stmmac_remove_config_dt(pdev, plat_dat); - return ret; + goto err_drv_probe; } =20 return 0; + +err_drv_probe: + mediatek_dwmac_clks_config(priv_plat, false); + return ret; +} + +static int mediatek_dwmac_remove(struct platform_device *pdev) +{ + struct mediatek_dwmac_plat_data *priv_plat =3D get_stmmac_bsp_priv(&pdev-= >dev); + int ret; + + ret =3D stmmac_pltfr_remove(pdev); + mediatek_dwmac_clks_config(priv_plat, false); + + return ret; } =20 static const struct of_device_id mediatek_dwmac_match[] =3D { @@ -733,7 +726,7 @@ MODULE_DEVICE_TABLE(of, mediatek_dwmac_match); =20 static struct platform_driver mediatek_dwmac_driver =3D { .probe =3D mediatek_dwmac_probe, - .remove =3D stmmac_pltfr_remove, + .remove =3D mediatek_dwmac_remove, .driver =3D { .name =3D "dwmac-mediatek", .pm =3D &stmmac_pltfr_pm_ops, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E897C19F2C for ; Wed, 27 Jul 2022 17:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242266AbiG0RfT (ORCPT ); Wed, 27 Jul 2022 13:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242103AbiG0Rdq (ORCPT ); Wed, 27 Jul 2022 13:33:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972EE8238B; Wed, 27 Jul 2022 09:48:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5331BB821BE; Wed, 27 Jul 2022 16:48:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0C9BC433D7; Wed, 27 Jul 2022 16:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940513; bh=y2bd9DdpkECpZ4Av2R+aDyqf3jrPr/dleq0g0aAcroA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lk3ShVJ/cqdmsu2swPbE8ioip4Ih0Wq5RnZfVd6Mi1k8h8j/PUbZitcWRR90GjBpr ENzJlyniN+9UyGcujolWE0n5qGvLG2TPt14VgPwc5ftfwOD0oObwmzHiyG+V+iqJqu L9rDGbanRLUP0oB+9GLJJTdqjJ31+jntrbGVJOlg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Biao Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 049/158] net: stmmac: fix pm runtime issue in stmmac_dvr_remove() Date: Wed, 27 Jul 2022 18:11:53 +0200 Message-Id: <20220727161023.483659059@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Biao Huang [ Upstream commit 0d9a15913b871e03fdd3b3d90a2e665fb22f9bcf ] If netif is running when stmmac_dvr_remove is invoked, the unregister_netdev will call ndo_stop(stmmac_release) and vlan_kill_rx_filter(stmmac_vlan_rx_kill_vid). Currently, stmmac_dvr_remove() will disable pm runtime before unregister_netdev. When stmmac_vlan_rx_kill_vid is invoked, pm_runtime_resume_and_get in it returns EACCESS error number, and reports: dwmac-mediatek 11021000.ethernet eth0: stmmac_dvr_remove: removing driver dwmac-mediatek 11021000.ethernet eth0: FPE workqueue stop dwmac-mediatek 11021000.ethernet eth0: failed to kill vid 0081/0 Move the pm_runtime_disable to the end of stmmac_dvr_remove to fix this issue. Fixes: 6449520391dfc ("net: stmmac: properly handle with runtime pm in stmm= ac_dvr_remove()") Signed-off-by: Biao Huang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 2525a80353b7..d43c9ba0b270 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7220,8 +7220,6 @@ int stmmac_dvr_remove(struct device *dev) netdev_info(priv->dev, "%s: removing driver", __func__); =20 pm_runtime_get_sync(dev); - pm_runtime_disable(dev); - pm_runtime_put_noidle(dev); =20 stmmac_stop_all_dma(priv); stmmac_mac_set(priv, priv->ioaddr, false); @@ -7248,6 +7246,9 @@ int stmmac_dvr_remove(struct device *dev) mutex_destroy(&priv->lock); bitmap_free(priv->af_xdp_zc_qps); =20 + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); + return 0; } EXPORT_SYMBOL_GPL(stmmac_dvr_remove); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E26C04A68 for ; Wed, 27 Jul 2022 17:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242448AbiG0Rdq (ORCPT ); Wed, 27 Jul 2022 13:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242300AbiG0RdJ (ORCPT ); Wed, 27 Jul 2022 13:33:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95593606B3; Wed, 27 Jul 2022 09:48:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0D5D8B821BA; Wed, 27 Jul 2022 16:48:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71D37C433C1; Wed, 27 Jul 2022 16:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940515; bh=TZ3DTx7gCxGl6xzl8zAlNkypg0HN/rgTN+t3RxB4vlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOFXqRIBKP+cafR4dxmgMOsCMSixRotpnreV+CXrfVkK6aLC/1ZfnjD4Wo7HPQ1pM sl0TCCgQeufsJxHSCml8z5hZOtkb4MFHZMKQb1Ck6t9OG61nPCXrxl64IZEk2JeMpG fiWRC66E4JJI+KyX7OmWPtDtqozZO+zQvh3P0JmA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Biao Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 050/158] net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow Date: Wed, 27 Jul 2022 18:11:54 +0200 Message-Id: <20220727161023.531618844@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Biao Huang [ Upstream commit f4c7d8948e866918d61493264dbbd67e45ef2bda ] Current stmmac driver will prepare/enable ptp_ref clock in stmmac_init_tstamp_counter(). The stmmac_pltfr_noirq_suspend will disable it once in suspend flow. But in resume flow, stmmac_pltfr_noirq_resume --> stmmac_init_tstamp_counter stmmac_resume --> stmmac_hw_setup --> stmmac_init_ptp --> stmmac_init_tsta= mp_counter ptp_ref clock reference counter increases twice, which leads to unbalance ptp clock when resume back. Move ptp_ref clock prepare/enable out of stmmac_init_tstamp_counter to fix = it. Fixes: 0735e639f129d ("net: stmmac: skip only stmmac_ptp_register when resu= me from suspend") Signed-off-by: Biao Huang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 ++++++++--------- .../ethernet/stmicro/stmmac/stmmac_platform.c | 8 +++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index d43c9ba0b270..6a7f63a58aef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -834,19 +834,10 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *pr= iv, u32 systime_flags) struct timespec64 now; u32 sec_inc =3D 0; u64 temp =3D 0; - int ret; =20 if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) return -EOPNOTSUPP; =20 - ret =3D clk_prepare_enable(priv->plat->clk_ptp_ref); - if (ret < 0) { - netdev_warn(priv->dev, - "failed to enable PTP reference clock: %pe\n", - ERR_PTR(ret)); - return ret; - } - stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags); priv->systime_flags =3D systime_flags; =20 @@ -3270,6 +3261,14 @@ static int stmmac_hw_setup(struct net_device *dev, b= ool ptp_register) =20 stmmac_mmc_setup(priv); =20 + if (ptp_register) { + ret =3D clk_prepare_enable(priv->plat->clk_ptp_ref); + if (ret < 0) + netdev_warn(priv->dev, + "failed to enable PTP reference clock: %pe\n", + ERR_PTR(ret)); + } + ret =3D stmmac_init_ptp(priv); if (ret =3D=3D -EOPNOTSUPP) netdev_info(priv->dev, "PTP not supported by HW\n"); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_platform.c index 11e1055e8260..9f5cac4000da 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -815,7 +815,13 @@ static int __maybe_unused stmmac_pltfr_noirq_resume(st= ruct device *dev) if (ret) return ret; =20 - stmmac_init_tstamp_counter(priv, priv->systime_flags); + ret =3D clk_prepare_enable(priv->plat->clk_ptp_ref); + if (ret < 0) { + netdev_warn(priv->dev, + "failed to enable PTP reference clock: %pe\n", + ERR_PTR(ret)); + return ret; + } } =20 return 0; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9414C04A68 for ; Wed, 27 Jul 2022 17:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238029AbiG0Rfe (ORCPT ); Wed, 27 Jul 2022 13:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242457AbiG0Rd4 (ORCPT ); Wed, 27 Jul 2022 13:33:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC9C882F87; Wed, 27 Jul 2022 09:48:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4F22A600BE; Wed, 27 Jul 2022 16:48:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3430EC43470; Wed, 27 Jul 2022 16:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940518; bh=acifiAZYGGEyPLvFGkAq/4jyGT+ETtNuHd0sN+qjSQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+t8jjQni1Qh7LXmWAhUeQfbCsCO2dKGy6Uacn3dBp5lcSAjr1sNm5ky7zJdH1+Wp THlzn/7Jp/a5Elnp7kndCw7Vz7UyJawzNRgQarTjabtiY5CIjEEhjGopUHoaOIckN5 7P2Coo8V0Pux0/Hr7PdC1ESIFFYVww4NsWg9loCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 051/158] net: dsa: microchip: ksz_common: Fix refcount leak bug Date: Wed, 27 Jul 2022 18:11:55 +0200 Message-Id: <20220727161023.569878060@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Liang He [ Upstream commit a14bd7475452c51835dd5a0cee4c8fa48dd0b539 ] In ksz_switch_register(), we should call of_node_put() for the reference returned by of_get_child_by_name() which has increased the refcount. Fixes: 912aae27c6af ("net: dsa: microchip: really look for phy-mode in port= nodes") Signed-off-by: Liang He Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220714153138.375919-1-windhl@126.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/dsa/microchip/ksz_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 8014b18d9391..aa0bcf01e20a 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -447,18 +447,21 @@ int ksz_switch_register(struct ksz_device *dev, ports =3D of_get_child_by_name(dev->dev->of_node, "ethernet-ports"); if (!ports) ports =3D of_get_child_by_name(dev->dev->of_node, "ports"); - if (ports) + if (ports) { for_each_available_child_of_node(ports, port) { if (of_property_read_u32(port, "reg", &port_num)) continue; if (!(dev->port_mask & BIT(port_num))) { of_node_put(port); + of_node_put(ports); return -EINVAL; } of_get_phy_mode(port, &dev->ports[port_num].interface); } + of_node_put(ports); + } dev->synclko_125 =3D of_property_read_bool(dev->dev->of_node, "microchip,synclko-125"); dev->synclko_disable =3D of_property_read_bool(dev->dev->of_node, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7281C04A68 for ; Wed, 27 Jul 2022 17:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241993AbiG0Rdy (ORCPT ); Wed, 27 Jul 2022 13:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242321AbiG0RdY (ORCPT ); Wed, 27 Jul 2022 13:33:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37588211B; Wed, 27 Jul 2022 09:48:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 127C661653; Wed, 27 Jul 2022 16:48:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DC1BC433C1; Wed, 27 Jul 2022 16:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940521; bh=6tTqnG+UGsQTZFp/mT3pDC17e4nCsbs5oYJkEl2c5JM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vQ/E5/lz1Uvutk58C/5IbJSp5E2qwy3rPxelGh//TfkQiSwHZ/jzL8VPU3qVtVBEv pGYC8q/rYLoCylKbesLENQ0/HH9RVyFy9UNEsAQgLQCWmwJummWg8EzSi4DzkXxa9v Mqf9D7pjlA7miYik4SdsvWj4OYHR8+uEGia1CuvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 052/158] tcp/udp: Make early_demux back namespacified. Date: Wed, 27 Jul 2022 18:11:56 +0200 Message-Id: <20220727161023.607020784@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 11052589cf5c0bab3b4884d423d5f60c38fcf25d ] Commit e21145a9871a ("ipv4: namespacify ip_early_demux sysctl knob") made it possible to enable/disable early_demux on a per-netns basis. Then, we introduced two knobs, tcp_early_demux and udp_early_demux, to switch it for TCP/UDP in commit dddb64bcb346 ("net: Add sysctl to toggle early demux for tcp and udp"). However, the .proc_handler() was wrong and actually disabled us from changing the behaviour in each netns. We can execute early_demux if net.ipv4.ip_early_demux is on and each proto .early_demux() handler is not NULL. When we toggle (tcp|udp)_early_demux, the change itself is saved in each netns variable, but the .early_demux() handler is a global variable, so the handler is switched based on the init_net's sysctl variable. Thus, netns (tcp|udp)_early_demux knobs have nothing to do with the logic. Whether we CAN execute proto .early_demux() is always decided by init_net's sysctl knob, and whether we DO it or not is by each netns ip_early_demux knob. This patch namespacifies (tcp|udp)_early_demux again. For now, the users of the .early_demux() handler are TCP and UDP only, and they are called directly to avoid retpoline. So, we can remove the .early_demux() handler from inet6?_protos and need not dereference them in ip6?_rcv_finish_core(). If another proto needs .early_demux(), we can restore it at that time. Fixes: dddb64bcb346 ("net: Add sysctl to toggle early demux for tcp and udp= ") Signed-off-by: Kuniyuki Iwashima Link: https://lore.kernel.org/r/20220713175207.7727-1-kuniyu@amazon.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/protocol.h | 4 --- include/net/tcp.h | 2 +- include/net/udp.h | 2 +- net/ipv4/af_inet.c | 14 ++------- net/ipv4/ip_input.c | 37 ++++++++++++++---------- net/ipv4/sysctl_net_ipv4.c | 59 ++------------------------------------ net/ipv6/ip6_input.c | 23 ++++++++------- net/ipv6/tcp_ipv6.c | 9 ++---- net/ipv6/udp.c | 9 ++---- 9 files changed, 45 insertions(+), 114 deletions(-) diff --git a/include/net/protocol.h b/include/net/protocol.h index f51c06ae365f..6aef8cb11cc8 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h @@ -35,8 +35,6 @@ =20 /* This is used to register protocols. */ struct net_protocol { - int (*early_demux)(struct sk_buff *skb); - int (*early_demux_handler)(struct sk_buff *skb); int (*handler)(struct sk_buff *skb); =20 /* This returns an error if we weren't able to handle the error. */ @@ -52,8 +50,6 @@ struct net_protocol { =20 #if IS_ENABLED(CONFIG_IPV6) struct inet6_protocol { - void (*early_demux)(struct sk_buff *skb); - void (*early_demux_handler)(struct sk_buff *skb); int (*handler)(struct sk_buff *skb); =20 /* This returns an error if we weren't able to handle the error. */ diff --git a/include/net/tcp.h b/include/net/tcp.h index 2d9a78b3beaa..113ce516ce42 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -932,7 +932,7 @@ extern const struct inet_connection_sock_af_ops ipv6_sp= ecific; =20 INDIRECT_CALLABLE_DECLARE(void tcp_v6_send_check(struct sock *sk, struct s= k_buff *skb)); INDIRECT_CALLABLE_DECLARE(int tcp_v6_rcv(struct sk_buff *skb)); -INDIRECT_CALLABLE_DECLARE(void tcp_v6_early_demux(struct sk_buff *skb)); +void tcp_v6_early_demux(struct sk_buff *skb); =20 #endif =20 diff --git a/include/net/udp.h b/include/net/udp.h index f1c2a88c9005..07d0ceadcf6e 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -167,7 +167,7 @@ static inline void udp_csum_pull_header(struct sk_buff = *skb) typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 spo= rt, __be16 dport); =20 -INDIRECT_CALLABLE_DECLARE(void udp_v6_early_demux(struct sk_buff *)); +void udp_v6_early_demux(struct sk_buff *skb); INDIRECT_CALLABLE_DECLARE(int udpv6_rcv(struct sk_buff *)); =20 struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 8c0a22a5b36c..f5d5911a8abd 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1711,24 +1711,14 @@ static const struct net_protocol igmp_protocol =3D { }; #endif =20 -/* thinking of making this const? Don't. - * early_demux can change based on sysctl. - */ -static struct net_protocol tcp_protocol =3D { - .early_demux =3D tcp_v4_early_demux, - .early_demux_handler =3D tcp_v4_early_demux, +static const struct net_protocol tcp_protocol =3D { .handler =3D tcp_v4_rcv, .err_handler =3D tcp_v4_err, .no_policy =3D 1, .icmp_strict_tag_validation =3D 1, }; =20 -/* thinking of making this const? Don't. - * early_demux can change based on sysctl. - */ -static struct net_protocol udp_protocol =3D { - .early_demux =3D udp_v4_early_demux, - .early_demux_handler =3D udp_v4_early_demux, +static const struct net_protocol udp_protocol =3D { .handler =3D udp_rcv, .err_handler =3D udp_err, .no_policy =3D 1, diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 95f7bb052784..f3fd6c398309 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -312,14 +312,13 @@ static bool ip_can_use_hint(const struct sk_buff *skb= , const struct iphdr *iph, ip_hdr(hint)->tos =3D=3D iph->tos; } =20 -INDIRECT_CALLABLE_DECLARE(int udp_v4_early_demux(struct sk_buff *)); -INDIRECT_CALLABLE_DECLARE(int tcp_v4_early_demux(struct sk_buff *)); +int tcp_v4_early_demux(struct sk_buff *skb); +int udp_v4_early_demux(struct sk_buff *skb); static int ip_rcv_finish_core(struct net *net, struct sock *sk, struct sk_buff *skb, struct net_device *dev, const struct sk_buff *hint) { const struct iphdr *iph =3D ip_hdr(skb); - int (*edemux)(struct sk_buff *skb); int err, drop_reason; struct rtable *rt; =20 @@ -332,21 +331,29 @@ static int ip_rcv_finish_core(struct net *net, struct= sock *sk, goto drop_error; } =20 - if (net->ipv4.sysctl_ip_early_demux && + if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) && !skb_dst(skb) && !skb->sk && !ip_is_fragment(iph)) { - const struct net_protocol *ipprot; - int protocol =3D iph->protocol; - - ipprot =3D rcu_dereference(inet_protos[protocol]); - if (ipprot && (edemux =3D READ_ONCE(ipprot->early_demux))) { - err =3D INDIRECT_CALL_2(edemux, tcp_v4_early_demux, - udp_v4_early_demux, skb); - if (unlikely(err)) - goto drop_error; - /* must reload iph, skb->head might have changed */ - iph =3D ip_hdr(skb); + switch (iph->protocol) { + case IPPROTO_TCP: + if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux)) { + tcp_v4_early_demux(skb); + + /* must reload iph, skb->head might have changed */ + iph =3D ip_hdr(skb); + } + break; + case IPPROTO_UDP: + if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) { + err =3D udp_v4_early_demux(skb); + if (unlikely(err)) + goto drop_error; + + /* must reload iph, skb->head might have changed */ + iph =3D ip_hdr(skb); + } + break; } } =20 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index ffe0264a51b8..6b718688865e 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -354,61 +354,6 @@ static int proc_tcp_fastopen_key(struct ctl_table *tab= le, int write, return ret; } =20 -static void proc_configure_early_demux(int enabled, int protocol) -{ - struct net_protocol *ipprot; -#if IS_ENABLED(CONFIG_IPV6) - struct inet6_protocol *ip6prot; -#endif - - rcu_read_lock(); - - ipprot =3D rcu_dereference(inet_protos[protocol]); - if (ipprot) - ipprot->early_demux =3D enabled ? ipprot->early_demux_handler : - NULL; - -#if IS_ENABLED(CONFIG_IPV6) - ip6prot =3D rcu_dereference(inet6_protos[protocol]); - if (ip6prot) - ip6prot->early_demux =3D enabled ? ip6prot->early_demux_handler : - NULL; -#endif - rcu_read_unlock(); -} - -static int proc_tcp_early_demux(struct ctl_table *table, int write, - void *buffer, size_t *lenp, loff_t *ppos) -{ - int ret =3D 0; - - ret =3D proc_dou8vec_minmax(table, write, buffer, lenp, ppos); - - if (write && !ret) { - int enabled =3D init_net.ipv4.sysctl_tcp_early_demux; - - proc_configure_early_demux(enabled, IPPROTO_TCP); - } - - return ret; -} - -static int proc_udp_early_demux(struct ctl_table *table, int write, - void *buffer, size_t *lenp, loff_t *ppos) -{ - int ret =3D 0; - - ret =3D proc_dou8vec_minmax(table, write, buffer, lenp, ppos); - - if (write && !ret) { - int enabled =3D init_net.ipv4.sysctl_udp_early_demux; - - proc_configure_early_demux(enabled, IPPROTO_UDP); - } - - return ret; -} - static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) @@ -711,14 +656,14 @@ static struct ctl_table ipv4_net_table[] =3D { .data =3D &init_net.ipv4.sysctl_udp_early_demux, .maxlen =3D sizeof(u8), .mode =3D 0644, - .proc_handler =3D proc_udp_early_demux + .proc_handler =3D proc_dou8vec_minmax, }, { .procname =3D "tcp_early_demux", .data =3D &init_net.ipv4.sysctl_tcp_early_demux, .maxlen =3D sizeof(u8), .mode =3D 0644, - .proc_handler =3D proc_tcp_early_demux + .proc_handler =3D proc_dou8vec_minmax, }, { .procname =3D "nexthop_compat_mode", diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 5b5ea35635f9..caba03e551ef 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -45,20 +45,23 @@ #include #include =20 -INDIRECT_CALLABLE_DECLARE(void tcp_v6_early_demux(struct sk_buff *)); static void ip6_rcv_finish_core(struct net *net, struct sock *sk, struct sk_buff *skb) { - void (*edemux)(struct sk_buff *skb); - - if (net->ipv4.sysctl_ip_early_demux && !skb_dst(skb) && skb->sk =3D=3D NU= LL) { - const struct inet6_protocol *ipprot; - - ipprot =3D rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]); - if (ipprot && (edemux =3D READ_ONCE(ipprot->early_demux))) - INDIRECT_CALL_2(edemux, tcp_v6_early_demux, - udp_v6_early_demux, skb); + if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) && + !skb_dst(skb) && !skb->sk) { + switch (ipv6_hdr(skb)->nexthdr) { + case IPPROTO_TCP: + if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux)) + tcp_v6_early_demux(skb); + break; + case IPPROTO_UDP: + if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) + udp_v6_early_demux(skb); + break; + } } + if (!skb_valid_dst(skb)) ip6_route_input(skb); } diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index cbc5fff3d846..5185c11dc444 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1822,7 +1822,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff= *skb) goto discard_it; } =20 -INDIRECT_CALLABLE_SCOPE void tcp_v6_early_demux(struct sk_buff *skb) +void tcp_v6_early_demux(struct sk_buff *skb) { const struct ipv6hdr *hdr; const struct tcphdr *th; @@ -2176,12 +2176,7 @@ struct proto tcpv6_prot =3D { }; EXPORT_SYMBOL_GPL(tcpv6_prot); =20 -/* thinking of making this const? Don't. - * early_demux can change based on sysctl. - */ -static struct inet6_protocol tcpv6_protocol =3D { - .early_demux =3D tcp_v6_early_demux, - .early_demux_handler =3D tcp_v6_early_demux, +static const struct inet6_protocol tcpv6_protocol =3D { .handler =3D tcp_v6_rcv, .err_handler =3D tcp_v6_err, .flags =3D INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index a535c3f2e4af..aea28bf701be 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1052,7 +1052,7 @@ static struct sock *__udp6_lib_demux_lookup(struct ne= t *net, return NULL; } =20 -INDIRECT_CALLABLE_SCOPE void udp_v6_early_demux(struct sk_buff *skb) +void udp_v6_early_demux(struct sk_buff *skb) { struct net *net =3D dev_net(skb->dev); const struct udphdr *uh; @@ -1660,12 +1660,7 @@ int udpv6_getsockopt(struct sock *sk, int level, int= optname, return ipv6_getsockopt(sk, level, optname, optval, optlen); } =20 -/* thinking of making this const? Don't. - * early_demux can change based on sysctl. - */ -static struct inet6_protocol udpv6_protocol =3D { - .early_demux =3D udp_v6_early_demux, - .early_demux_handler =3D udp_v6_early_demux, +static const struct inet6_protocol udpv6_protocol =3D { .handler =3D udpv6_rcv, .err_handler =3D udpv6_err, .flags =3D INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3113FC04A68 for ; Wed, 27 Jul 2022 17:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241719AbiG0Rd6 (ORCPT ); Wed, 27 Jul 2022 13:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242335AbiG0RdY (ORCPT ); Wed, 27 Jul 2022 13:33:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0497E823A7; Wed, 27 Jul 2022 09:48:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B810E61557; Wed, 27 Jul 2022 16:48:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA6AAC433C1; Wed, 27 Jul 2022 16:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940524; bh=k2x8KRa8zb0bGlUslzf5eGp7kQTir1VRH1brWNXvN8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=inVVL4xXEv7XT3gNtuQXnMRbdQn5qe43eP2eI4QUq/I7GRbtINu8THaC/yZ9Swunu vTqeoYft7QKm61gPT3ck/zg7CtaGWRAJ5C7anZ2tGV7GU3DzzjLSS8GGU2lXNHtWe8 S1zNoerARrRsmicKlNXO8ZhvUF7vvvoM+Nqx1+/w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vadim Pasternak , Wolfram Sang , Sasha Levin Subject: [PATCH 5.18 053/158] i2c: mlxcpld: Fix register setting for 400KHz frequency Date: Wed, 27 Jul 2022 18:11:57 +0200 Message-Id: <20220727161023.636086448@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vadim Pasternak [ Upstream commit e1f77ecc75aaee6bed04e8fd7830e00032af012e ] Fix setting of 'Half Cycle' register for 400KHz frequency. Fixes: fa1049135c15 ("i2c: mlxcpld: Modify register setting for 400KHz freq= uency") Signed-off-by: Vadim Pasternak Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/i2c/busses/i2c-mlxcpld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxc= pld.c index 56aa424fd71d..815cc561386b 100644 --- a/drivers/i2c/busses/i2c-mlxcpld.c +++ b/drivers/i2c/busses/i2c-mlxcpld.c @@ -49,7 +49,7 @@ #define MLXCPLD_LPCI2C_NACK_IND 2 =20 #define MLXCPLD_I2C_FREQ_1000KHZ_SET 0x04 -#define MLXCPLD_I2C_FREQ_400KHZ_SET 0x0c +#define MLXCPLD_I2C_FREQ_400KHZ_SET 0x0e #define MLXCPLD_I2C_FREQ_100KHZ_SET 0x42 =20 enum mlxcpld_i2c_frequency { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D558C19F28 for ; Wed, 27 Jul 2022 17:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236853AbiG0RfH (ORCPT ); Wed, 27 Jul 2022 13:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236506AbiG0Rdn (ORCPT ); Wed, 27 Jul 2022 13:33:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DA9861101; Wed, 27 Jul 2022 09:48:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1C439B821C5; Wed, 27 Jul 2022 16:48:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84F29C433C1; Wed, 27 Jul 2022 16:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940526; bh=OEykdUPXVNQvb/VQCM+52YVDVEsWYbSFVHjVP5N/vg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dU5BwEeiZcQdC4h9NEb3uhIAmmITLUzrpJf1wgGkDuD9oBTAWWC98MfnTkCyNk+Am dxt8OR0gcmooP7hQT6PMELIyBOuoJ+kd77KC3wL9mUnz7F9EUVUt2vzq2fzlwr8fVz 2Yh9gKA8tyG4p5dwUglmI8Ch7HcwXnQPpk/8qImA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , Shubhrajyoti Datta , Michal Simek , Wolfram Sang , Sasha Levin Subject: [PATCH 5.18 054/158] i2c: cadence: Change large transfer count reset logic to be unconditional Date: Wed, 27 Jul 2022 18:11:58 +0200 Message-Id: <20220727161023.685887172@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Robert Hancock [ Upstream commit 4ca8ca873d454635c20d508261bfc0081af75cf8 ] Problems were observed on the Xilinx ZynqMP platform with large I2C reads. When a read of 277 bytes was performed, the controller NAKed the transfer after only 252 bytes were transferred and returned an ENXIO error on the transfer. There is some code in cdns_i2c_master_isr to handle this case by resetting the transfer count in the controller before it reaches 0, to allow larger transfers to work, but it was conditional on the CDNS_I2C_BROKEN_HOLD_BIT quirk being set on the controller, and ZynqMP uses the r1p14 version of the core where this quirk is not being set. The requirement to do this to support larger reads seems like an inherently required workaround due to the core only having an 8-bit transfer size register, so it does not appear that this should be conditional on the broken HOLD bit quirk which is used elsewhere in the driver. Remove the dependency on the CDNS_I2C_BROKEN_HOLD_BIT for this transfer size reset logic to fix this problem. Fixes: 63cab195bf49 ("i2c: removed work arounds in i2c driver for Zynq Ultr= ascale+ MPSoC") Signed-off-by: Robert Hancock Reviewed-by: Shubhrajyoti Datta Acked-by: Michal Simek Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/i2c/busses/i2c-cadence.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cade= nce.c index 3d6f8ee355bf..630cfa4ddd46 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -388,9 +388,9 @@ static irqreturn_t cdns_i2c_slave_isr(void *ptr) */ static irqreturn_t cdns_i2c_master_isr(void *ptr) { - unsigned int isr_status, avail_bytes, updatetx; + unsigned int isr_status, avail_bytes; unsigned int bytes_to_send; - bool hold_quirk; + bool updatetx; struct cdns_i2c *id =3D ptr; /* Signal completion only after everything is updated */ int done_flag =3D 0; @@ -410,11 +410,7 @@ static irqreturn_t cdns_i2c_master_isr(void *ptr) * Check if transfer size register needs to be updated again for a * large data receive operation. */ - updatetx =3D 0; - if (id->recv_count > id->curr_recv_count) - updatetx =3D 1; - - hold_quirk =3D (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT) && updatetx; + updatetx =3D id->recv_count > id->curr_recv_count; =20 /* When receiving, handle data interrupt and completion interrupt */ if (id->p_recv_buf && @@ -445,7 +441,7 @@ static irqreturn_t cdns_i2c_master_isr(void *ptr) break; } =20 - if (cdns_is_holdquirk(id, hold_quirk)) + if (cdns_is_holdquirk(id, updatetx)) break; } =20 @@ -456,7 +452,7 @@ static irqreturn_t cdns_i2c_master_isr(void *ptr) * maintain transfer size non-zero while performing a large * receive operation. */ - if (cdns_is_holdquirk(id, hold_quirk)) { + if (cdns_is_holdquirk(id, updatetx)) { /* wait while fifo is full */ while (cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET) !=3D (id->curr_recv_count - CDNS_I2C_FIFO_DEPTH)) @@ -478,22 +474,6 @@ static irqreturn_t cdns_i2c_master_isr(void *ptr) CDNS_I2C_XFER_SIZE_OFFSET); id->curr_recv_count =3D id->recv_count; } - } else if (id->recv_count && !hold_quirk && - !id->curr_recv_count) { - - /* Set the slave address in address register*/ - cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK, - CDNS_I2C_ADDR_OFFSET); - - if (id->recv_count > CDNS_I2C_TRANSFER_SIZE) { - cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE, - CDNS_I2C_XFER_SIZE_OFFSET); - id->curr_recv_count =3D CDNS_I2C_TRANSFER_SIZE; - } else { - cdns_i2c_writereg(id->recv_count, - CDNS_I2C_XFER_SIZE_OFFSET); - id->curr_recv_count =3D id->recv_count; - } } =20 /* Clear hold (if not repeated start) and signal completion */ --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D11B2C04A68 for ; Wed, 27 Jul 2022 17:35:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242479AbiG0Rf5 (ORCPT ); Wed, 27 Jul 2022 13:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242540AbiG0ReV (ORCPT ); Wed, 27 Jul 2022 13:34:21 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFC9552FE3; Wed, 27 Jul 2022 09:49:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 5FAA7CE2315; Wed, 27 Jul 2022 16:48:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B16CC433D6; Wed, 27 Jul 2022 16:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940529; bh=IOh/2jB7rdGTmLQnOWdk4AKkBIus8bWns1MLLS8jkNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1jqERB1oTSmbwKoBJ62ZYnwXfcVIN2ukCNM+vBX0SmAvt043WO88YhnJvdyjybuZ7 VJpxkdczXSD0lcYSL0PaixhLY8LNMYsRFEErQKqU2mzuhit43oyuq/5DoWn5FE2LqO SAaIA2BNpBYW/a41qfBuUuhAKu9WSP/8yNZQkOuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , Adrian Hunter , Ian Rogers , Jiri Olsa , Namhyung Kim , Thomas Richter , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.18 055/158] perf tests: Stop Convert perf time to TSC test opening events twice Date: Wed, 27 Jul 2022 18:11:59 +0200 Message-Id: <20220727161023.717047753@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Adrian Hunter [ Upstream commit 498c7a54f169b2699104d3060604d840424f15d2 ] Do not call evlist__open() twice. Fixes: 5bb017d4b97a0f13 ("perf test: Fix error message for test case 71 on = s390, where it is not supported") Reviewed-by: Kan Liang Signed-off-by: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: Namhyung Kim Cc: Thomas Richter Link: https://lore.kernel.org/r/20220713123459.24145-2-adrian.hunter@intel.= com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- tools/perf/tests/perf-time-to-tsc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-ti= me-to-tsc.c index 4ad0dfbc8b21..8d6d60173693 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c @@ -123,11 +123,14 @@ static int test__perf_time_to_tsc(struct test_suite *= test __maybe_unused, int su evsel->core.attr.enable_on_exec =3D 0; } =20 - if (evlist__open(evlist) =3D=3D -ENOENT) { - err =3D TEST_SKIP; + ret =3D evlist__open(evlist); + if (ret < 0) { + if (ret =3D=3D -ENOENT) + err =3D TEST_SKIP; + else + pr_debug("evlist__open() failed\n"); goto out_err; } - CHECK__(evlist__open(evlist)); =20 CHECK__(evlist__mmap(evlist, UINT_MAX)); =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 273F0C04A68 for ; Wed, 27 Jul 2022 17:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242485AbiG0RgB (ORCPT ); Wed, 27 Jul 2022 13:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242563AbiG0ReY (ORCPT ); Wed, 27 Jul 2022 13:34:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B2D561705; Wed, 27 Jul 2022 09:49:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 78140B821BA; Wed, 27 Jul 2022 16:48:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACE1BC433D7; Wed, 27 Jul 2022 16:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940532; bh=YaFXX1Mfc+RUED/z5iG3G6u7AHYIefa00/zPTIXtQsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y6BpHXozZ90fgrrH+N3m9EKeEk5OUlVxZ087+niMAB4z4gjQuFrde1ZzeDtHGuC5m Il6i5srtPK75E1u/q/YumJ1mYNKenFCtu85Oej8os6Mp9jCdQIMwFOgAcasVys0frc ozCMieQ8DtBdiThkkrQKy86KMkoWOKgfOwaBdRog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , Adrian Hunter , Ian Rogers , Jin Yao , Jiri Olsa , Namhyung Kim , Thomas Richter , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.18 056/158] perf tests: Fix Convert perf time to TSC test for hybrid Date: Wed, 27 Jul 2022 18:12:00 +0200 Message-Id: <20220727161023.756075674@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Adrian Hunter [ Upstream commit deb44a6249f696106645c63c0603eab08a6122af ] The test does not always correctly determine the number of events for hybrids, nor allow for more than 1 evsel when parsing. Fix by iterating the events actually created and getting the correct evsel for the events processed. Fixes: d9da6f70eb235110 ("perf tests: Support 'Convert perf time to TSC' te= st for hybrid") Reviewed-by: Kan Liang Signed-off-by: Adrian Hunter Cc: Ian Rogers Cc: Jin Yao Cc: Jiri Olsa Cc: Namhyung Kim Cc: Thomas Richter Link: https://lore.kernel.org/r/20220713123459.24145-3-adrian.hunter@intel.= com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- tools/perf/tests/perf-time-to-tsc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-ti= me-to-tsc.c index 8d6d60173693..7c7d20fc503a 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c @@ -20,8 +20,6 @@ #include "tsc.h" #include "mmap.h" #include "tests.h" -#include "pmu.h" -#include "pmu-hybrid.h" =20 /* * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. J= ust @@ -106,18 +104,8 @@ static int test__perf_time_to_tsc(struct test_suite *t= est __maybe_unused, int su =20 evlist__config(evlist, &opts, NULL); =20 - evsel =3D evlist__first(evlist); - - evsel->core.attr.comm =3D 1; - evsel->core.attr.disabled =3D 1; - evsel->core.attr.enable_on_exec =3D 0; - - /* - * For hybrid "cycles:u", it creates two events. - * Init the second evsel here. - */ - if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom")) { - evsel =3D evsel__next(evsel); + /* For hybrid "cycles:u", it creates two events */ + evlist__for_each_entry(evlist, evsel) { evsel->core.attr.comm =3D 1; evsel->core.attr.disabled =3D 1; evsel->core.attr.enable_on_exec =3D 0; @@ -170,10 +158,12 @@ static int test__perf_time_to_tsc(struct test_suite *= test __maybe_unused, int su goto next_event; =20 if (strcmp(event->comm.comm, comm1) =3D=3D 0) { + CHECK_NOT_NULL__(evsel =3D evlist__event2evsel(evlist, event)); CHECK__(evsel__parse_sample(evsel, event, &sample)); comm1_time =3D sample.time; } if (strcmp(event->comm.comm, comm2) =3D=3D 0) { + CHECK_NOT_NULL__(evsel =3D evlist__event2evsel(evlist, event)); CHECK__(evsel__parse_sample(evsel, event, &sample)); comm2_time =3D sample.time; } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCAAFC04A68 for ; Wed, 27 Jul 2022 17:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242438AbiG0Rf2 (ORCPT ); Wed, 27 Jul 2022 13:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237827AbiG0ReI (ORCPT ); Wed, 27 Jul 2022 13:34:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 000EC82F97; Wed, 27 Jul 2022 09:48:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3EBE7B821D4; Wed, 27 Jul 2022 16:48:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90834C43140; Wed, 27 Jul 2022 16:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940534; bh=y453DtRhy183YpSqmE6b9Z4EHubiK9dU8CyYUEyJbTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWvTySu3UVYnrSgft7JzSsUfa1a4DhFbUFNUsxAy6xoSr5IcChMP2Xv5WrdvkiCGI fam4RfFSXXgjGP1d9PCabO7+3AQHk6mxcslq70OKjq0SytK8QXlHytQJ0xpjmtqydK 2M+rjJ33gueOR++QSVq8weeTTnEDn1YqJt3tprJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Andy Shevchenko , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 057/158] pinctrl: ocelot: Fix pincfg for lan966x Date: Wed, 27 Jul 2022 18:12:01 +0200 Message-Id: <20220727161023.795967960@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit dc62db7138aa9365480254dda4c3e1316b1b1bbc ] The blamed commit introduce support for lan966x which use the same pinconf_ops as sparx5. The problem is that pinconf_ops is specific to sparx5. More precisely the offset of the bits in the pincfg register are different and also lan966x doesn't have support for PIN_CONFIG_INPUT_SCHMITT_ENABLE. Fix this by making pinconf_ops more generic such that it can be also used by lan966x. This is done by introducing 'ocelot_pincfg_data' which contains the offset and what is supported for each SOC. Fixes: 531d6ab36571 ("pinctrl: ocelot: Extend support for lan966x") Signed-off-by: Horatiu Vultur Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20220713193750.4079621-2-horatiu.vultur@mic= rochip.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/pinctrl-ocelot.c | 195 ++++++++++++++++++++----------- 1 file changed, 124 insertions(+), 71 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-oce= lot.c index 6a956ee94494..2866365132fd 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -28,19 +28,12 @@ #define ocelot_clrsetbits(addr, clear, set) \ writel((readl(addr) & ~(clear)) | (set), (addr)) =20 -/* PINCONFIG bits (sparx5 only) */ enum { PINCONF_BIAS, PINCONF_SCHMITT, PINCONF_DRIVE_STRENGTH, }; =20 -#define BIAS_PD_BIT BIT(4) -#define BIAS_PU_BIT BIT(3) -#define BIAS_BITS (BIAS_PD_BIT|BIAS_PU_BIT) -#define SCHMITT_BIT BIT(2) -#define DRIVE_BITS GENMASK(1, 0) - /* GPIO standard registers */ #define OCELOT_GPIO_OUT_SET 0x0 #define OCELOT_GPIO_OUT_CLR 0x4 @@ -314,6 +307,13 @@ struct ocelot_pin_caps { unsigned char a_functions[OCELOT_FUNC_PER_PIN]; /* Additional functions */ }; =20 +struct ocelot_pincfg_data { + u8 pd_bit; + u8 pu_bit; + u8 drive_bits; + u8 schmitt_bit; +}; + struct ocelot_pinctrl { struct device *dev; struct pinctrl_dev *pctl; @@ -321,10 +321,16 @@ struct ocelot_pinctrl { struct regmap *map; struct regmap *pincfg; struct pinctrl_desc *desc; + const struct ocelot_pincfg_data *pincfg_data; struct ocelot_pmx_func func[FUNC_MAX]; u8 stride; }; =20 +struct ocelot_match_data { + struct pinctrl_desc desc; + struct ocelot_pincfg_data pincfg_data; +}; + #define LUTON_P(p, f0, f1) \ static struct ocelot_pin_caps luton_pin_##p =3D { \ .pin =3D p, \ @@ -1318,6 +1324,7 @@ static int ocelot_hw_get_value(struct ocelot_pinctrl = *info, int ret =3D -EOPNOTSUPP; =20 if (info->pincfg) { + const struct ocelot_pincfg_data *opd =3D info->pincfg_data; u32 regcfg; =20 ret =3D regmap_read(info->pincfg, pin, ®cfg); @@ -1327,15 +1334,15 @@ static int ocelot_hw_get_value(struct ocelot_pinctr= l *info, ret =3D 0; switch (reg) { case PINCONF_BIAS: - *val =3D regcfg & BIAS_BITS; + *val =3D regcfg & (opd->pd_bit | opd->pu_bit); break; =20 case PINCONF_SCHMITT: - *val =3D regcfg & SCHMITT_BIT; + *val =3D regcfg & opd->schmitt_bit; break; =20 case PINCONF_DRIVE_STRENGTH: - *val =3D regcfg & DRIVE_BITS; + *val =3D regcfg & opd->drive_bits; break; =20 default: @@ -1372,23 +1379,27 @@ static int ocelot_hw_set_value(struct ocelot_pinctr= l *info, int ret =3D -EOPNOTSUPP; =20 if (info->pincfg) { + const struct ocelot_pincfg_data *opd =3D info->pincfg_data; =20 ret =3D 0; switch (reg) { case PINCONF_BIAS: - ret =3D ocelot_pincfg_clrsetbits(info, pin, BIAS_BITS, + ret =3D ocelot_pincfg_clrsetbits(info, pin, + opd->pd_bit | opd->pu_bit, val); break; =20 case PINCONF_SCHMITT: - ret =3D ocelot_pincfg_clrsetbits(info, pin, SCHMITT_BIT, + ret =3D ocelot_pincfg_clrsetbits(info, pin, + opd->schmitt_bit, val); break; =20 case PINCONF_DRIVE_STRENGTH: if (val <=3D 3) ret =3D ocelot_pincfg_clrsetbits(info, pin, - DRIVE_BITS, val); + opd->drive_bits, + val); else ret =3D -EINVAL; break; @@ -1418,17 +1429,20 @@ static int ocelot_pinconf_get(struct pinctrl_dev *p= ctldev, if (param =3D=3D PIN_CONFIG_BIAS_DISABLE) val =3D (val =3D=3D 0); else if (param =3D=3D PIN_CONFIG_BIAS_PULL_DOWN) - val =3D (val & BIAS_PD_BIT ? true : false); + val =3D !!(val & info->pincfg_data->pd_bit); else /* PIN_CONFIG_BIAS_PULL_UP */ - val =3D (val & BIAS_PU_BIT ? true : false); + val =3D !!(val & info->pincfg_data->pu_bit); break; =20 case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + if (!info->pincfg_data->schmitt_bit) + return -EOPNOTSUPP; + err =3D ocelot_hw_get_value(info, pin, PINCONF_SCHMITT, &val); if (err) return err; =20 - val =3D (val & SCHMITT_BIT ? true : false); + val =3D !!(val & info->pincfg_data->schmitt_bit); break; =20 case PIN_CONFIG_DRIVE_STRENGTH: @@ -1472,6 +1486,7 @@ static int ocelot_pinconf_set(struct pinctrl_dev *pct= ldev, unsigned int pin, unsigned long *configs, unsigned int num_configs) { struct ocelot_pinctrl *info =3D pinctrl_dev_get_drvdata(pctldev); + const struct ocelot_pincfg_data *opd =3D info->pincfg_data; u32 param, arg, p; int cfg, err =3D 0; =20 @@ -1484,8 +1499,8 @@ static int ocelot_pinconf_set(struct pinctrl_dev *pct= ldev, unsigned int pin, case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_DOWN: arg =3D (param =3D=3D PIN_CONFIG_BIAS_DISABLE) ? 0 : - (param =3D=3D PIN_CONFIG_BIAS_PULL_UP) ? BIAS_PU_BIT : - BIAS_PD_BIT; + (param =3D=3D PIN_CONFIG_BIAS_PULL_UP) ? + opd->pu_bit : opd->pd_bit; =20 err =3D ocelot_hw_set_value(info, pin, PINCONF_BIAS, arg); if (err) @@ -1494,7 +1509,10 @@ static int ocelot_pinconf_set(struct pinctrl_dev *pc= tldev, unsigned int pin, break; =20 case PIN_CONFIG_INPUT_SCHMITT_ENABLE: - arg =3D arg ? SCHMITT_BIT : 0; + if (!opd->schmitt_bit) + return -EOPNOTSUPP; + + arg =3D arg ? opd->schmitt_bit : 0; err =3D ocelot_hw_set_value(info, pin, PINCONF_SCHMITT, arg); if (err) @@ -1555,69 +1573,94 @@ static const struct pinctrl_ops ocelot_pctl_ops =3D= { .dt_free_map =3D pinconf_generic_dt_free_map, }; =20 -static struct pinctrl_desc luton_desc =3D { - .name =3D "luton-pinctrl", - .pins =3D luton_pins, - .npins =3D ARRAY_SIZE(luton_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &ocelot_pmx_ops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data luton_desc =3D { + .desc =3D { + .name =3D "luton-pinctrl", + .pins =3D luton_pins, + .npins =3D ARRAY_SIZE(luton_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &ocelot_pmx_ops, + .owner =3D THIS_MODULE, + }, }; =20 -static struct pinctrl_desc serval_desc =3D { - .name =3D "serval-pinctrl", - .pins =3D serval_pins, - .npins =3D ARRAY_SIZE(serval_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &ocelot_pmx_ops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data serval_desc =3D { + .desc =3D { + .name =3D "serval-pinctrl", + .pins =3D serval_pins, + .npins =3D ARRAY_SIZE(serval_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &ocelot_pmx_ops, + .owner =3D THIS_MODULE, + }, }; =20 -static struct pinctrl_desc ocelot_desc =3D { - .name =3D "ocelot-pinctrl", - .pins =3D ocelot_pins, - .npins =3D ARRAY_SIZE(ocelot_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &ocelot_pmx_ops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data ocelot_desc =3D { + .desc =3D { + .name =3D "ocelot-pinctrl", + .pins =3D ocelot_pins, + .npins =3D ARRAY_SIZE(ocelot_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &ocelot_pmx_ops, + .owner =3D THIS_MODULE, + }, }; =20 -static struct pinctrl_desc jaguar2_desc =3D { - .name =3D "jaguar2-pinctrl", - .pins =3D jaguar2_pins, - .npins =3D ARRAY_SIZE(jaguar2_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &ocelot_pmx_ops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data jaguar2_desc =3D { + .desc =3D { + .name =3D "jaguar2-pinctrl", + .pins =3D jaguar2_pins, + .npins =3D ARRAY_SIZE(jaguar2_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &ocelot_pmx_ops, + .owner =3D THIS_MODULE, + }, }; =20 -static struct pinctrl_desc servalt_desc =3D { - .name =3D "servalt-pinctrl", - .pins =3D servalt_pins, - .npins =3D ARRAY_SIZE(servalt_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &ocelot_pmx_ops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data servalt_desc =3D { + .desc =3D { + .name =3D "servalt-pinctrl", + .pins =3D servalt_pins, + .npins =3D ARRAY_SIZE(servalt_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &ocelot_pmx_ops, + .owner =3D THIS_MODULE, + }, }; =20 -static struct pinctrl_desc sparx5_desc =3D { - .name =3D "sparx5-pinctrl", - .pins =3D sparx5_pins, - .npins =3D ARRAY_SIZE(sparx5_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &ocelot_pmx_ops, - .confops =3D &ocelot_confops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data sparx5_desc =3D { + .desc =3D { + .name =3D "sparx5-pinctrl", + .pins =3D sparx5_pins, + .npins =3D ARRAY_SIZE(sparx5_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &ocelot_pmx_ops, + .confops =3D &ocelot_confops, + .owner =3D THIS_MODULE, + }, + .pincfg_data =3D { + .pd_bit =3D BIT(4), + .pu_bit =3D BIT(3), + .drive_bits =3D GENMASK(1, 0), + .schmitt_bit =3D BIT(2), + }, }; =20 -static struct pinctrl_desc lan966x_desc =3D { - .name =3D "lan966x-pinctrl", - .pins =3D lan966x_pins, - .npins =3D ARRAY_SIZE(lan966x_pins), - .pctlops =3D &ocelot_pctl_ops, - .pmxops =3D &lan966x_pmx_ops, - .confops =3D &ocelot_confops, - .owner =3D THIS_MODULE, +static struct ocelot_match_data lan966x_desc =3D { + .desc =3D { + .name =3D "lan966x-pinctrl", + .pins =3D lan966x_pins, + .npins =3D ARRAY_SIZE(lan966x_pins), + .pctlops =3D &ocelot_pctl_ops, + .pmxops =3D &lan966x_pmx_ops, + .confops =3D &ocelot_confops, + .owner =3D THIS_MODULE, + }, + .pincfg_data =3D { + .pd_bit =3D BIT(3), + .pu_bit =3D BIT(2), + .drive_bits =3D GENMASK(1, 0), + }, }; =20 static int ocelot_create_group_func_map(struct device *dev, @@ -1906,6 +1949,7 @@ static struct regmap *ocelot_pinctrl_create_pincfg(st= ruct platform_device *pdev) =20 static int ocelot_pinctrl_probe(struct platform_device *pdev) { + const struct ocelot_match_data *data; struct device *dev =3D &pdev->dev; struct ocelot_pinctrl *info; struct regmap *pincfg; @@ -1921,7 +1965,16 @@ static int ocelot_pinctrl_probe(struct platform_devi= ce *pdev) if (!info) return -ENOMEM; =20 - info->desc =3D (struct pinctrl_desc *)device_get_match_data(dev); + data =3D device_get_match_data(dev); + if (!data) + return -EINVAL; + + info->desc =3D devm_kmemdup(dev, &data->desc, sizeof(*info->desc), + GFP_KERNEL); + if (!info->desc) + return -ENOMEM; + + info->pincfg_data =3D &data->pincfg_data; =20 base =3D devm_ioremap_resource(dev, platform_get_resource(pdev, IORESOURCE_MEM, 0)); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8DC3C19F2B for ; Wed, 27 Jul 2022 17:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242429AbiG0RfY (ORCPT ); Wed, 27 Jul 2022 13:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241544AbiG0ReJ (ORCPT ); Wed, 27 Jul 2022 13:34:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04D666110D; Wed, 27 Jul 2022 09:49:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DA7D9B821D5; Wed, 27 Jul 2022 16:48:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E3EDC433D7; Wed, 27 Jul 2022 16:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940537; bh=+yI6fT1ua0UpK7wgbiWkBbblYjVdQFfX2LfImLTqYp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G9Wd5J0fHHd17jIwqREFjWKTo7g9XETpSgVIazHzHitLrLdCqhSrE/CORsCWDR+zT One48m9Cu//PSOgda6Ul17HF1/hnd8WAakzQIkQCghQxb2mCav40LheauQzMTjuP9u N6QANSGf6Q76/EiZRNAj6rawH6iQDkNthK9Jbrh0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Foster , Andy Shevchenko , Horatiu Vultur , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 058/158] pinctrl: ocelot: Fix pincfg Date: Wed, 27 Jul 2022 18:12:02 +0200 Message-Id: <20220727161023.844748060@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit ba9c4745fca70bf773b2d5c602dcd85d1a40b07a ] The blamed commit changed to use regmaps instead of __iomem. But it didn't update the register offsets to be at word offset, so it uses byte offset. Another issue with the same commit is that it has a limit of 32 registers which is incorrect. The sparx5 has 64 while lan966x has 77. Fixes: 076d9e71bcf8 ("pinctrl: ocelot: convert pinctrl to regmap") Acked-by: Colin Foster Reviewed-by: Andy Shevchenko Signed-off-by: Horatiu Vultur Link: https://lore.kernel.org/r/20220713193750.4079621-3-horatiu.vultur@mic= rochip.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/pinctrl-ocelot.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-oce= lot.c index 2866365132fd..6ee9f0de8ede 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -1327,7 +1327,9 @@ static int ocelot_hw_get_value(struct ocelot_pinctrl = *info, const struct ocelot_pincfg_data *opd =3D info->pincfg_data; u32 regcfg; =20 - ret =3D regmap_read(info->pincfg, pin, ®cfg); + ret =3D regmap_read(info->pincfg, + pin * regmap_get_reg_stride(info->pincfg), + ®cfg); if (ret) return ret; =20 @@ -1359,14 +1361,18 @@ static int ocelot_pincfg_clrsetbits(struct ocelot_p= inctrl *info, u32 regaddr, u32 val; int ret; =20 - ret =3D regmap_read(info->pincfg, regaddr, &val); + ret =3D regmap_read(info->pincfg, + regaddr * regmap_get_reg_stride(info->pincfg), + &val); if (ret) return ret; =20 val &=3D ~clrbits; val |=3D setbits; =20 - ret =3D regmap_write(info->pincfg, regaddr, val); + ret =3D regmap_write(info->pincfg, + regaddr * regmap_get_reg_stride(info->pincfg), + val); =20 return ret; } @@ -1926,7 +1932,8 @@ static const struct of_device_id ocelot_pinctrl_of_ma= tch[] =3D { {}, }; =20 -static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device = *pdev) +static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device = *pdev, + const struct ocelot_pinctrl *info) { void __iomem *base; =20 @@ -1934,7 +1941,7 @@ static struct regmap *ocelot_pinctrl_create_pincfg(st= ruct platform_device *pdev) .reg_bits =3D 32, .val_bits =3D 32, .reg_stride =3D 4, - .max_register =3D 32, + .max_register =3D info->desc->npins * 4, .name =3D "pincfg", }; =20 @@ -1995,7 +2002,7 @@ static int ocelot_pinctrl_probe(struct platform_devic= e *pdev) =20 /* Pinconf registers */ if (info->desc->confops) { - pincfg =3D ocelot_pinctrl_create_pincfg(pdev); + pincfg =3D ocelot_pinctrl_create_pincfg(pdev, info); if (IS_ERR(pincfg)) dev_dbg(dev, "Failed to create pincfg regmap\n"); else --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE8A2C04A68 for ; Wed, 27 Jul 2022 17:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235810AbiG0RgO (ORCPT ); Wed, 27 Jul 2022 13:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242674AbiG0Reo (ORCPT ); Wed, 27 Jul 2022 13:34:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89CD883217; Wed, 27 Jul 2022 09:49:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5E1C5B8200D; Wed, 27 Jul 2022 16:49:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC666C4314B; Wed, 27 Jul 2022 16:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940543; bh=1FNzOP63Yh7F+2bl4b9dtHLmiHFN1ZIPU25hzTFYPpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1zX7W8fPbeH71zG9l0ZQzPXa096Q/RAi9uQJgMqVElAWgOemSaftRYexBL+B7UeT/ Z0PwfA6CXabRGvGOD1TRMTC7JMtTYvAb6K4OrtkWyb/2b6AdgkmuhdNi4lJf1Fdk8u w9L3RruaZ9bhFbwC7GP0CDRjymSvbi3e1Fpc69mk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cedric Wassenaar , Junxiao Chang , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 059/158] net: stmmac: fix dma queue left shift overflow issue Date: Wed, 27 Jul 2022 18:12:03 +0200 Message-Id: <20220727161023.874713129@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Junxiao Chang [ Upstream commit 613b065ca32e90209024ec4a6bb5ca887ee70980 ] When queue number is > 4, left shift overflows due to 32 bits integer variable. Mask calculation is wrong for MTL_RXQ_DMA_MAP1. If CONFIG_UBSAN is enabled, kernel dumps below warning: [ 10.363842] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ 10.363882] UBSAN: shift-out-of-bounds in /build/linux-intel-iotg-5.15-8= e6Tf4/ linux-intel-iotg-5.15-5.15.0/drivers/net/ethernet/stmicro/stmmac/dwmac4_cor= e.c:224:12 [ 10.363929] shift exponent 40 is too large for 32-bit type 'unsigned int' [ 10.363953] CPU: 1 PID: 599 Comm: NetworkManager Not tainted 5.15.0-1003= -intel-iotg [ 10.363956] Hardware name: ADLINK Technology Inc. LEC-EL/LEC-EL, BIOS 0.= 15.11 12/22/2021 [ 10.363958] Call Trace: [ 10.363960] [ 10.363963] dump_stack_lvl+0x4a/0x5f [ 10.363971] dump_stack+0x10/0x12 [ 10.363974] ubsan_epilogue+0x9/0x45 [ 10.363976] __ubsan_handle_shift_out_of_bounds.cold+0x61/0x10e [ 10.363979] ? wake_up_klogd+0x4a/0x50 [ 10.363983] ? vprintk_emit+0x8f/0x240 [ 10.363986] dwmac4_map_mtl_dma.cold+0x42/0x91 [stmmac] [ 10.364001] stmmac_mtl_configuration+0x1ce/0x7a0 [stmmac] [ 10.364009] ? dwmac410_dma_init_channel+0x70/0x70 [stmmac] [ 10.364020] stmmac_hw_setup.cold+0xf/0xb14 [stmmac] [ 10.364030] ? page_pool_alloc_pages+0x4d/0x70 [ 10.364034] ? stmmac_clear_tx_descriptors+0x6e/0xe0 [stmmac] [ 10.364042] stmmac_open+0x39e/0x920 [stmmac] [ 10.364050] __dev_open+0xf0/0x1a0 [ 10.364054] __dev_change_flags+0x188/0x1f0 [ 10.364057] dev_change_flags+0x26/0x60 [ 10.364059] do_setlink+0x908/0xc40 [ 10.364062] ? do_setlink+0xb10/0xc40 [ 10.364064] ? __nla_validate_parse+0x4c/0x1a0 [ 10.364068] __rtnl_newlink+0x597/0xa10 [ 10.364072] ? __nla_reserve+0x41/0x50 [ 10.364074] ? __kmalloc_node_track_caller+0x1d0/0x4d0 [ 10.364079] ? pskb_expand_head+0x75/0x310 [ 10.364082] ? nla_reserve_64bit+0x21/0x40 [ 10.364086] ? skb_free_head+0x65/0x80 [ 10.364089] ? security_sock_rcv_skb+0x2c/0x50 [ 10.364094] ? __cond_resched+0x19/0x30 [ 10.364097] ? kmem_cache_alloc_trace+0x15a/0x420 [ 10.364100] rtnl_newlink+0x49/0x70 This change fixes MTL_RXQ_DMA_MAP1 mask issue and channel/queue mapping warning. Fixes: d43042f4da3e ("net: stmmac: mapping mtl rx to dma channel") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D216195 Reported-by: Cedric Wassenaar Signed-off-by: Junxiao Chang Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac4_core.c index fd41db65fe1d..af3339041134 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -219,6 +219,9 @@ static void dwmac4_map_mtl_dma(struct mac_device_info *= hw, u32 queue, u32 chan) if (queue =3D=3D 0 || queue =3D=3D 4) { value &=3D ~MTL_RXQ_DMA_Q04MDMACH_MASK; value |=3D MTL_RXQ_DMA_Q04MDMACH(chan); + } else if (queue > 4) { + value &=3D ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4); + value |=3D MTL_RXQ_DMA_QXMDMACH(chan, queue - 4); } else { value &=3D ~MTL_RXQ_DMA_QXMDMACH_MASK(queue); value |=3D MTL_RXQ_DMA_QXMDMACH(chan, queue); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0C3CC04A68 for ; Wed, 27 Jul 2022 17:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbiG0RgK (ORCPT ); Wed, 27 Jul 2022 13:36:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242659AbiG0Rem (ORCPT ); Wed, 27 Jul 2022 13:34:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89FF18321C; Wed, 27 Jul 2022 09:49:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 64A0B61617; Wed, 27 Jul 2022 16:49:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70629C433C1; Wed, 27 Jul 2022 16:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940545; bh=2Cf6JN9PgoSTXEWTDC83QIbqqiH+x4fYYN/Cia/67fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EphxrXZt3g8po60xRT2+oP5cauYbFktTvmx2JerJorkMXboJ5hawSUjFlIDR4ZeJs 43/1T0/skfQPTX75vaC06BXh5kb9ZwWd0lJWF+6Xszv7kcyptH4eeo+jj28jvSE4km 8/E+kq723BoGhKolrYGx7/f+kBNklxjsQgIjNXkQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Tariq Toukan , Jakub Kicinski , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 060/158] net/tls: Fix race in TLS device down flow Date: Wed, 27 Jul 2022 18:12:04 +0200 Message-Id: <20220727161023.919938791@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tariq Toukan [ Upstream commit f08d8c1bb97c48f24a82afaa2fd8c140f8d3da8b ] Socket destruction flow and tls_device_down function sync against each other using tls_device_lock and the context refcount, to guarantee the device resources are freed via tls_dev_del() by the end of tls_device_down. In the following unfortunate flow, this won't happen: - refcount is decreased to zero in tls_device_sk_destruct. - tls_device_down starts, skips the context as refcount is zero, going all the way until it flushes the gc work, and returns without freeing the device resources. - only then, tls_device_queue_ctx_destruction is called, queues the gc work and frees the context's device resources. Solve it by decreasing the refcount in the socket's destruction flow under the tls_device_lock, for perfect synchronization. This does not slow down the common likely destructor flow, in which both the refcount is decreased and the spinlock is acquired, anyway. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Reviewed-by: Maxim Mikityanskiy Signed-off-by: Tariq Toukan Reviewed-by: Jakub Kicinski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/tls/tls_device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 3a61bb594544..9c3933781ad4 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -97,13 +97,16 @@ static void tls_device_queue_ctx_destruction(struct tls= _context *ctx) unsigned long flags; =20 spin_lock_irqsave(&tls_device_lock, flags); + if (unlikely(!refcount_dec_and_test(&ctx->refcount))) + goto unlock; + list_move_tail(&ctx->list, &tls_device_gc_list); =20 /* schedule_work inside the spinlock * to make sure tls_device_down waits for that work. */ schedule_work(&tls_device_gc_work); - +unlock: spin_unlock_irqrestore(&tls_device_lock, flags); } =20 @@ -194,8 +197,7 @@ void tls_device_sk_destruct(struct sock *sk) clean_acked_data_disable(inet_csk(sk)); } =20 - if (refcount_dec_and_test(&tls_ctx->refcount)) - tls_device_queue_ctx_destruction(tls_ctx); + tls_device_queue_ctx_destruction(tls_ctx); } EXPORT_SYMBOL_GPL(tls_device_sk_destruct); =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0CFCC04A68 for ; Wed, 27 Jul 2022 17:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242457AbiG0Rfr (ORCPT ); Wed, 27 Jul 2022 13:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242506AbiG0ReR (ORCPT ); Wed, 27 Jul 2022 13:34:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF28083205; Wed, 27 Jul 2022 09:49:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1BA6C616FA; Wed, 27 Jul 2022 16:49:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26A67C433D6; Wed, 27 Jul 2022 16:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940548; bh=w5sWh8F8n0FEZ5hPRhjKnS9zIrHd3MtT9EMOxialx48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vya4sr97ExJgtObazu/zkqH4UnikZnwe2RnmQW2baIqWWEc7SE3AwF47tETNYubhV TMDoTZHUfTeS1bZYpeVkcqiJHn93KnJdy7frUKIbvZi5QUegpdgm+9pApDrT7/LYLI CViI8y2T8TSEq6TKAx9We3JsRL/nihfZNJWvYIu4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maksym Glubokiy , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 061/158] net: prestera: acl: use proper mask for port selector Date: Wed, 27 Jul 2022 18:12:05 +0200 Message-Id: <20220727161023.950555886@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Maksym Glubokiy [ Upstream commit 1e20904e417738066b26490de2daf7ef3ed34483 ] Adjusted as per packet processor documentation. This allows to properly match 'indev' for clsact rules. Fixes: 47327e198d42 ("net: prestera: acl: migrate to new vTCAM api") Signed-off-by: Maksym Glubokiy Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/marvell/prestera/prestera_flower.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/driv= ers/net/ethernet/marvell/prestera/prestera_flower.c index 921959a980ee..d8cfa4a7de0f 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c @@ -139,12 +139,12 @@ static int prestera_flower_parse_meta(struct prestera= _acl_rule *rule, } port =3D netdev_priv(ingress_dev); =20 - mask =3D htons(0x1FFF); - key =3D htons(port->hw_id); + mask =3D htons(0x1FFF << 3); + key =3D htons(port->hw_id << 3); rule_match_set(r_match->key, SYS_PORT, key); rule_match_set(r_match->mask, SYS_PORT, mask); =20 - mask =3D htons(0x1FF); + mask =3D htons(0x3FF); key =3D htons(port->dev_id); rule_match_set(r_match->key, SYS_DEV, key); rule_match_set(r_match->mask, SYS_DEV, mask); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E81D6C04A68 for ; Wed, 27 Jul 2022 17:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242691AbiG0RkK (ORCPT ); Wed, 27 Jul 2022 13:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242790AbiG0RjP (ORCPT ); Wed, 27 Jul 2022 13:39:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F34787F62; Wed, 27 Jul 2022 09:51:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4ED6E61617; Wed, 27 Jul 2022 16:51:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E6C1C433D6; Wed, 27 Jul 2022 16:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940662; bh=zLQxbYrkLcDFl6J6e+B7wZO25bHdB5ORWRiwTpF/Ft4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzYKakc4osLDyam08H0Knd3npYFJ6JE2uUHFW7Kb5i0YD9NBWbGxw5/g45Zu6mGdc +bREJBD56xTn4AtT80vYX+BAGT00F+lXCmKFJKBxg7Q0yh7+IUmizkWRBg6wmfhaGL 7HFJTtsNuhF45uYTkgIHml1+ZOqlDo6k9lIawGQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 062/158] igmp: Fix data-races around sysctl_igmp_llm_reports. Date: Wed, 27 Jul 2022 18:12:06 +0200 Message-Id: <20220727161023.996054917@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit f6da2267e71106474fbc0943dc24928b9cb79119 ] While reading sysctl_igmp_llm_reports, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. This test can be packed into a helper, so such changes will be in the follow-up series after net is merged into net-next. if (ipv4_is_local_multicast(pmc->multiaddr) && !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) Fixes: df2cf4a78e48 ("IGMP: Inhibit reports for local multicast groups") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/igmp.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 1d9e6d5e9a76..0bde3774505f 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -467,7 +467,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, st= ruct ip_mc_list *pmc, =20 if (pmc->multiaddr =3D=3D IGMP_ALL_HOSTS) return skb; - if (ipv4_is_local_multicast(pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm= _reports) + if (ipv4_is_local_multicast(pmc->multiaddr) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return skb; =20 mtu =3D READ_ONCE(dev->mtu); @@ -593,7 +594,7 @@ static int igmpv3_send_report(struct in_device *in_dev,= struct ip_mc_list *pmc) if (pmc->multiaddr =3D=3D IGMP_ALL_HOSTS) continue; if (ipv4_is_local_multicast(pmc->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) continue; spin_lock_bh(&pmc->lock); if (pmc->sfcount[MCAST_EXCLUDE]) @@ -736,7 +737,8 @@ static int igmp_send_report(struct in_device *in_dev, s= truct ip_mc_list *pmc, if (type =3D=3D IGMPV3_HOST_MEMBERSHIP_REPORT) return igmpv3_send_report(in_dev, pmc); =20 - if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(group) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return 0; =20 if (type =3D=3D IGMP_HOST_LEAVE_MESSAGE) @@ -920,7 +922,8 @@ static bool igmp_heard_report(struct in_device *in_dev,= __be32 group) =20 if (group =3D=3D IGMP_ALL_HOSTS) return false; - if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports) + if (ipv4_is_local_multicast(group) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return false; =20 rcu_read_lock(); @@ -1045,7 +1048,7 @@ static bool igmp_heard_query(struct in_device *in_dev= , struct sk_buff *skb, if (im->multiaddr =3D=3D IGMP_ALL_HOSTS) continue; if (ipv4_is_local_multicast(im->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) continue; spin_lock_bh(&im->lock); if (im->tm_running) @@ -1296,7 +1299,8 @@ static void __igmp_group_dropped(struct ip_mc_list *i= m, gfp_t gfp) #ifdef CONFIG_IP_MULTICAST if (im->multiaddr =3D=3D IGMP_ALL_HOSTS) return; - if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_= reports) + if (ipv4_is_local_multicast(im->multiaddr) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return; =20 reporter =3D im->reporter; @@ -1338,7 +1342,8 @@ static void igmp_group_added(struct ip_mc_list *im) #ifdef CONFIG_IP_MULTICAST if (im->multiaddr =3D=3D IGMP_ALL_HOSTS) return; - if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_= reports) + if (ipv4_is_local_multicast(im->multiaddr) && + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) return; =20 if (in_dev->dead) @@ -1642,7 +1647,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_= dev) if (im->multiaddr =3D=3D IGMP_ALL_HOSTS) continue; if (ipv4_is_local_multicast(im->multiaddr) && - !net->ipv4.sysctl_igmp_llm_reports) + !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports)) continue; =20 /* a failover is happening and switches --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24214C04A68 for ; Wed, 27 Jul 2022 17:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242555AbiG0Rge (ORCPT ); Wed, 27 Jul 2022 13:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242719AbiG0Rev (ORCPT ); Wed, 27 Jul 2022 13:34:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FFA883F01; Wed, 27 Jul 2022 09:49:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7CB2F616FA; Wed, 27 Jul 2022 16:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A53FC433D6; Wed, 27 Jul 2022 16:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940570; bh=0sF3XmBinlmpRn9b2M9/yyQF7oPkyU+RtIReOy94uSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AeJ3oEGVqBL5okmmt7eRcVsrtSQCnxVrd6F2V1l7mbw/IVKLKiG6njQnpsNK/9Ywn XITAHQ0gHvN7VV/G6/TmFTSpZ8L9tNuffPUWDTZuVP3b5tUf35Gl4L30u5uqgz8L2+ JmS2VKf/5OoiAsBfx2dpt28acojunmWALWFO+LA8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 063/158] igmp: Fix a data-race around sysctl_igmp_max_memberships. Date: Wed, 27 Jul 2022 18:12:07 +0200 Message-Id: <20220727161024.030052380@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 6305d821e3b9b5379d348528e5b5faf316383bc2 ] While reading sysctl_igmp_max_memberships, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/igmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 0bde3774505f..d07d290bf0b9 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -2197,7 +2197,7 @@ static int __ip_mc_join_group(struct sock *sk, struct= ip_mreqn *imr, count++; } err =3D -ENOBUFS; - if (count >=3D net->ipv4.sysctl_igmp_max_memberships) + if (count >=3D READ_ONCE(net->ipv4.sysctl_igmp_max_memberships)) goto done; iml =3D sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL); if (!iml) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A6E4C04A68 for ; Wed, 27 Jul 2022 17:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242582AbiG0Rho (ORCPT ); Wed, 27 Jul 2022 13:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242349AbiG0RhT (ORCPT ); Wed, 27 Jul 2022 13:37:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F939643C; Wed, 27 Jul 2022 09:50:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A387061617; Wed, 27 Jul 2022 16:50:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF1E9C433D6; Wed, 27 Jul 2022 16:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940601; bh=WdxCw2olUIbPbEhWpLrHE/nPCFE4jkTx5PM6zSS/rEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oyyc0rPsb4Z5PO1vFqtmx6wbhb5ZG1bXNmEPcItDduz7LmV+ool4y+kPfw9KMAq9y 3ZOXJTeYTf4eAl8iWKbrCA3iFeMTIHJzed0wh5i+0sCk59R5OGVO4UlUXCp4LARchC MqRlcLdpkHe1yxCdWjVMlK0pF+zRE2cKmcMiPW3k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 064/158] igmp: Fix data-races around sysctl_igmp_max_msf. Date: Wed, 27 Jul 2022 18:12:08 +0200 Message-Id: <20220727161024.071332877@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 6ae0f2e553737b8cce49a1372573c81130ffa80e ] While reading sysctl_igmp_max_msf, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/igmp.c | 2 +- net/ipv4/ip_sockglue.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index d07d290bf0b9..655d2ab946e0 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -2384,7 +2384,7 @@ int ip_mc_source(int add, int omode, struct sock *sk,= struct } /* else, add a new source to the filter */ =20 - if (psl && psl->sl_count >=3D net->ipv4.sysctl_igmp_max_msf) { + if (psl && psl->sl_count >=3D READ_ONCE(net->ipv4.sysctl_igmp_max_msf)) { err =3D -ENOBUFS; goto done; } diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index d497d525dea3..a8a323ecbb54 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -782,7 +782,7 @@ static int ip_set_mcast_msfilter(struct sock *sk, sockp= tr_t optval, int optlen) /* numsrc >=3D (4G-140)/128 overflow in 32 bits */ err =3D -ENOBUFS; if (gsf->gf_numsrc >=3D 0x1ffffff || - gsf->gf_numsrc > sock_net(sk)->ipv4.sysctl_igmp_max_msf) + gsf->gf_numsrc > READ_ONCE(sock_net(sk)->ipv4.sysctl_igmp_max_msf)) goto out_free_gsf; =20 err =3D -EINVAL; @@ -832,7 +832,7 @@ static int compat_ip_set_mcast_msfilter(struct sock *sk= , sockptr_t optval, =20 /* numsrc >=3D (4G-140)/128 overflow in 32 bits */ err =3D -ENOBUFS; - if (n > sock_net(sk)->ipv4.sysctl_igmp_max_msf) + if (n > READ_ONCE(sock_net(sk)->ipv4.sysctl_igmp_max_msf)) goto out_free_gsf; err =3D set_mcast_msfilter(sk, gf32->gf_interface, n, gf32->gf_fmode, &gf32->gf_group, gf32->gf_slist_flex); @@ -1244,7 +1244,7 @@ static int do_ip_setsockopt(struct sock *sk, int leve= l, int optname, } /* numsrc >=3D (1G-4) overflow in 32 bits */ if (msf->imsf_numsrc >=3D 0x3ffffffcU || - msf->imsf_numsrc > net->ipv4.sysctl_igmp_max_msf) { + msf->imsf_numsrc > READ_ONCE(net->ipv4.sysctl_igmp_max_msf)) { kfree(msf); err =3D -ENOBUFS; break; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49DC7C04A68 for ; Wed, 27 Jul 2022 17:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242670AbiG0RiT (ORCPT ); Wed, 27 Jul 2022 13:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242616AbiG0Rhw (ORCPT ); Wed, 27 Jul 2022 13:37:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219AD86C04; Wed, 27 Jul 2022 09:50:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D71761715; Wed, 27 Jul 2022 16:50:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1935FC433D6; Wed, 27 Jul 2022 16:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940631; bh=DRQYRlbI2tk8VanfqfLKF4jeCb/5wKzDplKQLZQu1LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYDiaK/8EUzC3wtgVa5vZ2Y2H8gvyE87GQqc4wDyuxDXl0kEKfh+VTHO5fzrup1fm 8rzkVrFQM97R0hA1T+FFq6Men79JYBWG1hcT2kF3FxP931iCScG6ZuyvMfutXnIqrP pBagvP4gs8U6UCnehE9p/8ithnrl4nKMRmN7XSsA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 065/158] igmp: Fix data-races around sysctl_igmp_qrv. Date: Wed, 27 Jul 2022 18:12:09 +0200 Message-Id: <20220727161024.110473558@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 8ebcc62c738f68688ee7c6fec2efe5bc6d3d7e60 ] While reading sysctl_igmp_qrv, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. This test can be packed into a helper, so such changes will be in the follow-up series after net is merged into net-next. qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); Fixes: a9fe8e29945d ("ipv4: implement igmp_qrv sysctl to tune igmp robustne= ss variable") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 4 ++-- net/ipv4/igmp.c | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 14fe03dbd9b1..6c64953db487 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -563,7 +563,7 @@ static struct sk_buff *amt_build_igmp_gq(struct amt_dev= *amt) ihv3->nsrcs =3D 0; ihv3->resv =3D 0; ihv3->suppress =3D false; - ihv3->qrv =3D amt->net->ipv4.sysctl_igmp_qrv; + ihv3->qrv =3D READ_ONCE(amt->net->ipv4.sysctl_igmp_qrv); ihv3->csum =3D 0; csum =3D &ihv3->csum; csum_start =3D (void *)ihv3; @@ -3095,7 +3095,7 @@ static int amt_newlink(struct net *net, struct net_de= vice *dev, goto err; } if (amt->mode =3D=3D AMT_MODE_RELAY) { - amt->qrv =3D amt->net->ipv4.sysctl_igmp_qrv; + amt->qrv =3D READ_ONCE(amt->net->ipv4.sysctl_igmp_qrv); amt->qri =3D 10; dev->needed_headroom =3D amt->stream_dev->needed_headroom + AMT_RELAY_HLEN; diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 655d2ab946e0..0a0010f89627 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -827,7 +827,7 @@ static void igmp_ifc_event(struct in_device *in_dev) struct net *net =3D dev_net(in_dev->dev); if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) return; - WRITE_ONCE(in_dev->mr_ifc_count, in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_= qrv); + WRITE_ONCE(in_dev->mr_ifc_count, in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sy= sctl_igmp_qrv)); igmp_ifc_start_timer(in_dev, 1); } =20 @@ -1009,7 +1009,7 @@ static bool igmp_heard_query(struct in_device *in_dev= , struct sk_buff *skb, * received value was zero, use the default or statically * configured value. */ - in_dev->mr_qrv =3D ih3->qrv ?: net->ipv4.sysctl_igmp_qrv; + in_dev->mr_qrv =3D ih3->qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); in_dev->mr_qi =3D IGMPV3_QQIC(ih3->qqic)*HZ ?: IGMP_QUERY_INTERVAL; =20 /* RFC3376, 8.3. Query Response Interval: @@ -1189,7 +1189,7 @@ static void igmpv3_add_delrec(struct in_device *in_de= v, struct ip_mc_list *im, pmc->interface =3D im->interface; in_dev_hold(in_dev); pmc->multiaddr =3D im->multiaddr; - pmc->crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + pmc->crcount =3D in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); pmc->sfmode =3D im->sfmode; if (pmc->sfmode =3D=3D MCAST_INCLUDE) { struct ip_sf_list *psf; @@ -1240,9 +1240,11 @@ static void igmpv3_del_delrec(struct in_device *in_d= ev, struct ip_mc_list *im) swap(im->tomb, pmc->tomb); swap(im->sources, pmc->sources); for (psf =3D im->sources; psf; psf =3D psf->sf_next) - psf->sf_crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + psf->sf_crcount =3D in_dev->mr_qrv ?: + READ_ONCE(net->ipv4.sysctl_igmp_qrv); } else { - im->crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + im->crcount =3D in_dev->mr_qrv ?: + READ_ONCE(net->ipv4.sysctl_igmp_qrv); } in_dev_put(pmc->interface); kfree_pmc(pmc); @@ -1349,7 +1351,7 @@ static void igmp_group_added(struct ip_mc_list *im) if (in_dev->dead) return; =20 - im->unsolicit_count =3D net->ipv4.sysctl_igmp_qrv; + im->unsolicit_count =3D READ_ONCE(net->ipv4.sysctl_igmp_qrv); if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) { spin_lock_bh(&im->lock); igmp_start_timer(im, IGMP_INITIAL_REPORT_DELAY); @@ -1363,7 +1365,7 @@ static void igmp_group_added(struct ip_mc_list *im) * IN() to IN(A). */ if (im->sfmode =3D=3D MCAST_EXCLUDE) - im->crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + im->crcount =3D in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); =20 igmp_ifc_event(in_dev); #endif @@ -1754,7 +1756,7 @@ static void ip_mc_reset(struct in_device *in_dev) =20 in_dev->mr_qi =3D IGMP_QUERY_INTERVAL; in_dev->mr_qri =3D IGMP_QUERY_RESPONSE_INTERVAL; - in_dev->mr_qrv =3D net->ipv4.sysctl_igmp_qrv; + in_dev->mr_qrv =3D READ_ONCE(net->ipv4.sysctl_igmp_qrv); } #else static void ip_mc_reset(struct in_device *in_dev) @@ -1888,7 +1890,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int= sfmode, #ifdef CONFIG_IP_MULTICAST if (psf->sf_oldin && !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) { - psf->sf_crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + psf->sf_crcount =3D in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_q= rv); psf->sf_next =3D pmc->tomb; pmc->tomb =3D psf; rv =3D 1; @@ -1952,7 +1954,7 @@ static int ip_mc_del_src(struct in_device *in_dev, __= be32 *pmca, int sfmode, /* filter mode change */ pmc->sfmode =3D MCAST_INCLUDE; #ifdef CONFIG_IP_MULTICAST - pmc->crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + pmc->crcount =3D in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount); for (psf =3D pmc->sources; psf; psf =3D psf->sf_next) psf->sf_crcount =3D 0; @@ -2131,7 +2133,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __= be32 *pmca, int sfmode, #ifdef CONFIG_IP_MULTICAST /* else no filters; keep old mode for reports */ =20 - pmc->crcount =3D in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; + pmc->crcount =3D in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv); WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount); for (psf =3D pmc->sources; psf; psf =3D psf->sf_next) psf->sf_crcount =3D 0; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 055A3C04A68 for ; Wed, 27 Jul 2022 17:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242463AbiG0Rju (ORCPT ); Wed, 27 Jul 2022 13:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242514AbiG0Riu (ORCPT ); Wed, 27 Jul 2022 13:38:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC40787C19; Wed, 27 Jul 2022 09:50:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A4384B8200D; Wed, 27 Jul 2022 16:50:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8789C433D7; Wed, 27 Jul 2022 16:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940646; bh=fbUcAAptZ0SJDagFvqJi+fW4S7EGcpe/mG1Qv+t9/pM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJFKFDrXnMmiXZ7vAXrEef4284pIcXk0c6Sof6xMMydIui7HSvSNKMniaNEBRxyAU w9TIL7zEOLozPpIwrCTDtwc3IQcXMDJPgm7CBGADIOwSu5goUHo6NGF3IE1V6vDqX5 o+ahkHfTVwHIgbYPx81pC73RT8XZiSVTq7bXPFMs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 066/158] tcp: Fix data-races around keepalive sysctl knobs. Date: Wed, 27 Jul 2022 18:12:10 +0200 Message-Id: <20220727161024.152534620@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit f2f316e287e6c2e3a1c5bab8d9b77ee03daa0463 ] While reading sysctl_tcp_keepalive_(time|probes|intvl), they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/tcp.h | 9 ++++++--- net/smc/smc_llc.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 113ce516ce42..e6f9a02fa465 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1511,21 +1511,24 @@ static inline int keepalive_intvl_when(const struct= tcp_sock *tp) { struct net *net =3D sock_net((struct sock *)tp); =20 - return tp->keepalive_intvl ? : net->ipv4.sysctl_tcp_keepalive_intvl; + return tp->keepalive_intvl ? : + READ_ONCE(net->ipv4.sysctl_tcp_keepalive_intvl); } =20 static inline int keepalive_time_when(const struct tcp_sock *tp) { struct net *net =3D sock_net((struct sock *)tp); =20 - return tp->keepalive_time ? : net->ipv4.sysctl_tcp_keepalive_time; + return tp->keepalive_time ? : + READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time); } =20 static inline int keepalive_probes(const struct tcp_sock *tp) { struct net *net =3D sock_net((struct sock *)tp); =20 - return tp->keepalive_probes ? : net->ipv4.sysctl_tcp_keepalive_probes; + return tp->keepalive_probes ? : + READ_ONCE(net->ipv4.sysctl_tcp_keepalive_probes); } =20 static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp) diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c index c4d057b2941d..0bde36b56472 100644 --- a/net/smc/smc_llc.c +++ b/net/smc/smc_llc.c @@ -2122,7 +2122,7 @@ void smc_llc_lgr_init(struct smc_link_group *lgr, str= uct smc_sock *smc) init_waitqueue_head(&lgr->llc_flow_waiter); init_waitqueue_head(&lgr->llc_msg_waiter); mutex_init(&lgr->llc_conf_mutex); - lgr->llc_testlink_time =3D net->ipv4.sysctl_tcp_keepalive_time; + lgr->llc_testlink_time =3D READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time); } =20 /* called after lgr was removed from lgr_list */ --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2913FC04A68 for ; Wed, 27 Jul 2022 17:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242350AbiG0Rjq (ORCPT ); Wed, 27 Jul 2022 13:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242527AbiG0Riv (ORCPT ); Wed, 27 Jul 2022 13:38:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEE9761D59; Wed, 27 Jul 2022 09:50:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4761B61617; Wed, 27 Jul 2022 16:50:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55120C433C1; Wed, 27 Jul 2022 16:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940648; bh=adF74x9d7xXtzr19a8APZ0CrVp/SgZ0sMYxDKxqdacA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0fzoSrSBdza+TFo1J0dD0q8NBRmu0rZehV4NVCo1NeyWOzrCy+om6TjgSOnx2E94 +rEsItTqo8xjxR5lT2odAW58Iw+SjxEbPTfUaxw22HRI3s8uR8ATb6Q9RhDAcTILS3 AgquC9QK4Lhlwvtj2lmQQsd/ILjybVhnFJdF3QE4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 067/158] tcp: Fix data-races around sysctl_tcp_syn(ack)?_retries. Date: Wed, 27 Jul 2022 18:12:11 +0200 Message-Id: <20220727161024.191282043@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 20a3b1c0f603e8c55c3396abd12dfcfb523e4d3c ] While reading sysctl_tcp_syn(ack)?_retries, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/inet_connection_sock.c | 3 ++- net/ipv4/tcp.c | 3 ++- net/ipv4/tcp_timer.c | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_soc= k.c index dfb5a2d7ad85..cdc750ced525 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -829,7 +829,8 @@ static void reqsk_timer_handler(struct timer_list *t) =20 icsk =3D inet_csk(sk_listener); net =3D sock_net(sk_listener); - max_syn_ack_retries =3D icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_s= ynack_retries; + max_syn_ack_retries =3D icsk->icsk_syn_retries ? : + READ_ONCE(net->ipv4.sysctl_tcp_synack_retries); /* Normally all the openreqs are young and become mature * (i.e. converted to established socket) for first timeout. * If synack was not acknowledged for 1 second, it means diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f2fd1779d925..df3bf1a24c39 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3988,7 +3988,8 @@ static int do_tcp_getsockopt(struct sock *sk, int lev= el, val =3D keepalive_probes(tp); break; case TCP_SYNCNT: - val =3D icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries; + val =3D icsk->icsk_syn_retries ? : + READ_ONCE(net->ipv4.sysctl_tcp_syn_retries); break; case TCP_LINGER2: val =3D tp->linger2; diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 4f3b9ab222b6..a234704e8163 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -239,7 +239,8 @@ static int tcp_write_timeout(struct sock *sk) if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { if (icsk->icsk_retransmits) __dst_negative_advice(sk); - retry_until =3D icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retr= ies; + retry_until =3D icsk->icsk_syn_retries ? : + READ_ONCE(net->ipv4.sysctl_tcp_syn_retries); expired =3D icsk->icsk_retransmits >=3D retry_until; } else { if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) { @@ -406,12 +407,15 @@ abort: tcp_write_err(sk); static void tcp_fastopen_synack_timer(struct sock *sk, struct request_sock= *req) { struct inet_connection_sock *icsk =3D inet_csk(sk); - int max_retries =3D icsk->icsk_syn_retries ? : - sock_net(sk)->ipv4.sysctl_tcp_synack_retries + 1; /* add one more ret= ry for fastopen */ struct tcp_sock *tp =3D tcp_sk(sk); + int max_retries; =20 req->rsk_ops->syn_ack_timeout(req); =20 + /* add one more retry for fastopen */ + max_retries =3D icsk->icsk_syn_retries ? : + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_synack_retries) + 1; + if (req->num_timeout >=3D max_retries) { tcp_write_err(sk); return; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FFE7C04A68 for ; Wed, 27 Jul 2022 17:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242503AbiG0Rjx (ORCPT ); Wed, 27 Jul 2022 13:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242687AbiG0RjE (ORCPT ); Wed, 27 Jul 2022 13:39:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8008787C31; Wed, 27 Jul 2022 09:50:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B7233B821C5; Wed, 27 Jul 2022 16:50:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B7D1C433C1; Wed, 27 Jul 2022 16:50:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940651; bh=/RAmyf5LE2vjALLaA6Rn13Cr6GhTMG6PSmKRfiNe2Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZJDcKNI+n4pSYUfQe9ngKa5VrSMOuLdJ/PgGfK2OBqsefdiJrXQfDKluzWIudwMq t1pVaKJr+A5NfNkYsKeeqzxWkyNmUtZ1D6ZnMKR83HZkfoaiYSLk4WF9KzPuM91kIZ c2ygBQZdU01ie4a5rh4FvmtwFuz2Xi08zDU/YSI0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 068/158] tcp: Fix data-races around sysctl_tcp_syncookies. Date: Wed, 27 Jul 2022 18:12:12 +0200 Message-Id: <20220727161024.230653573@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit f2e383b5bb6bbc60a0b94b87b3e49a2b1aefd11e ] While reading sysctl_tcp_syncookies, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/core/filter.c | 4 ++-- net/ipv4/syncookies.c | 3 ++- net/ipv4/tcp_input.c | 20 ++++++++++++-------- net/ipv6/syncookies.c | 3 ++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 6391c1885bca..d0b0c163d3f3 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -7031,7 +7031,7 @@ BPF_CALL_5(bpf_tcp_check_syncookie, struct sock *, sk= , void *, iph, u32, iph_len if (sk->sk_protocol !=3D IPPROTO_TCP || sk->sk_state !=3D TCP_LISTEN) return -EINVAL; =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies)) return -EINVAL; =20 if (!th->ack || th->rst || th->syn) @@ -7106,7 +7106,7 @@ BPF_CALL_5(bpf_tcp_gen_syncookie, struct sock *, sk, = void *, iph, u32, iph_len, if (sk->sk_protocol !=3D IPPROTO_TCP || sk->sk_state !=3D TCP_LISTEN) return -EINVAL; =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies)) return -ENOENT; =20 if (!th->syn || th->ack || th->fin || th->rst) diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index b387c4835155..9b234b42021e 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -340,7 +340,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk= _buff *skb) struct flowi4 fl4; u32 tsoff =3D 0; =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies || !th->ack || th->rst) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) || + !th->ack || th->rst) goto out; =20 if (tcp_synq_no_recent_overflow(sk)) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2d71bcfcc759..f5ca08dfa02d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6780,11 +6780,14 @@ static bool tcp_syn_flood_action(const struct sock = *sk, const char *proto) { struct request_sock_queue *queue =3D &inet_csk(sk)->icsk_accept_queue; const char *msg =3D "Dropping request"; - bool want_cookie =3D false; struct net *net =3D sock_net(sk); + bool want_cookie =3D false; + u8 syncookies; + + syncookies =3D READ_ONCE(net->ipv4.sysctl_tcp_syncookies); =20 #ifdef CONFIG_SYN_COOKIES - if (net->ipv4.sysctl_tcp_syncookies) { + if (syncookies) { msg =3D "Sending cookies"; want_cookie =3D true; __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPREQQFULLDOCOOKIES); @@ -6792,8 +6795,7 @@ static bool tcp_syn_flood_action(const struct sock *s= k, const char *proto) #endif __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP); =20 - if (!queue->synflood_warned && - net->ipv4.sysctl_tcp_syncookies !=3D 2 && + if (!queue->synflood_warned && syncookies !=3D 2 && xchg(&queue->synflood_warned, 1) =3D=3D 0) net_info_ratelimited("%s: Possible SYN flooding on port %d. %s. Check S= NMP counters.\n", proto, sk->sk_num, msg); @@ -6842,7 +6844,7 @@ u16 tcp_get_syncookie_mss(struct request_sock_ops *rs= k_ops, struct tcp_sock *tp =3D tcp_sk(sk); u16 mss; =20 - if (sock_net(sk)->ipv4.sysctl_tcp_syncookies !=3D 2 && + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) !=3D 2 && !inet_csk_reqsk_queue_is_full(sk)) return 0; =20 @@ -6876,13 +6878,15 @@ int tcp_conn_request(struct request_sock_ops *rsk_o= ps, bool want_cookie =3D false; struct dst_entry *dst; struct flowi fl; + u8 syncookies; + + syncookies =3D READ_ONCE(net->ipv4.sysctl_tcp_syncookies); =20 /* TW buckets are converted to open requests without * limitations, they conserve resources and peer is * evidently real one. */ - if ((net->ipv4.sysctl_tcp_syncookies =3D=3D 2 || - inet_csk_reqsk_queue_is_full(sk)) && !isn) { + if ((syncookies =3D=3D 2 || inet_csk_reqsk_queue_is_full(sk)) && !isn) { want_cookie =3D tcp_syn_flood_action(sk, rsk_ops->slab_name); if (!want_cookie) goto drop; @@ -6932,7 +6936,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, =20 if (!want_cookie && !isn) { /* Kill the following clause, if you dislike this way. */ - if (!net->ipv4.sysctl_tcp_syncookies && + if (!syncookies && (net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) < (net->ipv4.sysctl_max_syn_backlog >> 2)) && !tcp_peer_is_proven(req, dst)) { diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 9cc123f000fb..5014aa663452 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c @@ -141,7 +141,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk= _buff *skb) __u8 rcv_wscale; u32 tsoff =3D 0; =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies || !th->ack || th->rst) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) || + !th->ack || th->rst) goto out; =20 if (tcp_synq_no_recent_overflow(sk)) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4912C04A68 for ; Wed, 27 Jul 2022 17:40:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242768AbiG0RkY (ORCPT ); Wed, 27 Jul 2022 13:40:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242882AbiG0RjZ (ORCPT ); Wed, 27 Jul 2022 13:39:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57EBF53D3F; Wed, 27 Jul 2022 09:51:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E13CB616D1; Wed, 27 Jul 2022 16:50:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEB12C433D6; Wed, 27 Jul 2022 16:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940654; bh=4nPOBYRVh1TeKFhmDIyIk4pggIEMowzCSYFN4GeClBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZuYS6jw0ktJo7lH3l9ejJsnzUgco/oi5Dom2DqQlK+lwz7/1gysnAv7RU4T6sHMkT 9qDGyshyhFxYYLx+o4zOCOrt8eVfXAw9EzXUgJ8U+JL0thPUOWB0LIme/24lEvbazD jBP2T/LXbzPpz3T01o1aNWzwILjvNNzGs2da7MIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 069/158] tcp: Fix data-races around sysctl_tcp_migrate_req. Date: Wed, 27 Jul 2022 18:12:13 +0200 Message-Id: <20220727161024.269885983@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 4177f545895b1da08447a80692f30617154efa6e ] While reading sysctl_tcp_migrate_req, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: f9ac779f881c ("net: Introduce net.ipv4.tcp_migrate_req.") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/core/sock_reuseport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c index 3f00a28fe762..5daa1fa54249 100644 --- a/net/core/sock_reuseport.c +++ b/net/core/sock_reuseport.c @@ -387,7 +387,7 @@ void reuseport_stop_listen_sock(struct sock *sk) prog =3D rcu_dereference_protected(reuse->prog, lockdep_is_held(&reuseport_lock)); =20 - if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req || + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req) || (prog && prog->expected_attach_type =3D=3D BPF_SK_REUSEPORT_SELECT_O= R_MIGRATE)) { /* Migration capable, move sk from the listening section * to the closed section. @@ -545,7 +545,7 @@ struct sock *reuseport_migrate_sock(struct sock *sk, hash =3D migrating_sk->sk_hash; prog =3D rcu_dereference(reuse->prog); if (!prog || prog->expected_attach_type !=3D BPF_SK_REUSEPORT_SELECT_OR_M= IGRATE) { - if (sock_net(sk)->ipv4.sysctl_tcp_migrate_req) + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req)) goto select_by_hash; goto failure; } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C92D2C04A68 for ; Wed, 27 Jul 2022 17:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242541AbiG0Rjz (ORCPT ); Wed, 27 Jul 2022 13:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242760AbiG0RjL (ORCPT ); Wed, 27 Jul 2022 13:39:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749F561D52; Wed, 27 Jul 2022 09:51:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 898C2B821AC; Wed, 27 Jul 2022 16:50:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2028C433C1; Wed, 27 Jul 2022 16:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940657; bh=7Mqre8JZG1CKvrxH2SAJXMU9h38rgBhPBRpY+Z7RhWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwXueyz8/YunWAeOe51jLjkplbixCsszATE36C1wJHMnGjpwRBg2f3kK0tAqRUufu doQ2eIX3/CCh3AiyjXJxs8YyHVsZ9oLbc3KC9eCtXL/G2Dj+VeF+QxR4AmhZrBdpYu 0JxXzy32uGwekNVETS0wORwdt2NqgaY4beI12SGA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 070/158] tcp: Fix data-races around sysctl_tcp_reordering. Date: Wed, 27 Jul 2022 18:12:14 +0200 Message-Id: <20220727161024.310392415@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 46778cd16e6a5ad1b2e3a91f6c057c907379418e ] While reading sysctl_tcp_reordering, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_input.c | 10 +++++++--- net/ipv4/tcp_metrics.c | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index df3bf1a24c39..0e0ee9c58257 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -441,7 +441,7 @@ void tcp_init_sock(struct sock *sk) tp->snd_cwnd_clamp =3D ~0; tp->mss_cache =3D TCP_MSS_DEFAULT; =20 - tp->reordering =3D sock_net(sk)->ipv4.sysctl_tcp_reordering; + tp->reordering =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reordering); tcp_assign_congestion_control(sk); =20 tp->tsoffset =3D 0; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index f5ca08dfa02d..391f4a3f10fd 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2139,6 +2139,7 @@ void tcp_enter_loss(struct sock *sk) struct tcp_sock *tp =3D tcp_sk(sk); struct net *net =3D sock_net(sk); bool new_recovery =3D icsk->icsk_ca_state < TCP_CA_Recovery; + u8 reordering; =20 tcp_timeout_mark_lost(sk); =20 @@ -2159,10 +2160,12 @@ void tcp_enter_loss(struct sock *sk) /* Timeout in disordered state after receiving substantial DUPACKs * suggests that the degree of reordering is over-estimated. */ + reordering =3D READ_ONCE(net->ipv4.sysctl_tcp_reordering); if (icsk->icsk_ca_state <=3D TCP_CA_Disorder && - tp->sacked_out >=3D net->ipv4.sysctl_tcp_reordering) + tp->sacked_out >=3D reordering) tp->reordering =3D min_t(unsigned int, tp->reordering, - net->ipv4.sysctl_tcp_reordering); + reordering); + tcp_set_ca_state(sk, TCP_CA_Loss); tp->high_seq =3D tp->snd_nxt; tcp_ecn_queue_cwr(tp); @@ -3464,7 +3467,8 @@ static inline bool tcp_may_raise_cwnd(const struct so= ck *sk, const int flag) * new SACK or ECE mark may first advance cwnd here and later reduce * cwnd in tcp_fastretrans_alert() based on more states. */ - if (tcp_sk(sk)->reordering > sock_net(sk)->ipv4.sysctl_tcp_reordering) + if (tcp_sk(sk)->reordering > + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reordering)) return flag & FLAG_FORWARD_PROGRESS; =20 return flag & FLAG_DATA_ACKED; diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c index 7029b0e98edb..a501150deaa3 100644 --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c @@ -428,7 +428,8 @@ void tcp_update_metrics(struct sock *sk) if (!tcp_metric_locked(tm, TCP_METRIC_REORDERING)) { val =3D tcp_metric_get(tm, TCP_METRIC_REORDERING); if (val < tp->reordering && - tp->reordering !=3D net->ipv4.sysctl_tcp_reordering) + tp->reordering !=3D + READ_ONCE(net->ipv4.sysctl_tcp_reordering)) tcp_metric_set(tm, TCP_METRIC_REORDERING, tp->reordering); } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0FBBC04A68 for ; Wed, 27 Jul 2022 17:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242639AbiG0RkE (ORCPT ); Wed, 27 Jul 2022 13:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242769AbiG0RjM (ORCPT ); Wed, 27 Jul 2022 13:39:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DDE87F53; Wed, 27 Jul 2022 09:51:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 61EEAB821D4; Wed, 27 Jul 2022 16:51:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6490C433C1; Wed, 27 Jul 2022 16:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940660; bh=9yN/mn+SzG6dTgAnbcM/egHblXWlEspSb8niTGl1DMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrlpH6CaSPQPWxqn2uFazONpBUDDUS5kM6w23Z1LY1nj7NgMGU+xb6iKawOibEFDI ywyRU4LzxBUwgPr1OOJuIC1Rh4PHCCpwhLeDqPnKKvWwyZjKmEikCosCD+rPE8iO26 vU0lw826ntU6OsAySIg2/a3rmnqCUDF5F9uPxNOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 071/158] tcp: Fix data-races around some timeout sysctl knobs. Date: Wed, 27 Jul 2022 18:12:15 +0200 Message-Id: <20220727161024.355385297@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 39e24435a776e9de5c6dd188836cf2523547804b ] While reading these sysctl knobs, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers. - tcp_retries1 - tcp_retries2 - tcp_orphan_retries - tcp_fin_timeout Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/tcp.h | 3 ++- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_output.c | 2 +- net/ipv4/tcp_timer.c | 10 +++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index e6f9a02fa465..815ea8f9b93f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1541,7 +1541,8 @@ static inline u32 keepalive_time_elapsed(const struct= tcp_sock *tp) =20 static inline int tcp_fin_time(const struct sock *sk) { - int fin_timeout =3D tcp_sk(sk)->linger2 ? : sock_net(sk)->ipv4.sysctl_tcp= _fin_timeout; + int fin_timeout =3D tcp_sk(sk)->linger2 ? : + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fin_timeout); const int rto =3D inet_csk(sk)->icsk_rto; =20 if (fin_timeout < (rto << 2) - (rto >> 1)) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 0e0ee9c58257..164603527399 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3994,7 +3994,7 @@ static int do_tcp_getsockopt(struct sock *sk, int lev= el, case TCP_LINGER2: val =3D tp->linger2; if (val >=3D 0) - val =3D (val ? : net->ipv4.sysctl_tcp_fin_timeout) / HZ; + val =3D (val ? : READ_ONCE(net->ipv4.sysctl_tcp_fin_timeout)) / HZ; break; case TCP_DEFER_ACCEPT: val =3D retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept, diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 99a2f4518e2e..3f20642c8171 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -4088,7 +4088,7 @@ void tcp_send_probe0(struct sock *sk) =20 icsk->icsk_probes_out++; if (err <=3D 0) { - if (icsk->icsk_backoff < net->ipv4.sysctl_tcp_retries2) + if (icsk->icsk_backoff < READ_ONCE(net->ipv4.sysctl_tcp_retries2)) icsk->icsk_backoff++; timeout =3D tcp_probe0_when(sk, TCP_RTO_MAX); } else { diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index a234704e8163..ec5277becc6a 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -143,7 +143,7 @@ static int tcp_out_of_resources(struct sock *sk, bool d= o_reset) */ static int tcp_orphan_retries(struct sock *sk, bool alive) { - int retries =3D sock_net(sk)->ipv4.sysctl_tcp_orphan_retries; /* May be z= ero. */ + int retries =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_orphan_retries); = /* May be zero. */ =20 /* We know from an ICMP that something is wrong. */ if (sk->sk_err_soft && !alive) @@ -243,14 +243,14 @@ static int tcp_write_timeout(struct sock *sk) READ_ONCE(net->ipv4.sysctl_tcp_syn_retries); expired =3D icsk->icsk_retransmits >=3D retry_until; } else { - if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) { + if (retransmits_timed_out(sk, READ_ONCE(net->ipv4.sysctl_tcp_retries1), = 0)) { /* Black hole detection */ tcp_mtu_probing(icsk, sk); =20 __dst_negative_advice(sk); } =20 - retry_until =3D net->ipv4.sysctl_tcp_retries2; + retry_until =3D READ_ONCE(net->ipv4.sysctl_tcp_retries2); if (sock_flag(sk, SOCK_DEAD)) { const bool alive =3D icsk->icsk_rto < TCP_RTO_MAX; =20 @@ -381,7 +381,7 @@ static void tcp_probe_timer(struct sock *sk) msecs_to_jiffies(icsk->icsk_user_timeout)) goto abort; =20 - max_probes =3D sock_net(sk)->ipv4.sysctl_tcp_retries2; + max_probes =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_retries2); if (sock_flag(sk, SOCK_DEAD)) { const bool alive =3D inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_M= AX; =20 @@ -589,7 +589,7 @@ void tcp_retransmit_timer(struct sock *sk) } inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, tcp_clamp_rto_to_user_timeout(sk), TCP_RTO_MAX); - if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1 + 1, 0)) + if (retransmits_timed_out(sk, READ_ONCE(net->ipv4.sysctl_tcp_retries1) + = 1, 0)) __sk_dst_reset(sk); =20 out:; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 405B2C04A68 for ; Wed, 27 Jul 2022 17:36:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231582AbiG0Rgn (ORCPT ); Wed, 27 Jul 2022 13:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242786AbiG0Re6 (ORCPT ); Wed, 27 Jul 2022 13:34:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FEF961B16; Wed, 27 Jul 2022 09:49:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30E5B61560; Wed, 27 Jul 2022 16:49:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CF1CC433C1; Wed, 27 Jul 2022 16:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940573; bh=dy39VTQLqjl3oCSWU7y0LdZ9XQDsjAkSbWuoLdmHovs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WJByOq7F3fQ9HIav1Gx12shhIsnw34YkX763C2Nly9bliGtqnh84EyDWIvLYQuMbF SeSZm2Bl/PU3WbI9Yrb2YIgiFX6YiuFGOCaIHvz8uD+M9ZOxh8lRx4SX1MZZNSSLfW h+UVCKxt8Ecr3VIUTVrvUjlSm8FaAZoGkUZOSmUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 072/158] tcp: Fix a data-race around sysctl_tcp_notsent_lowat. Date: Wed, 27 Jul 2022 18:12:16 +0200 Message-Id: <20220727161024.404079328@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 55be873695ed8912eb77ff46d1d1cadf028bd0f3 ] While reading sysctl_tcp_notsent_lowat, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: c9bee3b7fdec ("tcp: TCP_NOTSENT_LOWAT socket option") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/tcp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 815ea8f9b93f..8d02972e46cd 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2045,7 +2045,7 @@ void __tcp_v4_send_check(struct sk_buff *skb, __be32 = saddr, __be32 daddr); static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp) { struct net *net =3D sock_net((struct sock *)tp); - return tp->notsent_lowat ?: net->ipv4.sysctl_tcp_notsent_lowat; + return tp->notsent_lowat ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat); } =20 bool tcp_stream_memory_free(const struct sock *sk, int wake); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 655AAC04A68 for ; Wed, 27 Jul 2022 17:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242580AbiG0Rgv (ORCPT ); Wed, 27 Jul 2022 13:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238639AbiG0RfJ (ORCPT ); Wed, 27 Jul 2022 13:35:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B13983230; Wed, 27 Jul 2022 09:49:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 93489B821AC; Wed, 27 Jul 2022 16:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0077CC433D6; Wed, 27 Jul 2022 16:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940576; bh=N8QBShAdgh+hNRK6ey8Lx5hgQ2PapUc+DArPosW00v8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNaaaOmYhhatVpBLCsXk8b65xHnJXvzMyj+mTo0fbThQx2BY2kXl6dd6RdZyRiijZ NcWNKv3g/qAgBybrYW54wYthLweaNMyHxhJAryYDpoTlAct/OSr8JI3rgR6H4Wo6Hy vv9AZ7X5ZG4qG4i0HIBUqJl5srP7vvfDxvKfbVMI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 073/158] tcp: Fix a data-race around sysctl_tcp_tw_reuse. Date: Wed, 27 Jul 2022 18:12:17 +0200 Message-Id: <20220727161024.439306943@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit cbfc6495586a3f09f6f07d9fb3c7cafe807e3c55 ] While reading sysctl_tcp_tw_reuse, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index cd78b4fc334f..a57f96b86874 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -108,10 +108,10 @@ static u32 tcp_v4_init_ts_off(const struct net *net, = const struct sk_buff *skb) =20 int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp) { + int reuse =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_tw_reuse); const struct inet_timewait_sock *tw =3D inet_twsk(sktw); const struct tcp_timewait_sock *tcptw =3D tcp_twsk(sktw); struct tcp_sock *tp =3D tcp_sk(sk); - int reuse =3D sock_net(sk)->ipv4.sysctl_tcp_tw_reuse; =20 if (reuse =3D=3D 2) { /* Still does not detect *everything* that goes through --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F557C04A68 for ; Wed, 27 Jul 2022 17:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242304AbiG0Rgp (ORCPT ); Wed, 27 Jul 2022 13:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238009AbiG0RfE (ORCPT ); Wed, 27 Jul 2022 13:35:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB10261736; Wed, 27 Jul 2022 09:49:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9B1E616BD; Wed, 27 Jul 2022 16:49:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7729C433C1; Wed, 27 Jul 2022 16:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940579; bh=DyoHHfr/ZgtOgcLK1/79yqPAMmA10u0AIDGAhR0t7bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jkX0CRoCZAYwcmpbKbBKTK8LQkrNstYPORZhFNgqOm3mqBoehzbrxLw66oom9eUoL QkxPWj3c3Z/xNT8Z7h+GWSf61xZNL75IF20FJHFKbgibMmRNwYNzkAipOKxe3SlUj1 KkxboQdBFTFFkvNbFy2GbpOei7Nhf4lAZSSuA5rQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 074/158] tcp: Fix data-races around sysctl_max_syn_backlog. Date: Wed, 27 Jul 2022 18:12:18 +0200 Message-Id: <20220727161024.477753338@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 79539f34743d3e14cc1fa6577d326a82cc64d62f ] While reading sysctl_max_syn_backlog, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_input.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 391f4a3f10fd..d8d903ef61f7 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6939,10 +6939,12 @@ int tcp_conn_request(struct request_sock_ops *rsk_o= ps, tcp_rsk(req)->ts_off =3D af_ops->init_ts_off(net, skb); =20 if (!want_cookie && !isn) { + int max_syn_backlog =3D READ_ONCE(net->ipv4.sysctl_max_syn_backlog); + /* Kill the following clause, if you dislike this way. */ if (!syncookies && - (net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) < - (net->ipv4.sysctl_max_syn_backlog >> 2)) && + (max_syn_backlog - inet_csk_reqsk_queue_len(sk) < + (max_syn_backlog >> 2)) && !tcp_peer_is_proven(req, dst)) { /* Without syncookies last quarter of * backlog is filled with destinations, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6B5C04A68 for ; Wed, 27 Jul 2022 17:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242401AbiG0Rgy (ORCPT ); Wed, 27 Jul 2022 13:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241580AbiG0RfJ (ORCPT ); Wed, 27 Jul 2022 13:35:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964C883F38; Wed, 27 Jul 2022 09:49:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3947AB821C5; Wed, 27 Jul 2022 16:49:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85EBCC433B5; Wed, 27 Jul 2022 16:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940581; bh=iOq/THUgDmDM/j3le23+VopMrd/Pn4Vz7KF6fBtqEMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oiMIlCRagNimRVndyYkiWFg8QfdR0EK46MKFAYB3tihIRQFKqBnble6uunNeps9yB Ck1KmxUKyOs3w39Pi3ttO9F44rMcbYxSrrxDHCWp/7cdQeDiOtKslW/Dm70bTjJv4N cb3bPWdTvKzsC3DI5uyhg+vCTZllFA7bOYCdjuaE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , Yuchung Cheng , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 075/158] tcp: Fix data-races around sysctl_tcp_fastopen. Date: Wed, 27 Jul 2022 18:12:19 +0200 Message-Id: <20220727161024.517101568@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 5a54213318c43f4009ae158347aa6016e3b9b55a ] While reading sysctl_tcp_fastopen, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 2100c8d2d9db ("net-tcp: Fast Open base") Signed-off-by: Kuniyuki Iwashima Acked-by: Yuchung Cheng Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/af_inet.c | 2 +- net/ipv4/tcp.c | 6 ++++-- net/ipv4/tcp_fastopen.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f5d5911a8abd..5c207367b3b4 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -217,7 +217,7 @@ int inet_listen(struct socket *sock, int backlog) * because the socket was in TCP_LISTEN state previously but * was shutdown() rather than close(). */ - tcp_fastopen =3D sock_net(sk)->ipv4.sysctl_tcp_fastopen; + tcp_fastopen =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen); if ((tcp_fastopen & TFO_SERVER_WO_SOCKOPT1) && (tcp_fastopen & TFO_SERVER_ENABLE) && !inet_csk(sk)->icsk_accept_queue.fastopenq.max_qlen) { diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 164603527399..28db838e604a 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1151,7 +1151,8 @@ static int tcp_sendmsg_fastopen(struct sock *sk, stru= ct msghdr *msg, struct sockaddr *uaddr =3D msg->msg_name; int err, flags; =20 - if (!(sock_net(sk)->ipv4.sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) || + if (!(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen) & + TFO_CLIENT_ENABLE) || (uaddr && msg->msg_namelen >=3D sizeof(uaddr->sa_family) && uaddr->sa_family =3D=3D AF_UNSPEC)) return -EOPNOTSUPP; @@ -3638,7 +3639,8 @@ static int do_tcp_setsockopt(struct sock *sk, int lev= el, int optname, case TCP_FASTOPEN_CONNECT: if (val > 1 || val < 0) { err =3D -EINVAL; - } else if (net->ipv4.sysctl_tcp_fastopen & TFO_CLIENT_ENABLE) { + } else if (READ_ONCE(net->ipv4.sysctl_tcp_fastopen) & + TFO_CLIENT_ENABLE) { if (sk->sk_state =3D=3D TCP_CLOSE) tp->fastopen_connect =3D val; else diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index fdbcf2a6d08e..0acdb5473850 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c @@ -332,7 +332,7 @@ static bool tcp_fastopen_no_cookie(const struct sock *s= k, const struct dst_entry *dst, int flag) { - return (sock_net(sk)->ipv4.sysctl_tcp_fastopen & flag) || + return (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen) & flag) || tcp_sk(sk)->fastopen_no_cookie || (dst && dst_metric(dst, RTAX_FASTOPEN_NO_COOKIE)); } @@ -347,7 +347,7 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct s= k_buff *skb, const struct dst_entry *dst) { bool syn_data =3D TCP_SKB_CB(skb)->end_seq !=3D TCP_SKB_CB(skb)->seq + 1; - int tcp_fastopen =3D sock_net(sk)->ipv4.sysctl_tcp_fastopen; + int tcp_fastopen =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen); struct tcp_fastopen_cookie valid_foc =3D { .len =3D -1 }; struct sock *child; int ret =3D 0; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78A52C04A68 for ; Wed, 27 Jul 2022 17:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231814AbiG0Rg5 (ORCPT ); Wed, 27 Jul 2022 13:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241660AbiG0RfJ (ORCPT ); Wed, 27 Jul 2022 13:35:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDBB84EC1; Wed, 27 Jul 2022 09:49:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5126461479; Wed, 27 Jul 2022 16:49:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 590A8C433C1; Wed, 27 Jul 2022 16:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940584; bh=gX6oXyQi67phvXUaazyn0diBkW1dXjvmKBx9Z8YVdKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tWra0OkK04PeEgA4z/6F51be0TsfAIgUuKeSpmCkJcE/dmcfXVKN36lCgWtg9qHYh wPPgSCNU960Bp8QMDRLrzfXEICacw/DqXE68y87VqAlP9UbxjFFtXzrfPDcygXVnQq KH426haxxnjKrPcFGfTpfcnLyF005OOTdGSthj5E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 076/158] tcp: Fix data-races around sysctl_tcp_fastopen_blackhole_timeout. Date: Wed, 27 Jul 2022 18:12:20 +0200 Message-Id: <20220727161024.557121363@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 021266ec640c7a4527e6cd4b7349a512b351de1d ] While reading sysctl_tcp_fastopen_blackhole_timeout, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: cf1ef3f0719b ("net/tcp_fastopen: Disable active side TFO in certain = scenarios") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_fastopen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index 0acdb5473850..825b216d11f5 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c @@ -489,7 +489,7 @@ void tcp_fastopen_active_disable(struct sock *sk) { struct net *net =3D sock_net(sk); =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout)) return; =20 /* Paired with READ_ONCE() in tcp_fastopen_active_should_disable() */ @@ -510,7 +510,8 @@ void tcp_fastopen_active_disable(struct sock *sk) */ bool tcp_fastopen_active_should_disable(struct sock *sk) { - unsigned int tfo_bh_timeout =3D sock_net(sk)->ipv4.sysctl_tcp_fastopen_bl= ackhole_timeout; + unsigned int tfo_bh_timeout =3D + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fastopen_blackhole_timeout); unsigned long timeout; int tfo_da_times; int multiplier; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C8C8C04A68 for ; Wed, 27 Jul 2022 17:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242494AbiG0RhC (ORCPT ); Wed, 27 Jul 2022 13:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242463AbiG0Rfw (ORCPT ); Wed, 27 Jul 2022 13:35:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E00284EED; Wed, 27 Jul 2022 09:49:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C625DB821D4; Wed, 27 Jul 2022 16:49:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FD35C433C1; Wed, 27 Jul 2022 16:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940587; bh=Ei+cTiXPWIcK3gX0SnZfCM5G5CR4Tcy+IesGcyskhMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y/1HrHpGdIQ81OmB2V/sUPX+gYf0MPD9+nAc7Gq5hdI9w2k899xrFTPo3WgxcMLX0 AZi5kwB0JkkD9hY86JmPMKOK8Kqrz9jH2STdt7/ayeuCz6K28/Oa95QOdHoAH6NzQW NGs2dlsAKduB08YqCJZbNKr6bCu2xhrgADlK7isk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Przemyslaw Patynowski , Jedrzej Jagielski , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 077/158] iavf: Fix VLAN_V2 addition/rejection Date: Wed, 27 Jul 2022 18:12:21 +0200 Message-Id: <20220727161024.597506186@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Przemyslaw Patynowski [ Upstream commit 968996c070ef080ee7d6150faa98a4e562ce4625 ] Fix VLAN addition, so that PF driver does not reject whole VLAN batch. Add VLAN reject handling, so rejected VLANs, won't litter VLAN filter list. Fix handling of active_(c/s)vlans, so it will be possible to re-add VLAN filters for user. Without this patch, after changing trust to off, with VLAN filters saturated, no VLAN is added, due to PF rejecting addition. Fixes: 92fc50859872 ("iavf: Restrict maximum VLAN filters for VIRTCHNL_VF_O= FFLOAD_VLAN_V2") Signed-off-by: Przemyslaw Patynowski Signed-off-by: Jedrzej Jagielski Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/iavf/iavf.h | 9 ++- drivers/net/ethernet/intel/iavf/iavf_main.c | 10 ++- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 65 ++++++++++++++++++- 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index 49aed3e506a6..86bc61c300a7 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -159,8 +159,12 @@ struct iavf_vlan { struct iavf_vlan_filter { struct list_head list; struct iavf_vlan vlan; - bool remove; /* filter needs to be removed */ - bool add; /* filter needs to be added */ + struct { + u8 is_new_vlan:1; /* filter is new, wait for PF answer */ + u8 remove:1; /* filter needs to be removed */ + u8 add:1; /* filter needs to be added */ + u8 padding:5; + }; }; =20 #define IAVF_MAX_TRAFFIC_CLASS 4 @@ -520,6 +524,7 @@ int iavf_get_vf_config(struct iavf_adapter *adapter); int iavf_get_vf_vlan_v2_caps(struct iavf_adapter *adapter); int iavf_send_vf_offload_vlan_v2_msg(struct iavf_adapter *adapter); void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter); +u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter); void iavf_irq_enable(struct iavf_adapter *adapter, bool flush); void iavf_configure_queues(struct iavf_adapter *adapter); void iavf_deconfigure_queues(struct iavf_adapter *adapter); diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethe= rnet/intel/iavf/iavf_main.c index f3ecb3bca33d..2a8643e66331 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -843,7 +843,7 @@ static void iavf_restore_filters(struct iavf_adapter *a= dapter) * iavf_get_num_vlans_added - get number of VLANs added * @adapter: board private structure */ -static u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter) +u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter) { return bitmap_weight(adapter->vsi.active_cvlans, VLAN_N_VID) + bitmap_weight(adapter->vsi.active_svlans, VLAN_N_VID); @@ -906,11 +906,6 @@ static int iavf_vlan_rx_add_vid(struct net_device *net= dev, if (!iavf_add_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto)))) return -ENOMEM; =20 - if (proto =3D=3D cpu_to_be16(ETH_P_8021Q)) - set_bit(vid, adapter->vsi.active_cvlans); - else - set_bit(vid, adapter->vsi.active_svlans); - return 0; } =20 @@ -2956,6 +2951,9 @@ static void iavf_reset_task(struct work_struct *work) adapter->aq_required |=3D IAVF_FLAG_AQ_ADD_CLOUD_FILTER; iavf_misc_irq_enable(adapter); =20 + bitmap_clear(adapter->vsi.active_cvlans, 0, VLAN_N_VID); + bitmap_clear(adapter->vsi.active_svlans, 0, VLAN_N_VID); + mod_delayed_work(iavf_wq, &adapter->watchdog_task, 2); =20 /* We were running when the reset started, so we need to restore some diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/= ethernet/intel/iavf/iavf_virtchnl.c index 782450d5c12f..1603e99bae4a 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -626,6 +626,33 @@ static void iavf_mac_add_reject(struct iavf_adapter *a= dapter) spin_unlock_bh(&adapter->mac_vlan_list_lock); } =20 +/** + * iavf_vlan_add_reject + * @adapter: adapter structure + * + * Remove VLAN filters from list based on PF response. + **/ +static void iavf_vlan_add_reject(struct iavf_adapter *adapter) +{ + struct iavf_vlan_filter *f, *ftmp; + + spin_lock_bh(&adapter->mac_vlan_list_lock); + list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { + if (f->is_new_vlan) { + if (f->vlan.tpid =3D=3D ETH_P_8021Q) + clear_bit(f->vlan.vid, + adapter->vsi.active_cvlans); + else + clear_bit(f->vlan.vid, + adapter->vsi.active_svlans); + + list_del(&f->list); + kfree(f); + } + } + spin_unlock_bh(&adapter->mac_vlan_list_lock); +} + /** * iavf_add_vlans * @adapter: adapter structure @@ -683,6 +710,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter) vvfl->vlan_id[i] =3D f->vlan.vid; i++; f->add =3D false; + f->is_new_vlan =3D true; if (i =3D=3D count) break; } @@ -695,10 +723,18 @@ void iavf_add_vlans(struct iavf_adapter *adapter) iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len); kfree(vvfl); } else { + u16 max_vlans =3D adapter->vlan_v2_caps.filtering.max_filters; + u16 current_vlans =3D iavf_get_num_vlans_added(adapter); struct virtchnl_vlan_filter_list_v2 *vvfl_v2; =20 adapter->current_op =3D VIRTCHNL_OP_ADD_VLAN_V2; =20 + if ((count + current_vlans) > max_vlans && + current_vlans < max_vlans) { + count =3D max_vlans - iavf_get_num_vlans_added(adapter); + more =3D true; + } + len =3D sizeof(*vvfl_v2) + ((count - 1) * sizeof(struct virtchnl_vlan_filter)); if (len > IAVF_MAX_AQ_BUF_SIZE) { @@ -725,6 +761,9 @@ void iavf_add_vlans(struct iavf_adapter *adapter) &adapter->vlan_v2_caps.filtering.filtering_support; struct virtchnl_vlan *vlan; =20 + if (i =3D=3D count) + break; + /* give priority over outer if it's enabled */ if (filtering_support->outer) vlan =3D &vvfl_v2->filters[i].outer; @@ -736,8 +775,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter) =20 i++; f->add =3D false; - if (i =3D=3D count) - break; + f->is_new_vlan =3D true; } } =20 @@ -2080,6 +2118,11 @@ void iavf_virtchnl_completion(struct iavf_adapter *a= dapter, */ iavf_netdev_features_vlan_strip_set(netdev, true); break; + case VIRTCHNL_OP_ADD_VLAN_V2: + iavf_vlan_add_reject(adapter); + dev_warn(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n", + iavf_stat_str(&adapter->hw, v_retval)); + break; default: dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request = %d\n", v_retval, iavf_stat_str(&adapter->hw, v_retval), @@ -2332,6 +2375,24 @@ void iavf_virtchnl_completion(struct iavf_adapter *a= dapter, spin_unlock_bh(&adapter->adv_rss_lock); } break; + case VIRTCHNL_OP_ADD_VLAN_V2: { + struct iavf_vlan_filter *f; + + spin_lock_bh(&adapter->mac_vlan_list_lock); + list_for_each_entry(f, &adapter->vlan_filter_list, list) { + if (f->is_new_vlan) { + f->is_new_vlan =3D false; + if (f->vlan.tpid =3D=3D ETH_P_8021Q) + set_bit(f->vlan.vid, + adapter->vsi.active_cvlans); + else + set_bit(f->vlan.vid, + adapter->vsi.active_svlans); + } + } + spin_unlock_bh(&adapter->mac_vlan_list_lock); + } + break; case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: /* PF enabled vlan strip on this VF. * Update netdev->features if needed to be in sync with ethtool. --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40436C04A68 for ; Wed, 27 Jul 2022 17:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242611AbiG0RhP (ORCPT ); Wed, 27 Jul 2022 13:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242551AbiG0Rgd (ORCPT ); Wed, 27 Jul 2022 13:36:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F5C485F96; Wed, 27 Jul 2022 09:49:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8F885B8200D; Wed, 27 Jul 2022 16:49:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEA3AC433D7; Wed, 27 Jul 2022 16:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940590; bh=yG0xUPiK8x2rLDphnnDND5z6LPWXqGx5Q78tQ6Iqivs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oTp+4AklTU5abllCHKKyBQC9E4mem5r3Hl/jXrW8P9UopRqZLElJFjlxkhZmMXGus iBg60bq0VPjGov0OTPubmu4PIVyOfhU6+XAD8vuyxQOLxiZCyJQsxcTYZxuCfcOAeG xPtfn9suxCfN6hXUIDd2dLIsYuOHs8EF+ksGPEvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Przemyslaw Patynowski , Jun Zhang , Marek Szlosek , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 078/158] iavf: Disallow changing rx/tx-frames and rx/tx-frames-irq Date: Wed, 27 Jul 2022 18:12:22 +0200 Message-Id: <20220727161024.642080212@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Przemyslaw Patynowski [ Upstream commit 4635fd3a9d77581498f34ab9a7e4bcc211bf0a4c ] Remove from supported_coalesce_params ETHTOOL_COALESCE_MAX_FRAMES and ETHTOOL_COALESCE_MAX_FRAMES_IRQ. As tx-frames-irq allowed user to change budget for iavf_clean_tx_irq, remove work_limit and use define for budget. Without this patch there would be possibility to change rx/tx-frames and rx/tx-frames-irq, which for rx/tx-frames did nothing, while for rx/tx-frames-irq it changed rx/tx-frames and only changed budget for cleaning NAPI poll. Fixes: fbb7ddfef253 ("i40evf: core ethtool functionality") Signed-off-by: Przemyslaw Patynowski Signed-off-by: Jun Zhang Tested-by: Marek Szlosek Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/iavf/iavf.h | 1 - drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 10 ---------- drivers/net/ethernet/intel/iavf/iavf_main.c | 1 - drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +- 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index 86bc61c300a7..2a7b3c085aa9 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -64,7 +64,6 @@ struct iavf_vsi { u16 id; DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__); int base_vector; - u16 work_limit; u16 qs_handle; void *priv; /* client driver data reference. */ }; diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/e= thernet/intel/iavf/iavf_ethtool.c index 3bb56714beb0..e535d4c3da49 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c @@ -692,12 +692,8 @@ static int __iavf_get_coalesce(struct net_device *netd= ev, struct ethtool_coalesce *ec, int queue) { struct iavf_adapter *adapter =3D netdev_priv(netdev); - struct iavf_vsi *vsi =3D &adapter->vsi; struct iavf_ring *rx_ring, *tx_ring; =20 - ec->tx_max_coalesced_frames =3D vsi->work_limit; - ec->rx_max_coalesced_frames =3D vsi->work_limit; - /* Rx and Tx usecs per queue value. If user doesn't specify the * queue, return queue 0's value to represent. */ @@ -825,12 +821,8 @@ static int __iavf_set_coalesce(struct net_device *netd= ev, struct ethtool_coalesce *ec, int queue) { struct iavf_adapter *adapter =3D netdev_priv(netdev); - struct iavf_vsi *vsi =3D &adapter->vsi; int i; =20 - if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq) - vsi->work_limit =3D ec->tx_max_coalesced_frames_irq; - if (ec->rx_coalesce_usecs =3D=3D 0) { if (ec->use_adaptive_rx_coalesce) netif_info(adapter, drv, netdev, "rx-usecs=3D0, need to disable adaptiv= e-rx for a complete disable\n"); @@ -1969,8 +1961,6 @@ static int iavf_set_rxfh(struct net_device *netdev, c= onst u32 *indir, =20 static const struct ethtool_ops iavf_ethtool_ops =3D { .supported_coalesce_params =3D ETHTOOL_COALESCE_USECS | - ETHTOOL_COALESCE_MAX_FRAMES | - ETHTOOL_COALESCE_MAX_FRAMES_IRQ | ETHTOOL_COALESCE_USE_ADAPTIVE, .get_drvinfo =3D iavf_get_drvinfo, .get_link =3D ethtool_op_get_link, diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethe= rnet/intel/iavf/iavf_main.c index 2a8643e66331..2e2c153ce46a 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -2240,7 +2240,6 @@ int iavf_parse_vf_resource_msg(struct iavf_adapter *a= dapter) =20 adapter->vsi.back =3D adapter; adapter->vsi.base_vector =3D 1; - adapter->vsi.work_limit =3D IAVF_DEFAULT_IRQ_WORK; vsi->netdev =3D adapter->netdev; vsi->qs_handle =3D adapter->vsi_res->qset_handle; if (adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) { diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethe= rnet/intel/iavf/iavf_txrx.c index 978f651c6b09..7bf8c25dc824 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -194,7 +194,7 @@ static bool iavf_clean_tx_irq(struct iavf_vsi *vsi, struct iavf_tx_buffer *tx_buf; struct iavf_tx_desc *tx_desc; unsigned int total_bytes =3D 0, total_packets =3D 0; - unsigned int budget =3D vsi->work_limit; + unsigned int budget =3D IAVF_DEFAULT_IRQ_WORK; =20 tx_buf =3D &tx_ring->tx_bi[i]; tx_desc =3D IAVF_TX_DESC(tx_ring, i); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11326C04A68 for ; Wed, 27 Jul 2022 17:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242600AbiG0RhF (ORCPT ); Wed, 27 Jul 2022 13:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbiG0RgN (ORCPT ); Wed, 27 Jul 2022 13:36:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF5152DE3; Wed, 27 Jul 2022 09:49:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9267D60D3B; Wed, 27 Jul 2022 16:49:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BE9EC433C1; Wed, 27 Jul 2022 16:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940593; bh=KKdT/9iR7TxYAZKdWin+O1J7BxALUpfcJc6N5xM2Tcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1kcI9vm3rSO3n4aun9UOOMtxXMk8MMBnjIVx54p302O2XMFm2uWyZ+LirjbThyFA jZRxaS+gmX5QoHDew+wMtPG2k1LvciHjp/7L3EutNHX5ALeu66VsA3BtFhb+q0v+zZ pa7lS0UV5GRtGuqmIKBFrggHJZ+ME2x8G3Z5qgHg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Przemyslaw Patynowski , Jesse Brandeburg , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 079/158] iavf: Fix handling of dummy receive descriptors Date: Wed, 27 Jul 2022 18:12:23 +0200 Message-Id: <20220727161024.676498293@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Przemyslaw Patynowski [ Upstream commit a9f49e0060301a9bfebeca76739158d0cf91cdf6 ] Fix memory leak caused by not handling dummy receive descriptor properly. iavf_get_rx_buffer now sets the rx_buffer return value for dummy receive descriptors. Without this patch, when the hardware writes a dummy descriptor, iavf would not free the page allocated for the previous receive buffer. This is an unlikely event but can still happen. [Jesse: massaged commit message] Fixes: efa14c398582 ("iavf: allow null RX descriptors") Signed-off-by: Przemyslaw Patynowski Signed-off-by: Jesse Brandeburg Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethe= rnet/intel/iavf/iavf_txrx.c index 7bf8c25dc824..06d18797d25a 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -1285,11 +1285,10 @@ static struct iavf_rx_buffer *iavf_get_rx_buffer(st= ruct iavf_ring *rx_ring, { struct iavf_rx_buffer *rx_buffer; =20 - if (!size) - return NULL; - rx_buffer =3D &rx_ring->rx_bi[rx_ring->next_to_clean]; prefetchw(rx_buffer->page); + if (!size) + return rx_buffer; =20 /* we are reusing so sync this buffer for CPU use */ dma_sync_single_range_for_cpu(rx_ring->dev, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24E28C04A68 for ; Wed, 27 Jul 2022 17:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239659AbiG0Rha (ORCPT ); Wed, 27 Jul 2022 13:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240106AbiG0RhJ (ORCPT ); Wed, 27 Jul 2022 13:37:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D786863D6; Wed, 27 Jul 2022 09:50:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E0114B821D6; Wed, 27 Jul 2022 16:49:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DC9AC433D6; Wed, 27 Jul 2022 16:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940595; bh=zZ/9f23sDmN1CWFHzWyAvJwPqv0U6mY2o48R35fTxeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bzkGse2VtFMioMdEbauj9D441BG93AeTpW7WDI/BQmpHpoFWCnkkjc5e+eKVNYelW NjEEjTdFIswDREEBUMVhR34wgF5IEvkbynFT/C36UdxEIb+g24WO+UzL05dMsvUx3F 78j431osvuhTE/ieyp7DcKIKZYxXpqkWR0C3oTUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Przemyslaw Patynowski , Jun Zhang , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.18 080/158] iavf: Fix missing state logs Date: Wed, 27 Jul 2022 18:12:24 +0200 Message-Id: <20220727161024.705697137@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Przemyslaw Patynowski [ Upstream commit d8fa2fd791a72087c1ce3336fbeefec4057c37c8 ] Fix debug prints, by adding missing state prints. Extend iavf_state_str by strings for __IAVF_INIT_EXTENDED_CAPS and __IAVF_INIT_CONFIG_ADAPTER. Without this patch, when enabling debug prints for iavf.h, user will see: iavf 0000:06:0e.0: state transition from:__IAVF_INIT_GET_RESOURCES to:__IAV= F_UNKNOWN_STATE iavf 0000:06:0e.0: state transition from:__IAVF_UNKNOWN_STATE to:__IAVF_UNK= NOWN_STATE Fixes: 605ca7c5c670 ("iavf: Fix kernel BUG in free_msi_irqs") Signed-off-by: Przemyslaw Patynowski Signed-off-by: Jun Zhang Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/iavf/iavf.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index 2a7b3c085aa9..0ea0361cd86b 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -464,6 +464,10 @@ static inline const char *iavf_state_str(enum iavf_sta= te_t state) return "__IAVF_INIT_VERSION_CHECK"; case __IAVF_INIT_GET_RESOURCES: return "__IAVF_INIT_GET_RESOURCES"; + case __IAVF_INIT_EXTENDED_CAPS: + return "__IAVF_INIT_EXTENDED_CAPS"; + case __IAVF_INIT_CONFIG_ADAPTER: + return "__IAVF_INIT_CONFIG_ADAPTER"; case __IAVF_INIT_SW: return "__IAVF_INIT_SW"; case __IAVF_INIT_FAILED: --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34344C04A68 for ; Wed, 27 Jul 2022 17:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242626AbiG0Rhj (ORCPT ); Wed, 27 Jul 2022 13:37:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241666AbiG0RhP (ORCPT ); Wed, 27 Jul 2022 13:37:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 338E92714; Wed, 27 Jul 2022 09:50:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA91D61479; Wed, 27 Jul 2022 16:49:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EED02C433D7; Wed, 27 Jul 2022 16:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940598; bh=0H1NXs+/dIxIZ/a66/1Fny6x8s5AZbE/YcAANoqu4/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNKP9BEuFP0Y0zplXOvDiUjR9MAdPfkoZndJuZ4yEs2PNVt86ZAkkdcqDzrfw13kG o48L3hwKJtstp8dMzMG7v1dijS1ZIRc5SexoV/fYd/vre+fs66V/AA91247dATjW/u RrEz+5eT+P4oDoNqktTcU7zlifnSnMejxywsEpvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre Gondois , Mario Limonciello , "Rafael J. Wysocki" , Sasha Levin , =?UTF-8?q?Arek=20Ru=C5=9Bniak?= Subject: [PATCH 5.18 081/158] ACPI: CPPC: Dont require flexible address space if X86_FEATURE_CPPC is supported Date: Wed, 27 Jul 2022 18:12:25 +0200 Message-Id: <20220727161024.750164524@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mario Limonciello [ Upstream commit 09073396ea62d0a10b03f5661dcabfd8eca3f098 ] Commit 0651ab90e4ad ("ACPI: CPPC: Check _OSC for flexible address space") changed _CPC probing to require flexible address space to be negotiated for CPPC to work. However it was observed that this caused a regression for Arek's ROG Zephyrus G15 GA503QM which previously CPPC worked, but now it stopped working. To avoid causing a regression waive this failure when the CPU is known to support CPPC. Cc: Pierre Gondois Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D216248 Fixes: 0651ab90e4ad ("ACPI: CPPC: Check _OSC for flexible address space") Reported-and-tested-by: Arek Ru=C5=9Bniak Signed-off-by: Mario Limonciello Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/acpi/cppc_acpi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 57ca7aa0e169..b8e26b6b5523 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -764,7 +764,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) =20 if (!osc_cpc_flexible_adr_space_confirmed) { pr_debug("Flexible address space capability not supported\n"); - goto out_free; + if (!cpc_supported_by_cpu()) + goto out_free; } =20 addr =3D ioremap(gas_t->address, gas_t->bit_width/8); @@ -791,7 +792,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) } if (!osc_cpc_flexible_adr_space_confirmed) { pr_debug("Flexible address space capability not supported\n"); - goto out_free; + if (!cpc_supported_by_cpu()) + goto out_free; } } else { if (gas_t->space_id !=3D ACPI_ADR_SPACE_FIXED_HARDWARE || !cpc_ffh_sup= ported()) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9C9DC19F2C for ; Wed, 27 Jul 2022 17:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242644AbiG0RiX (ORCPT ); Wed, 27 Jul 2022 13:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242619AbiG0Rhy (ORCPT ); Wed, 27 Jul 2022 13:37:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC43B8689F; Wed, 27 Jul 2022 09:50:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 60B3F616FA; Wed, 27 Jul 2022 16:50:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B9E1C433D6; Wed, 27 Jul 2022 16:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940603; bh=49Ylmd6QtRg5NoLeTrOXyRJ1bNwFt5vYNEfZxBZVBSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g5klBnD2u4hcpmOhr2Gt+ZNGX/p/9zhSvM/eIIMX0gaCOdu4O4ZUNPpFD9cy7q+XC aa3FwLxRG2TTZ0hQWAJSCSK2AxEEhzX5w5n3lGvggBYwm852XdpBcqNoX8aB/vn72k G1HKCsAnrrxzlyoP6IWwpAWHEwvzYnH3i1ZHcDa8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Sasha Levin Subject: [PATCH 5.18 082/158] pinctrl: armada-37xx: Reuse GPIO fwnode in armada_37xx_irqchip_register() Date: Wed, 27 Jul 2022 18:12:26 +0200 Message-Id: <20220727161024.788030612@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko [ Upstream commit 46d34d4d502ea1030f5de434e6677ec96ca131c3 ] Since we have fwnode of the first found GPIO controller assigned to the struct gpio_chip, we may reuse it in the armada_37xx_irqchip_register(). Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/= mvebu/pinctrl-armada-37xx.c index 5fc305222d2f..226798d9c067 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -726,23 +726,13 @@ static int armada_37xx_irqchip_register(struct platfo= rm_device *pdev, struct gpio_chip *gc =3D &info->gpio_chip; struct irq_chip *irqchip =3D &info->irq_chip; struct gpio_irq_chip *girq =3D &gc->irq; + struct device_node *np =3D to_of_node(gc->fwnode); struct device *dev =3D &pdev->dev; - struct device_node *np; - int ret =3D -ENODEV, i, nr_irq_parent; - - /* Check if we have at least one gpio-controller child node */ - for_each_child_of_node(dev->of_node, np) { - if (of_property_read_bool(np, "gpio-controller")) { - ret =3D 0; - break; - } - } - if (ret) - return dev_err_probe(dev, ret, "no gpio-controller child node\n"); + unsigned int i, nr_irq_parent; =20 - nr_irq_parent =3D of_irq_count(np); spin_lock_init(&info->irq_lock); =20 + nr_irq_parent =3D of_irq_count(np); if (!nr_irq_parent) { dev_err(dev, "invalid or no IRQ\n"); return 0; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AECBEC04A68 for ; Wed, 27 Jul 2022 17:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242696AbiG0Rih (ORCPT ); Wed, 27 Jul 2022 13:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242643AbiG0Rh5 (ORCPT ); Wed, 27 Jul 2022 13:37:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2657853D14; Wed, 27 Jul 2022 09:50:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AF2F6B821D5; Wed, 27 Jul 2022 16:50:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F9AFC433C1; Wed, 27 Jul 2022 16:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940606; bh=T6fb930px444ePCCvfwrLitz4OYLqTRU1yJPo9RUxlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQQOWPPkQFdX37I1A/feuVrtERy/ABHThbnCSUbsMEQuqb9WWzDi3uQVaE+nLfUbU GttUEP9L4NpMWraidrOrMu25QsIENuobotuesrIGOEJK7avcx3Qopg9INolg8Zu+jR ZPMxDhFphF7WU2Do+2x/LFPIP2aMQEpawYFwagNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Linus Walleij , Sasha Levin Subject: [PATCH 5.18 083/158] pinctrl: armada-37xx: make irq_lock a raw spinlock to avoid invalid wait context Date: Wed, 27 Jul 2022 18:12:27 +0200 Message-Id: <20220727161024.829251550@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit 984245b66cf32c494b1e4f95f5ed6ba16b8771eb ] The irqchip->irq_set_type method is called by __irq_set_trigger() under the desc->lock raw spinlock. The armada-37xx implementation, armada_37xx_irq_set_type(), takes a plain spinlock, the kind that becomes sleepable on RT. Therefore, this is an invalid locking scheme for which we get a kernel splat stating just that ("[ BUG: Invalid wait context ]"), because the context in which the plain spinlock may sleep is atomic due to the raw spinlock. We need to go raw spinlocks all the way. Replace the driver's irq_lock with a raw spinlock, to disable preemption even on RT. Cc: # 5.15+ Fixes: 2f227605394b ("pinctrl: armada-37xx: Add irqchip support") Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220716233745.1704677-2-vladimir.oltean@nx= p.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 38 ++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/= mvebu/pinctrl-armada-37xx.c index 226798d9c067..b920dd5237c7 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -101,7 +101,7 @@ struct armada_37xx_pinctrl { struct device *dev; struct gpio_chip gpio_chip; struct irq_chip irq_chip; - spinlock_t irq_lock; + raw_spinlock_t irq_lock; struct pinctrl_desc pctl; struct pinctrl_dev *pctl_dev; struct armada_37xx_pin_group *groups; @@ -522,9 +522,9 @@ static void armada_37xx_irq_ack(struct irq_data *d) unsigned long flags; =20 armada_37xx_irq_update_reg(®, d); - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); writel(d->mask, info->base + reg); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); } =20 static void armada_37xx_irq_mask(struct irq_data *d) @@ -535,10 +535,10 @@ static void armada_37xx_irq_mask(struct irq_data *d) unsigned long flags; =20 armada_37xx_irq_update_reg(®, d); - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); val =3D readl(info->base + reg); writel(val & ~d->mask, info->base + reg); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); } =20 static void armada_37xx_irq_unmask(struct irq_data *d) @@ -549,10 +549,10 @@ static void armada_37xx_irq_unmask(struct irq_data *d) unsigned long flags; =20 armada_37xx_irq_update_reg(®, d); - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); val =3D readl(info->base + reg); writel(val | d->mask, info->base + reg); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); } =20 static int armada_37xx_irq_set_wake(struct irq_data *d, unsigned int on) @@ -563,14 +563,14 @@ static int armada_37xx_irq_set_wake(struct irq_data *= d, unsigned int on) unsigned long flags; =20 armada_37xx_irq_update_reg(®, d); - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); val =3D readl(info->base + reg); if (on) val |=3D (BIT(d->hwirq % GPIO_PER_REG)); else val &=3D ~(BIT(d->hwirq % GPIO_PER_REG)); writel(val, info->base + reg); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); =20 return 0; } @@ -582,7 +582,7 @@ static int armada_37xx_irq_set_type(struct irq_data *d,= unsigned int type) u32 val, reg =3D IRQ_POL; unsigned long flags; =20 - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); armada_37xx_irq_update_reg(®, d); val =3D readl(info->base + reg); switch (type) { @@ -606,11 +606,11 @@ static int armada_37xx_irq_set_type(struct irq_data *= d, unsigned int type) break; } default: - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); return -EINVAL; } writel(val, info->base + reg); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); =20 return 0; } @@ -625,7 +625,7 @@ static int armada_37xx_edge_both_irq_swap_pol(struct ar= mada_37xx_pinctrl *info, =20 regmap_read(info->regmap, INPUT_VAL + 4*reg_idx, &l); =20 - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); p =3D readl(info->base + IRQ_POL + 4 * reg_idx); if ((p ^ l) & (1 << bit_num)) { /* @@ -646,7 +646,7 @@ static int armada_37xx_edge_both_irq_swap_pol(struct ar= mada_37xx_pinctrl *info, ret =3D -1; } =20 - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); return ret; } =20 @@ -663,11 +663,11 @@ static void armada_37xx_irq_handler(struct irq_desc *= desc) u32 status; unsigned long flags; =20 - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); status =3D readl_relaxed(info->base + IRQ_STATUS + 4 * i); /* Manage only the interrupt that was enabled */ status &=3D readl_relaxed(info->base + IRQ_EN + 4 * i); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); while (status) { u32 hwirq =3D ffs(status) - 1; u32 virq =3D irq_find_mapping(d, hwirq + @@ -694,12 +694,12 @@ static void armada_37xx_irq_handler(struct irq_desc *= desc) =20 update_status: /* Update status in case a new IRQ appears */ - spin_lock_irqsave(&info->irq_lock, flags); + raw_spin_lock_irqsave(&info->irq_lock, flags); status =3D readl_relaxed(info->base + IRQ_STATUS + 4 * i); /* Manage only the interrupt that was enabled */ status &=3D readl_relaxed(info->base + IRQ_EN + 4 * i); - spin_unlock_irqrestore(&info->irq_lock, flags); + raw_spin_unlock_irqrestore(&info->irq_lock, flags); } } chained_irq_exit(chip, desc); @@ -730,7 +730,7 @@ static int armada_37xx_irqchip_register(struct platform= _device *pdev, struct device *dev =3D &pdev->dev; unsigned int i, nr_irq_parent; =20 - spin_lock_init(&info->irq_lock); + raw_spin_lock_init(&info->irq_lock); =20 nr_irq_parent =3D of_irq_count(np); if (!nr_irq_parent) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFEC1C04A68 for ; Wed, 27 Jul 2022 17:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242654AbiG0Ri1 (ORCPT ); Wed, 27 Jul 2022 13:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242533AbiG0Rh4 (ORCPT ); Wed, 27 Jul 2022 13:37:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2695186C0B; Wed, 27 Jul 2022 09:50:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B5DDC60D3B; Wed, 27 Jul 2022 16:50:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C57A8C433D6; Wed, 27 Jul 2022 16:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940609; bh=MB48tir69+UgtBlHJV7vcCVKs43QLs5qQdmeSAwoAEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fvX1sHmxirNuM/WSsZYBP1g5B+aoN2FTm0XrbIzOjUr+/qCs5As3PufZavFzuRLbU rNX+KQ6XphA5WoIiNGTznEZtUg+KZzPIC3ACbi7QBHgFHVKZ/yi/Mrcr2jCFEe7jVK Bl5e7bSqSi1u8xwow7HZZwJdlAYlaW8PPB4cBdxE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 084/158] net: lan966x: Fix taking rtnl_lock while holding spin_lock Date: Wed, 27 Jul 2022 18:12:28 +0200 Message-Id: <20220727161024.861930432@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit 45533a534a45cb12c20c81615d17306176cb1c57 ] When the HW deletes an entry in MAC table then it generates an interrupt. The SW will go through it's own list of MAC entries and if it is not found then it would notify the listeners about this. The problem is that when the SW will go through it's own list it would take a spin lock(lan966x->mac_lock) and when it notifies that the entry is deleted. But to notify the listeners it taking the rtnl_lock which is illegal. This is fixed by instead of notifying right away that the entry is deleted, move the entry on a temp list and once, it checks all the entries then just notify that the entries from temp list are deleted. Fixes: 5ccd66e01cbe ("net: lan966x: add support for interrupts from analyze= r") Signed-off-by: Horatiu Vultur Reviewed-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../ethernet/microchip/lan966x/lan966x_mac.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_mac.c index 005e56ea5da1..2d2b83c03796 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c @@ -325,10 +325,13 @@ static void lan966x_mac_irq_process(struct lan966x *l= an966x, u32 row, { struct lan966x_mac_entry *mac_entry, *tmp; unsigned char mac[ETH_ALEN] __aligned(2); + struct list_head mac_deleted_entries; u32 dest_idx; u32 column; u16 vid; =20 + INIT_LIST_HEAD(&mac_deleted_entries); + spin_lock(&lan966x->mac_lock); list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, list) { bool found =3D false; @@ -362,20 +365,26 @@ static void lan966x_mac_irq_process(struct lan966x *l= an966x, u32 row, } =20 if (!found) { - /* Notify the bridge that the entry doesn't exist - * anymore in the HW and remove the entry from the SW - * list - */ - lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE, - mac_entry->mac, mac_entry->vid, - lan966x->ports[mac_entry->port_index]->dev); - list_del(&mac_entry->list); - kfree(mac_entry); + /* Move the entry from SW list to a tmp list such that + * it would be deleted later + */ + list_add_tail(&mac_entry->list, &mac_deleted_entries); } } spin_unlock(&lan966x->mac_lock); =20 + list_for_each_entry_safe(mac_entry, tmp, &mac_deleted_entries, list) { + /* Notify the bridge that the entry doesn't exist + * anymore in the HW + */ + lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE, + mac_entry->mac, mac_entry->vid, + lan966x->ports[mac_entry->port_index]->dev); + list_del(&mac_entry->list); + kfree(mac_entry); + } + /* Now go to the list of columns and see if any entry was not in the SW * list, then that means that the entry is new so it needs to notify the * bridge. --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1C6CC04A68 for ; Wed, 27 Jul 2022 17:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242663AbiG0Rie (ORCPT ); Wed, 27 Jul 2022 13:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242620AbiG0Rh4 (ORCPT ); Wed, 27 Jul 2022 13:37:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6B97A51C; Wed, 27 Jul 2022 09:50:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 68A9F61704; Wed, 27 Jul 2022 16:50:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74C22C433C1; Wed, 27 Jul 2022 16:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940611; bh=uSjfjjmA0mMqQuqXklqFXawGwEGcYoWVmhQFzp2fvNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NSJLOwF7QSF00hUkoTsTpbKIqjzz54r/YrrFodowVmx7Uuf9wmWrqA3CBG2KLI+we 9Owa6voqYXb7/l75FqWKw7Y5xoJe02UkeKxHvWAWMNSI1sgrGbqlzpl4m/fzUrFgwd OwlQhphYDh61YX8drM3ucpc0gHzQE6J+cHyPhbXw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 085/158] net: lan966x: Fix usage of lan966x->mac_lock when entry is added Date: Wed, 27 Jul 2022 18:12:29 +0200 Message-Id: <20220727161024.897285986@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit 43243bb3195b0dc27741679471e23baed1efe98e ] To add an entry to the MAC table, it is required first to setup the entry and then issue a command for the MAC to learn the entry. So if it happens for two threads to add simultaneously an entry in MAC table then it would be a race condition. Fix this by using lan966x->mac_lock to protect the HW access. Fixes: fc0c3fe7486f2 ("net: lan966x: Add function lan966x_mac_ip_learn()") Signed-off-by: Horatiu Vultur Reviewed-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/microchip/lan966x/lan966x_mac.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_mac.c index 2d2b83c03796..4f8fd5cde950 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c @@ -75,6 +75,9 @@ static int __lan966x_mac_learn(struct lan966x *lan966x, i= nt pgid, unsigned int vid, enum macaccess_entry_type type) { + int ret; + + spin_lock(&lan966x->mac_lock); lan966x_mac_select(lan966x, mac, vid); =20 /* Issue a write command */ @@ -86,7 +89,10 @@ static int __lan966x_mac_learn(struct lan966x *lan966x, = int pgid, ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_LEARN), lan966x, ANA_MACACCESS); =20 - return lan966x_mac_wait_for_completion(lan966x); + ret =3D lan966x_mac_wait_for_completion(lan966x); + spin_unlock(&lan966x->mac_lock); + + return ret; } =20 /* The mask of the front ports is encoded inside the mac parameter via a c= all --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21A99C04A68 for ; Wed, 27 Jul 2022 17:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242642AbiG0Rh4 (ORCPT ); Wed, 27 Jul 2022 13:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242529AbiG0Rha (ORCPT ); Wed, 27 Jul 2022 13:37:30 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E18B245042; Wed, 27 Jul 2022 09:50:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 49A94CE2309; Wed, 27 Jul 2022 16:50:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54E90C433D6; Wed, 27 Jul 2022 16:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940614; bh=+8SJxx9RJkr5LTCCI4UBjOurlm0KCiWs5ONe1w8diZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uH4d9B9eg429FSpp8IddUCmqwyKO5uq9ZDvQu7Ec2uYTr1BZVs48F2sd4BD5NEJya Fas1SA7ByhgOHzieYhbNquOMmwxLpsEouYJLd/Z85kkQ37M7+uT4HbjNvQclIa4jdU 5E9dr4ldkmvTjIHvJDacbnzWivlFlS3Kbb/jmxZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 086/158] net: lan966x: Fix usage of lan966x->mac_lock when entry is removed Date: Wed, 27 Jul 2022 18:12:30 +0200 Message-Id: <20220727161024.927677733@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit 99343cfa4f7560abf933fff7ab3ea58a6905c917 ] To remove an entry to the MAC table, it is required first to setup the entry and then issue a command for the MAC to forget the entry. So if it happens for two threads to remove simultaneously an entry in MAC table then it would be a race condition. Fix this by using lan966x->mac_lock to protect the HW access. Fixes: e18aba8941b40 ("net: lan966x: add mactable support") Signed-off-by: Horatiu Vultur Reviewed-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../ethernet/microchip/lan966x/lan966x_mac.c | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_mac.c index 4f8fd5cde950..d0b8eba0a66d 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c @@ -119,11 +119,13 @@ int lan966x_mac_learn(struct lan966x *lan966x, int po= rt, return __lan966x_mac_learn(lan966x, port, false, mac, vid, type); } =20 -int lan966x_mac_forget(struct lan966x *lan966x, - const unsigned char mac[ETH_ALEN], - unsigned int vid, - enum macaccess_entry_type type) +static int lan966x_mac_forget_locked(struct lan966x *lan966x, + const unsigned char mac[ETH_ALEN], + unsigned int vid, + enum macaccess_entry_type type) { + lockdep_assert_held(&lan966x->mac_lock); + lan966x_mac_select(lan966x, mac, vid); =20 /* Issue a forget command */ @@ -134,6 +136,20 @@ int lan966x_mac_forget(struct lan966x *lan966x, return lan966x_mac_wait_for_completion(lan966x); } =20 +int lan966x_mac_forget(struct lan966x *lan966x, + const unsigned char mac[ETH_ALEN], + unsigned int vid, + enum macaccess_entry_type type) +{ + int ret; + + spin_lock(&lan966x->mac_lock); + ret =3D lan966x_mac_forget_locked(lan966x, mac, vid, type); + spin_unlock(&lan966x->mac_lock); + + return ret; +} + int lan966x_mac_cpu_learn(struct lan966x *lan966x, const char *addr, u16 v= id) { return lan966x_mac_learn(lan966x, PGID_CPU, addr, vid, ENTRYTYPE_LOCKED); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CF8AC04A68 for ; Wed, 27 Jul 2022 17:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242321AbiG0Rik (ORCPT ); Wed, 27 Jul 2022 13:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242653AbiG0RiD (ORCPT ); Wed, 27 Jul 2022 13:38:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D578086C27; Wed, 27 Jul 2022 09:50:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 09BDE616BD; Wed, 27 Jul 2022 16:50:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16A7AC433C1; Wed, 27 Jul 2022 16:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940617; bh=S0pWMV/TRcjMiJTSJysZSUB2PC/SsjxITO9QWcWCoMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rxr+1ZWryFBFCdb5UQbONkUKmBnfryXCztkS59EsOEC2VDIWl0PXBfCIjDa3+2LJr GS0u7tdeQs+K6rud937Njr2+YviQRYpC/2JiNg4svtH3evqKTcgHTdwoP03FuMyF3h OBhcHGqYU1/GJ3xergB+OHN+tQ0fIKG8C7PycYcY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 087/158] net: lan966x: Fix usage of lan966x->mac_lock inside lan966x_mac_irq_handler Date: Wed, 27 Jul 2022 18:12:31 +0200 Message-Id: <20220727161024.965216524@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit c1924684369762b112428a333ad00eac6ca89d96 ] The problem with this spin lock is that it was just protecting the list of the MAC entries in SW and not also the access to the MAC entries in HW. Because the access to HW is indirect, then it could happen to have race conditions. For example when SW introduced an entry in MAC table and the irq mac is trying to read something from the MAC. Update such that also the access to MAC entries in HW is protected by this lock. Fixes: 5ccd66e01cbef ("net: lan966x: add support for interrupts from analyz= er") Signed-off-by: Horatiu Vultur Reviewed-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../ethernet/microchip/lan966x/lan966x_mac.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_mac.c index d0b8eba0a66d..69e343b7f4af 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c @@ -183,7 +183,7 @@ static struct lan966x_mac_entry *lan966x_mac_alloc_entr= y(const unsigned char *ma { struct lan966x_mac_entry *mac_entry; =20 - mac_entry =3D kzalloc(sizeof(*mac_entry), GFP_KERNEL); + mac_entry =3D kzalloc(sizeof(*mac_entry), GFP_ATOMIC); if (!mac_entry) return NULL; =20 @@ -310,8 +310,8 @@ void lan966x_mac_purge_entries(struct lan966x *lan966x) spin_lock(&lan966x->mac_lock); list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, list) { - lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid, - ENTRYTYPE_LOCKED); + lan966x_mac_forget_locked(lan966x, mac_entry->mac, + mac_entry->vid, ENTRYTYPE_LOCKED); =20 list_del(&mac_entry->list); kfree(mac_entry); @@ -427,13 +427,14 @@ static void lan966x_mac_irq_process(struct lan966x *l= an966x, u32 row, if (WARN_ON(dest_idx >=3D lan966x->num_phys_ports)) continue; =20 + spin_lock(&lan966x->mac_lock); mac_entry =3D lan966x_mac_alloc_entry(mac, vid, dest_idx); - if (!mac_entry) + if (!mac_entry) { + spin_unlock(&lan966x->mac_lock); return; + } =20 mac_entry->row =3D row; - - spin_lock(&lan966x->mac_lock); list_add_tail(&mac_entry->list, &lan966x->mac_entries); spin_unlock(&lan966x->mac_lock); =20 @@ -455,6 +456,7 @@ irqreturn_t lan966x_mac_irq_handler(struct lan966x *lan= 966x) lan966x, ANA_MACTINDX); =20 while (1) { + spin_lock(&lan966x->mac_lock); lan_rmw(ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_SYNC_GET_NEXT), ANA_MACACCESS_MAC_TABLE_CMD, lan966x, ANA_MACACCESS); @@ -478,12 +480,15 @@ irqreturn_t lan966x_mac_irq_handler(struct lan966x *l= an966x) stop =3D false; =20 if (column =3D=3D LAN966X_MAC_COLUMNS - 1 && - index =3D=3D 0 && stop) + index =3D=3D 0 && stop) { + spin_unlock(&lan966x->mac_lock); break; + } =20 entry[column].mach =3D lan_rd(lan966x, ANA_MACHDATA); entry[column].macl =3D lan_rd(lan966x, ANA_MACLDATA); entry[column].maca =3D lan_rd(lan966x, ANA_MACACCESS); + spin_unlock(&lan966x->mac_lock); =20 /* Once all the columns are read process them */ if (column =3D=3D LAN966X_MAC_COLUMNS - 1) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BAF5C04A68 for ; Wed, 27 Jul 2022 17:39:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238403AbiG0Ri6 (ORCPT ); Wed, 27 Jul 2022 13:38:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242602AbiG0RiS (ORCPT ); Wed, 27 Jul 2022 13:38:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 161638722B; Wed, 27 Jul 2022 09:50:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB37F61709; Wed, 27 Jul 2022 16:50:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2034C433D7; Wed, 27 Jul 2022 16:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940620; bh=7FXiz8Wqs8s3IpD8TXzH/H16cPz+n1lRHTcYIBx3ioU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ExZQGXi9yVHqTuLPDOyNNF9mZyAIs9283yafi99xP01AChm1iwCKXaue2k0C+8Owv j5HjtaAqfflOrLYVwGVRvXxLlLHGIbQWPhtwEnd77lmfSGDehgS31bZCL3YeflWRrp HUoqci5nCzv/TiFGtApJJ8tQ4p+90dlyKzfX2o7E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 088/158] net: lan966x: Fix usage of lan966x->mac_lock when used by FDB Date: Wed, 27 Jul 2022 18:12:32 +0200 Message-Id: <20220727161025.007895912@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit 675c807ae26b267233b97cd5006979a6bb8d54d4 ] When the SW bridge was trying to add/remove entries to/from HW, the access to HW was not protected by any lock. In this way, it was possible to have race conditions. Fix this by using the lan966x->mac_lock to protect parallel access to HW for this cases. Fixes: 25ee9561ec622 ("net: lan966x: More MAC table functionality") Signed-off-by: Horatiu Vultur Reviewed-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../ethernet/microchip/lan966x/lan966x_mac.c | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c b/drivers= /net/ethernet/microchip/lan966x/lan966x_mac.c index 69e343b7f4af..5893770bfd94 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_mac.c @@ -201,7 +201,6 @@ static struct lan966x_mac_entry *lan966x_mac_find_entry= (struct lan966x *lan966x, struct lan966x_mac_entry *res =3D NULL; struct lan966x_mac_entry *mac_entry; =20 - spin_lock(&lan966x->mac_lock); list_for_each_entry(mac_entry, &lan966x->mac_entries, list) { if (mac_entry->vid =3D=3D vid && ether_addr_equal(mac, mac_entry->mac) && @@ -210,7 +209,6 @@ static struct lan966x_mac_entry *lan966x_mac_find_entry= (struct lan966x *lan966x, break; } } - spin_unlock(&lan966x->mac_lock); =20 return res; } @@ -253,8 +251,11 @@ int lan966x_mac_add_entry(struct lan966x *lan966x, str= uct lan966x_port *port, { struct lan966x_mac_entry *mac_entry; =20 - if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) + spin_lock(&lan966x->mac_lock); + if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) { + spin_unlock(&lan966x->mac_lock); return 0; + } =20 /* In case the entry already exists, don't add it again to SW, * just update HW, but we need to look in the actual HW because @@ -263,21 +264,25 @@ int lan966x_mac_add_entry(struct lan966x *lan966x, st= ruct lan966x_port *port, * add the entry but without the extern_learn flag. */ mac_entry =3D lan966x_mac_find_entry(lan966x, addr, vid, port->chip_port); - if (mac_entry) - return lan966x_mac_learn(lan966x, port->chip_port, - addr, vid, ENTRYTYPE_LOCKED); + if (mac_entry) { + spin_unlock(&lan966x->mac_lock); + goto mac_learn; + } =20 mac_entry =3D lan966x_mac_alloc_entry(addr, vid, port->chip_port); - if (!mac_entry) + if (!mac_entry) { + spin_unlock(&lan966x->mac_lock); return -ENOMEM; + } =20 - spin_lock(&lan966x->mac_lock); list_add_tail(&mac_entry->list, &lan966x->mac_entries); spin_unlock(&lan966x->mac_lock); =20 - lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED); lan966x_fdb_call_notifiers(SWITCHDEV_FDB_OFFLOADED, addr, vid, port->dev); =20 +mac_learn: + lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED); + return 0; } =20 @@ -291,8 +296,9 @@ int lan966x_mac_del_entry(struct lan966x *lan966x, cons= t unsigned char *addr, list) { if (mac_entry->vid =3D=3D vid && ether_addr_equal(addr, mac_entry->mac)) { - lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid, - ENTRYTYPE_LOCKED); + lan966x_mac_forget_locked(lan966x, mac_entry->mac, + mac_entry->vid, + ENTRYTYPE_LOCKED); =20 list_del(&mac_entry->list); kfree(mac_entry); @@ -428,6 +434,12 @@ static void lan966x_mac_irq_process(struct lan966x *la= n966x, u32 row, continue; =20 spin_lock(&lan966x->mac_lock); + mac_entry =3D lan966x_mac_find_entry(lan966x, mac, vid, dest_idx); + if (mac_entry) { + spin_unlock(&lan966x->mac_lock); + continue; + } + mac_entry =3D lan966x_mac_alloc_entry(mac, vid, dest_idx); if (!mac_entry) { spin_unlock(&lan966x->mac_lock); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEC79C04A68 for ; Wed, 27 Jul 2022 17:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242621AbiG0RkA (ORCPT ); Wed, 27 Jul 2022 13:40:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242766AbiG0RjM (ORCPT ); Wed, 27 Jul 2022 13:39:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6843661D6D; Wed, 27 Jul 2022 09:51:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 414AAB821BE; Wed, 27 Jul 2022 16:50:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D185C433D6; Wed, 27 Jul 2022 16:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940623; bh=0Hz8/hFoBN0GjaM6W/+HjXYAMPRkWM8xHaE1RB5/m1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ib8lxNaq2LOb+vqDINmyiIquxXVTXRVeD67UiGAHRbEkjSzGTtvixC+Cla8vZu5Kj AWXP23w3jA32iwJ1f5paZjZ/mIIyuscClipSSd0VzvGrR3ZTRH1lGwJ7Il6/Ukxz54 qbTXK0i9WCTKRIgaF5BHZC94a+0g/CCzkb6MNwPs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dawid Lukwinski , Jan Sokolowski , Konrad Jankowski , Tony Nguyen , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 089/158] i40e: Fix erroneous adapter reinitialization during recovery process Date: Wed, 27 Jul 2022 18:12:33 +0200 Message-Id: <20220727161025.042585831@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dawid Lukwinski [ Upstream commit f838a63369818faadec4ad1736cfbd20ab5da00e ] Fix an issue when driver incorrectly detects state of recovery process and erroneously reinitializes interrupts, which results in a kernel error and call trace message. The issue was caused by a combination of two factors: 1. Assuming the EMP reset issued after completing firmware recovery means the whole recovery process is complete. 2. Erroneous reinitialization of interrupt vector after detecting the above mentioned EMP reset. Fixes (1) by changing how recovery state change is detected and (2) by adjusting the conditional expression to ensure using proper interrupt reinitialization method, depending on the situation. Fixes: 4ff0ee1af016 ("i40e: Introduce recovery mode support") Signed-off-by: Dawid Lukwinski Signed-off-by: Jan Sokolowski Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Link: https://lore.kernel.org/r/20220715214542.2968762-1-anthony.l.nguyen@i= ntel.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethe= rnet/intel/i40e/i40e_main.c index 77eb9c726205..6f01bffd7e5c 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -10645,7 +10645,7 @@ static int i40e_reset(struct i40e_pf *pf) **/ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquir= ed) { - int old_recovery_mode_bit =3D test_bit(__I40E_RECOVERY_MODE, pf->state); + const bool is_recovery_mode_reported =3D i40e_check_recovery_mode(pf); struct i40e_vsi *vsi =3D pf->vsi[pf->lan_vsi]; struct i40e_hw *hw =3D &pf->hw; i40e_status ret; @@ -10653,13 +10653,11 @@ static void i40e_rebuild(struct i40e_pf *pf, bool= reinit, bool lock_acquired) int v; =20 if (test_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state) && - i40e_check_recovery_mode(pf)) { + is_recovery_mode_reported) i40e_set_ethtool_ops(pf->vsi[pf->lan_vsi]->netdev); - } =20 if (test_bit(__I40E_DOWN, pf->state) && - !test_bit(__I40E_RECOVERY_MODE, pf->state) && - !old_recovery_mode_bit) + !test_bit(__I40E_RECOVERY_MODE, pf->state)) goto clear_recovery; dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n"); =20 @@ -10686,13 +10684,12 @@ static void i40e_rebuild(struct i40e_pf *pf, bool= reinit, bool lock_acquired) * accordingly with regard to resources initialization * and deinitialization */ - if (test_bit(__I40E_RECOVERY_MODE, pf->state) || - old_recovery_mode_bit) { + if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { if (i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities)) goto end_unlock; =20 - if (test_bit(__I40E_RECOVERY_MODE, pf->state)) { + if (is_recovery_mode_reported) { /* we're staying in recovery mode so we'll reinitialize * misc vector here */ --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0486EC04A68 for ; Wed, 27 Jul 2022 17:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241840AbiG0RiC (ORCPT ); Wed, 27 Jul 2022 13:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242244AbiG0Rhg (ORCPT ); Wed, 27 Jul 2022 13:37:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE48E61B26; Wed, 27 Jul 2022 09:50:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3DC646171D; Wed, 27 Jul 2022 16:50:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50E7AC433D6; Wed, 27 Jul 2022 16:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940625; bh=sug5mC5+Ufrz0rs1ltH6b7wUJuRja1OEsV+BxJmRvBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kib4pjsxIyVqaAvb9ps64362dOOaX+BrCz+YvEYvnW+4GZdr5Tg0+50/9nfBgF+Ic CFtKei/7qbe7Vx3gaLoB2pUkDuW+JlMVmCzMMfTITgN/4bmRFqrqCOcnH1o3fORZIS LC33Yz+L9++B1ff0V0GlbBxEmvE5NDxThlfIgcvo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Piotr Skajewski , Marek Szlosek , Tony Nguyen , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 090/158] ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero Date: Wed, 27 Jul 2022 18:12:34 +0200 Message-Id: <20220727161025.077884206@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Piotr Skajewski [ Upstream commit 1e53834ce541d4fe271cdcca7703e50be0a44f8a ] It is possible to disable VFs while the PF driver is processing requests from the VF driver. This can result in a panic. BUG: unable to handle kernel paging request at 000000000000106c PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI CPU: 8 PID: 0 Comm: swapper/8 Kdump: loaded Tainted: G I --------- - Hardware name: Dell Inc. PowerEdge R740/06WXJT, BIOS 2.8.2 08/27/2020 RIP: 0010:ixgbe_msg_task+0x4c8/0x1690 [ixgbe] Code: 00 00 48 8d 04 40 48 c1 e0 05 89 7c 24 24 89 fd 48 89 44 24 10 83 ff 01 0f 84 b8 04 00 00 4c 8b 64 24 10 4d 03 a5 48 22 00 00 <41> 80 7c 24 4c 00 0f 84 8a 03 00 00 0f b7 c7 83 f8 08 0f 84 8f 0a RSP: 0018:ffffb337869f8df8 EFLAGS: 00010002 RAX: 0000000000001020 RBX: 0000000000000000 RCX: 000000000000002b RDX: 0000000000000002 RSI: 0000000000000008 RDI: 0000000000000006 RBP: 0000000000000006 R08: 0000000000000002 R09: 0000000000029780 R10: 00006957d8f42832 R11: 0000000000000000 R12: 0000000000001020 R13: ffff8a00e8978ac0 R14: 000000000000002b R15: ffff8a00e8979c80 FS: 0000000000000000(0000) GS:ffff8a07dfd00000(0000) knlGS:00000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000106c CR3: 0000000063e10004 CR4: 00000000007726e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: ? ttwu_do_wakeup+0x19/0x140 ? try_to_wake_up+0x1cd/0x550 ? ixgbevf_update_xcast_mode+0x71/0xc0 [ixgbevf] ixgbe_msix_other+0x17e/0x310 [ixgbe] __handle_irq_event_percpu+0x40/0x180 handle_irq_event_percpu+0x30/0x80 handle_irq_event+0x36/0x53 handle_edge_irq+0x82/0x190 handle_irq+0x1c/0x30 do_IRQ+0x49/0xd0 common_interrupt+0xf/0xf This can be eventually be reproduced with the following script: while : do echo 63 > /sys/class/net//device/sriov_numvfs sleep 1 echo 0 > /sys/class/net//device/sriov_numvfs sleep 1 done Add lock when disabling SR-IOV to prevent process VF mailbox communication. Fixes: d773d1310625 ("ixgbe: Fix memory leak when SR-IOV VFs are direct ass= igned") Signed-off-by: Piotr Skajewski Tested-by: Marek Szlosek Signed-off-by: Tony Nguyen Link: https://lore.kernel.org/r/20220715214456.2968711-1-anthony.l.nguyen@i= ntel.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 1 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++ drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/etherne= t/intel/ixgbe/ixgbe.h index 921a4d977d65..8813b4dd6872 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -779,6 +779,7 @@ struct ixgbe_adapter { #ifdef CONFIG_IXGBE_IPSEC struct ixgbe_ipsec *ipsec; #endif /* CONFIG_IXGBE_IPSEC */ + spinlock_t vfs_lock; }; =20 static inline int ixgbe_determine_xdp_q_idx(int cpu) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/et= hernet/intel/ixgbe/ixgbe_main.c index c4a4954aa317..6c403f112d29 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6402,6 +6402,9 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapte= r, /* n-tuple support exists, always init our spinlock */ spin_lock_init(&adapter->fdir_perfect_lock); =20 + /* init spinlock to avoid concurrency of VF resources */ + spin_lock_init(&adapter->vfs_lock); + #ifdef CONFIG_IXGBE_DCB ixgbe_init_dcb(adapter); #endif diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/e= thernet/intel/ixgbe/ixgbe_sriov.c index d4e63f0644c3..a1e69c734863 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -205,10 +205,13 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter= , unsigned int max_vfs) int ixgbe_disable_sriov(struct ixgbe_adapter *adapter) { unsigned int num_vfs =3D adapter->num_vfs, vf; + unsigned long flags; int rss; =20 + spin_lock_irqsave(&adapter->vfs_lock, flags); /* set num VFs to 0 to prevent access to vfinfo */ adapter->num_vfs =3D 0; + spin_unlock_irqrestore(&adapter->vfs_lock, flags); =20 /* put the reference to all of the vf devices */ for (vf =3D 0; vf < num_vfs; ++vf) { @@ -1355,8 +1358,10 @@ static void ixgbe_rcv_ack_from_vf(struct ixgbe_adapt= er *adapter, u32 vf) void ixgbe_msg_task(struct ixgbe_adapter *adapter) { struct ixgbe_hw *hw =3D &adapter->hw; + unsigned long flags; u32 vf; =20 + spin_lock_irqsave(&adapter->vfs_lock, flags); for (vf =3D 0; vf < adapter->num_vfs; vf++) { /* process any reset requests */ if (!ixgbe_check_for_rst(hw, vf)) @@ -1370,6 +1375,7 @@ void ixgbe_msg_task(struct ixgbe_adapter *adapter) if (!ixgbe_check_for_ack(hw, vf)) ixgbe_rcv_ack_from_vf(adapter, vf); } + spin_unlock_irqrestore(&adapter->vfs_lock, flags); } =20 static inline void ixgbe_ping_vf(struct ixgbe_adapter *adapter, int vf) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44B90C3F6B0 for ; Wed, 27 Jul 2022 17:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242673AbiG0RjD (ORCPT ); Wed, 27 Jul 2022 13:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242638AbiG0RiS (ORCPT ); Wed, 27 Jul 2022 13:38:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44B9D87233; Wed, 27 Jul 2022 09:50:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4716561700; Wed, 27 Jul 2022 16:50:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21BF5C433D6; Wed, 27 Jul 2022 16:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940628; bh=ZuA+typshrCmrsRBPWqRteM1Ok9S+840Vcu8naMnhHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aeCA4e2KrTGqMp2F2A+KY11XdaM1SZrJ77zLW4pEruPMCDD39sB1Ogw3ItqcDkWfl 4C6fScv/MwvKlFGUmM1DmgCO8a3j3lKxpK29zUUvDySx12lxsHZTiOa9WZzzNCFhBQ qF/OJUNaE6d8ucg5UKCb+CnFere9Ebwx+wuN4IxY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucian Banu , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 091/158] net: dsa: fix dsa_port_vlan_filtering when global Date: Wed, 27 Jul 2022 18:12:35 +0200 Message-Id: <20220727161025.117414644@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit 4db2a5ef4ccbe6d138828284cfab241b434b5d95 ] The blamed refactoring commit changed a "port" iterator with "other_dp", but still looked at the slave_dev of the dp outside the loop, instead of other_dp->slave from the loop. As a result, dsa_port_vlan_filtering() would not call dsa_slave_manage_vlan_filtering() except for the port in cause, and not for all switch ports as expected. Fixes: d0004a020bb5 ("net: dsa: remove the "dsa_to_port in a loop" antipatt= ern from the core") Reported-by: Lucian Banu Signed-off-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/dsa/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index bdccb613285d..4b72513cc9e4 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -752,7 +752,7 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool v= lan_filtering, ds->vlan_filtering =3D vlan_filtering; =20 dsa_switch_for_each_user_port(other_dp, ds) { - struct net_device *slave =3D dp->slave; + struct net_device *slave =3D other_dp->slave; =20 /* We might be called in the unbind path, so not * all slave devices might still be registered. --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9408C19F2B for ; Wed, 27 Jul 2022 17:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241666AbiG0Rjk (ORCPT ); Wed, 27 Jul 2022 13:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242658AbiG0Ri3 (ORCPT ); Wed, 27 Jul 2022 13:38:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F36E787228; Wed, 27 Jul 2022 09:50:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8122BB821D4; Wed, 27 Jul 2022 16:50:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D13E8C433C1; Wed, 27 Jul 2022 16:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940635; bh=1c0hP79Llw0SJOxtm92TfeWvvwn6BhuVT9xoXPPxJQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xAzXpBJqEtejT+5I0Hzgj/KrmMzweuLxrvj6Guamq4vrnmwO9nU/amIFm+nuXacX8 m8SH3idv5veT4j13glHm4Vecg4J0YuN+8Au2LZYirAUTQJJ9cCl1mU23B3d3CO08ix gJxgQGHbFzrXEE6ZPmlyuoq6/Gc96QBuaGyaSDL0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 092/158] net: dsa: move reset of VLAN filtering to dsa_port_switchdev_unsync_attrs Date: Wed, 27 Jul 2022 18:12:36 +0200 Message-Id: <20220727161025.151576087@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit 8e9e678e4758b69b6231d3ad4d26d3381fdb5f3f ] In dsa_port_switchdev_unsync_attrs() there is a comment that resetting the VLAN filtering isn't done where it is expected. And since commit 108dc8741c20 ("net: dsa: Avoid cross-chip syncing of VLAN filtering"), there is no reason to handle this in switch.c either. Therefore, move the logic to port.c, and adapt it slightly to the data structures and naming conventions from there. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/dsa/port.c | 60 +++++++++++++++++++++++++++++++++++++++++++++--- net/dsa/switch.c | 58 ---------------------------------------------- 2 files changed, 57 insertions(+), 61 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index 4b72513cc9e4..6aab5768ef96 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -242,6 +242,59 @@ void dsa_port_disable(struct dsa_port *dp) rtnl_unlock(); } =20 +static void dsa_port_reset_vlan_filtering(struct dsa_port *dp, + struct dsa_bridge bridge) +{ + struct netlink_ext_ack extack =3D {0}; + bool change_vlan_filtering =3D false; + struct dsa_switch *ds =3D dp->ds; + bool vlan_filtering; + int err; + + if (ds->needs_standalone_vlan_filtering && + !br_vlan_enabled(bridge.dev)) { + change_vlan_filtering =3D true; + vlan_filtering =3D true; + } else if (!ds->needs_standalone_vlan_filtering && + br_vlan_enabled(bridge.dev)) { + change_vlan_filtering =3D true; + vlan_filtering =3D false; + } + + /* If the bridge was vlan_filtering, the bridge core doesn't trigger an + * event for changing vlan_filtering setting upon slave ports leaving + * it. That is a good thing, because that lets us handle it and also + * handle the case where the switch's vlan_filtering setting is global + * (not per port). When that happens, the correct moment to trigger the + * vlan_filtering callback is only when the last port leaves the last + * VLAN-aware bridge. + */ + if (change_vlan_filtering && ds->vlan_filtering_is_global) { + dsa_switch_for_each_port(dp, ds) { + struct net_device *br =3D dsa_port_bridge_dev_get(dp); + + if (br && br_vlan_enabled(br)) { + change_vlan_filtering =3D false; + break; + } + } + } + + if (!change_vlan_filtering) + return; + + err =3D dsa_port_vlan_filtering(dp, vlan_filtering, &extack); + if (extack._msg) { + dev_err(ds->dev, "port %d: %s\n", dp->index, + extack._msg); + } + if (err && err !=3D -EOPNOTSUPP) { + dev_err(ds->dev, + "port %d failed to reset VLAN filtering to %d: %pe\n", + dp->index, vlan_filtering, ERR_PTR(err)); + } +} + static int dsa_port_inherit_brport_flags(struct dsa_port *dp, struct netlink_ext_ack *extack) { @@ -313,7 +366,8 @@ static int dsa_port_switchdev_sync_attrs(struct dsa_por= t *dp, return 0; } =20 -static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp) +static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp, + struct dsa_bridge bridge) { /* Configure the port for standalone mode (no address learning, * flood everything). @@ -333,7 +387,7 @@ static void dsa_port_switchdev_unsync_attrs(struct dsa_= port *dp) */ dsa_port_set_state_now(dp, BR_STATE_FORWARDING, true); =20 - /* VLAN filtering is handled by dsa_switch_bridge_leave */ + dsa_port_reset_vlan_filtering(dp, bridge); =20 /* Ageing time may be global to the switch chip, so don't change it * here because we have no good reason (or value) to change it to. @@ -502,7 +556,7 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct = net_device *br) "port %d failed to notify DSA_NOTIFIER_BRIDGE_LEAVE: %pe\n", dp->index, ERR_PTR(err)); =20 - dsa_port_switchdev_unsync_attrs(dp); + dsa_port_switchdev_unsync_attrs(dp, info.bridge); } =20 int dsa_port_lag_change(struct dsa_port *dp, diff --git a/net/dsa/switch.c b/net/dsa/switch.c index d25cd1da3eb3..d8a80cf9742c 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -115,62 +115,10 @@ static int dsa_switch_bridge_join(struct dsa_switch *= ds, return 0; } =20 -static int dsa_switch_sync_vlan_filtering(struct dsa_switch *ds, - struct dsa_notifier_bridge_info *info) -{ - struct netlink_ext_ack extack =3D {0}; - bool change_vlan_filtering =3D false; - bool vlan_filtering; - struct dsa_port *dp; - int err; - - if (ds->needs_standalone_vlan_filtering && - !br_vlan_enabled(info->bridge.dev)) { - change_vlan_filtering =3D true; - vlan_filtering =3D true; - } else if (!ds->needs_standalone_vlan_filtering && - br_vlan_enabled(info->bridge.dev)) { - change_vlan_filtering =3D true; - vlan_filtering =3D false; - } - - /* If the bridge was vlan_filtering, the bridge core doesn't trigger an - * event for changing vlan_filtering setting upon slave ports leaving - * it. That is a good thing, because that lets us handle it and also - * handle the case where the switch's vlan_filtering setting is global - * (not per port). When that happens, the correct moment to trigger the - * vlan_filtering callback is only when the last port leaves the last - * VLAN-aware bridge. - */ - if (change_vlan_filtering && ds->vlan_filtering_is_global) { - dsa_switch_for_each_port(dp, ds) { - struct net_device *br =3D dsa_port_bridge_dev_get(dp); - - if (br && br_vlan_enabled(br)) { - change_vlan_filtering =3D false; - break; - } - } - } - - if (change_vlan_filtering) { - err =3D dsa_port_vlan_filtering(dsa_to_port(ds, info->port), - vlan_filtering, &extack); - if (extack._msg) - dev_err(ds->dev, "port %d: %s\n", info->port, - extack._msg); - if (err && err !=3D -EOPNOTSUPP) - return err; - } - - return 0; -} - static int dsa_switch_bridge_leave(struct dsa_switch *ds, struct dsa_notifier_bridge_info *info) { struct dsa_switch_tree *dst =3D ds->dst; - int err; =20 if (dst->index =3D=3D info->tree_index && ds->index =3D=3D info->sw_index= && ds->ops->port_bridge_leave) @@ -182,12 +130,6 @@ static int dsa_switch_bridge_leave(struct dsa_switch *= ds, info->sw_index, info->port, info->bridge); =20 - if (ds->dst->index =3D=3D info->tree_index && ds->index =3D=3D info->sw_i= ndex) { - err =3D dsa_switch_sync_vlan_filtering(ds, info); - if (err) - return err; - } - return 0; } =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64CA4C19F2B for ; Wed, 27 Jul 2022 17:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242718AbiG0RjG (ORCPT ); Wed, 27 Jul 2022 13:39:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242674AbiG0RiT (ORCPT ); Wed, 27 Jul 2022 13:38:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D945C8720C; Wed, 27 Jul 2022 09:50:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8263061703; Wed, 27 Jul 2022 16:50:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AC19C433D6; Wed, 27 Jul 2022 16:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940637; bh=o+akZ35ZAEw0I3rv/1uVKaBlVR4impvq0HOGY5wcKYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mR3snXN57K0UJiorfNTINx2sh+2vxSb4hw6DXTC1zcb5SMWnaTxZA7lzYzc5sb8cz 7uVeKdzoZbOJPfPljJtVeYGPZyMudvwettZGcuNiURcx7TQXJ56Pwqe7fAIuZzBCOm dQQWwMJQMRvNryxaZCyvxSu0CM0+daaxvLSbD3RE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 093/158] net: dsa: fix NULL pointer dereference in dsa_port_reset_vlan_filtering Date: Wed, 27 Jul 2022 18:12:37 +0200 Message-Id: <20220727161025.191624282@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit 1699b4d502eda3c7ea4070debad3ee570b5091b1 ] The "ds" iterator variable used in dsa_port_reset_vlan_filtering() -> dsa_switch_for_each_port() overwrites the "dp" received as argument, which is later used to call dsa_port_vlan_filtering() proper. As a result, switches which do enter that code path (the ones with vlan_filtering_is_global=3Dtrue) will dereference an invalid dp in dsa_port_reset_vlan_filtering() after leaving a VLAN-aware bridge. Use a dedicated "other_dp" iterator variable to avoid this from happening. Fixes: d0004a020bb5 ("net: dsa: remove the "dsa_to_port in a loop" antipatt= ern from the core") Signed-off-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/dsa/port.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index 6aab5768ef96..7bc79e28d48e 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -248,6 +248,7 @@ static void dsa_port_reset_vlan_filtering(struct dsa_po= rt *dp, struct netlink_ext_ack extack =3D {0}; bool change_vlan_filtering =3D false; struct dsa_switch *ds =3D dp->ds; + struct dsa_port *other_dp; bool vlan_filtering; int err; =20 @@ -270,8 +271,8 @@ static void dsa_port_reset_vlan_filtering(struct dsa_po= rt *dp, * VLAN-aware bridge. */ if (change_vlan_filtering && ds->vlan_filtering_is_global) { - dsa_switch_for_each_port(dp, ds) { - struct net_device *br =3D dsa_port_bridge_dev_get(dp); + dsa_switch_for_each_port(other_dp, ds) { + struct net_device *br =3D dsa_port_bridge_dev_get(other_dp); =20 if (br && br_vlan_enabled(br)) { change_vlan_filtering =3D false; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30347C04A68 for ; Wed, 27 Jul 2022 17:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242674AbiG0RkH (ORCPT ); Wed, 27 Jul 2022 13:40:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242779AbiG0RjO (ORCPT ); Wed, 27 Jul 2022 13:39:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 515B061D51; Wed, 27 Jul 2022 09:51:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F0DD4B821D5; Wed, 27 Jul 2022 16:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43BA7C433C1; Wed, 27 Jul 2022 16:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940640; bh=AIwM/I+phVjD+oYqdvliQ+tHcIar9EIALVjDGeHJd4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SdxgVNPy9gkg8N/zpHCKHMvrmakYOTzwaiLB8RDNBUpDoLA8mQwMpDC5HpBQdZKE2 V8c1Y6UJSIEUQQQ2lX6xxCC0OGczpQcSiP77edbvTKU/h/4XIprtsulNB7C9L6DgRr KMozNEfUv3/WdmMvOZfkokBY+g5GcvhemahF4qxg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wong Vee Khee , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.18 094/158] net: stmmac: remove redunctant disable xPCS EEE call Date: Wed, 27 Jul 2022 18:12:38 +0200 Message-Id: <20220727161025.231313079@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wong Vee Khee [ Upstream commit da791bac104a3169b05b54270afe75daacba4641 ] Disable is done in stmmac_init_eee() on the event of MAC link down. Since setting enable/disable EEE via ethtool will eventually trigger a MAC down, removing this redunctant call in stmmac_ethtool.c to avoid calling xpcs_config_eee() twice. Fixes: d4aeaed80b0e ("net: stmmac: trigger PCS EEE to turn off on link down= ") Signed-off-by: Wong Vee Khee Link: https://lore.kernel.org/r/20220715122402.1017470-1-vee.khee.wong@linu= x.intel.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers= /net/ethernet/stmicro/stmmac/stmmac_ethtool.c index abfb3cd5958d..9c3055ee2608 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -803,14 +803,6 @@ static int stmmac_ethtool_op_set_eee(struct net_device= *dev, netdev_warn(priv->dev, "Setting EEE tx-lpi is not supported\n"); =20 - if (priv->hw->xpcs) { - ret =3D xpcs_config_eee(priv->hw->xpcs, - priv->plat->mult_fact_100ns, - edata->eee_enabled); - if (ret) - return ret; - } - if (!edata->eee_enabled) stmmac_disable_eee_mode(priv); =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F9EFC04A68 for ; Wed, 27 Jul 2022 17:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242705AbiG0RkO (ORCPT ); Wed, 27 Jul 2022 13:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242840AbiG0RjV (ORCPT ); Wed, 27 Jul 2022 13:39:21 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D389B88744; Wed, 27 Jul 2022 09:51:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 104AECE2318; Wed, 27 Jul 2022 16:50:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0027BC433C1; Wed, 27 Jul 2022 16:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940643; bh=eud4DlPytkXEZKbDVsexOqCQ7QIhHImI570wrqSzK54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ce34G7LNOb6rLKhrEQtVlchvSmxWK6erQI4IyB1eNOliyeihLSQlzLy5cVYfNBiqZ KXxWoIOno/36w6MVyw8vqJfkayR113UbH6YS9KMSleB4Y3KbuSyEKBl1BuWJ+Dkeva ngWqUtjob8weCk28XlJthD8QbnuzojqipmabKGHI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Andy Shevchenko , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.18 095/158] gpio: pca953x: only use single read/write for No AI mode Date: Wed, 27 Jul 2022 18:12:39 +0200 Message-Id: <20220727161025.261253948@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Haibo Chen [ Upstream commit db8edaa09d7461ec08672a92a2eef63d5882bb79 ] For the device use NO AI mode(not support auto address increment), only use the single read/write when config the regmap. We meet issue on PCA9557PW on i.MX8QXP/DXL evk board, this device do not support AI mode, but when do the regmap sync, regmap will sync 3 byte data to register 1, logically this means write first data to register 1, write second data to register 2, write third data to register 3. But this device do not support AI mode, finally, these three data write only into register 1 one by one. the reault is the value of register 1 alway equal to the latest data, here is the third data, no operation happened on register 2 and register 3. This is not what we expect. Fixes: 49427232764d ("gpio: pca953x: Perform basic regmap conversion") Signed-off-by: Haibo Chen Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpio/gpio-pca953x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 33683295a0bf..f334c8556a22 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -351,6 +351,9 @@ static const struct regmap_config pca953x_i2c_regmap = =3D { .reg_bits =3D 8, .val_bits =3D 8, =20 + .use_single_read =3D true, + .use_single_write =3D true, + .readable_reg =3D pca953x_readable_register, .writeable_reg =3D pca953x_writeable_register, .volatile_reg =3D pca953x_volatile_register, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8885CC04A68 for ; Wed, 27 Jul 2022 17:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242786AbiG0RqJ (ORCPT ); Wed, 27 Jul 2022 13:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242731AbiG0Rn7 (ORCPT ); Wed, 27 Jul 2022 13:43:59 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A9189EBD; Wed, 27 Jul 2022 09:52:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id BDF21CE22F9; Wed, 27 Jul 2022 16:52:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB2C8C433C1; Wed, 27 Jul 2022 16:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940759; bh=OUAQxsIyHhoQKpoTT2pFpB3kZknsg4snkdYeH8FRRwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OiZhYIF5aPSRjoNI+1HR5Z0JAPoUN5UeQSQG0fnEb3gSzhKPebUTgNGiiNenAFaFx /JaHYdqumdOWrhmUdo5LEQn5+eBPpNP6DTCvKKZQuzwAcGqRtGOIj20tgqHjAuHmRU qmvQuq4dtR1W1J+UlcNWkxs3dPdqdQhADHp0rXDo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Andy Shevchenko , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.18 096/158] gpio: pca953x: use the correct range when do regmap sync Date: Wed, 27 Jul 2022 18:12:40 +0200 Message-Id: <20220727161025.300630697@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Haibo Chen [ Upstream commit 2abc17a93867dc816f0ed9d32021dda8078e7330 ] regmap will sync a range of registers, here use the correct range to make sure the sync do not touch other unexpected registers. Find on pca9557pw on imx8qxp/dxl evk board, this device support 8 pin, so only need one register(8 bits) to cover all the 8 pins's property setting. But when sync the output, we find it actually update two registers, output register and the following register. Fixes: b76574300504 ("gpio: pca953x: Restore registers after suspend/resume= cycle") Fixes: ec82d1eba346 ("gpio: pca953x: Zap ad-hoc reg_output cache") Fixes: 0f25fda840a9 ("gpio: pca953x: Zap ad-hoc reg_direction cache") Signed-off-by: Haibo Chen Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpio/gpio-pca953x.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index f334c8556a22..60b7616dd4aa 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -900,12 +900,12 @@ static int device_pca95xx_init(struct pca953x_chip *c= hip, u32 invert) int ret; =20 ret =3D regcache_sync_region(chip->regmap, chip->regs->output, - chip->regs->output + NBANK(chip)); + chip->regs->output + NBANK(chip) - 1); if (ret) goto out; =20 ret =3D regcache_sync_region(chip->regmap, chip->regs->direction, - chip->regs->direction + NBANK(chip)); + chip->regs->direction + NBANK(chip) - 1); if (ret) goto out; =20 @@ -1118,14 +1118,14 @@ static int pca953x_regcache_sync(struct device *dev) * sync these registers first and only then sync the rest. */ regaddr =3D pca953x_recalc_addr(chip, chip->regs->direction, 0); - ret =3D regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip)= ); + ret =3D regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip)= - 1); if (ret) { dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret); return ret; } =20 regaddr =3D pca953x_recalc_addr(chip, chip->regs->output, 0); - ret =3D regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip)= ); + ret =3D regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip)= - 1); if (ret) { dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret); return ret; @@ -1135,7 +1135,7 @@ static int pca953x_regcache_sync(struct device *dev) if (chip->driver_data & PCA_PCAL) { regaddr =3D pca953x_recalc_addr(chip, PCAL953X_IN_LATCH, 0); ret =3D regcache_sync_region(chip->regmap, regaddr, - regaddr + NBANK(chip)); + regaddr + NBANK(chip) - 1); if (ret) { dev_err(dev, "Failed to sync INT latch registers: %d\n", ret); @@ -1144,7 +1144,7 @@ static int pca953x_regcache_sync(struct device *dev) =20 regaddr =3D pca953x_recalc_addr(chip, PCAL953X_INT_MASK, 0); ret =3D regcache_sync_region(chip->regmap, regaddr, - regaddr + NBANK(chip)); + regaddr + NBANK(chip) - 1); if (ret) { dev_err(dev, "Failed to sync INT mask registers: %d\n", ret); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEFB6C04A68 for ; Wed, 27 Jul 2022 17:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242755AbiG0Rko (ORCPT ); Wed, 27 Jul 2022 13:40:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242936AbiG0Rjc (ORCPT ); Wed, 27 Jul 2022 13:39:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5B4D88CC3; Wed, 27 Jul 2022 09:51:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E9258616ED; Wed, 27 Jul 2022 16:51:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0172AC433D6; Wed, 27 Jul 2022 16:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940665; bh=BFJdDl0BVAGoHtb4izvkJFUW5xUjgpjEeVVSQdffYQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XX4yihu5iT90RDwCPIgPp5TVLt+tx8yOWaITc85Nt0SlkwcQ7gkaQ+bWBITFZb0EN sb4tVYC4C/zOLH6FSBx2niPq7kgaV71T2vCbTSfk/4WsIgDEeRE8tzyAyiOCBMadvW 80+Nr6frLUvOnpvcrylNKPwvNr7ksWF32MFMKk5E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haibo Chen , Andy Shevchenko , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.18 097/158] gpio: pca953x: use the correct register address when regcache sync during init Date: Wed, 27 Jul 2022 18:12:41 +0200 Message-Id: <20220727161025.335410255@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Haibo Chen [ Upstream commit b8c768ccdd8338504fb78370747728d5002b1b5a ] For regcache_sync_region, we need to use pca953x_recalc_addr() to get the real register address. Fixes: ec82d1eba346 ("gpio: pca953x: Zap ad-hoc reg_output cache") Fixes: 0f25fda840a9 ("gpio: pca953x: Zap ad-hoc reg_direction cache") Signed-off-by: Haibo Chen Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpio/gpio-pca953x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 60b7616dd4aa..64befd6f702b 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -897,15 +897,18 @@ static int pca953x_irq_setup(struct pca953x_chip *chi= p, static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert) { DECLARE_BITMAP(val, MAX_LINE); + u8 regaddr; int ret; =20 - ret =3D regcache_sync_region(chip->regmap, chip->regs->output, - chip->regs->output + NBANK(chip) - 1); + regaddr =3D pca953x_recalc_addr(chip, chip->regs->output, 0); + ret =3D regcache_sync_region(chip->regmap, regaddr, + regaddr + NBANK(chip) - 1); if (ret) goto out; =20 - ret =3D regcache_sync_region(chip->regmap, chip->regs->direction, - chip->regs->direction + NBANK(chip) - 1); + regaddr =3D pca953x_recalc_addr(chip, chip->regs->direction, 0); + ret =3D regcache_sync_region(chip->regmap, regaddr, + regaddr + NBANK(chip) - 1); if (ret) goto out; =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 068AAC04A68 for ; Wed, 27 Jul 2022 17:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242875AbiG0Rlw (ORCPT ); Wed, 27 Jul 2022 13:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242740AbiG0RlO (ORCPT ); Wed, 27 Jul 2022 13:41:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B0F653D3D; Wed, 27 Jul 2022 09:51:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 23EC160DDB; Wed, 27 Jul 2022 16:51:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 080D9C433D7; Wed, 27 Jul 2022 16:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940695; bh=ZAE4Fdr+XHc995+dUbbMNpWrwfG+1pIU5PZ7h19nfZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rtUxwRBa1NP+UpP9wejZtQoUHSPFJh8KtrTd2U47MmlWZRhi4loWiGXSsmyanh9XR LNUVbTqZcIrPh/o8dp1SRahMO0Jjaxd8pBEP8mmtb2TzW094vWgSqIyot4P2TIBr2i nMSThrvKKxYnzi+Iy8v3VgSbjvaxQ9y0pAf3hRaI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hristo Venev , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 098/158] be2net: Fix buffer overflow in be_get_module_eeprom Date: Wed, 27 Jul 2022 18:12:42 +0200 Message-Id: <20220727161025.375372301@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hristo Venev [ Upstream commit d7241f679a59cfe27f92cb5c6272cb429fb1f7ec ] be_cmd_read_port_transceiver_data assumes that it is given a buffer that is at least PAGE_DATA_LEN long, or twice that if the module supports SFF 8472. However, this is not always the case. Fix this by passing the desired offset and length to be_cmd_read_port_transceiver_data so that we only copy the bytes once. Fixes: e36edd9d26cf ("be2net: add ethtool "-m" option support") Signed-off-by: Hristo Venev Link: https://lore.kernel.org/r/20220716085134.6095-1-hristo@venev.name Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/emulex/benet/be_cmds.c | 10 +++--- drivers/net/ethernet/emulex/benet/be_cmds.h | 2 +- .../net/ethernet/emulex/benet/be_ethtool.c | 31 ++++++++++++------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethe= rnet/emulex/benet/be_cmds.c index 528eb0f223b1..b4f5e57d0285 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -2287,7 +2287,7 @@ int be_cmd_get_beacon_state(struct be_adapter *adapte= r, u8 port_num, u32 *state) =20 /* Uses sync mcc */ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, - u8 page_num, u8 *data) + u8 page_num, u32 off, u32 len, u8 *data) { struct be_dma_mem cmd; struct be_mcc_wrb *wrb; @@ -2321,10 +2321,10 @@ int be_cmd_read_port_transceiver_data(struct be_ada= pter *adapter, req->port =3D cpu_to_le32(adapter->hba_port_num); req->page_num =3D cpu_to_le32(page_num); status =3D be_mcc_notify_wait(adapter); - if (!status) { + if (!status && len > 0) { struct be_cmd_resp_port_type *resp =3D cmd.va; =20 - memcpy(data, resp->page_data, PAGE_DATA_LEN); + memcpy(data, resp->page_data + off, len); } err: mutex_unlock(&adapter->mcc_lock); @@ -2415,7 +2415,7 @@ int be_cmd_query_cable_type(struct be_adapter *adapte= r) int status; =20 status =3D be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, - page_data); + 0, PAGE_DATA_LEN, page_data); if (!status) { switch (adapter->phy.interface_type) { case PHY_TYPE_QSFP: @@ -2440,7 +2440,7 @@ int be_cmd_query_sfp_info(struct be_adapter *adapter) int status; =20 status =3D be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, - page_data); + 0, PAGE_DATA_LEN, page_data); if (!status) { strlcpy(adapter->phy.vendor_name, page_data + SFP_VENDOR_NAME_OFFSET, SFP_VENDOR_NAME_LEN - 1); diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethe= rnet/emulex/benet/be_cmds.h index db1f3b908582..e2085c68c0ee 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -2427,7 +2427,7 @@ int be_cmd_set_beacon_state(struct be_adapter *adapte= r, u8 port_num, u8 beacon, int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state); int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, - u8 page_num, u8 *data); + u8 page_num, u32 off, u32 len, u8 *data); int be_cmd_query_cable_type(struct be_adapter *adapter); int be_cmd_query_sfp_info(struct be_adapter *adapter); int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *= cmd, diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/e= thernet/emulex/benet/be_ethtool.c index dfa784339781..bd0df189d871 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -1344,7 +1344,7 @@ static int be_get_module_info(struct net_device *netd= ev, return -EOPNOTSUPP; =20 status =3D be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, - page_data); + 0, PAGE_DATA_LEN, page_data); if (!status) { if (!page_data[SFP_PLUS_SFF_8472_COMP]) { modinfo->type =3D ETH_MODULE_SFF_8079; @@ -1362,25 +1362,32 @@ static int be_get_module_eeprom(struct net_device *= netdev, { struct be_adapter *adapter =3D netdev_priv(netdev); int status; + u32 begin, end; =20 if (!check_privilege(adapter, MAX_PRIVILEGES)) return -EOPNOTSUPP; =20 - status =3D be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, - data); - if (status) - goto err; + begin =3D eeprom->offset; + end =3D eeprom->offset + eeprom->len; + + if (begin < PAGE_DATA_LEN) { + status =3D be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, begin, + min_t(u32, end, PAGE_DATA_LEN) - begin, + data); + if (status) + goto err; + + data +=3D PAGE_DATA_LEN - begin; + begin =3D PAGE_DATA_LEN; + } =20 - if (eeprom->offset + eeprom->len > PAGE_DATA_LEN) { - status =3D be_cmd_read_port_transceiver_data(adapter, - TR_PAGE_A2, - data + - PAGE_DATA_LEN); + if (end > PAGE_DATA_LEN) { + status =3D be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A2, + begin - PAGE_DATA_LEN, + end - begin, data); if (status) goto err; } - if (eeprom->offset) - memcpy(data, data + eeprom->offset, eeprom->len); err: return be_cmd_status(status); } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8460C19F2B for ; Wed, 27 Jul 2022 17:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242790AbiG0RnK (ORCPT ); Wed, 27 Jul 2022 13:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242786AbiG0Rmp (ORCPT ); Wed, 27 Jul 2022 13:42:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B74089A99; Wed, 27 Jul 2022 09:52:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 08B6EB821D5; Wed, 27 Jul 2022 16:52:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BBCDC433C1; Wed, 27 Jul 2022 16:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940725; bh=S8MbOHpDXGviGRD/I1+/w6TY0TLAHiwFdOgvISSGvt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OK2qT3q3LnEzligtTI7AKM8MVYofjTVAunNOgKAibBB3bydtnvxapwL6+GY0FOLbJ IUl5uIgFt910l+DHe2BNciYlEapAmmkiiWQEYXJTdBVbR9lKa8DV72R/O1dop8qzG8 K9qNA8L6MbcPF0yMuYj7JTKSROVza6TrVYBhCq5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksij Rempel , Vladimir Oltean , Florian Fainelli , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 099/158] net: dsa: sja1105: silent spi_device_id warnings Date: Wed, 27 Jul 2022 18:12:43 +0200 Message-Id: <20220727161025.419040793@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Oleksij Rempel [ Upstream commit 855fe49984a8a3899f07ae1d149d46cd8d4acb52 ] Add spi_device_id entries to silent following warnings: SPI driver sja1105 has no spi_device_id for nxp,sja1105e SPI driver sja1105 has no spi_device_id for nxp,sja1105t SPI driver sja1105 has no spi_device_id for nxp,sja1105p SPI driver sja1105 has no spi_device_id for nxp,sja1105q SPI driver sja1105 has no spi_device_id for nxp,sja1105r SPI driver sja1105 has no spi_device_id for nxp,sja1105s SPI driver sja1105 has no spi_device_id for nxp,sja1110a SPI driver sja1105 has no spi_device_id for nxp,sja1110b SPI driver sja1105 has no spi_device_id for nxp,sja1110c SPI driver sja1105 has no spi_device_id for nxp,sja1110d Fixes: 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT compat= ible") Signed-off-by: Oleksij Rempel Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20220717135831.2492844-1-o.rempel@pengutron= ix.de Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/dsa/sja1105/sja1105_main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja11= 05/sja1105_main.c index b33841c6507a..7734c6b1baca 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -3383,12 +3383,28 @@ static const struct of_device_id sja1105_dt_ids[] = =3D { }; MODULE_DEVICE_TABLE(of, sja1105_dt_ids); =20 +static const struct spi_device_id sja1105_spi_ids[] =3D { + { "sja1105e" }, + { "sja1105t" }, + { "sja1105p" }, + { "sja1105q" }, + { "sja1105r" }, + { "sja1105s" }, + { "sja1110a" }, + { "sja1110b" }, + { "sja1110c" }, + { "sja1110d" }, + { }, +}; +MODULE_DEVICE_TABLE(spi, sja1105_spi_ids); + static struct spi_driver sja1105_driver =3D { .driver =3D { .name =3D "sja1105", .owner =3D THIS_MODULE, .of_match_table =3D of_match_ptr(sja1105_dt_ids), }, + .id_table =3D sja1105_spi_ids, .probe =3D sja1105_probe, .remove =3D sja1105_remove, .shutdown =3D sja1105_shutdown, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFC7FC19F2B for ; Wed, 27 Jul 2022 17:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242981AbiG0Rn5 (ORCPT ); Wed, 27 Jul 2022 13:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242974AbiG0RnQ (ORCPT ); Wed, 27 Jul 2022 13:43:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E4989EA8; Wed, 27 Jul 2022 09:52:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8032AB821AC; Wed, 27 Jul 2022 16:52:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0B56C433D6; Wed, 27 Jul 2022 16:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940742; bh=OJcd3z38Zh8nkGq4PkOJbi8tLzOObhuROopTRYiPVIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLIyuOQ5NznVN2OC+fZK45yFgqwyrXa+sfH3X+6kWlSKxkHkY1Wu9BmPxdLTNfeTh 3vePwedBHR5+6MgDO5xKn8sJ7ab6ks8UYkj3hN3t2LoH6cehe0HzBe0I3ZiCTTXh7M wBUyclgWQr8RMNa/iH8M64S8CHPlBJoXTT/E/1KQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksij Rempel , Vladimir Oltean , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 100/158] net: dsa: vitesse-vsc73xx: silent spi_device_id warnings Date: Wed, 27 Jul 2022 18:12:44 +0200 Message-Id: <20220727161025.468303678@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Oleksij Rempel [ Upstream commit 1774559f07993e1cac33c2406e99049d4bdea6c8 ] Add spi_device_id entries to silent SPI warnings. Fixes: 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT compat= ible") Signed-off-by: Oleksij Rempel Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220717135831.2492844-2-o.rempel@pengutron= ix.de Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/dsa/vitesse-vsc73xx-spi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/dsa/vitesse-vsc73xx-spi.c b/drivers/net/dsa/vitess= e-vsc73xx-spi.c index 3110895358d8..97a92e6da60d 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-spi.c +++ b/drivers/net/dsa/vitesse-vsc73xx-spi.c @@ -205,10 +205,20 @@ static const struct of_device_id vsc73xx_of_match[] = =3D { }; MODULE_DEVICE_TABLE(of, vsc73xx_of_match); =20 +static const struct spi_device_id vsc73xx_spi_ids[] =3D { + { "vsc7385" }, + { "vsc7388" }, + { "vsc7395" }, + { "vsc7398" }, + { }, +}; +MODULE_DEVICE_TABLE(spi, vsc73xx_spi_ids); + static struct spi_driver vsc73xx_spi_driver =3D { .probe =3D vsc73xx_spi_probe, .remove =3D vsc73xx_spi_remove, .shutdown =3D vsc73xx_spi_shutdown, + .id_table =3D vsc73xx_spi_ids, .driver =3D { .name =3D "vsc73xx-spi", .of_match_table =3D vsc73xx_of_match, --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E85CAC19F2B for ; Wed, 27 Jul 2022 17:43:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243001AbiG0Rnh (ORCPT ); Wed, 27 Jul 2022 13:43:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242895AbiG0RnD (ORCPT ); Wed, 27 Jul 2022 13:43:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 542C789A91; Wed, 27 Jul 2022 09:52:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 89D4161727; Wed, 27 Jul 2022 16:52:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94D4BC4314C; Wed, 27 Jul 2022 16:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940745; bh=l0QRjqsE/PLnnKYLcI5xL3LQIUn0lFVG2r6ccn1t/gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0p7WGe3f3l/SmvhRZrc6VvCLstEPt/Udy+nYPU0yfNz9EkZzo5J82AUR4z46RldVP hOu3MCGKpTJ2cndjoEwZZnmEb7I6+NgAapEWvD5iPg6Tthe0rkfYRiV49xA06+ARjk ZdQTpjmVbtp15krxaqBntpq1Gr8aVWuc+iCdA0Rs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 101/158] amt: use workqueue for gateway side message handling Date: Wed, 27 Jul 2022 18:12:45 +0200 Message-Id: <20220727161025.503216107@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 30e22a6ebca039572ce9bc10f1934f4eabfb5b7f ] There are some synchronization issues(amt->status, amt->req_cnt, etc) if the interface is in gateway mode because gateway message handlers are processed concurrently. This applies a work queue for processing these messages instead of expanding the locking context. So, the purposes of this patch are to fix exist race conditions and to make gateway to be able to validate a gateway status more correctly. When the AMT gateway interface is created, it tries to establish to relay. The establishment step looks stateless, but it should be managed well. In order to handle messages in the gateway, it saves the current status(i.e. AMT_STATUS_XXX). This patch makes gateway code to be worked with a single thread. Now, all messages except the multicast are triggered(received or delay expired), and these messages will be stored in the event queue(amt->events). Then, the single worker processes stored messages asynchronously one by one. The multicast data message type will be still processed immediately. Now, amt->lock is only needed to access the event queue(amt->events) if an interface is the gateway mode. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 159 +++++++++++++++++++++++++++++++++++++++++----- include/net/amt.h | 20 ++++++ 2 files changed, 164 insertions(+), 15 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 6c64953db487..f8e8381e266b 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -900,6 +900,28 @@ static void amt_send_mld_gq(struct amt_dev *amt, struc= t amt_tunnel_list *tunnel) } #endif =20 +static bool amt_queue_event(struct amt_dev *amt, enum amt_event event, + struct sk_buff *skb) +{ + int index; + + spin_lock_bh(&amt->lock); + if (amt->nr_events >=3D AMT_MAX_EVENTS) { + spin_unlock_bh(&amt->lock); + return 1; + } + + index =3D (amt->event_idx + amt->nr_events) % AMT_MAX_EVENTS; + amt->events[index].event =3D event; + amt->events[index].skb =3D skb; + amt->nr_events++; + amt->event_idx %=3D AMT_MAX_EVENTS; + queue_work(amt_wq, &amt->event_wq); + spin_unlock_bh(&amt->lock); + + return 0; +} + static void amt_secret_work(struct work_struct *work) { struct amt_dev *amt =3D container_of(to_delayed_work(work), @@ -913,12 +935,8 @@ static void amt_secret_work(struct work_struct *work) msecs_to_jiffies(AMT_SECRET_TIMEOUT)); } =20 -static void amt_discovery_work(struct work_struct *work) +static void amt_event_send_discovery(struct amt_dev *amt) { - struct amt_dev *amt =3D container_of(to_delayed_work(work), - struct amt_dev, - discovery_wq); - spin_lock_bh(&amt->lock); if (amt->status > AMT_STATUS_SENT_DISCOVERY) goto out; @@ -933,11 +951,19 @@ static void amt_discovery_work(struct work_struct *wo= rk) spin_unlock_bh(&amt->lock); } =20 -static void amt_req_work(struct work_struct *work) +static void amt_discovery_work(struct work_struct *work) { struct amt_dev *amt =3D container_of(to_delayed_work(work), struct amt_dev, - req_wq); + discovery_wq); + + if (amt_queue_event(amt, AMT_EVENT_SEND_DISCOVERY, NULL)) + mod_delayed_work(amt_wq, &amt->discovery_wq, + msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT)); +} + +static void amt_event_send_request(struct amt_dev *amt) +{ u32 exp; =20 spin_lock_bh(&amt->lock); @@ -967,6 +993,17 @@ static void amt_req_work(struct work_struct *work) spin_unlock_bh(&amt->lock); } =20 +static void amt_req_work(struct work_struct *work) +{ + struct amt_dev *amt =3D container_of(to_delayed_work(work), + struct amt_dev, + req_wq); + + if (amt_queue_event(amt, AMT_EVENT_SEND_REQUEST, NULL)) + mod_delayed_work(amt_wq, &amt->req_wq, + msecs_to_jiffies(100)); +} + static bool amt_send_membership_update(struct amt_dev *amt, struct sk_buff *skb, bool v6) @@ -2392,12 +2429,14 @@ static bool amt_membership_query_handler(struct amt= _dev *amt, skb->pkt_type =3D PACKET_MULTICAST; skb->ip_summed =3D CHECKSUM_NONE; len =3D skb->len; + local_bh_disable(); if (__netif_rx(skb) =3D=3D NET_RX_SUCCESS) { amt_update_gw_status(amt, AMT_STATUS_RECEIVED_QUERY, true); dev_sw_netstats_rx_add(amt->dev, len); } else { amt->dev->stats.rx_dropped++; } + local_bh_enable(); =20 return false; } @@ -2688,6 +2727,38 @@ static bool amt_request_handler(struct amt_dev *amt,= struct sk_buff *skb) return false; } =20 +static void amt_gw_rcv(struct amt_dev *amt, struct sk_buff *skb) +{ + int type =3D amt_parse_type(skb); + int err =3D 1; + + if (type =3D=3D -1) + goto drop; + + if (amt->mode =3D=3D AMT_MODE_GATEWAY) { + switch (type) { + case AMT_MSG_ADVERTISEMENT: + err =3D amt_advertisement_handler(amt, skb); + break; + case AMT_MSG_MEMBERSHIP_QUERY: + err =3D amt_membership_query_handler(amt, skb); + if (!err) + return; + break; + default: + netdev_dbg(amt->dev, "Invalid type of Gateway\n"); + break; + } + } +drop: + if (err) { + amt->dev->stats.rx_dropped++; + kfree_skb(skb); + } else { + consume_skb(skb); + } +} + static int amt_rcv(struct sock *sk, struct sk_buff *skb) { struct amt_dev *amt; @@ -2719,8 +2790,12 @@ static int amt_rcv(struct sock *sk, struct sk_buff *= skb) err =3D true; goto drop; } - err =3D amt_advertisement_handler(amt, skb); - break; + if (amt_queue_event(amt, AMT_EVENT_RECEIVE, skb)) { + netdev_dbg(amt->dev, "AMT Event queue full\n"); + err =3D true; + goto drop; + } + goto out; case AMT_MSG_MULTICAST_DATA: if (iph->saddr !=3D amt->remote_ip) { netdev_dbg(amt->dev, "Invalid Relay IP\n"); @@ -2738,11 +2813,12 @@ static int amt_rcv(struct sock *sk, struct sk_buff = *skb) err =3D true; goto drop; } - err =3D amt_membership_query_handler(amt, skb); - if (err) + if (amt_queue_event(amt, AMT_EVENT_RECEIVE, skb)) { + netdev_dbg(amt->dev, "AMT Event queue full\n"); + err =3D true; goto drop; - else - goto out; + } + goto out; default: err =3D true; netdev_dbg(amt->dev, "Invalid type of Gateway\n"); @@ -2780,6 +2856,46 @@ static int amt_rcv(struct sock *sk, struct sk_buff *= skb) return 0; } =20 +static void amt_event_work(struct work_struct *work) +{ + struct amt_dev *amt =3D container_of(work, struct amt_dev, event_wq); + struct sk_buff *skb; + u8 event; + int i; + + for (i =3D 0; i < AMT_MAX_EVENTS; i++) { + spin_lock_bh(&amt->lock); + if (amt->nr_events =3D=3D 0) { + spin_unlock_bh(&amt->lock); + return; + } + event =3D amt->events[amt->event_idx].event; + skb =3D amt->events[amt->event_idx].skb; + amt->events[amt->event_idx].event =3D AMT_EVENT_NONE; + amt->events[amt->event_idx].skb =3D NULL; + amt->nr_events--; + amt->event_idx++; + amt->event_idx %=3D AMT_MAX_EVENTS; + spin_unlock_bh(&amt->lock); + + switch (event) { + case AMT_EVENT_RECEIVE: + amt_gw_rcv(amt, skb); + break; + case AMT_EVENT_SEND_DISCOVERY: + amt_event_send_discovery(amt); + break; + case AMT_EVENT_SEND_REQUEST: + amt_event_send_request(amt); + break; + default: + if (skb) + kfree_skb(skb); + break; + } + } +} + static int amt_err_lookup(struct sock *sk, struct sk_buff *skb) { struct amt_dev *amt; @@ -2867,6 +2983,8 @@ static int amt_dev_open(struct net_device *dev) =20 amt->ready4 =3D false; amt->ready6 =3D false; + amt->event_idx =3D 0; + amt->nr_events =3D 0; =20 err =3D amt_socket_create(amt); if (err) @@ -2892,6 +3010,8 @@ static int amt_dev_stop(struct net_device *dev) struct amt_dev *amt =3D netdev_priv(dev); struct amt_tunnel_list *tunnel, *tmp; struct socket *sock; + struct sk_buff *skb; + int i; =20 cancel_delayed_work_sync(&amt->req_wq); cancel_delayed_work_sync(&amt->discovery_wq); @@ -2904,6 +3024,15 @@ static int amt_dev_stop(struct net_device *dev) if (sock) udp_tunnel_sock_release(sock); =20 + cancel_work_sync(&amt->event_wq); + for (i =3D 0; i < AMT_MAX_EVENTS; i++) { + skb =3D amt->events[i].skb; + if (skb) + kfree_skb(skb); + amt->events[i].event =3D AMT_EVENT_NONE; + amt->events[i].skb =3D NULL; + } + amt->ready4 =3D false; amt->ready6 =3D false; amt->req_cnt =3D 0; @@ -3146,8 +3275,8 @@ static int amt_newlink(struct net *net, struct net_de= vice *dev, INIT_DELAYED_WORK(&amt->discovery_wq, amt_discovery_work); INIT_DELAYED_WORK(&amt->req_wq, amt_req_work); INIT_DELAYED_WORK(&amt->secret_wq, amt_secret_work); + INIT_WORK(&amt->event_wq, amt_event_work); INIT_LIST_HEAD(&amt->tunnel_list); - return 0; err: dev_put(amt->stream_dev); @@ -3280,7 +3409,7 @@ static int __init amt_init(void) if (err < 0) goto unregister_notifier; =20 - amt_wq =3D alloc_workqueue("amt", WQ_UNBOUND, 1); + amt_wq =3D alloc_workqueue("amt", WQ_UNBOUND, 0); if (!amt_wq) { err =3D -ENOMEM; goto rtnl_unregister; diff --git a/include/net/amt.h b/include/net/amt.h index 7a4db8b903ee..44acadf3a69e 100644 --- a/include/net/amt.h +++ b/include/net/amt.h @@ -78,6 +78,15 @@ enum amt_status { =20 #define AMT_STATUS_MAX (__AMT_STATUS_MAX - 1) =20 +/* Gateway events only */ +enum amt_event { + AMT_EVENT_NONE, + AMT_EVENT_RECEIVE, + AMT_EVENT_SEND_DISCOVERY, + AMT_EVENT_SEND_REQUEST, + __AMT_EVENT_MAX, +}; + struct amt_header { #if defined(__LITTLE_ENDIAN_BITFIELD) u8 type:4, @@ -292,6 +301,12 @@ struct amt_group_node { struct hlist_head sources[]; }; =20 +#define AMT_MAX_EVENTS 16 +struct amt_events { + enum amt_event event; + struct sk_buff *skb; +}; + struct amt_dev { struct net_device *dev; struct net_device *stream_dev; @@ -308,6 +323,7 @@ struct amt_dev { struct delayed_work req_wq; /* Protected by RTNL */ struct delayed_work secret_wq; + struct work_struct event_wq; /* AMT status */ enum amt_status status; /* Generated key */ @@ -345,6 +361,10 @@ struct amt_dev { /* Used only in gateway mode */ u64 mac:48, reserved:16; + /* AMT gateway side message handler queue */ + struct amt_events events[AMT_MAX_EVENTS]; + u8 event_idx; + u8 nr_events; }; =20 #define AMT_TOS 0xc0 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6D31C04A68 for ; Wed, 27 Jul 2022 17:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243024AbiG0RoE (ORCPT ); Wed, 27 Jul 2022 13:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242943AbiG0Rn1 (ORCPT ); Wed, 27 Jul 2022 13:43:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D03F89EBA; Wed, 27 Jul 2022 09:52:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5FBE1616BD; Wed, 27 Jul 2022 16:52:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66CD7C433D6; Wed, 27 Jul 2022 16:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940747; bh=09q0fp0UNnv65fb09KZBA3JX8+stgJ9Pdq795VBDTWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wgPgVNiNe5SYdWJ2+dg8/mjFnsmw4WAAiXZJtMwOwv9/JO2OIRcAVpMay2CwwXL88 1RRLXHlZl1SD2Ot8vJ6TBA6aHDgBpZzyLpUPg0PJghGDvDmSnH8p+EXtEO2bQ11DEa LAdmexzoJzg886BgNhYBpD+rpkR9TyTktxYCuTQs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 102/158] amt: remove unnecessary locks Date: Wed, 27 Jul 2022 18:12:46 +0200 Message-Id: <20220727161025.552206594@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 9c343ea6185febe5f6b74f7f7b3757f3dd9c5af6 ] By the previous patch, amt gateway handlers are changed to worked by a single thread. So, most locks for gateway are not needed. So, it removes. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index f8e8381e266b..615f26a553ae 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -577,8 +577,8 @@ static struct sk_buff *amt_build_igmp_gq(struct amt_dev= *amt) return skb; } =20 -static void __amt_update_gw_status(struct amt_dev *amt, enum amt_status st= atus, - bool validate) +static void amt_update_gw_status(struct amt_dev *amt, enum amt_status stat= us, + bool validate) { if (validate && amt->status >=3D status) return; @@ -600,14 +600,6 @@ static void __amt_update_relay_status(struct amt_tunne= l_list *tunnel, tunnel->status =3D status; } =20 -static void amt_update_gw_status(struct amt_dev *amt, enum amt_status stat= us, - bool validate) -{ - spin_lock_bh(&amt->lock); - __amt_update_gw_status(amt, status, validate); - spin_unlock_bh(&amt->lock); -} - static void amt_update_relay_status(struct amt_tunnel_list *tunnel, enum amt_status status, bool validate) { @@ -700,9 +692,7 @@ static void amt_send_discovery(struct amt_dev *amt) if (unlikely(net_xmit_eval(err))) amt->dev->stats.tx_errors++; =20 - spin_lock_bh(&amt->lock); - __amt_update_gw_status(amt, AMT_STATUS_SENT_DISCOVERY, true); - spin_unlock_bh(&amt->lock); + amt_update_gw_status(amt, AMT_STATUS_SENT_DISCOVERY, true); out: rcu_read_unlock(); } @@ -937,18 +927,14 @@ static void amt_secret_work(struct work_struct *work) =20 static void amt_event_send_discovery(struct amt_dev *amt) { - spin_lock_bh(&amt->lock); if (amt->status > AMT_STATUS_SENT_DISCOVERY) goto out; get_random_bytes(&amt->nonce, sizeof(__be32)); - spin_unlock_bh(&amt->lock); =20 amt_send_discovery(amt); - spin_lock_bh(&amt->lock); out: mod_delayed_work(amt_wq, &amt->discovery_wq, msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT)); - spin_unlock_bh(&amt->lock); } =20 static void amt_discovery_work(struct work_struct *work) @@ -966,7 +952,6 @@ static void amt_event_send_request(struct amt_dev *amt) { u32 exp; =20 - spin_lock_bh(&amt->lock); if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT) goto out; =20 @@ -976,21 +961,18 @@ static void amt_event_send_request(struct amt_dev *am= t) amt->ready4 =3D false; amt->ready6 =3D false; amt->remote_ip =3D 0; - __amt_update_gw_status(amt, AMT_STATUS_INIT, false); + amt_update_gw_status(amt, AMT_STATUS_INIT, false); amt->req_cnt =3D 0; goto out; } - spin_unlock_bh(&amt->lock); =20 amt_send_request(amt, false); amt_send_request(amt, true); - spin_lock_bh(&amt->lock); - __amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); + amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); amt->req_cnt++; out: exp =3D min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT); mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000)); - spin_unlock_bh(&amt->lock); } =20 static void amt_req_work(struct work_struct *work) @@ -2386,12 +2368,10 @@ static bool amt_membership_query_handler(struct amt= _dev *amt, ihv3 =3D skb_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS); skb_reset_transport_header(skb); skb_push(skb, sizeof(*iph) + AMT_IPHDR_OPTS); - spin_lock_bh(&amt->lock); amt->ready4 =3D true; amt->mac =3D amtmq->response_mac; amt->req_cnt =3D 0; amt->qi =3D ihv3->qqic; - spin_unlock_bh(&amt->lock); skb->protocol =3D htons(ETH_P_IP); eth->h_proto =3D htons(ETH_P_IP); ip_eth_mc_map(iph->daddr, eth->h_dest); @@ -2411,12 +2391,10 @@ static bool amt_membership_query_handler(struct amt= _dev *amt, mld2q =3D skb_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); skb_reset_transport_header(skb); skb_push(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); - spin_lock_bh(&amt->lock); amt->ready6 =3D true; amt->mac =3D amtmq->response_mac; amt->req_cnt =3D 0; amt->qi =3D mld2q->mld2q_qqic; - spin_unlock_bh(&amt->lock); skb->protocol =3D htons(ETH_P_IPV6); eth->h_proto =3D htons(ETH_P_IPV6); ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EC5CC04A68 for ; Wed, 27 Jul 2022 17:43:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243008AbiG0Rnr (ORCPT ); Wed, 27 Jul 2022 13:43:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242951AbiG0RnF (ORCPT ); Wed, 27 Jul 2022 13:43:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B1F189E96; Wed, 27 Jul 2022 09:52:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 005F5B821C5; Wed, 27 Jul 2022 16:52:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B084C433D6; Wed, 27 Jul 2022 16:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940750; bh=KyG0K0b3BcFKnfJuykmQL/fQ2eRx4YGZhGc1jZw4O4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9fNykvS5aoUmPGzf7P5yAKsSGd2XNJw+1CsSrUyq+Lhp3JARGkiAVvUMeC9oZPiQ 5Y37E0NpMz11VcAT5aec5dn/+29u9hoIkwj28dl9EB4zM28Phm1a9J0hirHz5joOw8 BPUK0BglKV788/1X02DfKA+KnQ7uZgIh/DFvlCkA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 103/158] amt: use READ_ONCE() in amt module Date: Wed, 27 Jul 2022 18:12:47 +0200 Message-Id: <20220727161025.591054387@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 928f353cb8672f0d6078aad75eeec0ed33875b12 ] There are some data races in the amt module. amt->ready4, amt->ready6, and amt->status can be accessed concurrently without locks. So, it uses READ_ONCE() and WRITE_ONCE(). Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 615f26a553ae..ff859d4a4b50 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -584,7 +584,7 @@ static void amt_update_gw_status(struct amt_dev *amt, e= num amt_status status, return; netdev_dbg(amt->dev, "Update GW status %s -> %s", status_str[amt->status], status_str[status]); - amt->status =3D status; + WRITE_ONCE(amt->status, status); } =20 static void __amt_update_relay_status(struct amt_tunnel_list *tunnel, @@ -958,8 +958,8 @@ static void amt_event_send_request(struct amt_dev *amt) if (amt->req_cnt > AMT_MAX_REQ_COUNT) { netdev_dbg(amt->dev, "Gateway is not ready"); amt->qi =3D AMT_INIT_REQ_TIMEOUT; - amt->ready4 =3D false; - amt->ready6 =3D false; + WRITE_ONCE(amt->ready4, false); + WRITE_ONCE(amt->ready6, false); amt->remote_ip =3D 0; amt_update_gw_status(amt, AMT_STATUS_INIT, false); amt->req_cnt =3D 0; @@ -1239,7 +1239,8 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, = struct net_device *dev) /* Gateway only passes IGMP/MLD packets */ if (!report) goto free; - if ((!v6 && !amt->ready4) || (v6 && !amt->ready6)) + if ((!v6 && !READ_ONCE(amt->ready4)) || + (v6 && !READ_ONCE(amt->ready6))) goto free; if (amt_send_membership_update(amt, skb, v6)) goto free; @@ -2368,7 +2369,7 @@ static bool amt_membership_query_handler(struct amt_d= ev *amt, ihv3 =3D skb_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS); skb_reset_transport_header(skb); skb_push(skb, sizeof(*iph) + AMT_IPHDR_OPTS); - amt->ready4 =3D true; + WRITE_ONCE(amt->ready4, true); amt->mac =3D amtmq->response_mac; amt->req_cnt =3D 0; amt->qi =3D ihv3->qqic; @@ -2391,7 +2392,7 @@ static bool amt_membership_query_handler(struct amt_d= ev *amt, mld2q =3D skb_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); skb_reset_transport_header(skb); skb_push(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); - amt->ready6 =3D true; + WRITE_ONCE(amt->ready6, true); amt->mac =3D amtmq->response_mac; amt->req_cnt =3D 0; amt->qi =3D mld2q->mld2q_qqic; @@ -2898,7 +2899,7 @@ static int amt_err_lookup(struct sock *sk, struct sk_= buff *skb) break; case AMT_MSG_REQUEST: case AMT_MSG_MEMBERSHIP_UPDATE: - if (amt->status >=3D AMT_STATUS_RECEIVED_ADVERTISEMENT) + if (READ_ONCE(amt->status) >=3D AMT_STATUS_RECEIVED_ADVERTISEMENT) mod_delayed_work(amt_wq, &amt->req_wq, 0); break; default: --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 162C3C19F2D for ; Wed, 27 Jul 2022 17:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242894AbiG0Roz (ORCPT ); Wed, 27 Jul 2022 13:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242793AbiG0Rna (ORCPT ); Wed, 27 Jul 2022 13:43:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15C18AB0F; Wed, 27 Jul 2022 09:52:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A4D54B8200D; Wed, 27 Jul 2022 16:52:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02C8FC433C1; Wed, 27 Jul 2022 16:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940753; bh=zpgNjnfSpwP+s2pDPQsvK7PQ9b8gheUQM579VcK0bLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zLAYF6OWJMypTYaDSs4PCBwtLxAInSVVoYRWOUN04vcMLWN/d1kMgSRxyZ0tfUMEB GbR2QsMLogPLLj1hQepf3Nb9RsiUpA1z9qCnANSYf7/EsM6Wy34jZxLitaYPwFX1Ye m2l89vfR0jE3NJlchl/seEPWCrZZ9pSw/0i8cXWg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 104/158] amt: add missing regeneration nonce logic in request logic Date: Wed, 27 Jul 2022 18:12:48 +0200 Message-Id: <20220727161025.629946179@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 627f16931bf3cb20d50274d9341380ac2c3035fd ] When AMT gateway starts sending a new request message, it should regenerate the nonce variable. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index ff859d4a4b50..2fe56640e493 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -963,9 +963,13 @@ static void amt_event_send_request(struct amt_dev *amt) amt->remote_ip =3D 0; amt_update_gw_status(amt, AMT_STATUS_INIT, false); amt->req_cnt =3D 0; + amt->nonce =3D 0; goto out; } =20 + if (!amt->req_cnt) + get_random_bytes(&amt->nonce, sizeof(__be32)); + amt_send_request(amt, false); amt_send_request(amt, true); amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79B36C25B08 for ; Wed, 27 Jul 2022 17:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232630AbiG0Ro7 (ORCPT ); Wed, 27 Jul 2022 13:44:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242853AbiG0Rnb (ORCPT ); Wed, 27 Jul 2022 13:43:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B95789E83; Wed, 27 Jul 2022 09:52:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A508CB821BE; Wed, 27 Jul 2022 16:52:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE42DC433C1; Wed, 27 Jul 2022 16:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940756; bh=OQUb/8RzLCrzVZweQIabAHag8h5C3q52n++aj87Xar8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zDTgB9ERv7Z7lfQqiYKLGfV2EqBGRtbDKfozR7RnSlQrt0rmsGvP0zmg+Y+QiW/76 wF5gmf34AUmTU24xniKYoi+1+ViIYEVYm0c0BeN2yZpxALQyDGP2xDQB+kJW69u6hk KAZUc0LVfR1c0TyGzihMlSnQN4Umwyzwwvj+nl+E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 105/158] amt: drop unexpected advertisement message Date: Wed, 27 Jul 2022 18:12:49 +0200 Message-Id: <20220727161025.678539930@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 40185f359fbabaa61da754cc29d12f3a41e0a987 ] AMT gateway interface should not receive unexpected advertisement messages. In order to drop these packets, it should check nonce and amt->status. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 2fe56640e493..0811a5211ec4 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -2260,6 +2260,10 @@ static bool amt_advertisement_handler(struct amt_dev= *amt, struct sk_buff *skb) ipv4_is_zeronet(amta->ip4)) return true; =20 + if (amt->status !=3D AMT_STATUS_SENT_DISCOVERY || + amt->nonce !=3D amta->nonce) + return true; + amt->remote_ip =3D amta->ip4; netdev_dbg(amt->dev, "advertised remote ip =3D %pI4\n", &amt->remote_ip); mod_delayed_work(amt_wq, &amt->req_wq, 0); @@ -2975,6 +2979,7 @@ static int amt_dev_open(struct net_device *dev) =20 amt->req_cnt =3D 0; amt->remote_ip =3D 0; + amt->nonce =3D 0; get_random_bytes(&amt->key, sizeof(siphash_key_t)); =20 amt->status =3D AMT_STATUS_INIT; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6B9EC04A68 for ; Wed, 27 Jul 2022 17:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242729AbiG0RkU (ORCPT ); Wed, 27 Jul 2022 13:40:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242861AbiG0RjX (ORCPT ); Wed, 27 Jul 2022 13:39:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB9A288758; Wed, 27 Jul 2022 09:51:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 58C5EB821C5; Wed, 27 Jul 2022 16:51:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9639C433D6; Wed, 27 Jul 2022 16:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940668; bh=/eMDGI/9OToQZPUaNvF2iNvmdwDeVgUaWbAg4meaaP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOdIV9hgn5tGTajYaQyR1g8oNsLp+g9Ov+Aa0jsyWGbJ0O8oF446y9rCsLWjve5no 2xYpUYngz/Z1GPVYCHI0LnWci3i8PyRg8MEYTLAX6wGr41TJYc9E6FYj9qzjkkDv1d hegrwc8uZwmNB64m5r6wRTuIBMKXyyKUoSL4TZpw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 106/158] amt: drop unexpected query message Date: Wed, 27 Jul 2022 18:12:50 +0200 Message-Id: <20220727161025.717770820@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 239d886601e38d948a28f3b2a1c9ce5f01bf75f2 ] AMT gateway interface should not receive unexpected query messages. In order to drop unexpected query messages, it checks nonce. And it also checks ready4 and ready6 variables to drop duplicated messages. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 0811a5211ec4..5c65908abd5a 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -967,8 +967,11 @@ static void amt_event_send_request(struct amt_dev *amt) goto out; } =20 - if (!amt->req_cnt) + if (!amt->req_cnt) { + WRITE_ONCE(amt->ready4, false); + WRITE_ONCE(amt->ready6, false); get_random_bytes(&amt->nonce, sizeof(__be32)); + } =20 amt_send_request(amt, false); amt_send_request(amt, true); @@ -2353,6 +2356,9 @@ static bool amt_membership_query_handler(struct amt_d= ev *amt, if (amtmq->reserved || amtmq->version) return true; =20 + if (amtmq->nonce !=3D amt->nonce) + return true; + hdr_size -=3D sizeof(*eth); if (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_TEB), false)) return true; @@ -2367,6 +2373,9 @@ static bool amt_membership_query_handler(struct amt_d= ev *amt, =20 iph =3D ip_hdr(skb); if (iph->version =3D=3D 4) { + if (READ_ONCE(amt->ready4)) + return true; + if (!pskb_may_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS + sizeof(*ihv3))) return true; @@ -2389,6 +2398,9 @@ static bool amt_membership_query_handler(struct amt_d= ev *amt, struct mld2_query *mld2q; struct ipv6hdr *ip6h; =20 + if (READ_ONCE(amt->ready6)) + return true; + if (!pskb_may_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS + sizeof(*mld2q))) return true; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65EC7C04A68 for ; Wed, 27 Jul 2022 17:40:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242778AbiG0Rk2 (ORCPT ); Wed, 27 Jul 2022 13:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242889AbiG0Rj1 (ORCPT ); Wed, 27 Jul 2022 13:39:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAA2661D7A; Wed, 27 Jul 2022 09:51:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2DCD9B821BE; Wed, 27 Jul 2022 16:51:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B0ECC433D6; Wed, 27 Jul 2022 16:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940670; bh=wQ4x2T2sHA5A7GZsTF5GyIl9+xpUVMCBVkOEG3kfipU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJEj0IDMr6eWkFotdAkLz71SIj50BdsqlCBGvfmKMPp/HQAKoyjwyhU4DZeUtkRTy UWOGmb40h/Wb/cWsFSA6Ey43ZoAErrSNrpOZxhIMtsQ5AK03Zu0Q1BnxbkVGF30DXW 206EGl424Fi1Q/CuZk+Mz+N9JzSgnAEfjRdNwOdk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 107/158] amt: drop unexpected multicast data Date: Wed, 27 Jul 2022 18:12:51 +0200 Message-Id: <20220727161025.765824123@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit e882827d5b8942a27b4d28548aa27562a3a7e94c ] AMT gateway interface should not receive unexpected multicast data. Multicast data message type should be received after sending an update message, which means all establishment between gateway and relay is finished. So, amt_multicast_data_handler() checks amt->status. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 5c65908abd5a..4277924ab3b9 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -2282,6 +2282,9 @@ static bool amt_multicast_data_handler(struct amt_dev= *amt, struct sk_buff *skb) struct ethhdr *eth; struct iphdr *iph; =20 + if (READ_ONCE(amt->status) !=3D AMT_STATUS_SENT_UPDATE) + return true; + hdr_size =3D sizeof(*amtmd) + sizeof(struct udphdr); if (!pskb_may_pull(skb, hdr_size)) return true; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEC16C04A68 for ; Wed, 27 Jul 2022 17:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242381AbiG0RlF (ORCPT ); Wed, 27 Jul 2022 13:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242774AbiG0RkZ (ORCPT ); Wed, 27 Jul 2022 13:40:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551DB61D91; Wed, 27 Jul 2022 09:51:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1D91661560; Wed, 27 Jul 2022 16:51:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E93EC433C1; Wed, 27 Jul 2022 16:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940673; bh=bM892KhhPAeee0HH8jIulRXOdwogdtlf43M4Vsm/Nmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lohNuymgEliGYh6pDYLbTRVCBsEj9JC5KZayxZOmHlwWxmtHxaNHTTMUZoT9mRkkO lVln+gMrQ1kwlDSmbpZGYfNmXHQGy95N9dA/Cj7QT4AAwVkGE6MInaKmBsFbGhMtGW j9V9GU7q/Mm3sM1IQ3OXSTysk5blAoaLkgCkN5Nc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 108/158] amt: do not use amt->nr_tunnels outside of lock Date: Wed, 27 Jul 2022 18:12:52 +0200 Message-Id: <20220727161025.804001140@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Taehee Yoo [ Upstream commit 989918482bbccbbce3ba2bb9156eb4c193319983 ] amt->nr_tunnels is protected by amt->lock. But, amt_request_handler() has been using this variable without the amt->lock. So, it expands context of amt->lock in the amt_request_handler() to protect amt->nr_tunnels variable. Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/amt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 4277924ab3b9..acf5ea96652f 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -2679,7 +2679,9 @@ static bool amt_request_handler(struct amt_dev *amt, = struct sk_buff *skb) if (tunnel->ip4 =3D=3D iph->saddr) goto send; =20 + spin_lock_bh(&amt->lock); if (amt->nr_tunnels >=3D amt->max_tunnels) { + spin_unlock_bh(&amt->lock); icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); return true; } @@ -2687,8 +2689,10 @@ static bool amt_request_handler(struct amt_dev *amt,= struct sk_buff *skb) tunnel =3D kzalloc(sizeof(*tunnel) + (sizeof(struct hlist_head) * amt->hash_buckets), GFP_ATOMIC); - if (!tunnel) + if (!tunnel) { + spin_unlock_bh(&amt->lock); return true; + } =20 tunnel->source_port =3D udph->source; tunnel->ip4 =3D iph->saddr; @@ -2701,10 +2705,9 @@ static bool amt_request_handler(struct amt_dev *amt,= struct sk_buff *skb) =20 INIT_DELAYED_WORK(&tunnel->gc_wq, amt_tunnel_expire); =20 - spin_lock_bh(&amt->lock); list_add_tail_rcu(&tunnel->list, &amt->tunnel_list); tunnel->key =3D amt->key; - amt_update_relay_status(tunnel, AMT_STATUS_RECEIVED_REQUEST, true); + __amt_update_relay_status(tunnel, AMT_STATUS_RECEIVED_REQUEST, true); amt->nr_tunnels++; mod_delayed_work(amt_wq, &tunnel->gc_wq, msecs_to_jiffies(amt_gmi(amt))); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F4D3C19F2B for ; Wed, 27 Jul 2022 17:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbiG0Rkt (ORCPT ); Wed, 27 Jul 2022 13:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242514AbiG0Rjx (ORCPT ); Wed, 27 Jul 2022 13:39:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2347288CD7; Wed, 27 Jul 2022 09:51:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 77791B821D4; Wed, 27 Jul 2022 16:51:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C80A9C433C1; Wed, 27 Jul 2022 16:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940676; bh=q0JSE8ux2FV7K2RUeGZwHsCybUA+f+mNEP39HiD25Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DruJfRfxdpKh2/Op4i41nHsmNaPQEvY1YDOAyofr7exktP5QbB5QcyRpXONFxtOvO kPSfi8UI1jHazsyHnMLPWEn6UbEYRHH0qKlAQN+iztxUvsTATE16+r+uN/Xk5jjJW7 OX+YHKzuX+wdZlVZQtBVg+jirgeuFG9Cr+f0ox2A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "=?UTF-8?q?N=C3=ADcolas=20F . =20R . =20A . =20Prado?=" , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Douglas Anderson , Sasha Levin Subject: [PATCH 5.18 109/158] drm/panel-edp: Fix variable typo when saving hpd absent delay from DT Date: Wed, 27 Jul 2022 18:12:53 +0200 Message-Id: <20220727161025.849277072@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: N=C3=ADcolas F. R. A. Prado [ Upstream commit ef2084a8388b19c8812356106e0c8d29915f9d8b ] The value read from the "hpd-absent-delay-ms" property in DT was being saved to the wrong variable, overriding the hpd_reliable delay. Fix the typo. Fixes: 5540cf8f3e8d ("drm/panel-edp: Implement generic "edp-panel"s probed = by EDID") Signed-off-by: N=C3=ADcolas F. R. A. Prado Reviewed-by: Andr=C3=A9 Almeida Reviewed-by: Douglas Anderson Signed-off-by: Douglas Anderson Link: https://patchwork.freedesktop.org/patch/msgid/20220719203857.1488831-= 4-nfraprado@collabora.com Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpu/drm/panel/panel-edp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/pane= l-edp.c index f7bfcf63d48e..701a258d2e11 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -713,7 +713,7 @@ static int generic_edp_panel_probe(struct device *dev, = struct panel_edp *panel) of_property_read_u32(dev->of_node, "hpd-reliable-delay-ms", &reliable_ms); desc->delay.hpd_reliable =3D reliable_ms; of_property_read_u32(dev->of_node, "hpd-absent-delay-ms", &absent_ms); - desc->delay.hpd_reliable =3D absent_ms; + desc->delay.hpd_absent =3D absent_ms; =20 /* Power the panel on so we can read the EDID */ ret =3D pm_runtime_get_sync(dev); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02493C04A68 for ; Wed, 27 Jul 2022 17:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242843AbiG0Rl1 (ORCPT ); Wed, 27 Jul 2022 13:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242174AbiG0Rk4 (ORCPT ); Wed, 27 Jul 2022 13:40:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAFCE88E31; Wed, 27 Jul 2022 09:51:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 33470B821C5; Wed, 27 Jul 2022 16:51:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AE0DC433C1; Wed, 27 Jul 2022 16:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940678; bh=laAW4N7hZQuQqUG5fJRWifvSw1PQRaXRy9+COPCqzQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmD3zVrDUGL+E7CJmQGdYzg1dtwkxnFPYZ/Ojz4GeYNf4oP5jbu9UThAQw2N5Dyfc 4s9ZUGcmx5ybaitb5QHYupcnGUoChCNR645QJuNFVeuwWp8hzVI1AyTwDfE5j0WpB7 /cAdz3S+qlBiMALjlQbdUCmKSKZe1NzrldotD9FA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Laurentiu Palcu , Sasha Levin Subject: [PATCH 5.18 110/158] drm/imx/dcss: Add missing of_node_put() in fail path Date: Wed, 27 Jul 2022 18:12:54 +0200 Message-Id: <20220727161025.880308594@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Liang He [ Upstream commit 02c87df2480ac855d88ee308ce3fa857d9bd55a8 ] In dcss_dev_create() and dcss_dev_destroy(), we should call of_node_put() in fail path or before the dcss's destroy as of_graph_get_port_by_id() has increased the refcount. Fixes: 9021c317b770 ("drm/imx: Add initial support for DCSS on iMX8MQ") Signed-off-by: Liang He Reviewed-by: Laurentiu Palcu Signed-off-by: Laurentiu Palcu Link: https://patchwork.freedesktop.org/patch/msgid/20220714081337.374761-1= -windhl@126.com Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpu/drm/imx/dcss/dcss-dev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c b/drivers/gpu/drm/imx/dcss= /dcss-dev.c index c849533ca83e..3f5750cc2673 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-dev.c +++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c @@ -207,6 +207,7 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bo= ol hdmi_output) =20 ret =3D dcss_submodules_init(dcss); if (ret) { + of_node_put(dcss->of_port); dev_err(dev, "submodules initialization failed\n"); goto clks_err; } @@ -237,6 +238,8 @@ void dcss_dev_destroy(struct dcss_dev *dcss) dcss_clocks_disable(dcss); } =20 + of_node_put(dcss->of_port); + pm_runtime_disable(dcss->dev); =20 dcss_submodules_stop(dcss); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C10A5C19F2B for ; Wed, 27 Jul 2022 17:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242772AbiG0RlB (ORCPT ); Wed, 27 Jul 2022 13:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242754AbiG0RkW (ORCPT ); Wed, 27 Jul 2022 13:40:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A48F88CF4; Wed, 27 Jul 2022 09:51:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CDD21B821D5; Wed, 27 Jul 2022 16:51:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34BE8C433D6; Wed, 27 Jul 2022 16:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940681; bh=Y2lqLdKXlUsPjo/KKDUbq0isrq7bD1P1nDugIYzLdZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q5D1zRSdr44fepxCQgDfzjw2lpR6EbesN+tW4PW4RbWp0pz/yCp8/IUUQ02jlBuMz 7fFepENm7Zdi8MA9jQRsd0gZVULqkYYqd+gGmY3yWpZMzvLAcpmHHTB1UH8755RFUQ rNw8IMqzchgml3OkKmiTxh29zN9U/R3WAceJ7GzE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.18 111/158] can: rcar_canfd: Add missing of_node_put() in rcar_canfd_probe() Date: Wed, 27 Jul 2022 18:12:55 +0200 Message-Id: <20220727161025.923480839@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Liang He [ Upstream commit 7b66dfcc6e1e1f018492619c3d0fc432b6b54272 ] We should use of_node_put() for the reference returned by of_get_child_by_name() which has increased the refcount. Fixes: 45721c406dcf ("can: rcar_canfd: Add support for r8a779a0 SoC") Link: https://lore.kernel.org/all/20220712095623.364287-1-windhl@126.com Signed-off-by: Liang He Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/can/rcar/rcar_canfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_= canfd.c index 589996cef5db..8d457d2c3bcc 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -1850,6 +1850,7 @@ static int rcar_canfd_probe(struct platform_device *p= dev) of_child =3D of_get_child_by_name(pdev->dev.of_node, name); if (of_child && of_device_is_available(of_child)) channels_mask |=3D BIT(i); + of_node_put(of_child); } =20 if (chip_id !=3D RENESAS_RZG2L) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B4E2C04A68 for ; Wed, 27 Jul 2022 17:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242451AbiG0RlU (ORCPT ); Wed, 27 Jul 2022 13:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242810AbiG0Rkp (ORCPT ); Wed, 27 Jul 2022 13:40:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E9B88E1B; Wed, 27 Jul 2022 09:51:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AAED4B821D6; Wed, 27 Jul 2022 16:51:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFBF4C433D6; Wed, 27 Jul 2022 16:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940684; bh=BXt+/DsJ/RD7ujmlAfRZ6rwtE/OfsSQKVIpcz+npSWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vysvOr33iYHn8MCKsKi8B//k49kGUAlegBwDkxfPO/2P5n+D8pT6eG7KBbEa5etjU rKVxUSBqx20KWNgB/BGhk6Ux9PNujykeoOkpdNg5WyGmTH4wRpXXiusnZACWqm1JIl 4mAo7Mz3yqZC2Epy71UJZfkiBiA9hHJwl9cgaY0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 112/158] ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh. Date: Wed, 27 Jul 2022 18:12:56 +0200 Message-Id: <20220727161025.969819245@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 87507bcb4f5de16bb419e9509d874f4db6c0ad0f ] While reading sysctl_fib_multipath_use_neigh, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: a6db4494d218 ("net: ipv4: Consider failed nexthops in multipath rout= es") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/fib_semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 720f65f7bd0b..9f5c1c26c8f2 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -2216,7 +2216,7 @@ void fib_select_multipath(struct fib_result *res, int= hash) } =20 change_nexthops(fi) { - if (net->ipv4.sysctl_fib_multipath_use_neigh) { + if (READ_ONCE(net->ipv4.sysctl_fib_multipath_use_neigh)) { if (!fib_good_nh(nexthop_nh)) continue; if (!first) { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42594C19F2B for ; Wed, 27 Jul 2022 17:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242753AbiG0Rla (ORCPT ); Wed, 27 Jul 2022 13:41:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242687AbiG0Rk4 (ORCPT ); Wed, 27 Jul 2022 13:40:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFEE961D98; Wed, 27 Jul 2022 09:51:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE40960D3B; Wed, 27 Jul 2022 16:51:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4514C433D6; Wed, 27 Jul 2022 16:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940687; bh=sSY7dCyFkJhDPqPhL1QYXNCCoC4XKFtB7Dmnqf7/TrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spExzINp1Zbt6DUE3nMx8X7pJNEW326ZMW7RUXWbd6SGIcgK0qKDmXwo9u6K8OFmw PBnGkc7cpWqIA6GyQONZSMPvWOzQ6MOyBFOeXZtjG+J/kydMs1zN5+qzp3HwejTwBB kqFO6FvekcDHelseYnYwjI0GS0wmIarUie2cdA+k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 113/158] ipv4: Fix data-races around sysctl_fib_multipath_hash_policy. Date: Wed, 27 Jul 2022 18:12:57 +0200 Message-Id: <20220727161025.999900903@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 7998c12a08c97cc26660532c9f90a34bd7d8da5a ] While reading sysctl_fib_multipath_hash_policy, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: bf4e0a3db97e ("net: ipv4: add support for ECMP hash policy choice") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- net/ipv4/route.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/driver= s/net/ethernet/mellanox/mlxsw/spectrum_router.c index 994bd2e14e55..6bcb0f1b0816 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -10263,7 +10263,7 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp = *mlxsw_sp, unsigned long *fields =3D config->fields; u32 hash_fields; =20 - switch (net->ipv4.sysctl_fib_multipath_hash_policy) { + switch (READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_policy)) { case 0: mlxsw_sp_mp4_hash_outer_addr(config); break; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8363e575c455..907cb11cbea5 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2047,7 +2047,7 @@ int fib_multipath_hash(const struct net *net, const s= truct flowi4 *fl4, struct flow_keys hash_keys; u32 mhash =3D 0; =20 - switch (net->ipv4.sysctl_fib_multipath_hash_policy) { + switch (READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_policy)) { case 0: memset(&hash_keys, 0, sizeof(hash_keys)); hash_keys.control.addr_type =3D FLOW_DISSECTOR_KEY_IPV4_ADDRS; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67828C04A68 for ; Wed, 27 Jul 2022 17:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242785AbiG0Rll (ORCPT ); Wed, 27 Jul 2022 13:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242754AbiG0RlC (ORCPT ); Wed, 27 Jul 2022 13:41:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B62788F04; Wed, 27 Jul 2022 09:51:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 37039B821BE; Wed, 27 Jul 2022 16:51:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E357C433C1; Wed, 27 Jul 2022 16:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940690; bh=8bZ0b7bWiHjQAOrjYWtzLe7K+pj3Y+wOjeW+dTBZ99o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O86Xt74J3e0oOTxZ4lMV5PMcuABrOIhbBcY18Cytr0FsxiWsWOwadZgWsN8waG4NW CIDsLDzmMnliSdsoKFTZmF6pfbEPycXNTTk/xarfXqQYMy25pdyTvoT3fBeeZaY5AF Aq2Mwg+jMKN3h2m2ajWFmEJ+dAXIyf1s7PN+HcZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , Ido Schimmel , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 114/158] ipv4: Fix data-races around sysctl_fib_multipath_hash_fields. Date: Wed, 27 Jul 2022 18:12:58 +0200 Message-Id: <20220727161026.048539202@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 8895a9c2ac76fb9d3922fed4fe092c8ec5e5cccc ] While reading sysctl_fib_multipath_hash_fields, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: ce5c9c20d364 ("ipv4: Add a sysctl to control multipath hash fields") Signed-off-by: Kuniyuki Iwashima Reviewed-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- net/ipv4/route.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/driver= s/net/ethernet/mellanox/mlxsw/spectrum_router.c index 6bcb0f1b0816..c00d6c4ed37c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -10281,7 +10281,7 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp = *mlxsw_sp, mlxsw_sp_mp_hash_inner_l3(config); break; case 3: - hash_fields =3D net->ipv4.sysctl_fib_multipath_hash_fields; + hash_fields =3D READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); /* Outer */ MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP); MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP); diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 907cb11cbea5..02a0a397a2f3 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1928,7 +1928,7 @@ static u32 fib_multipath_custom_hash_outer(const stru= ct net *net, const struct sk_buff *skb, bool *p_has_inner) { - u32 hash_fields =3D net->ipv4.sysctl_fib_multipath_hash_fields; + u32 hash_fields =3D READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); struct flow_keys keys, hash_keys; =20 if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK)) @@ -1957,7 +1957,7 @@ static u32 fib_multipath_custom_hash_inner(const stru= ct net *net, const struct sk_buff *skb, bool has_inner) { - u32 hash_fields =3D net->ipv4.sysctl_fib_multipath_hash_fields; + u32 hash_fields =3D READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); struct flow_keys keys, hash_keys; =20 /* We assume the packet carries an encapsulation, but if none was @@ -2017,7 +2017,7 @@ static u32 fib_multipath_custom_hash_skb(const struct= net *net, static u32 fib_multipath_custom_hash_fl4(const struct net *net, const struct flowi4 *fl4) { - u32 hash_fields =3D net->ipv4.sysctl_fib_multipath_hash_fields; + u32 hash_fields =3D READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields); struct flow_keys hash_keys; =20 if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK)) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17F49C04A68 for ; Wed, 27 Jul 2022 17:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242863AbiG0Rlq (ORCPT ); Wed, 27 Jul 2022 13:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232341AbiG0RlC (ORCPT ); Wed, 27 Jul 2022 13:41:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243FF88F0A; Wed, 27 Jul 2022 09:51:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EA642B821D5; Wed, 27 Jul 2022 16:51:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59DC8C433D6; Wed, 27 Jul 2022 16:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940692; bh=dBqxS9MFnhhp2KUlVEf/seckEOvY4cbnnTTfewgHBMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gp4GgQlSe+9cRxzNmrxNwyYBBmvytQJFiNqup0kvNNr7WsHO0DZRCp5RhN2h34t1K DErdcKWyALEU4MB6ckrJTRXawgRtHChH5+aBil1ozaK/QKWD6P/Q/9Uwhc1z/XqnpZ VYIoWcN85uWv2IBpp8byU7z1xE/JbQxzRAou9MsY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 115/158] ip: Fix data-races around sysctl_ip_prot_sock. Date: Wed, 27 Jul 2022 18:12:59 +0200 Message-Id: <20220727161026.078402813@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 9b55c20f83369dd54541d9ddbe3a018a8377f451 ] sysctl_ip_prot_sock is accessed concurrently, and there is always a chance of data-race. So, all readers and writers need some basic protection to avoid load/store-tearing. Fixes: 4548b683b781 ("Introduce a sysctl that modifies the value of PROT_SO= CK.") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/ip.h | 2 +- net/ipv4/sysctl_net_ipv4.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 4a15b6bcb4b8..1c979fd1904c 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -357,7 +357,7 @@ static inline bool sysctl_dev_name_is_allowed(const cha= r *name) =20 static inline bool inet_port_requires_bind_service(struct net *net, unsign= ed short port) { - return port < net->ipv4.sysctl_ip_prot_sock; + return port < READ_ONCE(net->ipv4.sysctl_ip_prot_sock); } =20 #else diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 6b718688865e..344cdcd5a7d5 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -88,7 +88,7 @@ static int ipv4_local_port_range(struct ctl_table *table,= int write, * port limit. */ if ((range[1] < range[0]) || - (range[0] < net->ipv4.sysctl_ip_prot_sock)) + (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock))) ret =3D -EINVAL; else set_local_port_range(net, range); @@ -114,7 +114,7 @@ static int ipv4_privileged_ports(struct ctl_table *tabl= e, int write, .extra2 =3D &ip_privileged_port_max, }; =20 - pports =3D net->ipv4.sysctl_ip_prot_sock; + pports =3D READ_ONCE(net->ipv4.sysctl_ip_prot_sock); =20 ret =3D proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); =20 @@ -126,7 +126,7 @@ static int ipv4_privileged_ports(struct ctl_table *tabl= e, int write, if (range[0] < pports) ret =3D -EINVAL; else - net->ipv4.sysctl_ip_prot_sock =3D pports; + WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports); } =20 return ret; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FF8FC04A68 for ; Wed, 27 Jul 2022 17:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242770AbiG0Rlt (ORCPT ); Wed, 27 Jul 2022 13:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242805AbiG0RlR (ORCPT ); Wed, 27 Jul 2022 13:41:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A77E188F26; Wed, 27 Jul 2022 09:51:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CAF656153B; Wed, 27 Jul 2022 16:51:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B9DC433B5; Wed, 27 Jul 2022 16:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940698; bh=IycWulTsbIOVLrtfqv4k1FCYzWz7cNhjIqVpMmvVDzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L6nVlh6tgdXU/WPnebctZZxisgBthH/TdYjxLOI4/VPqSKbLAIU7cXooBLhJbVQS8 eeXQkEo67Q/c8wpG3zoiVomNw4nNzFIfw8t/jIvg+krxqWMwid3/+NX/7dAmS+VVW+ vABXXTSPLJB/3x22kGaB0QFVj5aDwMX+M6eXGf64= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 116/158] udp: Fix a data-race around sysctl_udp_l3mdev_accept. Date: Wed, 27 Jul 2022 18:13:00 +0200 Message-Id: <20220727161026.116104651@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 3d72bb4188c708bb16758c60822fc4dda7a95174 ] While reading sysctl_udp_l3mdev_accept, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 63a6fff353d0 ("net: Avoid receiving packets with an l3mdev on unboun= d UDP sockets") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/udp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/udp.h b/include/net/udp.h index 07d0ceadcf6e..abe91ab9030d 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -238,7 +238,7 @@ static inline bool udp_sk_bound_dev_eq(struct net *net,= int bound_dev_if, int dif, int sdif) { #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) - return inet_bound_dev_eq(!!net->ipv4.sysctl_udp_l3mdev_accept, + return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_udp_l3mdev_accept), bound_dev_if, dif, sdif); #else return inet_bound_dev_eq(true, bound_dev_if, dif, sdif); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FFC7C04A68 for ; Wed, 27 Jul 2022 17:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242881AbiG0Rl4 (ORCPT ); Wed, 27 Jul 2022 13:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242830AbiG0RlT (ORCPT ); Wed, 27 Jul 2022 13:41:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B73B88E1D; Wed, 27 Jul 2022 09:51:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7E304616BD; Wed, 27 Jul 2022 16:51:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D27AC433D6; Wed, 27 Jul 2022 16:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940700; bh=yaO39FCIkog0GdspnVXs1MhPwE03uqdlb4jPCvcewdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYUV/6E6gtaIDdBkzybzV8htHNCHIS34I+/aUvOgrPkDtXaLfCqazFQ6H33T4mKi7 b/Fg+bTMNxS2tAu+nhHypZ/w3jZYZHGtsR76fb5UmxySqqape0ViMaKz2OetPjlM8F +gLNsW32J2VthPkOvVysS1+uGVziypHmieyjnLjk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 117/158] tcp: Fix data-races around sysctl knobs related to SYN option. Date: Wed, 27 Jul 2022 18:13:01 +0200 Message-Id: <20220727161026.153846951@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 3666f666e99600518ab20982af04a078bbdad277 ] While reading these knobs, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers. - tcp_sack - tcp_window_scaling - tcp_timestamps Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- .../ethernet/chelsio/inline_crypto/chtls/chtls_cm.c | 6 +++--- net/core/secure_seq.c | 4 ++-- net/ipv4/syncookies.c | 6 +++--- net/ipv4/tcp_input.c | 6 +++--- net/ipv4/tcp_output.c | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c b/= drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c index 7c760aa65540..ddfe9208529a 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c @@ -1236,8 +1236,8 @@ static struct sock *chtls_recv_sock(struct sock *lsk, csk->sndbuf =3D newsk->sk_sndbuf; csk->smac_idx =3D ((struct port_info *)netdev_priv(ndev))->smt_idx; RCV_WSCALE(tp) =3D select_rcv_wscale(tcp_full_space(newsk), - sock_net(newsk)-> - ipv4.sysctl_tcp_window_scaling, + READ_ONCE(sock_net(newsk)-> + ipv4.sysctl_tcp_window_scaling), tp->window_clamp); neigh_release(n); inet_inherit_port(&tcp_hashinfo, lsk, newsk); @@ -1384,7 +1384,7 @@ static void chtls_pass_accept_request(struct sock *sk, #endif } if (req->tcpopt.wsf <=3D 14 && - sock_net(sk)->ipv4.sysctl_tcp_window_scaling) { + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_window_scaling)) { inet_rsk(oreq)->wscale_ok =3D 1; inet_rsk(oreq)->snd_wscale =3D req->tcpopt.wsf; } diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c index 5f85e01d4093..b0ff6153be62 100644 --- a/net/core/secure_seq.c +++ b/net/core/secure_seq.c @@ -64,7 +64,7 @@ u32 secure_tcpv6_ts_off(const struct net *net, .daddr =3D *(struct in6_addr *)daddr, }; =20 - if (net->ipv4.sysctl_tcp_timestamps !=3D 1) + if (READ_ONCE(net->ipv4.sysctl_tcp_timestamps) !=3D 1) return 0; =20 ts_secret_init(); @@ -120,7 +120,7 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral); #ifdef CONFIG_INET u32 secure_tcp_ts_off(const struct net *net, __be32 saddr, __be32 daddr) { - if (net->ipv4.sysctl_tcp_timestamps !=3D 1) + if (READ_ONCE(net->ipv4.sysctl_tcp_timestamps) !=3D 1) return 0; =20 ts_secret_init(); diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 9b234b42021e..942d2dfa1115 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -247,12 +247,12 @@ bool cookie_timestamp_decode(const struct net *net, return true; } =20 - if (!net->ipv4.sysctl_tcp_timestamps) + if (!READ_ONCE(net->ipv4.sysctl_tcp_timestamps)) return false; =20 tcp_opt->sack_ok =3D (options & TS_OPT_SACK) ? TCP_SACK_SEEN : 0; =20 - if (tcp_opt->sack_ok && !net->ipv4.sysctl_tcp_sack) + if (tcp_opt->sack_ok && !READ_ONCE(net->ipv4.sysctl_tcp_sack)) return false; =20 if ((options & TS_OPT_WSCALE_MASK) =3D=3D TS_OPT_WSCALE_MASK) @@ -261,7 +261,7 @@ bool cookie_timestamp_decode(const struct net *net, tcp_opt->wscale_ok =3D 1; tcp_opt->snd_wscale =3D options & TS_OPT_WSCALE_MASK; =20 - return net->ipv4.sysctl_tcp_window_scaling !=3D 0; + return READ_ONCE(net->ipv4.sysctl_tcp_window_scaling) !=3D 0; } EXPORT_SYMBOL(cookie_timestamp_decode); =20 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index d8d903ef61f7..c2431fe41b09 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4060,7 +4060,7 @@ void tcp_parse_options(const struct net *net, break; case TCPOPT_WINDOW: if (opsize =3D=3D TCPOLEN_WINDOW && th->syn && - !estab && net->ipv4.sysctl_tcp_window_scaling) { + !estab && READ_ONCE(net->ipv4.sysctl_tcp_window_scaling)) { __u8 snd_wscale =3D *(__u8 *)ptr; opt_rx->wscale_ok =3D 1; if (snd_wscale > TCP_MAX_WSCALE) { @@ -4076,7 +4076,7 @@ void tcp_parse_options(const struct net *net, case TCPOPT_TIMESTAMP: if ((opsize =3D=3D TCPOLEN_TIMESTAMP) && ((estab && opt_rx->tstamp_ok) || - (!estab && net->ipv4.sysctl_tcp_timestamps))) { + (!estab && READ_ONCE(net->ipv4.sysctl_tcp_timestamps)))) { opt_rx->saw_tstamp =3D 1; opt_rx->rcv_tsval =3D get_unaligned_be32(ptr); opt_rx->rcv_tsecr =3D get_unaligned_be32(ptr + 4); @@ -4084,7 +4084,7 @@ void tcp_parse_options(const struct net *net, break; case TCPOPT_SACK_PERM: if (opsize =3D=3D TCPOLEN_SACK_PERM && th->syn && - !estab && net->ipv4.sysctl_tcp_sack) { + !estab && READ_ONCE(net->ipv4.sysctl_tcp_sack)) { opt_rx->sack_ok =3D TCP_SACK_SEEN; tcp_sack_reset(opt_rx); } diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 3f20642c8171..be3e90b526d8 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -789,18 +789,18 @@ static unsigned int tcp_syn_options(struct sock *sk, = struct sk_buff *skb, opts->mss =3D tcp_advertise_mss(sk); remaining -=3D TCPOLEN_MSS_ALIGNED; =20 - if (likely(sock_net(sk)->ipv4.sysctl_tcp_timestamps && !*md5)) { + if (likely(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_timestamps) && !*md5))= { opts->options |=3D OPTION_TS; opts->tsval =3D tcp_skb_timestamp(skb) + tp->tsoffset; opts->tsecr =3D tp->rx_opt.ts_recent; remaining -=3D TCPOLEN_TSTAMP_ALIGNED; } - if (likely(sock_net(sk)->ipv4.sysctl_tcp_window_scaling)) { + if (likely(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_window_scaling))) { opts->ws =3D tp->rx_opt.rcv_wscale; opts->options |=3D OPTION_WSCALE; remaining -=3D TCPOLEN_WSCALE_ALIGNED; } - if (likely(sock_net(sk)->ipv4.sysctl_tcp_sack)) { + if (likely(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_sack))) { opts->options |=3D OPTION_SACK_ADVERTISE; if (unlikely(!(OPTION_TS & opts->options))) remaining -=3D TCPOLEN_SACKPERM_ALIGNED; @@ -3645,7 +3645,7 @@ static void tcp_connect_init(struct sock *sk) * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. */ tp->tcp_header_len =3D sizeof(struct tcphdr); - if (sock_net(sk)->ipv4.sysctl_tcp_timestamps) + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_timestamps)) tp->tcp_header_len +=3D TCPOLEN_TSTAMP_ALIGNED; =20 #ifdef CONFIG_TCP_MD5SIG @@ -3681,7 +3681,7 @@ static void tcp_connect_init(struct sock *sk) tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - size= of(struct tcphdr) : 0), &tp->rcv_wnd, &tp->window_clamp, - sock_net(sk)->ipv4.sysctl_tcp_window_scaling, + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_window_scaling), &rcv_wscale, rcv_wnd); =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D515CC19F28 for ; Wed, 27 Jul 2022 17:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242892AbiG0RmL (ORCPT ); Wed, 27 Jul 2022 13:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242174AbiG0Rl2 (ORCPT ); Wed, 27 Jul 2022 13:41:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E3E61DA9; Wed, 27 Jul 2022 09:51:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E75B9B821BE; Wed, 27 Jul 2022 16:51:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47594C433D7; Wed, 27 Jul 2022 16:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940703; bh=rrAiAUY+CENqu8GGV7DyCdwuyRFhTpEkcN0ZD03/S7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNEW3cikC9G2YwH/wCt5apXK7id+LUO7+y2l+vS+veczlRgLlpadtPXfiRLAQSET/ JgOA+0lKxeZNz5e/OMXvinNPqkAQHtXAlL1n2q98j6BA8pLTYYWuoUYqRnD6OnKyh/ 673qrkpFmpbdEm3B/dUgp+Gtrdpxv08P5APuQxuA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 118/158] tcp: Fix a data-race around sysctl_tcp_early_retrans. Date: Wed, 27 Jul 2022 18:13:02 +0200 Message-Id: <20220727161026.194391483@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 52e65865deb6a36718a463030500f16530eaab74 ] While reading sysctl_tcp_early_retrans, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: eed530b6c676 ("tcp: early retransmit") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index be3e90b526d8..5cda762a43dd 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2739,7 +2739,7 @@ bool tcp_schedule_loss_probe(struct sock *sk, bool ad= vancing_rto) if (rcu_access_pointer(tp->fastopen_rsk)) return false; =20 - early_retrans =3D sock_net(sk)->ipv4.sysctl_tcp_early_retrans; + early_retrans =3D READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_early_retrans); /* Schedule a loss probe in 2*RTT for SACK capable connections * not in loss recovery, that are either limited by cwnd or application. */ --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDCEDC04A68 for ; Wed, 27 Jul 2022 17:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242903AbiG0RmO (ORCPT ); Wed, 27 Jul 2022 13:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242715AbiG0Rli (ORCPT ); Wed, 27 Jul 2022 13:41:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AEEF62482; Wed, 27 Jul 2022 09:51:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AFD85B821D5; Wed, 27 Jul 2022 16:51:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C6C4C433C1; Wed, 27 Jul 2022 16:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940706; bh=YJOP/FUyxZsIkOStIFg3/BX0znM1CjbRTOAZXfoPaQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGIatiC7wN1XODNFXYNeC+nhWr/Ro/0uJAHueIZ+YuNh8wGBtO0ZtgHX4GsQ4yk7Y kitzkGGeFjmqeo0e8efS31d2JpjPkiFdWrz/TrWyMY1XUZXK5dWcif7sFjWShIGmGp JIF/XKTmOeML1jt1IiMUjLisJHMqpRTKKEu7BcLM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 119/158] tcp: Fix data-races around sysctl_tcp_recovery. Date: Wed, 27 Jul 2022 18:13:03 +0200 Message-Id: <20220727161026.223820035@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit e7d2ef837e14a971a05f60ea08c47f3fed1a36e4 ] While reading sysctl_tcp_recovery, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 4f41b1c58a32 ("tcp: use RACK to detect losses") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_input.c | 3 ++- net/ipv4/tcp_recovery.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index c2431fe41b09..61f93f51adbb 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2095,7 +2095,8 @@ static inline void tcp_init_undo(struct tcp_sock *tp) =20 static bool tcp_is_rack(const struct sock *sk) { - return sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_LOSS_DETECTION; + return READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & + TCP_RACK_LOSS_DETECTION; } =20 /* If we detect SACK reneging, forget all SACK information diff --git a/net/ipv4/tcp_recovery.c b/net/ipv4/tcp_recovery.c index fd113f6226ef..ac14216f6204 100644 --- a/net/ipv4/tcp_recovery.c +++ b/net/ipv4/tcp_recovery.c @@ -19,7 +19,8 @@ static u32 tcp_rack_reo_wnd(const struct sock *sk) return 0; =20 if (tp->sacked_out >=3D tp->reordering && - !(sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_NO_DUPTHRESH)) + !(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & + TCP_RACK_NO_DUPTHRESH)) return 0; } =20 @@ -192,7 +193,8 @@ void tcp_rack_update_reo_wnd(struct sock *sk, struct ra= te_sample *rs) { struct tcp_sock *tp =3D tcp_sk(sk); =20 - if (sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_STATIC_REO_WND || + if ((READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) & + TCP_RACK_STATIC_REO_WND) || !rs->prior_delivered) return; =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D158EC04A68 for ; Wed, 27 Jul 2022 17:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242860AbiG0RmQ (ORCPT ); Wed, 27 Jul 2022 13:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242823AbiG0Rlk (ORCPT ); Wed, 27 Jul 2022 13:41:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D9FE88F1F; Wed, 27 Jul 2022 09:51:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9C63601CD; Wed, 27 Jul 2022 16:51:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5757C433C1; Wed, 27 Jul 2022 16:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940709; bh=WFxdTAFTDOeA3kkSiLosrw9dd3leJML+aRruvvmgrDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=skHRtzXn89xMoRmj39XY7AeF7/cybr54OlUcvbORaKWcHuxbtTLQWk+J9EwiAKx4F AiLeKrrNsydVLIB5eiCKY28RqI1O5VJGWtMWWzKQ0ai763rRi+Ej/OnKlaZo6jIxWA UnvOZ+ahTosnHjlWUN+q4glpVA/6DaCAhRAHdMeA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 120/158] tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts. Date: Wed, 27 Jul 2022 18:13:04 +0200 Message-Id: <20220727161026.265804658@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 7c6f2a86ca590d5187a073d987e9599985fb1c7c ] While reading sysctl_tcp_thin_linear_timeouts, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 36e31b0af587 ("net: TCP thin linear timeouts") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index ec5277becc6a..50bba370486e 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -578,7 +578,7 @@ void tcp_retransmit_timer(struct sock *sk) * linear-timeout retransmissions into a black hole */ if (sk->sk_state =3D=3D TCP_ESTABLISHED && - (tp->thin_lto || net->ipv4.sysctl_tcp_thin_linear_timeouts) && + (tp->thin_lto || READ_ONCE(net->ipv4.sysctl_tcp_thin_linear_timeouts)= ) && tcp_stream_is_thin(tp) && icsk->icsk_retransmits <=3D TCP_THIN_LINEAR_RETRIES) { icsk->icsk_backoff =3D 0; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D4C2C19F28 for ; Wed, 27 Jul 2022 17:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242836AbiG0Rm2 (ORCPT ); Wed, 27 Jul 2022 13:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242802AbiG0Rlm (ORCPT ); Wed, 27 Jul 2022 13:41:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68C2189647; Wed, 27 Jul 2022 09:51:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 07686B821BE; Wed, 27 Jul 2022 16:51:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67DB9C433C1; Wed, 27 Jul 2022 16:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940711; bh=klKyENgDMgQoTOB1na83eS8HEPD+pBR+wp44LUbuklY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dbd8c//+lRo1TJnAncv2uHH2HkHMAryE3H9jBsdkIZ9LXRm8YIaNTWEfqLGH1OCcT Ziu45p7f9bWyUcQuMVT03ba+qEqk9+6QOdqzw6a8pQXQGmxF35DHNABKj2ERHOloSU N+So08HIxpCBiQq6sWYAVUJgwL3fVqPYGxQr/thU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 121/158] tcp: Fix data-races around sysctl_tcp_slow_start_after_idle. Date: Wed, 27 Jul 2022 18:13:05 +0200 Message-Id: <20220727161026.301572600@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 4845b5713ab18a1bb6e31d1fbb4d600240b8b691 ] While reading sysctl_tcp_slow_start_after_idle, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 35089bb203f4 ("[TCP]: Add tcp_slow_start_after_idle sysctl.") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- include/net/tcp.h | 4 ++-- net/ipv4/tcp_output.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 8d02972e46cd..4f5de382e192 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1421,8 +1421,8 @@ static inline void tcp_slow_start_after_idle_check(st= ruct sock *sk) struct tcp_sock *tp =3D tcp_sk(sk); s32 delta; =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle || tp->packets_o= ut || - ca_ops->cong_control) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) || + tp->packets_out || ca_ops->cong_control) return; delta =3D tcp_jiffies32 - tp->lsndtime; if (delta > inet_csk(sk)->icsk_rto) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5cda762a43dd..5bcd12a9d8ff 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1896,7 +1896,7 @@ static void tcp_cwnd_validate(struct sock *sk, bool i= s_cwnd_limited) if (tp->packets_out > tp->snd_cwnd_used) tp->snd_cwnd_used =3D tp->packets_out; =20 - if (sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle && + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_slow_start_after_idle) && (s32)(tcp_jiffies32 - tp->snd_cwnd_stamp) >=3D inet_csk(sk)->icsk_rt= o && !ca_ops->cong_control) tcp_cwnd_application_limited(sk); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A77DC19F2B for ; Wed, 27 Jul 2022 17:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242923AbiG0Rmd (ORCPT ); Wed, 27 Jul 2022 13:42:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242830AbiG0RmD (ORCPT ); Wed, 27 Jul 2022 13:42:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1213589673; Wed, 27 Jul 2022 09:51:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B9DE6B821D6; Wed, 27 Jul 2022 16:51:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C96C433C1; Wed, 27 Jul 2022 16:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940714; bh=l3mwjhAdh9vaET8S0McZQ161/v+bpnj6NIuGufFIO/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/Wx2N1emBdDmBk79A+NrjHxDHA55le4nXFQ6CJ7B4GgPL7I7OFt+2MEcLPt3yuHu tv6N0QfaEfiH9PR2x/6s+AKPuILoyLaAgzKx/SXRLsrweD9eP7HDjCwBA0w3oDcHnM lzN4gF0LBl55cZ8ycKr+0rt47Hrs/459hVepRdpo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 122/158] tcp: Fix a data-race around sysctl_tcp_retrans_collapse. Date: Wed, 27 Jul 2022 18:13:06 +0200 Message-Id: <20220727161026.339594298@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 1a63cb91f0c2fcdeced6d6edee8d1d886583d139 ] While reading sysctl_tcp_retrans_collapse, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5bcd12a9d8ff..3554a4c1e1b8 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3103,7 +3103,7 @@ static void tcp_retrans_try_collapse(struct sock *sk,= struct sk_buff *to, struct sk_buff *skb =3D to, *tmp; bool first =3D true; =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_retrans_collapse) + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_retrans_collapse)) return; if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) return; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CA9DC04A68 for ; Wed, 27 Jul 2022 17:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242934AbiG0Rmg (ORCPT ); Wed, 27 Jul 2022 13:42:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242630AbiG0RmI (ORCPT ); Wed, 27 Jul 2022 13:42:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69C389A41; Wed, 27 Jul 2022 09:51:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D204860D3B; Wed, 27 Jul 2022 16:51:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7177C433C1; Wed, 27 Jul 2022 16:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940717; bh=bEvh96giO+mQ+UXB0KNDCrEldLcmJT88Vz8ftaHMaKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X2x+Yx3jDWFQmzmXlT0iN34IcfYXIC5jelx6YKfSesCGe/QtG1jm63lx/b4I6wRdf /3Bu76R4AUcFJ2vbaZyhjdZ1ZAYQ1WNAYD2wQkPfkCbnH2bXGteoduCwfIcBkbh8hI s+6m+vuBcSLpB3/Gukoml2JVMlBIGxeNJ09uRS50= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 123/158] tcp: Fix a data-race around sysctl_tcp_stdurg. Date: Wed, 27 Jul 2022 18:13:07 +0200 Message-Id: <20220727161026.372963345@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 4e08ed41cb1194009fc1a916a59ce3ed4afd77cd ] While reading sysctl_tcp_stdurg, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 61f93f51adbb..f200dd654e05 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5576,7 +5576,7 @@ static void tcp_check_urg(struct sock *sk, const stru= ct tcphdr *th) struct tcp_sock *tp =3D tcp_sk(sk); u32 ptr =3D ntohs(th->urg_ptr); =20 - if (ptr && !sock_net(sk)->ipv4.sysctl_tcp_stdurg) + if (ptr && !READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_stdurg)) ptr--; ptr +=3D ntohl(th->seq); =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C25FC04A68 for ; Wed, 27 Jul 2022 17:42:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242913AbiG0Rms (ORCPT ); Wed, 27 Jul 2022 13:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242915AbiG0Rm1 (ORCPT ); Wed, 27 Jul 2022 13:42:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90F2E89A75; Wed, 27 Jul 2022 09:52:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4773BB821C5; Wed, 27 Jul 2022 16:52:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE3F7C433C1; Wed, 27 Jul 2022 16:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940720; bh=Xl9sRDF9sc29xWgP/tW10flhp2hCMprbdKqXNsWxBqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y6Z/l4IlW10m/kO0LIcgJ8emT7Awu6RqcTXtsjnPjX3JunrX/qRD7Orzvulz8TiSt CPvJKWf/Zm3fPc3/iivrwIZX20ae96mv8AhRqvAfuQQVFnBLtSGSq43TUOJa7axmsQ GAXHGliQzsqqBvWdIc5+/9A61AGpgjKAMB0moDTM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 124/158] tcp: Fix a data-race around sysctl_tcp_rfc1337. Date: Wed, 27 Jul 2022 18:13:08 +0200 Message-Id: <20220727161026.402649066@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 0b484c91911e758e53656d570de58c2ed81ec6f2 ] While reading sysctl_tcp_rfc1337, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_minisocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 6854bb1fb32b..700ea548d125 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -173,7 +173,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *t= w, struct sk_buff *skb, * Oh well... nobody has a sufficient solution to this * protocol bug yet. */ - if (twsk_net(tw)->ipv4.sysctl_tcp_rfc1337 =3D=3D 0) { + if (!READ_ONCE(twsk_net(tw)->ipv4.sysctl_tcp_rfc1337)) { kill: inet_twsk_deschedule_put(tw); return TCP_TW_SUCCESS; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE898C19F2C for ; Wed, 27 Jul 2022 17:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242862AbiG0RnE (ORCPT ); Wed, 27 Jul 2022 13:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242857AbiG0Rmn (ORCPT ); Wed, 27 Jul 2022 13:42:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC88D89A90; Wed, 27 Jul 2022 09:52:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 37A6CB821D7; Wed, 27 Jul 2022 16:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86FFCC433C1; Wed, 27 Jul 2022 16:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940722; bh=hxgcvMTvNSZKY1LbJyxjDjAjHTORj28qIVb/oxjNTkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZdBoWvoybVPgN3A4QthOr2EtbPxOcnzAGEsJ1dFlfR71KYTF214QG57QQI5y1w6nN GUpDSOCqjoLbwLEZ5WjwFoF++GVdHrwdoUKuXWC4ljxyFlP6yvGRumWCIMSjouLNwV /5RVB5LR8tFE2WmqGnlBpe3FfX6MIVmQ0ZdcS4SY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 125/158] tcp: Fix a data-race around sysctl_tcp_abort_on_overflow. Date: Wed, 27 Jul 2022 18:13:09 +0200 Message-Id: <20220727161026.431866849@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 2d17d9c7382327d00aeaea35af44e9b26d53206e ] While reading sysctl_tcp_abort_on_overflow, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_minisocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 700ea548d125..cb95d88497ae 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -781,7 +781,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_b= uff *skb, if (sk !=3D req->rsk_listener) __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMIGRATEREQFAILURE); =20 - if (!sock_net(sk)->ipv4.sysctl_tcp_abort_on_overflow) { + if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_abort_on_overflow)) { inet_rsk(req)->acked =3D 1; return NULL; } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 134F1C04A68 for ; Wed, 27 Jul 2022 17:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242952AbiG0RnH (ORCPT ); Wed, 27 Jul 2022 13:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238233AbiG0Rmo (ORCPT ); Wed, 27 Jul 2022 13:42:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6349D62A45; Wed, 27 Jul 2022 09:52:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC70C61748; Wed, 27 Jul 2022 16:52:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0727EC433D6; Wed, 27 Jul 2022 16:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940728; bh=nE0ZGl0fvIwXNuurVCSkbU/ykXts7IWIG215q8LiHyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zByXmEdf08SAp6mADNcxqDedl5VDrvAZCwqe+EgiXppWI3du+Wrk1amIHIRHgHB6J fgnSoRjubS086bbE6PCiNVeNN5X4Ptni1vDqOl2m0gLYc/dw7rVxMEr2xo/hat+fiu RSyFrdKB/DuzHUKM1kPBkiYx2Th+Ym199CHKv4+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 126/158] tcp: Fix data-races around sysctl_tcp_max_reordering. Date: Wed, 27 Jul 2022 18:13:10 +0200 Message-Id: <20220727161026.462814413@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit a11e5b3e7a59fde1a90b0eaeaa82320495cf8cae ] While reading sysctl_tcp_max_reordering, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: dca145ffaa8d ("tcp: allow for bigger reordering level") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- net/ipv4/tcp_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index f200dd654e05..19b186a4a8e8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1051,7 +1051,7 @@ static void tcp_check_sack_reordering(struct sock *sk= , const u32 low_seq, tp->undo_marker ? tp->undo_retrans : 0); #endif tp->reordering =3D min_t(u32, (metric + mss - 1) / mss, - sock_net(sk)->ipv4.sysctl_tcp_max_reordering); + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_max_reordering)); } =20 /* This exciting event is worth to be remembered. 8) */ @@ -2030,7 +2030,7 @@ static void tcp_check_reno_reordering(struct sock *sk= , const int addend) return; =20 tp->reordering =3D min_t(u32, tp->packets_out + addend, - sock_net(sk)->ipv4.sysctl_tcp_max_reordering); + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_max_reordering)); tp->reord_seen++; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRENOREORDER); } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A689C19F2B for ; Wed, 27 Jul 2022 17:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242976AbiG0RnQ (ORCPT ); Wed, 27 Jul 2022 13:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242910AbiG0Rmr (ORCPT ); Wed, 27 Jul 2022 13:42:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7FF54ACA; Wed, 27 Jul 2022 09:52:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7DB1CB821D4; Wed, 27 Jul 2022 16:52:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBCB1C433C1; Wed, 27 Jul 2022 16:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940731; bh=W/HHsRq2sC87P8Jl6L/qDVBFwjJgLDL+rERMXNdKZ0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=or/Y+9hG4ZTKz4NPsfuENi0KzFrBYEJkivuagANuG9iNOAyG/dg7XcKvAhCWN2kEp x5Fc4DVOCbbI85JyRftd09j0BMfdEqIfo8FI5o+GuhPcSoqeBHe2GGaq1m/Mlt8Mp3 UULdzwZlLIxG70qyWqT9SPi855HTUhY8TM9NOU00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oz Shlomo , Roi Dayan , Baowen Zheng , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 127/158] net/sched: cls_api: Fix flow action initialization Date: Wed, 27 Jul 2022 18:13:11 +0200 Message-Id: <20220727161026.492887422@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Oz Shlomo [ Upstream commit c0f47c2822aadeb8b2829f3e4c3792f184c7be33 ] The cited commit refactored the flow action initialization sequence to use an interface method when translating tc action instances to flow offload objects. The refactored version skips the initialization of the generic flow action attributes for tc actions, such as pedit, that allocate more than one offload entry. This can cause potential issues for drivers mapping flow action ids. Populate the generic flow action fields for all the flow action entries. Fixes: c54e1d920f04 ("flow_offload: add ops to tc_action_ops for flow actio= n setup") Signed-off-by: Oz Shlomo Reviewed-by: Roi Dayan Reviewed-by: Baowen Zheng Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee ---- v1 -> v2: - coalese the generic flow action fields initialization to a single loop Reviewed-by: Baowen Zheng Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/cls_api.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2d4dc1468a9a..6fd33c75d6bb 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3531,7 +3531,7 @@ int tc_setup_action(struct flow_action *flow_action, struct tc_action *actions[], struct netlink_ext_ack *extack) { - int i, j, index, err =3D 0; + int i, j, k, index, err =3D 0; struct tc_action *act; =20 BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY !=3D FLOW_ACTION_HW_STATS_ANY); @@ -3551,14 +3551,18 @@ int tc_setup_action(struct flow_action *flow_action, if (err) goto err_out_locked; =20 - entry->hw_stats =3D tc_act_hw_stats(act->hw_stats); - entry->hw_index =3D act->tcfa_index; index =3D 0; err =3D tc_setup_offload_act(act, entry, &index, extack); - if (!err) - j +=3D index; - else + if (err) goto err_out_locked; + + for (k =3D 0; k < index ; k++) { + entry[k].hw_stats =3D tc_act_hw_stats(act->hw_stats); + entry[k].hw_index =3D act->tcfa_index; + } + + j +=3D index; + spin_unlock_bh(&act->tcfa_lock); } =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72A04C04A68 for ; Wed, 27 Jul 2022 17:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242856AbiG0Rnc (ORCPT ); Wed, 27 Jul 2022 13:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242739AbiG0Rm6 (ORCPT ); Wed, 27 Jul 2022 13:42:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23CD654656; Wed, 27 Jul 2022 09:52:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7E0E0616D1; Wed, 27 Jul 2022 16:52:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B06AC433C1; Wed, 27 Jul 2022 16:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940733; bh=A4PSEb0B3P0mqsdnh4osQB/Gotdxco+7iYeqMIbckC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=itvK3J/0WE+cT/J3QsNCX3C6l1QAN07iHuzpUIzj7FjNpPeVLtqstsBdl10oabR0v A0kO2B3y0RCPqAQ9aT5dRsbe+bb9qqrZdubCo1rX63lNnC7K/TEvVLX8MaHdjka2m/ 9banBrlOE8hsk5BCjdR2jAHG/cPj46BqIAzHsiQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Kent Gibson , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.18 128/158] selftests: gpio: fix include path to kernel headers for out of tree builds Date: Wed, 27 Jul 2022 18:13:12 +0200 Message-Id: <20220727161026.541816139@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kent Gibson [ Upstream commit f63731e18e8d8350e05b0176e39a76639f6483c7 ] When building selftests out of the kernel tree the gpio.h the include path is incorrect and the build falls back to the system includes which may be outdated. Add the KHDR_INCLUDES to the CFLAGS to include the gpio.h from the build tree. Fixes: 4f4d0af7b2d9 ("selftests: gpio: restore CFLAGS options") Reported-by: kernel test robot Signed-off-by: Kent Gibson Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- tools/testing/selftests/gpio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftest= s/gpio/Makefile index 71b306602368..616ed4019655 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -3,6 +3,6 @@ TEST_PROGS :=3D gpio-mockup.sh gpio-sim.sh TEST_FILES :=3D gpio-mockup-sysfs.sh TEST_GEN_PROGS_EXTENDED :=3D gpio-mockup-cdev gpio-chip-info gpio-line-name -CFLAGS +=3D -O2 -g -Wall -I../../../../usr/include/ +CFLAGS +=3D -O2 -g -Wall -I../../../../usr/include/ $(KHDR_INCLUDES) =20 include ../lib.mk --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94266C19F28 for ; Wed, 27 Jul 2022 17:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242925AbiG0RnT (ORCPT ); Wed, 27 Jul 2022 13:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242926AbiG0Rmu (ORCPT ); Wed, 27 Jul 2022 13:42:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC41B89AA4; Wed, 27 Jul 2022 09:52:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E6DDFB821C5; Wed, 27 Jul 2022 16:52:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44A09C433C1; Wed, 27 Jul 2022 16:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940736; bh=fuBdEORhVUHgoKP0511WtVTCy7BoG+RleVc/OuNVrLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CFr85k42K/0hzjbJFLDHewwTBHiZ2u8kEthZ60V+YrErEwAP0UpcvzKzuksq3ajM7 GBcanww6RBcpyzx4Ivv0T6+xi0ijE8QrBH7AE4CmCVV7gtI4BhX+U1G4OaHWzSemZg TuNILn6atLq4S3yIrLoueQBssJu5iwNYZGPAuSr0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Neeli , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.18 129/158] gpio: gpio-xilinx: Fix integer overflow Date: Wed, 27 Jul 2022 18:13:13 +0200 Message-Id: <20220727161026.580717761@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Srinivas Neeli [ Upstream commit 32c094a09d5829ad9b02cdf667569aefa8de0ea6 ] Current implementation is not able to configure more than 32 pins due to incorrect data type. So type casting with unsigned long to avoid it. Fixes: 02b3f84d9080 ("xilinx: Switch to use bitmap APIs") Signed-off-by: Srinivas Neeli Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpio/gpio-xilinx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index b6d3a57e27ed..7f8e2fed2988 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -99,7 +99,7 @@ static inline void xgpio_set_value32(unsigned long *map, = int bit, u32 v) const unsigned long offset =3D (bit % BITS_PER_LONG) & BIT(5); =20 map[index] &=3D ~(0xFFFFFFFFul << offset); - map[index] |=3D v << offset; + map[index] |=3D (unsigned long)v << offset; } =20 static inline int xgpio_regoffset(struct xgpio_instance *chip, int ch) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2675C19F28 for ; Wed, 27 Jul 2022 17:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242935AbiG0Rn3 (ORCPT ); Wed, 27 Jul 2022 13:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242931AbiG0Rm5 (ORCPT ); Wed, 27 Jul 2022 13:42:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB77B62A50; Wed, 27 Jul 2022 09:52:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C4E660D3B; Wed, 27 Jul 2022 16:52:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2475CC433C1; Wed, 27 Jul 2022 16:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940739; bh=nuk6k46O1twf9CdjFjcfM3U4cWPkm33h0fNx0B0HY3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oUAmARHiE9bYAMdfJx9fMrSoxKcWbCVw0wPEGVXigak0F7TJcSENQxepiwJSOmwdq sMNWmDvn1FyJfC9Q87dIjlkwjEPtppL0G9MK9HFLBTA+rRWHFWsZvi1PyJhU8urwV8 mmET15ioMflC3MnkWF/SNOs+PwjthNDXo4KnLDpU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Gavin Shan , Oliver Upton , Andrew Jones , Paolo Bonzini Subject: [PATCH 5.18 130/158] KVM: selftests: Fix target thread to be migrated in rseq_test Date: Wed, 27 Jul 2022 18:13:14 +0200 Message-Id: <20220727161026.610932328@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Gavin Shan commit e923b0537d28e15c9d31ce8b38f810b325816903 upstream. In rseq_test, there are two threads, which are vCPU thread and migration worker separately. Unfortunately, the test has the wrong PID passed to sched_setaffinity() in the migration worker. It forces migration on the migration worker because zeroed PID represents the calling thread, which is the migration worker itself. It means the vCPU thread is never enforced to migration and it can migrate at any time, which eventually leads to failure as the following logs show. host# uname -r 5.19.0-rc6-gavin+ host# # cat /proc/cpuinfo | grep processor | tail -n 1 processor : 223 host# pwd /home/gavin/sandbox/linux.main/tools/testing/selftests/kvm host# for i in `seq 1 100`; do \ echo "--------> $i"; ./rseq_test; done --------> 1 --------> 2 --------> 3 --------> 4 --------> 5 --------> 6 =3D=3D=3D=3D Test Assertion Failure =3D=3D=3D=3D rseq_test.c:265: rseq_cpu =3D=3D cpu pid=3D3925 tid=3D3925 errno=3D4 - Interrupted system call 1 0x0000000000401963: main at rseq_test.c:265 (discriminator 2) 2 0x0000ffffb044affb: ?? ??:0 3 0x0000ffffb044b0c7: ?? ??:0 4 0x0000000000401a6f: _start at ??:? rseq CPU =3D 4, sched CPU =3D 27 Fix the issue by passing correct parameter, TID of the vCPU thread, to sched_setaffinity() in the migration worker. Fixes: 61e52f1630f5 ("KVM: selftests: Add a test for KVM_RUN+rseq to detect= task migration bugs") Suggested-by: Sean Christopherson Signed-off-by: Gavin Shan Reviewed-by: Oliver Upton Message-Id: <20220719020830.3479482-1-gshan@redhat.com> Reviewed-by: Andrew Jones Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- tools/testing/selftests/kvm/rseq_test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/tools/testing/selftests/kvm/rseq_test.c +++ b/tools/testing/selftests/kvm/rseq_test.c @@ -82,8 +82,9 @@ static int next_cpu(int cpu) return cpu; } =20 -static void *migration_worker(void *ign) +static void *migration_worker(void *__rseq_tid) { + pid_t rseq_tid =3D (pid_t)(unsigned long)__rseq_tid; cpu_set_t allowed_mask; int r, i, cpu; =20 @@ -106,7 +107,7 @@ static void *migration_worker(void *ign) * stable, i.e. while changing affinity is in-progress. */ smp_wmb(); - r =3D sched_setaffinity(0, sizeof(allowed_mask), &allowed_mask); + r =3D sched_setaffinity(rseq_tid, sizeof(allowed_mask), &allowed_mask); TEST_ASSERT(!r, "sched_setaffinity failed, errno =3D %d (%s)", errno, strerror(errno)); smp_wmb(); @@ -231,7 +232,8 @@ int main(int argc, char *argv[]) vm =3D vm_create_default(VCPU_ID, 0, guest_code); ucall_init(vm, NULL); =20 - pthread_create(&migration_thread, NULL, migration_worker, 0); + pthread_create(&migration_thread, NULL, migration_worker, + (void *)(unsigned long)gettid()); =20 for (i =3D 0; !done; i++) { vcpu_run(vm, VCPU_ID); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6970C04A68 for ; Wed, 27 Jul 2022 17:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242739AbiG0Rsu (ORCPT ); Wed, 27 Jul 2022 13:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243201AbiG0RsS (ORCPT ); Wed, 27 Jul 2022 13:48:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5505F2E9F7; Wed, 27 Jul 2022 09:54:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2152BB821AC; Wed, 27 Jul 2022 16:53:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F0CEC433D6; Wed, 27 Jul 2022 16:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940837; bh=Nz5k/Pa4IhuCRVsu7UChZptB4Ka9QpSOYr0VI7yB1mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ykKm8yErsQe6Tv6TWPNuFtE4//NY8UD0HEZuJX1lHLLykn8xJp8TqADhh2/8AhMpk PMcnw058rnPUZ5Apz5ZZ4vUMZ4xuxrOquLVcrolUYhMM1Sgrxh0NUxW19a1N8/fn2o eLunvE9up1j1AbR9VP9dWR2A+BVuPHnDnEFm47/s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Marc Kleine-Budde , Mark Brown Subject: [PATCH 5.18 131/158] spi: bcm2835: bcm2835_spi_handle_err(): fix NULL pointer deref for non DMA transfers Date: Wed, 27 Jul 2022 18:13:15 +0200 Message-Id: <20220727161026.649979100@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Marc Kleine-Budde commit 4ceaa684459d414992acbefb4e4c31f2dfc50641 upstream. In case a IRQ based transfer times out the bcm2835_spi_handle_err() function is called. Since commit 1513ceee70f2 ("spi: bcm2835: Drop dma_pending flag") the TX and RX DMA transfers are unconditionally canceled, leading to NULL pointer derefs if ctlr->dma_tx or ctlr->dma_rx are not set. Fix the NULL pointer deref by checking that ctlr->dma_tx and ctlr->dma_rx are valid pointers before accessing them. Fixes: 1513ceee70f2 ("spi: bcm2835: Drop dma_pending flag") Cc: Lukas Wunner Signed-off-by: Marc Kleine-Budde Link: https://lore.kernel.org/r/20220719072234.2782764-1-mkl@pengutronix.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/spi/spi-bcm2835.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -1138,10 +1138,14 @@ static void bcm2835_spi_handle_err(struc struct bcm2835_spi *bs =3D spi_controller_get_devdata(ctlr); =20 /* if an error occurred and we have an active dma, then terminate */ - dmaengine_terminate_sync(ctlr->dma_tx); - bs->tx_dma_active =3D false; - dmaengine_terminate_sync(ctlr->dma_rx); - bs->rx_dma_active =3D false; + if (ctlr->dma_tx) { + dmaengine_terminate_sync(ctlr->dma_tx); + bs->tx_dma_active =3D false; + } + if (ctlr->dma_rx) { + dmaengine_terminate_sync(ctlr->dma_rx); + bs->rx_dma_active =3D false; + } bcm2835_spi_undo_prologue(bs); =20 /* and reset */ From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4343EC04A68 for ; Wed, 27 Jul 2022 17:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242972AbiG0RpE (ORCPT ); Wed, 27 Jul 2022 13:45:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242884AbiG0Rnx (ORCPT ); Wed, 27 Jul 2022 13:43:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D188AB22; Wed, 27 Jul 2022 09:52:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 287ABB821C5; Wed, 27 Jul 2022 16:52:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80F31C433C1; Wed, 27 Jul 2022 16:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940761; bh=ccuhAFP7Pd2RNc4Jmg+ShmILDJdlYXwxHsxkBs6VuDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1D1x3/47YuRjAFX5LNanRHhZsXuItYrr/d6o2kejSgg7k6YHlf6eo3AsGsyKnkP6 reql2QqBqnRW82Zm6Gy9hDQSiSa6kKreAOPZh2CS1U5wKmtnEOQp2fw7++BCtHg4m7 hC4Tq+fxNwFrXg+aY2f2Zl3nxNnQKdaPoBc6u0tA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , Alexey Kardashevskiy Subject: [PATCH 5.18 132/158] KVM: Dont null dereference ops->destroy Date: Wed, 27 Jul 2022 18:13:16 +0200 Message-Id: <20220727161026.679104794@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexey Kardashevskiy commit e8bc2427018826e02add7b0ed0fc625a60390ae5 upstream. A KVM device cleanup happens in either of two callbacks: 1) destroy() which is called when the VM is being destroyed; 2) release() which is called when a device fd is closed. Most KVM devices use 1) but Book3s's interrupt controller KVM devices (XICS, XIVE, XIVE-native) use 2) as they need to close and reopen during the machine execution. The error handling in kvm_ioctl_create_device() assumes destroy() is always defined which leads to NULL dereference as discovered by Syzkaller. This adds a checks for destroy!=3DNULL and adds a missing release(). This is not changing kvm_destroy_devices() as devices with defined release() should have been removed from the KVM devices list by then. Suggested-by: Paolo Bonzini Signed-off-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- virt/kvm/kvm_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4299,8 +4299,11 @@ static int kvm_ioctl_create_device(struc kvm_put_kvm_no_destroy(kvm); mutex_lock(&kvm->lock); list_del(&dev->vm_node); + if (ops->release) + ops->release(dev); mutex_unlock(&kvm->lock); - ops->destroy(dev); + if (ops->destroy) + ops->destroy(dev); return ret; } From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90891C04A68 for ; Wed, 27 Jul 2022 17:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243131AbiG0Rp4 (ORCPT ); Wed, 27 Jul 2022 13:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243256AbiG0Rod (ORCPT ); Wed, 27 Jul 2022 13:44:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9884B8BAA2; Wed, 27 Jul 2022 09:53:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 18936B821C5; Wed, 27 Jul 2022 16:53:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 737D4C433C1; Wed, 27 Jul 2022 16:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940792; bh=pUwlwt6IhOGRGSV4Ytm/b7hka4ogE1ebBrYzVKUBDbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=parUcETPDJJcArJDt6nLQN2t6NIycR9TwEUjH9NAgLBsdBIiZnPpN2OvOTkCkWRaQ iU6gqvJkuUgqPJyFUdsvbZ4C7RtpsIJFEuv/DBM6Y3Dsny7VhjF/Aq2WNaaNTSEfDM B0OKXoUtefdmTuB4AfUFBW6VZvsRD2R7LDGcumIM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Cheng , syzbot+217f792c92599518a2ab@syzkaller.appspotmail.com, David Rientjes , Vlastimil Babka , Andrew Morton Subject: [PATCH 5.18 133/158] mm/mempolicy: fix uninit-value in mpol_rebind_policy() Date: Wed, 27 Jul 2022 18:13:17 +0200 Message-Id: <20220727161026.719300448@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Wang Cheng commit 018160ad314d75b1409129b2247b614a9f35894c upstream. mpol_set_nodemask()(mm/mempolicy.c) does not set up nodemask when pol->mode is MPOL_LOCAL. Check pol->mode before access pol->w.cpuset_mems_allowed in mpol_rebind_policy()(mm/mempolicy.c). BUG: KMSAN: uninit-value in mpol_rebind_policy mm/mempolicy.c:352 [inline] BUG: KMSAN: uninit-value in mpol_rebind_task+0x2ac/0x2c0 mm/mempolicy.c:368 mpol_rebind_policy mm/mempolicy.c:352 [inline] mpol_rebind_task+0x2ac/0x2c0 mm/mempolicy.c:368 cpuset_change_task_nodemask kernel/cgroup/cpuset.c:1711 [inline] cpuset_attach+0x787/0x15e0 kernel/cgroup/cpuset.c:2278 cgroup_migrate_execute+0x1023/0x1d20 kernel/cgroup/cgroup.c:2515 cgroup_migrate kernel/cgroup/cgroup.c:2771 [inline] cgroup_attach_task+0x540/0x8b0 kernel/cgroup/cgroup.c:2804 __cgroup1_procs_write+0x5cc/0x7a0 kernel/cgroup/cgroup-v1.c:520 cgroup1_tasks_write+0x94/0xb0 kernel/cgroup/cgroup-v1.c:539 cgroup_file_write+0x4c2/0x9e0 kernel/cgroup/cgroup.c:3852 kernfs_fop_write_iter+0x66a/0x9f0 fs/kernfs/file.c:296 call_write_iter include/linux/fs.h:2162 [inline] new_sync_write fs/read_write.c:503 [inline] vfs_write+0x1318/0x2030 fs/read_write.c:590 ksys_write+0x28b/0x510 fs/read_write.c:643 __do_sys_write fs/read_write.c:655 [inline] __se_sys_write fs/read_write.c:652 [inline] __x64_sys_write+0xdb/0x120 fs/read_write.c:652 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x44/0xae Uninit was created at: slab_post_alloc_hook mm/slab.h:524 [inline] slab_alloc_node mm/slub.c:3251 [inline] slab_alloc mm/slub.c:3259 [inline] kmem_cache_alloc+0x902/0x11c0 mm/slub.c:3264 mpol_new mm/mempolicy.c:293 [inline] do_set_mempolicy+0x421/0xb70 mm/mempolicy.c:853 kernel_set_mempolicy mm/mempolicy.c:1504 [inline] __do_sys_set_mempolicy mm/mempolicy.c:1510 [inline] __se_sys_set_mempolicy+0x44c/0xb60 mm/mempolicy.c:1507 __x64_sys_set_mempolicy+0xd8/0x110 mm/mempolicy.c:1507 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x44/0xae KMSAN: uninit-value in mpol_rebind_task (2) https://syzkaller.appspot.com/bug?id=3Dd6eb90f952c2a5de9ea718a1b873c55cb13b= 59dc This patch seems to fix below bug too. KMSAN: uninit-value in mpol_rebind_mm (2) https://syzkaller.appspot.com/bug?id=3Df2fecd0d7013f54ec4162f60743a2b28df40= 926b The uninit-value is pol->w.cpuset_mems_allowed in mpol_rebind_policy(). When syzkaller reproducer runs to the beginning of mpol_new(), mpol_new() mm/mempolicy.c do_mbind() mm/mempolicy.c kernel_mbind() mm/mempolicy.c `mode` is 1(MPOL_PREFERRED), nodes_empty(*nodes) is `true` and `flags` is 0. Then mode =3D MPOL_LOCAL; ... policy->mode =3D mode; policy->flags =3D flags; will be executed. So in mpol_set_nodemask(), mpol_set_nodemask() mm/mempolicy.c do_mbind() kernel_mbind() pol->mode is 4 (MPOL_LOCAL), that `nodemask` in `pol` is not initialized, which will be accessed in mpol_rebind_policy(). Link: https://lkml.kernel.org/r/20220512123428.fq3wofedp6oiotd4@ppc.localdo= main Signed-off-by: Wang Cheng Reported-by: Tested-by: Cc: David Rientjes Cc: Vlastimil Babka Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -350,7 +350,7 @@ static void mpol_rebind_preferred(struct */ static void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *ne= wmask) { - if (!pol) + if (!pol || pol->mode =3D=3D MPOL_LOCAL) return; if (!mpol_store_user_nodemask(pol) && nodes_equal(pol->w.cpuset_mems_allowed, *newmask)) From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8CF2C04A68 for ; Wed, 27 Jul 2022 17:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243002AbiG0Rqw (ORCPT ); Wed, 27 Jul 2022 13:46:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242993AbiG0RqY (ORCPT ); Wed, 27 Jul 2022 13:46:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3EA8C5AC; Wed, 27 Jul 2022 09:53:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 71500B821D9; Wed, 27 Jul 2022 16:53:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBD77C433C1; Wed, 27 Jul 2022 16:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940818; bh=u/XzXGZFA2dYFioj9Dm6L2aIM9lGaJmYbqnm9tjzGC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hCAp/jWC2x8eFFFHawx3MP7Iw/L8nWBizFm8q0vjLB4MxvDOY1kx9Mu/2q5WgBStz qjSFPHLhT+IXtk+4JhYzcZRKPGNa8R0a1eFhBUPQ9Tg/+nadsuvT3NL2705j6+vg5/ 0Myyf6utpSo8BrdIEVzRnl3OIRDzF2N8OlBY5A1U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Eric Dumazet , Daniel Borkmann Subject: [PATCH 5.18 134/158] bpf: Make sure mac_header was set before using it Date: Wed, 27 Jul 2022 18:13:18 +0200 Message-Id: <20220727161026.754087236@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Eric Dumazet commit 0326195f523a549e0a9d7fd44c70b26fd7265090 upstream. Classic BPF has a way to load bytes starting from the mac header. Some skbs do not have a mac header, and skb_mac_header() in this case is returning a pointer that 65535 bytes after skb->head. Existing range check in bpf_internal_load_pointer_neg_helper() was properly kicking and no illegal access was happening. New sanity check in skb_mac_header() is firing, so we need to avoid it. WARNING: CPU: 1 PID: 28990 at include/linux/skbuff.h:2785 skb_mac_header in= clude/linux/skbuff.h:2785 [inline] WARNING: CPU: 1 PID: 28990 at include/linux/skbuff.h:2785 bpf_internal_load= _pointer_neg_helper+0x1b1/0x1c0 kernel/bpf/core.c:74 Modules linked in: CPU: 1 PID: 28990 Comm: syz-executor.0 Not tainted 5.19.0-rc4-syzkaller-008= 65-g4874fb9484be #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 06/29/2022 RIP: 0010:skb_mac_header include/linux/skbuff.h:2785 [inline] RIP: 0010:bpf_internal_load_pointer_neg_helper+0x1b1/0x1c0 kernel/bpf/core.= c:74 Code: ff ff 45 31 f6 e9 5a ff ff ff e8 aa 27 40 00 e9 3b ff ff ff e8 90 27 = 40 00 e9 df fe ff ff e8 86 27 40 00 eb 9e e8 2f 2c f3 ff <0f> 0b eb b1 e8 9= 6 27 40 00 e9 79 fe ff ff 90 41 57 41 56 41 55 41 RSP: 0018:ffffc9000309f668 EFLAGS: 00010216 RAX: 0000000000000118 RBX: ffffffffffeff00c RCX: ffffc9000e417000 RDX: 0000000000040000 RSI: ffffffff81873f21 RDI: 0000000000000003 RBP: ffff8880842878c0 R08: 0000000000000003 R09: 000000000000ffff R10: 000000000000ffff R11: 0000000000000001 R12: 0000000000000004 R13: ffff88803ac56c00 R14: 000000000000ffff R15: dffffc0000000000 FS: 00007f5c88a16700(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fdaa9f6c058 CR3: 000000003a82c000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ____bpf_skb_load_helper_32 net/core/filter.c:276 [inline] bpf_skb_load_helper_32+0x191/0x220 net/core/filter.c:264 Fixes: f9aefd6b2aa3 ("net: warn if mac header was not set") Reported-by: syzbot Signed-off-by: Eric Dumazet Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20220707123900.945305-1-edumazet@google.c= om Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- kernel/bpf/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -68,11 +68,13 @@ void *bpf_internal_load_pointer_neg_help { u8 *ptr =3D NULL; =20 - if (k >=3D SKF_NET_OFF) + if (k >=3D SKF_NET_OFF) { ptr =3D skb_network_header(skb) + k - SKF_NET_OFF; - else if (k >=3D SKF_LL_OFF) + } else if (k >=3D SKF_LL_OFF) { + if (unlikely(!skb_mac_header_was_set(skb))) + return NULL; ptr =3D skb_mac_header(skb) + k - SKF_LL_OFF; - + } if (ptr >=3D skb->head && ptr + size <=3D skb_tail_pointer(skb)) return ptr; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4DB7C04A68 for ; Wed, 27 Jul 2022 17:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243223AbiG0Rrm (ORCPT ); Wed, 27 Jul 2022 13:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243219AbiG0RrG (ORCPT ); Wed, 27 Jul 2022 13:47:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D99328CC8C; Wed, 27 Jul 2022 09:53:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3974BB821D8; Wed, 27 Jul 2022 16:53:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B7D9C433D6; Wed, 27 Jul 2022 16:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940820; bh=BjWDKkSbTVk6HOTJj0Ix1G7Bfz2vtR9DF2xF7kRNZnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoJyM5nlCTUtLV2s0V+evgdnhgCDR9AEP3UXziXuMk4lwNDfr30DbII62SXZs6lxt t7VNSEDT9nJCIKPU2n6X5pD5WAeprYsZfoyifYjKqotuO69s10Bec/WgWT8buXTa3s 9xQMCw/nDNkE30JonuHL6EmA2J3A43HbP0OZQ+Rk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juri Lelli , "Peter Zijlstra (Intel)" Subject: [PATCH 5.18 135/158] sched/deadline: Fix BUG_ON condition for deboosted tasks Date: Wed, 27 Jul 2022 18:13:19 +0200 Message-Id: <20220727161026.787205695@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Juri Lelli commit ddfc710395cccc61247348df9eb18ea50321cbed upstream. Tasks the are being deboosted from SCHED_DEADLINE might enter enqueue_task_dl() one last time and hit an erroneous BUG_ON condition: since they are not boosted anymore, the if (is_dl_boosted()) branch is not taken, but the else if (!dl_prio) is and inside this one we BUG_ON(!is_dl_boosted), which is of course false (BUG_ON triggered) otherwise we had entered the if branch above. Long story short, the current condition doesn't make sense and always leads to triggering of a BUG. Fix this by only checking enqueue flags, properly: ENQUEUE_REPLENISH has to be present, but additional flags are not a problem. Fixes: 64be6f1f5f71 ("sched/deadline: Don't replenish from a !SCHED_DEADLIN= E entity") Signed-off-by: Juri Lelli Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20220714151908.533052-1-juri.lelli@redhat.c= om Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- kernel/sched/deadline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1669,7 +1669,10 @@ static void enqueue_task_dl(struct rq *r * the throttle. */ p->dl.dl_throttled =3D 0; - BUG_ON(!is_dl_boosted(&p->dl) || flags !=3D ENQUEUE_REPLENISH); + if (!(flags & ENQUEUE_REPLENISH)) + printk_deferred_once("sched: DL de-boosted task PID %d: REPLENISH flag = missing\n", + task_pid_nr(p)); + return; } From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CCEDC19F28 for ; Wed, 27 Jul 2022 17:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243097AbiG0RrH (ORCPT ); Wed, 27 Jul 2022 13:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243080AbiG0Rqb (ORCPT ); Wed, 27 Jul 2022 13:46:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A8D8C76A; Wed, 27 Jul 2022 09:53:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 319D161743; Wed, 27 Jul 2022 16:53:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FEFCC433C1; Wed, 27 Jul 2022 16:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940823; bh=BgXZK7+K8o2mjyPze4zimnYbMgx7vzX+PZeG7dtgKOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LHrs3mDEgNVBKOLCVawVIkuhhh5AdJ1q6zPSiw8oalHmyLE6sDguGoSydU35ou1or RYxaUyy1pugQiRjRGs2WuNZXgAd0UtT9aEqum9vTHsY8+8dClfaJAcgD2pUUNyUgSG 1CufDvF7rbiVRfbv8tpAx/1JPV+HwphuixsgXslk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vince Weaver , Kan Liang , "Peter Zijlstra (Intel)" Subject: [PATCH 5.18 136/158] perf/x86/intel/lbr: Fix unchecked MSR access error on HSW Date: Wed, 27 Jul 2022 18:13:20 +0200 Message-Id: <20220727161026.822310872@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang commit b0380e13502adf7dd8be4c47d622c3522aae6c63 upstream. The fuzzer triggers the below trace. [ 7763.384369] unchecked MSR access error: WRMSR to 0x689 (tried to write 0x1fffffff8101349e) at rIP: 0xffffffff810704a4 (native_write_msr+0x4/0x20) [ 7763.397420] Call Trace: [ 7763.399881] [ 7763.401994] intel_pmu_lbr_restore+0x9a/0x1f0 [ 7763.406363] intel_pmu_lbr_sched_task+0x91/0x1c0 [ 7763.410992] __perf_event_task_sched_in+0x1cd/0x240 On a machine with the LBR format LBR_FORMAT_EIP_FLAGS2, when the TSX is disabled, a TSX quirk is required to access LBR from registers. The lbr_from_signext_quirk_needed() is introduced to determine whether the TSX quirk should be applied. However, the lbr_from_signext_quirk_needed() is invoked before the intel_pmu_lbr_init(), which parses the LBR format information. Without the correct LBR format information, the TSX quirk never be applied. Move the lbr_from_signext_quirk_needed() into the intel_pmu_lbr_init(). Checking x86_pmu.lbr_has_tsx in the lbr_from_signext_quirk_needed() is not required anymore. Both LBR_FORMAT_EIP_FLAGS2 and LBR_FORMAT_INFO have LBR_TSX flag, but only the LBR_FORMAT_EIP_FLAGS2 requirs the quirk. Update the comments accordingly. Fixes: 1ac7fd8159a8 ("perf/x86/intel/lbr: Support LBR format V7") Reported-by: Vince Weaver Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20220714182630.342107-1-kan.liang@linux.int= el.com Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/x86/events/intel/lbr.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -278,9 +278,9 @@ enum { }; =20 /* - * For formats with LBR_TSX flags (e.g. LBR_FORMAT_EIP_FLAGS2), bits 61:62= in - * MSR_LAST_BRANCH_FROM_x are the TSX flags when TSX is supported, but when - * TSX is not supported they have no consistent behavior: + * For format LBR_FORMAT_EIP_FLAGS2, bits 61:62 in MSR_LAST_BRANCH_FROM_x + * are the TSX flags when TSX is supported, but when TSX is not supported + * they have no consistent behavior: * * - For wrmsr(), bits 61:62 are considered part of the sign extension. * - For HW updates (branch captures) bits 61:62 are always OFF and are = not @@ -288,7 +288,7 @@ enum { * * Therefore, if: * - * 1) LBR has TSX format + * 1) LBR format LBR_FORMAT_EIP_FLAGS2 * 2) CPU has no TSX support enabled * * ... then any value passed to wrmsr() must be sign extended to 63 bits a= nd any @@ -300,7 +300,7 @@ static inline bool lbr_from_signext_quir bool tsx_support =3D boot_cpu_has(X86_FEATURE_HLE) || boot_cpu_has(X86_FEATURE_RTM); =20 - return !tsx_support && x86_pmu.lbr_has_tsx; + return !tsx_support; } =20 static DEFINE_STATIC_KEY_FALSE(lbr_from_quirk_key); @@ -1611,9 +1611,6 @@ void intel_pmu_lbr_init_hsw(void) x86_pmu.lbr_sel_map =3D hsw_lbr_sel_map; =20 x86_get_pmu(smp_processor_id())->task_ctx_cache =3D create_lbr_kmem_cache= (size, 0); - - if (lbr_from_signext_quirk_needed()) - static_branch_enable(&lbr_from_quirk_key); } =20 /* skylake */ @@ -1704,7 +1701,11 @@ void intel_pmu_lbr_init(void) switch (x86_pmu.intel_cap.lbr_format) { case LBR_FORMAT_EIP_FLAGS2: x86_pmu.lbr_has_tsx =3D 1; - fallthrough; + x86_pmu.lbr_from_flags =3D 1; + if (lbr_from_signext_quirk_needed()) + static_branch_enable(&lbr_from_quirk_key); + break; + case LBR_FORMAT_EIP_FLAGS: x86_pmu.lbr_from_flags =3D 1; break; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D502C04A68 for ; Wed, 27 Jul 2022 17:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243168AbiG0RrO (ORCPT ); Wed, 27 Jul 2022 13:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243196AbiG0Rqj (ORCPT ); Wed, 27 Jul 2022 13:46:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7A84D4CB; Wed, 27 Jul 2022 09:53:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 82B67B821B9; Wed, 27 Jul 2022 16:53:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E066CC433D6; Wed, 27 Jul 2022 16:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940826; bh=xzLNXcz4miuOscNHT52+ulkgeYXs8Noj2UPKsvKI/sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UjODPlLPzo0xDwjwl6mxSJQ+YePeSyljkS78N74zj29beypFSkNPZWs8lEaNgcLVy +Ibh8WrS9FN9FAoX9o+l4ULb+nY+nRFnc1ayOenKZEIb0H6n097NUh1o+7tGhWm7Cz GPjqaaUlVO4rQoDso5ZBNPQX7NKurTcJ0uYKUngU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pawan Gupta , "Peter Zijlstra (Intel)" , Thadeu Lima de Souza Cascardo Subject: [PATCH 5.18 137/158] x86/bugs: Warn when "ibrs" mitigation is selected on Enhanced IBRS parts Date: Wed, 27 Jul 2022 18:13:21 +0200 Message-Id: <20220727161026.871390189@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pawan Gupta commit eb23b5ef9131e6d65011de349a4d25ef1b3d4314 upstream. IBRS mitigation for spectre_v2 forces write to MSR_IA32_SPEC_CTRL at every kernel entry/exit. On Enhanced IBRS parts setting MSR_IA32_SPEC_CTRL[IBRS] only once at boot is sufficient. MSR writes at every kernel entry/exit incur unnecessary performance loss. When Enhanced IBRS feature is present, print a warning about this unnecessary performance loss. Signed-off-by: Pawan Gupta Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Thadeu Lima de Souza Cascardo Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/2a5eaf54583c2bfe0edc4fea64006656256cca17.16= 57814857.git.pawan.kumar.gupta@linux.intel.com Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/x86/kernel/cpu/bugs.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -968,6 +968,7 @@ static inline const char *spectre_v2_mod #define SPECTRE_V2_LFENCE_MSG "WARNING: LFENCE mitigation is not recommend= ed for this CPU, data leaks possible!\n" #define SPECTRE_V2_EIBRS_EBPF_MSG "WARNING: Unprivileged eBPF is enabled w= ith eIBRS on, data leaks possible via Spectre v2 BHB attacks!\n" #define SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG "WARNING: Unprivileged eBPF i= s enabled with eIBRS+LFENCE mitigation and SMT, data leaks possible via Spe= ctre v2 BHB attacks!\n" +#define SPECTRE_V2_IBRS_PERF_MSG "WARNING: IBRS mitigation selected on Enh= anced IBRS CPU, this may cause unnecessary performance loss\n" =20 #ifdef CONFIG_BPF_SYSCALL void unpriv_ebpf_notify(int new_state) @@ -1408,6 +1409,8 @@ static void __init spectre_v2_select_mit =20 case SPECTRE_V2_IBRS: setup_force_cpu_cap(X86_FEATURE_KERNEL_IBRS); + if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) + pr_warn(SPECTRE_V2_IBRS_PERF_MSG); break; =20 case SPECTRE_V2_LFENCE: From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5874C19F2B for ; Wed, 27 Jul 2022 17:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243101AbiG0Rrd (ORCPT ); Wed, 27 Jul 2022 13:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243055AbiG0RrB (ORCPT ); Wed, 27 Jul 2022 13:47:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F7A8C8F4; Wed, 27 Jul 2022 09:53:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4D69CB821BE; Wed, 27 Jul 2022 16:53:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD1EBC433B5; Wed, 27 Jul 2022 16:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940829; bh=zkO/9ryiqC/LNgFhXI//VGH66ltD+m2e3mz8jrIhSMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rpImecHESHFHnv/+v+92Xl9U1KIG3SbeLpnwOZlC0ddfoYqz1stkVJNwlkCX3QIPB 7P4Cr3floM+K0JPtwtTUPnJQT38UKtlyrg9+gwAOwm2LOpe4z/UBNdQGzc6b6G34T2 +PFgh0L7we79fb/KfeDIAEGgr/RpKa29mgpDVfxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herve Codina , Claudiu Beznea , Michael Walle , Stephen Boyd Subject: [PATCH 5.18 138/158] clk: lan966x: Fix the lan966x clock gate register address Date: Wed, 27 Jul 2022 18:13:22 +0200 Message-Id: <20220727161026.906148348@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Herve Codina commit 25c2a075eb6a3031813b6051bd10dfc22c36a2a4 upstream. The register address used for the clock gate register is the base register address coming from first reg map (ie. the generic clock registers) instead of the second reg map defining the clock gate register. Use the correct clock gate register address. Fixes: 5ad5915dea00 ("clk: lan966x: Extend lan966x clock driver for clock g= ating support") Signed-off-by: Herve Codina Link: https://lore.kernel.org/r/20220704102845.168438-2-herve.codina@bootli= n.com Reviewed-by: Claudiu Beznea Tested-by: Michael Walle Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/clk/clk-lan966x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/clk/clk-lan966x.c +++ b/drivers/clk/clk-lan966x.c @@ -213,7 +213,7 @@ static int lan966x_gate_clk_register(str =20 hw_data->hws[i] =3D devm_clk_hw_register_gate(dev, clk_gate_desc[idx].name, - "lan966x", 0, base, + "lan966x", 0, gate_base, clk_gate_desc[idx].bit_idx, 0, &clk_gate_lock); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFD93C04A68 for ; Wed, 27 Jul 2022 17:48:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243241AbiG0RsL (ORCPT ); Wed, 27 Jul 2022 13:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243066AbiG0Rrc (ORCPT ); Wed, 27 Jul 2022 13:47:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2ABC8CE8F; Wed, 27 Jul 2022 09:54:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 88B95600BE; Wed, 27 Jul 2022 16:53:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92647C433C1; Wed, 27 Jul 2022 16:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940832; bh=wf8BNnkAc+gkIrTF0feT5mq5TPqrtY31kJFzXpcVfcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9S7AIQrx6IrKO/lboJ0l9jxgTvYwwRajm1ZGWFjAUy29hOYXtPekY/llg92AB5kH B/c6/TMwd6Hz4aKi3D1azg810cghIVEeLpFUDVwBdPD36MlY56mA8uBNTZA8HSEP1P qlHwquNjr4QjLNiGBA8pk2Dw1aIqyJXQmywoy8DI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland , Sasha Levin Subject: [PATCH 5.18 139/158] dlm: fix pending remove if msg allocation fails Date: Wed, 27 Jul 2022 18:13:23 +0200 Message-Id: <20220727161026.936455745@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Aring [ Upstream commit ba58995909b5098ca4003af65b0ccd5a8d13dd25 ] This patch unsets ls_remove_len and ls_remove_name if a message allocation of a remove messages fails. In this case we never send a remove message out but set the per ls ls_remove_len ls_remove_name variable for a pending remove. Unset those variable should indicate possible waiters in wait_pending_remove() that no pending remove is going on at this moment. Cc: stable@vger.kernel.org Signed-off-by: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- fs/dlm/lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 5b485cd96c93..5298a3a43bc7 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -4085,13 +4085,14 @@ static void send_repeat_remove(struct dlm_ls *ls, c= har *ms_name, int len) rv =3D _create_message(ls, sizeof(struct dlm_message) + len, dir_nodeid, DLM_MSG_REMOVE, &ms, &mh); if (rv) - return; + goto out; =20 memcpy(ms->m_extra, name, len); ms->m_hash =3D hash; =20 send_message(mh, ms); =20 +out: spin_lock(&ls->ls_remove_spin); ls->ls_remove_len =3D 0; memset(ls->ls_remove_name, 0, DLM_RESNAME_MAXLEN); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B5DAC19F2B for ; Wed, 27 Jul 2022 17:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243247AbiG0Rrf (ORCPT ); Wed, 27 Jul 2022 13:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243067AbiG0RrE (ORCPT ); Wed, 27 Jul 2022 13:47:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 718268C8F8; Wed, 27 Jul 2022 09:53:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13CEEB821D7; Wed, 27 Jul 2022 16:53:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6631DC433C1; Wed, 27 Jul 2022 16:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940834; bh=8TAjTG3BVgjt6+mej6insq8utXxrMq0kT2BsFUAqqQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VIAhOq9vzkWI7u/e4YyxkGNSRZrHtobCvUUwU95DWi2JQLiyP5TXANhwI44J/qyNt BHyHm1StdLj+11g6Mii0BWrLeip2+NBYlKVIkMtR56XkvYhvkCGH6kBU7yaD4jc0K9 c/SG5EGJrg6GD9NdYs3eZYkqQRPTMHMN+xSrFkEk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 140/158] crypto: qat - set to zero DH parameters before free Date: Wed, 27 Jul 2022 18:13:24 +0200 Message-Id: <20220727161026.976342511@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 1731160ff7c7bbb11bb1aacb14dd25e18d522779 ] Set to zero the context buffers containing the DH key before they are freed. This is a defense in depth measure that avoids keys to be recovered from memory in case the system is compromised between the free of the buffer and when that area of memory (containing keys) gets overwritten. Cc: stable@vger.kernel.org Fixes: c9839143ebbf ("crypto: qat - Add DH support") Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index b0b78445418b..5633f9df3b6f 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -420,14 +420,17 @@ static int qat_dh_set_params(struct qat_dh_ctx *ctx, = struct dh *params) static void qat_dh_clear_ctx(struct device *dev, struct qat_dh_ctx *ctx) { if (ctx->g) { + memset(ctx->g, 0, ctx->p_size); dma_free_coherent(dev, ctx->p_size, ctx->g, ctx->dma_g); ctx->g =3D NULL; } if (ctx->xa) { + memset(ctx->xa, 0, ctx->p_size); dma_free_coherent(dev, ctx->p_size, ctx->xa, ctx->dma_xa); ctx->xa =3D NULL; } if (ctx->p) { + memset(ctx->p, 0, ctx->p_size); dma_free_coherent(dev, ctx->p_size, ctx->p, ctx->dma_p); ctx->p =3D NULL; } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32CDEC04A68 for ; Wed, 27 Jul 2022 17:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243011AbiG0RpG (ORCPT ); Wed, 27 Jul 2022 13:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242973AbiG0Rny (ORCPT ); Wed, 27 Jul 2022 13:43:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF9C4D154; Wed, 27 Jul 2022 09:52:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 26CD1B821D4; Wed, 27 Jul 2022 16:52:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7281EC433C1; Wed, 27 Jul 2022 16:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940764; bh=ExWebhwnzEVWFIDCEFYoZ68tGImeblCF9aJvnPOKp+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XcMXbGJ1Q7nrScyHmKRijxXaC5UNy6dPMWMW/hR/NaxB0JseMnhbFcEVRFNfJ105z FZYNTnIRGsCbwsiOmf7B3j+qobj10QmrTttgCTcNFXXL6gPU08FM3os17kfaZkUEJo 1Nu3vXBImZhGYrzIhEm7LRXUWrVCV7A5T4EJnquk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Giovanni Cabiddu , Marco Chiappero , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 141/158] crypto: qat - use pre-allocated buffers in datapath Date: Wed, 27 Jul 2022 18:13:25 +0200 Message-Id: <20220727161027.015397882@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit e0831e7af4e03f2715de102e18e9179ec0a81562 ] In order to do DMAs, the QAT device requires that the scatterlist structures are mapped and translated into a format that the firmware can understand. This is defined as the composition of a scatter gather list (SGL) descriptor header, the struct qat_alg_buf_list, plus a variable number of flat buffer descriptors, the struct qat_alg_buf. The allocation and mapping of these data structures is done each time a request is received from the skcipher and aead APIs. In an OOM situation, this behaviour might lead to a dead-lock if an allocation fails. Based on the conversation in [1], increase the size of the aead and skcipher request contexts to include an SGL descriptor that can handle a maximum of 4 flat buffers. If requests exceed 4 entries buffers, memory is allocated dynamically. [1] https://lore.kernel.org/linux-crypto/20200722072932.GA27544@gondor.apan= a.org.au/ Cc: stable@vger.kernel.org Fixes: d370cec32194 ("crypto: qat - Intel(R) QAT crypto interface") Reported-by: Mikulas Patocka Signed-off-by: Giovanni Cabiddu Reviewed-by: Marco Chiappero Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_algs.c | 64 +++++++++++++--------- drivers/crypto/qat/qat_common/qat_crypto.h | 24 ++++++++ 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/= qat_common/qat_algs.c index f998ed58457c..ec635fe44c1f 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -46,19 +46,6 @@ static DEFINE_MUTEX(algs_lock); static unsigned int active_devs; =20 -struct qat_alg_buf { - u32 len; - u32 resrvd; - u64 addr; -} __packed; - -struct qat_alg_buf_list { - u64 resrvd; - u32 num_bufs; - u32 num_mapped_bufs; - struct qat_alg_buf bufers[]; -} __packed __aligned(64); - /* Common content descriptor */ struct qat_alg_cd { union { @@ -693,7 +680,10 @@ static void qat_alg_free_bufl(struct qat_crypto_instan= ce *inst, bl->bufers[i].len, DMA_BIDIRECTIONAL); =20 dma_unmap_single(dev, blp, sz, DMA_TO_DEVICE); - kfree(bl); + + if (!qat_req->buf.sgl_src_valid) + kfree(bl); + if (blp !=3D blpout) { /* If out of place operation dma unmap only data */ int bufless =3D blout->num_bufs - blout->num_mapped_bufs; @@ -704,7 +694,9 @@ static void qat_alg_free_bufl(struct qat_crypto_instanc= e *inst, DMA_BIDIRECTIONAL); } dma_unmap_single(dev, blpout, sz_out, DMA_TO_DEVICE); - kfree(blout); + + if (!qat_req->buf.sgl_dst_valid) + kfree(blout); } } =20 @@ -721,15 +713,24 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_inst= ance *inst, dma_addr_t blp =3D DMA_MAPPING_ERROR; dma_addr_t bloutp =3D DMA_MAPPING_ERROR; struct scatterlist *sg; - size_t sz_out, sz =3D struct_size(bufl, bufers, n + 1); + size_t sz_out, sz =3D struct_size(bufl, bufers, n); + int node =3D dev_to_node(&GET_DEV(inst->accel_dev)); =20 if (unlikely(!n)) return -EINVAL; =20 - bufl =3D kzalloc_node(sz, GFP_ATOMIC, - dev_to_node(&GET_DEV(inst->accel_dev))); - if (unlikely(!bufl)) - return -ENOMEM; + qat_req->buf.sgl_src_valid =3D false; + qat_req->buf.sgl_dst_valid =3D false; + + if (n > QAT_MAX_BUFF_DESC) { + bufl =3D kzalloc_node(sz, GFP_ATOMIC, node); + if (unlikely(!bufl)) + return -ENOMEM; + } else { + bufl =3D &qat_req->buf.sgl_src.sgl_hdr; + memset(bufl, 0, sizeof(struct qat_alg_buf_list)); + qat_req->buf.sgl_src_valid =3D true; + } =20 for_each_sg(sgl, sg, n, i) bufl->bufers[i].addr =3D DMA_MAPPING_ERROR; @@ -760,12 +761,18 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_inst= ance *inst, struct qat_alg_buf *bufers; =20 n =3D sg_nents(sglout); - sz_out =3D struct_size(buflout, bufers, n + 1); + sz_out =3D struct_size(buflout, bufers, n); sg_nctr =3D 0; - buflout =3D kzalloc_node(sz_out, GFP_ATOMIC, - dev_to_node(&GET_DEV(inst->accel_dev))); - if (unlikely(!buflout)) - goto err_in; + + if (n > QAT_MAX_BUFF_DESC) { + buflout =3D kzalloc_node(sz_out, GFP_ATOMIC, node); + if (unlikely(!buflout)) + goto err_in; + } else { + buflout =3D &qat_req->buf.sgl_dst.sgl_hdr; + memset(buflout, 0, sizeof(struct qat_alg_buf_list)); + qat_req->buf.sgl_dst_valid =3D true; + } =20 bufers =3D buflout->bufers; for_each_sg(sglout, sg, n, i) @@ -810,7 +817,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instan= ce *inst, dma_unmap_single(dev, buflout->bufers[i].addr, buflout->bufers[i].len, DMA_BIDIRECTIONAL); - kfree(buflout); + + if (!qat_req->buf.sgl_dst_valid) + kfree(buflout); =20 err_in: if (!dma_mapping_error(dev, blp)) @@ -823,7 +832,8 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instan= ce *inst, bufl->bufers[i].len, DMA_BIDIRECTIONAL); =20 - kfree(bufl); + if (!qat_req->buf.sgl_src_valid) + kfree(bufl); =20 dev_err(dev, "Failed to map buf for dma\n"); return -ENOMEM; diff --git a/drivers/crypto/qat/qat_common/qat_crypto.h b/drivers/crypto/qa= t/qat_common/qat_crypto.h index b6a4c95ae003..0928f159ea99 100644 --- a/drivers/crypto/qat/qat_common/qat_crypto.h +++ b/drivers/crypto/qat/qat_common/qat_crypto.h @@ -21,6 +21,26 @@ struct qat_crypto_instance { atomic_t refctr; }; =20 +#define QAT_MAX_BUFF_DESC 4 + +struct qat_alg_buf { + u32 len; + u32 resrvd; + u64 addr; +} __packed; + +struct qat_alg_buf_list { + u64 resrvd; + u32 num_bufs; + u32 num_mapped_bufs; + struct qat_alg_buf bufers[]; +} __packed; + +struct qat_alg_fixed_buf_list { + struct qat_alg_buf_list sgl_hdr; + struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC]; +} __packed __aligned(64); + struct qat_crypto_request_buffs { struct qat_alg_buf_list *bl; dma_addr_t blp; @@ -28,6 +48,10 @@ struct qat_crypto_request_buffs { dma_addr_t bloutp; size_t sz; size_t sz_out; + bool sgl_src_valid; + bool sgl_dst_valid; + struct qat_alg_fixed_buf_list sgl_src; + struct qat_alg_fixed_buf_list sgl_dst; }; =20 struct qat_crypto_request; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DED6CC04A68 for ; Wed, 27 Jul 2022 17:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243050AbiG0RpX (ORCPT ); Wed, 27 Jul 2022 13:45:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243075AbiG0RoL (ORCPT ); Wed, 27 Jul 2022 13:44:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC2A8AEDF; Wed, 27 Jul 2022 09:52:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4345D61617; Wed, 27 Jul 2022 16:52:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E23AC433C1; Wed, 27 Jul 2022 16:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940767; bh=B1O5LJ3mcoKU98lhvoeqSH2c9q0Ri4+h/qk7Uck2GRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Qnroypi5o4xgV4PoY+iUxub8Vno5JO2bgGsfsIujZ1m4UPtcjbixY2qOkUAHyqXx GBNp0GiXHMyNo/0WP5cYHejJ9Y1KU6vOMZfVB5BMJt5nR1Th+0MFhdS/xYrUrcBxDl rQfHGol5J/5P3Mh44ZcEUc5DOxwDPO1UFyU/bxsk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Marco Chiappero , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 142/158] crypto: qat - refactor submission logic Date: Wed, 27 Jul 2022 18:13:26 +0200 Message-Id: <20220727161027.045340491@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit af88d3c109aa5edfaa11c9a26d9c0ff21ddf501c ] All the algorithms in qat_algs.c and qat_asym_algs.c use the same pattern to submit messages to the HW queues. Move the submission loop to a new function, qat_alg_send_message(), and share it between the symmetric and the asymmetric algorithms. As part of this rework, since the number of retries before returning an error is inconsistent between the symmetric and asymmetric implementations, set it to a value that works for both (i.e. 20, was 10 in qat_algs.c and 100 in qat_asym_algs.c) In addition fix the return code reported when the HW queues are full. In that case return -ENOSPC instead of -EBUSY. Including stable in CC since (1) the error code returned if the HW queues are full is incorrect and (2) to facilitate the backport of the next fix "crypto: qat - add backlog mechanism". Cc: stable@vger.kernel.org Signed-off-by: Giovanni Cabiddu Reviewed-by: Marco Chiappero Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/Makefile | 1 + drivers/crypto/qat/qat_common/qat_algs.c | 68 +++++++++---------- drivers/crypto/qat/qat_common/qat_algs_send.c | 21 ++++++ drivers/crypto/qat/qat_common/qat_algs_send.h | 10 +++ drivers/crypto/qat/qat_common/qat_asym_algs.c | 50 +++++++++----- drivers/crypto/qat/qat_common/qat_crypto.h | 5 ++ 6 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/qat_algs_send.c create mode 100644 drivers/crypto/qat/qat_common/qat_algs_send.h diff --git a/drivers/crypto/qat/qat_common/Makefile b/drivers/crypto/qat/qa= t_common/Makefile index f25a6c8edfc7..04f058acc4d3 100644 --- a/drivers/crypto/qat/qat_common/Makefile +++ b/drivers/crypto/qat/qat_common/Makefile @@ -16,6 +16,7 @@ intel_qat-objs :=3D adf_cfg.o \ qat_crypto.o \ qat_algs.o \ qat_asym_algs.o \ + qat_algs_send.o \ qat_uclo.o \ qat_hal.o =20 diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/= qat_common/qat_algs.c index ec635fe44c1f..6017ae82c713 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -17,7 +17,7 @@ #include #include #include "adf_accel_devices.h" -#include "adf_transport.h" +#include "qat_algs_send.h" #include "adf_common_drv.h" #include "qat_crypto.h" #include "icp_qat_hw.h" @@ -939,6 +939,17 @@ void qat_alg_callback(void *resp) qat_req->cb(qat_resp, qat_req); } =20 +static int qat_alg_send_sym_message(struct qat_crypto_request *qat_req, + struct qat_crypto_instance *inst) +{ + struct qat_alg_req req; + + req.fw_req =3D (u32 *)&qat_req->req; + req.tx_ring =3D inst->sym_tx; + + return qat_alg_send_message(&req); +} + static int qat_alg_aead_dec(struct aead_request *areq) { struct crypto_aead *aead_tfm =3D crypto_aead_reqtfm(areq); @@ -949,7 +960,7 @@ static int qat_alg_aead_dec(struct aead_request *areq) struct icp_qat_fw_la_auth_req_params *auth_param; struct icp_qat_fw_la_bulk_req *msg; int digst_size =3D crypto_aead_authsize(aead_tfm); - int ret, ctr =3D 0; + int ret; u32 cipher_len; =20 cipher_len =3D areq->cryptlen - digst_size; @@ -975,15 +986,12 @@ static int qat_alg_aead_dec(struct aead_request *areq) auth_param =3D (void *)((u8 *)cipher_param + sizeof(*cipher_param)); auth_param->auth_off =3D 0; auth_param->auth_len =3D areq->assoclen + cipher_param->cipher_length; - do { - ret =3D adf_send_message(ctx->inst->sym_tx, (u32 *)msg); - } while (ret =3D=3D -EAGAIN && ctr++ < 10); =20 - if (ret =3D=3D -EAGAIN) { + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); - return -EBUSY; - } - return -EINPROGRESS; + + return ret; } =20 static int qat_alg_aead_enc(struct aead_request *areq) @@ -996,7 +1004,7 @@ static int qat_alg_aead_enc(struct aead_request *areq) struct icp_qat_fw_la_auth_req_params *auth_param; struct icp_qat_fw_la_bulk_req *msg; u8 *iv =3D areq->iv; - int ret, ctr =3D 0; + int ret; =20 if (areq->cryptlen % AES_BLOCK_SIZE !=3D 0) return -EINVAL; @@ -1023,15 +1031,11 @@ static int qat_alg_aead_enc(struct aead_request *ar= eq) auth_param->auth_off =3D 0; auth_param->auth_len =3D areq->assoclen + areq->cryptlen; =20 - do { - ret =3D adf_send_message(ctx->inst->sym_tx, (u32 *)msg); - } while (ret =3D=3D -EAGAIN && ctr++ < 10); - - if (ret =3D=3D -EAGAIN) { + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); - return -EBUSY; - } - return -EINPROGRESS; + + return ret; } =20 static int qat_alg_skcipher_rekey(struct qat_alg_skcipher_ctx *ctx, @@ -1184,7 +1188,7 @@ static int qat_alg_skcipher_encrypt(struct skcipher_r= equest *req) struct qat_crypto_request *qat_req =3D skcipher_request_ctx(req); struct icp_qat_fw_la_cipher_req_params *cipher_param; struct icp_qat_fw_la_bulk_req *msg; - int ret, ctr =3D 0; + int ret; =20 if (req->cryptlen =3D=3D 0) return 0; @@ -1208,15 +1212,11 @@ static int qat_alg_skcipher_encrypt(struct skcipher= _request *req) =20 qat_alg_set_req_iv(qat_req); =20 - do { - ret =3D adf_send_message(ctx->inst->sym_tx, (u32 *)msg); - } while (ret =3D=3D -EAGAIN && ctr++ < 10); - - if (ret =3D=3D -EAGAIN) { + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); - return -EBUSY; - } - return -EINPROGRESS; + + return ret; } =20 static int qat_alg_skcipher_blk_encrypt(struct skcipher_request *req) @@ -1253,7 +1253,7 @@ static int qat_alg_skcipher_decrypt(struct skcipher_r= equest *req) struct qat_crypto_request *qat_req =3D skcipher_request_ctx(req); struct icp_qat_fw_la_cipher_req_params *cipher_param; struct icp_qat_fw_la_bulk_req *msg; - int ret, ctr =3D 0; + int ret; =20 if (req->cryptlen =3D=3D 0) return 0; @@ -1278,15 +1278,11 @@ static int qat_alg_skcipher_decrypt(struct skcipher= _request *req) qat_alg_set_req_iv(qat_req); qat_alg_update_iv(qat_req); =20 - do { - ret =3D adf_send_message(ctx->inst->sym_tx, (u32 *)msg); - } while (ret =3D=3D -EAGAIN && ctr++ < 10); - - if (ret =3D=3D -EAGAIN) { + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); - return -EBUSY; - } - return -EINPROGRESS; + + return ret; } =20 static int qat_alg_skcipher_blk_decrypt(struct skcipher_request *req) diff --git a/drivers/crypto/qat/qat_common/qat_algs_send.c b/drivers/crypto= /qat/qat_common/qat_algs_send.c new file mode 100644 index 000000000000..78f1bb8c26c0 --- /dev/null +++ b/drivers/crypto/qat/qat_common/qat_algs_send.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) +/* Copyright(c) 2022 Intel Corporation */ +#include "adf_transport.h" +#include "qat_algs_send.h" +#include "qat_crypto.h" + +#define ADF_MAX_RETRIES 20 + +int qat_alg_send_message(struct qat_alg_req *req) +{ + int ret =3D 0, ctr =3D 0; + + do { + ret =3D adf_send_message(req->tx_ring, req->fw_req); + } while (ret =3D=3D -EAGAIN && ctr++ < ADF_MAX_RETRIES); + + if (ret =3D=3D -EAGAIN) + return -ENOSPC; + + return -EINPROGRESS; +} diff --git a/drivers/crypto/qat/qat_common/qat_algs_send.h b/drivers/crypto= /qat/qat_common/qat_algs_send.h new file mode 100644 index 000000000000..3fa685d0c293 --- /dev/null +++ b/drivers/crypto/qat/qat_common/qat_algs_send.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ +/* Copyright(c) 2022 Intel Corporation */ +#ifndef QAT_ALGS_SEND_H +#define QAT_ALGS_SEND_H + +#include "qat_crypto.h" + +int qat_alg_send_message(struct qat_alg_req *req); + +#endif diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index 5633f9df3b6f..08b8d83e070a 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -12,6 +12,7 @@ #include #include "icp_qat_fw_pke.h" #include "adf_accel_devices.h" +#include "qat_algs_send.h" #include "adf_transport.h" #include "adf_common_drv.h" #include "qat_crypto.h" @@ -137,6 +138,17 @@ struct qat_asym_request { void (*cb)(struct icp_qat_fw_pke_resp *resp); } __aligned(64); =20 +static int qat_alg_send_asym_message(struct qat_asym_request *qat_req, + struct qat_crypto_instance *inst) +{ + struct qat_alg_req req; + + req.fw_req =3D (u32 *)&qat_req->req; + req.tx_ring =3D inst->pke_tx; + + return qat_alg_send_message(&req); +} + static void qat_dh_cb(struct icp_qat_fw_pke_resp *resp) { struct qat_asym_request *req =3D (void *)(__force long)resp->opaque; @@ -213,7 +225,7 @@ static int qat_dh_compute_value(struct kpp_request *req) struct qat_asym_request *qat_req =3D PTR_ALIGN(kpp_request_ctx(req), 64); struct icp_qat_fw_pke_request *msg =3D &qat_req->req; - int ret, ctr =3D 0; + int ret; int n_input_params =3D 0; =20 if (unlikely(!ctx->xa)) @@ -338,13 +350,13 @@ static int qat_dh_compute_value(struct kpp_request *r= eq) msg->input_param_count =3D n_input_params; msg->output_param_count =3D 1; =20 - do { - ret =3D adf_send_message(ctx->inst->pke_tx, (u32 *)msg); - } while (ret =3D=3D -EBUSY && ctr++ < 100); + ret =3D qat_alg_send_asym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) + goto unmap_all; =20 - if (!ret) - return -EINPROGRESS; + return ret; =20 +unmap_all: if (!dma_mapping_error(dev, qat_req->phy_out)) dma_unmap_single(dev, qat_req->phy_out, sizeof(struct qat_dh_output_params), @@ -645,7 +657,7 @@ static int qat_rsa_enc(struct akcipher_request *req) struct qat_asym_request *qat_req =3D PTR_ALIGN(akcipher_request_ctx(req), 64); struct icp_qat_fw_pke_request *msg =3D &qat_req->req; - int ret, ctr =3D 0; + int ret; =20 if (unlikely(!ctx->n || !ctx->e)) return -EINVAL; @@ -735,13 +747,14 @@ static int qat_rsa_enc(struct akcipher_request *req) msg->pke_mid.opaque =3D (u64)(__force long)qat_req; msg->input_param_count =3D 3; msg->output_param_count =3D 1; - do { - ret =3D adf_send_message(ctx->inst->pke_tx, (u32 *)msg); - } while (ret =3D=3D -EBUSY && ctr++ < 100); =20 - if (!ret) - return -EINPROGRESS; + ret =3D qat_alg_send_asym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) + goto unmap_all; + + return ret; =20 +unmap_all: if (!dma_mapping_error(dev, qat_req->phy_out)) dma_unmap_single(dev, qat_req->phy_out, sizeof(struct qat_rsa_output_params), @@ -779,7 +792,7 @@ static int qat_rsa_dec(struct akcipher_request *req) struct qat_asym_request *qat_req =3D PTR_ALIGN(akcipher_request_ctx(req), 64); struct icp_qat_fw_pke_request *msg =3D &qat_req->req; - int ret, ctr =3D 0; + int ret; =20 if (unlikely(!ctx->n || !ctx->d)) return -EINVAL; @@ -887,13 +900,14 @@ static int qat_rsa_dec(struct akcipher_request *req) msg->input_param_count =3D 3; =20 msg->output_param_count =3D 1; - do { - ret =3D adf_send_message(ctx->inst->pke_tx, (u32 *)msg); - } while (ret =3D=3D -EBUSY && ctr++ < 100); =20 - if (!ret) - return -EINPROGRESS; + ret =3D qat_alg_send_asym_message(qat_req, ctx->inst); + if (ret =3D=3D -ENOSPC) + goto unmap_all; + + return ret; =20 +unmap_all: if (!dma_mapping_error(dev, qat_req->phy_out)) dma_unmap_single(dev, qat_req->phy_out, sizeof(struct qat_rsa_output_params), diff --git a/drivers/crypto/qat/qat_common/qat_crypto.h b/drivers/crypto/qa= t/qat_common/qat_crypto.h index 0928f159ea99..0dcba6fc358c 100644 --- a/drivers/crypto/qat/qat_common/qat_crypto.h +++ b/drivers/crypto/qat/qat_common/qat_crypto.h @@ -9,6 +9,11 @@ #include "adf_accel_devices.h" #include "icp_qat_fw_la.h" =20 +struct qat_alg_req { + u32 *fw_req; + struct adf_etr_ring_data *tx_ring; +}; + struct qat_crypto_instance { struct adf_etr_ring_data *sym_tx; struct adf_etr_ring_data *sym_rx; --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D701FC04A68 for ; Wed, 27 Jul 2022 17:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243028AbiG0RpO (ORCPT ); Wed, 27 Jul 2022 13:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243038AbiG0RoH (ORCPT ); Wed, 27 Jul 2022 13:44:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70D298AEC7; Wed, 27 Jul 2022 09:52:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CCAF0B8200D; Wed, 27 Jul 2022 16:52:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C50CC433C1; Wed, 27 Jul 2022 16:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940770; bh=AiR+1XfHyaa2bLwMo7kQjMxZj23pwZQoJNh4pPBJIDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vTJBvksfqrUpSIJDplvFt0yTcXCb6Hmz3pTnaZ5PHhsE1Rp0zuKTt5ZctzIgfkEfX HBtnN1UHBf5byDcLtPWuaB6XYwqFZKRR3QrH8pyiv26hcuaClGJpLeFGo6D9VSwLqw y+4OmrTwL9TYGuOSsRYlJThB9W+xzJyakihZV2fQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Kyle Sanderson , Giovanni Cabiddu , Marco Chiappero , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 143/158] crypto: qat - add backlog mechanism Date: Wed, 27 Jul 2022 18:13:27 +0200 Message-Id: <20220727161027.078711608@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 38682383973280e5be2802ba8a8d4a636d36cb19 ] The implementations of the crypto algorithms (aead, skcipher, etc) in the QAT driver do not properly support requests with the CRYPTO_TFM_REQ_MAY_BACKLOG flag set. If the HW queue is full, the driver returns -EBUSY but does not enqueue the request. This can result in applications like dm-crypt waiting indefinitely for the completion of a request that was never submitted to the hardware. Fix this by adding a software backlog queue: if the ring buffer is more than eighty percent full, then the request is enqueued to a backlog list and the error code -EBUSY is returned back to the caller. Requests in the backlog queue are resubmitted at a later time, in the context of the callback of a previously submitted request. The request for which -EBUSY is returned is then marked as -EINPROGRESS once submitted to the HW queues. The submission loop inside the function qat_alg_send_message() has been modified to decide which submission policy to use based on the request flags. If the request does not have the CRYPTO_TFM_REQ_MAY_BACKLOG set, the previous behaviour has been preserved. Based on a patch by Vishnu Das Ramachandran Cc: stable@vger.kernel.org Fixes: d370cec32194 ("crypto: qat - Intel(R) QAT crypto interface") Reported-by: Mikulas Patocka Reported-by: Kyle Sanderson Signed-off-by: Giovanni Cabiddu Reviewed-by: Marco Chiappero Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/adf_transport.c | 11 +++ drivers/crypto/qat/qat_common/adf_transport.h | 1 + .../qat/qat_common/adf_transport_internal.h | 1 + drivers/crypto/qat/qat_common/qat_algs.c | 24 ++++--- drivers/crypto/qat/qat_common/qat_algs_send.c | 67 ++++++++++++++++++- drivers/crypto/qat/qat_common/qat_algs_send.h | 1 + drivers/crypto/qat/qat_common/qat_asym_algs.c | 23 ++++--- drivers/crypto/qat/qat_common/qat_crypto.c | 3 + drivers/crypto/qat/qat_common/qat_crypto.h | 10 +++ 9 files changed, 123 insertions(+), 18 deletions(-) diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto= /qat/qat_common/adf_transport.c index 8ba28409fb74..630d0483c4e0 100644 --- a/drivers/crypto/qat/qat_common/adf_transport.c +++ b/drivers/crypto/qat/qat_common/adf_transport.c @@ -8,6 +8,9 @@ #include "adf_cfg.h" #include "adf_common_drv.h" =20 +#define ADF_MAX_RING_THRESHOLD 80 +#define ADF_PERCENT(tot, percent) (((tot) * (percent)) / 100) + static inline u32 adf_modulo(u32 data, u32 shift) { u32 div =3D data >> shift; @@ -77,6 +80,11 @@ static void adf_disable_ring_irq(struct adf_etr_bank_dat= a *bank, u32 ring) bank->irq_mask); } =20 +bool adf_ring_nearly_full(struct adf_etr_ring_data *ring) +{ + return atomic_read(ring->inflights) > ring->threshold; +} + int adf_send_message(struct adf_etr_ring_data *ring, u32 *msg) { struct adf_hw_csr_ops *csr_ops =3D GET_CSR_OPS(ring->bank->accel_dev); @@ -217,6 +225,7 @@ int adf_create_ring(struct adf_accel_dev *accel_dev, co= nst char *section, struct adf_etr_bank_data *bank; struct adf_etr_ring_data *ring; char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES]; + int max_inflights; u32 ring_num; int ret; =20 @@ -263,6 +272,8 @@ int adf_create_ring(struct adf_accel_dev *accel_dev, co= nst char *section, ring->ring_size =3D adf_verify_ring_size(msg_size, num_msgs); ring->head =3D 0; ring->tail =3D 0; + max_inflights =3D ADF_MAX_INFLIGHTS(ring->ring_size, ring->msg_size); + ring->threshold =3D ADF_PERCENT(max_inflights, ADF_MAX_RING_THRESHOLD); atomic_set(ring->inflights, 0); ret =3D adf_init_ring(ring); if (ret) diff --git a/drivers/crypto/qat/qat_common/adf_transport.h b/drivers/crypto= /qat/qat_common/adf_transport.h index 2c95f1697c76..e6ef6f9b7691 100644 --- a/drivers/crypto/qat/qat_common/adf_transport.h +++ b/drivers/crypto/qat/qat_common/adf_transport.h @@ -14,6 +14,7 @@ int adf_create_ring(struct adf_accel_dev *accel_dev, cons= t char *section, const char *ring_name, adf_callback_fn callback, int poll_mode, struct adf_etr_ring_data **ring_ptr); =20 +bool adf_ring_nearly_full(struct adf_etr_ring_data *ring); int adf_send_message(struct adf_etr_ring_data *ring, u32 *msg); void adf_remove_ring(struct adf_etr_ring_data *ring); #endif diff --git a/drivers/crypto/qat/qat_common/adf_transport_internal.h b/drive= rs/crypto/qat/qat_common/adf_transport_internal.h index 501bcf0f1809..8b2c92ba7ca1 100644 --- a/drivers/crypto/qat/qat_common/adf_transport_internal.h +++ b/drivers/crypto/qat/qat_common/adf_transport_internal.h @@ -22,6 +22,7 @@ struct adf_etr_ring_data { spinlock_t lock; /* protects ring data struct */ u16 head; u16 tail; + u32 threshold; u8 ring_number; u8 ring_size; u8 msg_size; diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/= qat_common/qat_algs.c index 6017ae82c713..873533dc43a7 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -935,19 +935,25 @@ void qat_alg_callback(void *resp) struct icp_qat_fw_la_resp *qat_resp =3D resp; struct qat_crypto_request *qat_req =3D (void *)(__force long)qat_resp->opaque_data; + struct qat_instance_backlog *backlog =3D qat_req->alg_req.backlog; =20 qat_req->cb(qat_resp, qat_req); + + qat_alg_send_backlog(backlog); } =20 static int qat_alg_send_sym_message(struct qat_crypto_request *qat_req, - struct qat_crypto_instance *inst) + struct qat_crypto_instance *inst, + struct crypto_async_request *base) { - struct qat_alg_req req; + struct qat_alg_req *alg_req =3D &qat_req->alg_req; =20 - req.fw_req =3D (u32 *)&qat_req->req; - req.tx_ring =3D inst->sym_tx; + alg_req->fw_req =3D (u32 *)&qat_req->req; + alg_req->tx_ring =3D inst->sym_tx; + alg_req->base =3D base; + alg_req->backlog =3D &inst->backlog; =20 - return qat_alg_send_message(&req); + return qat_alg_send_message(alg_req); } =20 static int qat_alg_aead_dec(struct aead_request *areq) @@ -987,7 +993,7 @@ static int qat_alg_aead_dec(struct aead_request *areq) auth_param->auth_off =3D 0; auth_param->auth_len =3D areq->assoclen + cipher_param->cipher_length; =20 - ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst, &areq->base); if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); =20 @@ -1031,7 +1037,7 @@ static int qat_alg_aead_enc(struct aead_request *areq) auth_param->auth_off =3D 0; auth_param->auth_len =3D areq->assoclen + areq->cryptlen; =20 - ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst, &areq->base); if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); =20 @@ -1212,7 +1218,7 @@ static int qat_alg_skcipher_encrypt(struct skcipher_r= equest *req) =20 qat_alg_set_req_iv(qat_req); =20 - ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst, &req->base); if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); =20 @@ -1278,7 +1284,7 @@ static int qat_alg_skcipher_decrypt(struct skcipher_r= equest *req) qat_alg_set_req_iv(qat_req); qat_alg_update_iv(qat_req); =20 - ret =3D qat_alg_send_sym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_sym_message(qat_req, ctx->inst, &req->base); if (ret =3D=3D -ENOSPC) qat_alg_free_bufl(ctx->inst, qat_req); =20 diff --git a/drivers/crypto/qat/qat_common/qat_algs_send.c b/drivers/crypto= /qat/qat_common/qat_algs_send.c index 78f1bb8c26c0..ff5b4347f783 100644 --- a/drivers/crypto/qat/qat_common/qat_algs_send.c +++ b/drivers/crypto/qat/qat_common/qat_algs_send.c @@ -6,7 +6,7 @@ =20 #define ADF_MAX_RETRIES 20 =20 -int qat_alg_send_message(struct qat_alg_req *req) +static int qat_alg_send_message_retry(struct qat_alg_req *req) { int ret =3D 0, ctr =3D 0; =20 @@ -19,3 +19,68 @@ int qat_alg_send_message(struct qat_alg_req *req) =20 return -EINPROGRESS; } + +void qat_alg_send_backlog(struct qat_instance_backlog *backlog) +{ + struct qat_alg_req *req, *tmp; + + spin_lock_bh(&backlog->lock); + list_for_each_entry_safe(req, tmp, &backlog->list, list) { + if (adf_send_message(req->tx_ring, req->fw_req)) { + /* The HW ring is full. Do nothing. + * qat_alg_send_backlog() will be invoked again by + * another callback. + */ + break; + } + list_del(&req->list); + req->base->complete(req->base, -EINPROGRESS); + } + spin_unlock_bh(&backlog->lock); +} + +static void qat_alg_backlog_req(struct qat_alg_req *req, + struct qat_instance_backlog *backlog) +{ + INIT_LIST_HEAD(&req->list); + + spin_lock_bh(&backlog->lock); + list_add_tail(&req->list, &backlog->list); + spin_unlock_bh(&backlog->lock); +} + +static int qat_alg_send_message_maybacklog(struct qat_alg_req *req) +{ + struct qat_instance_backlog *backlog =3D req->backlog; + struct adf_etr_ring_data *tx_ring =3D req->tx_ring; + u32 *fw_req =3D req->fw_req; + + /* If any request is already backlogged, then add to backlog list */ + if (!list_empty(&backlog->list)) + goto enqueue; + + /* If ring is nearly full, then add to backlog list */ + if (adf_ring_nearly_full(tx_ring)) + goto enqueue; + + /* If adding request to HW ring fails, then add to backlog list */ + if (adf_send_message(tx_ring, fw_req)) + goto enqueue; + + return -EINPROGRESS; + +enqueue: + qat_alg_backlog_req(req, backlog); + + return -EBUSY; +} + +int qat_alg_send_message(struct qat_alg_req *req) +{ + u32 flags =3D req->base->flags; + + if (flags & CRYPTO_TFM_REQ_MAY_BACKLOG) + return qat_alg_send_message_maybacklog(req); + else + return qat_alg_send_message_retry(req); +} diff --git a/drivers/crypto/qat/qat_common/qat_algs_send.h b/drivers/crypto= /qat/qat_common/qat_algs_send.h index 3fa685d0c293..5ce9f4f69d8f 100644 --- a/drivers/crypto/qat/qat_common/qat_algs_send.h +++ b/drivers/crypto/qat/qat_common/qat_algs_send.h @@ -6,5 +6,6 @@ #include "qat_crypto.h" =20 int qat_alg_send_message(struct qat_alg_req *req); +void qat_alg_send_backlog(struct qat_instance_backlog *backlog); =20 #endif diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index 08b8d83e070a..ff7249c093c9 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -136,17 +136,21 @@ struct qat_asym_request { } areq; int err; void (*cb)(struct icp_qat_fw_pke_resp *resp); + struct qat_alg_req alg_req; } __aligned(64); =20 static int qat_alg_send_asym_message(struct qat_asym_request *qat_req, - struct qat_crypto_instance *inst) + struct qat_crypto_instance *inst, + struct crypto_async_request *base) { - struct qat_alg_req req; + struct qat_alg_req *alg_req =3D &qat_req->alg_req; =20 - req.fw_req =3D (u32 *)&qat_req->req; - req.tx_ring =3D inst->pke_tx; + alg_req->fw_req =3D (u32 *)&qat_req->req; + alg_req->tx_ring =3D inst->pke_tx; + alg_req->base =3D base; + alg_req->backlog =3D &inst->backlog; =20 - return qat_alg_send_message(&req); + return qat_alg_send_message(alg_req); } =20 static void qat_dh_cb(struct icp_qat_fw_pke_resp *resp) @@ -350,7 +354,7 @@ static int qat_dh_compute_value(struct kpp_request *req) msg->input_param_count =3D n_input_params; msg->output_param_count =3D 1; =20 - ret =3D qat_alg_send_asym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_asym_message(qat_req, inst, &req->base); if (ret =3D=3D -ENOSPC) goto unmap_all; =20 @@ -557,8 +561,11 @@ void qat_alg_asym_callback(void *_resp) { struct icp_qat_fw_pke_resp *resp =3D _resp; struct qat_asym_request *areq =3D (void *)(__force long)resp->opaque; + struct qat_instance_backlog *backlog =3D areq->alg_req.backlog; =20 areq->cb(resp); + + qat_alg_send_backlog(backlog); } =20 #define PKE_RSA_EP_512 0x1c161b21 @@ -748,7 +755,7 @@ static int qat_rsa_enc(struct akcipher_request *req) msg->input_param_count =3D 3; msg->output_param_count =3D 1; =20 - ret =3D qat_alg_send_asym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_asym_message(qat_req, inst, &req->base); if (ret =3D=3D -ENOSPC) goto unmap_all; =20 @@ -901,7 +908,7 @@ static int qat_rsa_dec(struct akcipher_request *req) =20 msg->output_param_count =3D 1; =20 - ret =3D qat_alg_send_asym_message(qat_req, ctx->inst); + ret =3D qat_alg_send_asym_message(qat_req, inst, &req->base); if (ret =3D=3D -ENOSPC) goto unmap_all; =20 diff --git a/drivers/crypto/qat/qat_common/qat_crypto.c b/drivers/crypto/qa= t/qat_common/qat_crypto.c index 67c9588e89df..80d905ed102e 100644 --- a/drivers/crypto/qat/qat_common/qat_crypto.c +++ b/drivers/crypto/qat/qat_common/qat_crypto.c @@ -353,6 +353,9 @@ static int qat_crypto_create_instances(struct adf_accel= _dev *accel_dev) &inst->pke_rx); if (ret) goto err; + + INIT_LIST_HEAD(&inst->backlog.list); + spin_lock_init(&inst->backlog.lock); } return 0; err: diff --git a/drivers/crypto/qat/qat_common/qat_crypto.h b/drivers/crypto/qa= t/qat_common/qat_crypto.h index 0dcba6fc358c..245b6d9a3650 100644 --- a/drivers/crypto/qat/qat_common/qat_crypto.h +++ b/drivers/crypto/qat/qat_common/qat_crypto.h @@ -9,9 +9,17 @@ #include "adf_accel_devices.h" #include "icp_qat_fw_la.h" =20 +struct qat_instance_backlog { + struct list_head list; + spinlock_t lock; /* protects backlog list */ +}; + struct qat_alg_req { u32 *fw_req; struct adf_etr_ring_data *tx_ring; + struct crypto_async_request *base; + struct list_head list; + struct qat_instance_backlog *backlog; }; =20 struct qat_crypto_instance { @@ -24,6 +32,7 @@ struct qat_crypto_instance { unsigned long state; int id; atomic_t refctr; + struct qat_instance_backlog backlog; }; =20 #define QAT_MAX_BUFF_DESC 4 @@ -82,6 +91,7 @@ struct qat_crypto_request { u8 iv[AES_BLOCK_SIZE]; }; bool encryption; + struct qat_alg_req alg_req; }; =20 static inline bool adf_hw_dev_has_crypto(struct adf_accel_dev *accel_dev) --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE37EC19F28 for ; Wed, 27 Jul 2022 17:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243063AbiG0Rpc (ORCPT ); Wed, 27 Jul 2022 13:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243093AbiG0RoO (ORCPT ); Wed, 27 Jul 2022 13:44:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5778AB2C; Wed, 27 Jul 2022 09:52:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8E181B821AC; Wed, 27 Jul 2022 16:52:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE7BBC433D6; Wed, 27 Jul 2022 16:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940773; bh=9I/JEJjN3N7i7yzhTwu3g+bbof/43fJ1qkVXXeHxttY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z9LOXYYgm9fn/oj3i02sw+SM56AvVMpgU+8heag7SgncTJzWzualDocfmCVQKn3T1 vli40Ltq82oyX1aPy1uqk6IfWmGesKUXcymtkNuuf5lio3xYTu4KmtfwVJK9UiW8qa PHko4Fc9zU8FlGtYSBQsYu4pJpKDgqb1LkALuHeQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 144/158] crypto: qat - fix memory leak in RSA Date: Wed, 27 Jul 2022 18:13:28 +0200 Message-Id: <20220727161027.125433230@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 80a52e1ee7757b742f96bfb0d58f0c14eb6583d0 ] When an RSA key represented in form 2 (as defined in PKCS #1 V2.1) is used, some components of the private key persist even after the TFM is released. Replace the explicit calls to free the buffers in qat_rsa_exit_tfm() with a call to qat_rsa_clear_ctx() which frees all buffers referenced in the TFM context. Cc: stable@vger.kernel.org Fixes: 879f77e9071f ("crypto: qat - Add RSA CRT mode") Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index ff7249c093c9..2bc02c75398e 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -1257,18 +1257,8 @@ static void qat_rsa_exit_tfm(struct crypto_akcipher = *tfm) struct qat_rsa_ctx *ctx =3D akcipher_tfm_ctx(tfm); struct device *dev =3D &GET_DEV(ctx->inst->accel_dev); =20 - if (ctx->n) - dma_free_coherent(dev, ctx->key_sz, ctx->n, ctx->dma_n); - if (ctx->e) - dma_free_coherent(dev, ctx->key_sz, ctx->e, ctx->dma_e); - if (ctx->d) { - memset(ctx->d, '\0', ctx->key_sz); - dma_free_coherent(dev, ctx->key_sz, ctx->d, ctx->dma_d); - } + qat_rsa_clear_ctx(dev, ctx); qat_crypto_put_instance(ctx->inst); - ctx->n =3D NULL; - ctx->e =3D NULL; - ctx->d =3D NULL; } =20 static struct akcipher_alg rsa =3D { --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6609EC19F2B for ; Wed, 27 Jul 2022 17:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243045AbiG0RpQ (ORCPT ); Wed, 27 Jul 2022 13:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243080AbiG0RoM (ORCPT ); Wed, 27 Jul 2022 13:44:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D89D88AEE3; Wed, 27 Jul 2022 09:52:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7BEC8B821D7; Wed, 27 Jul 2022 16:52:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C82D8C433D6; Wed, 27 Jul 2022 16:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940776; bh=IWqERPbPXuzAJi43HWMg9GWZIDPCSP25alnEokDZ0nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djza8EcYkmhVi9wzVqY/9z79dqHOSYTChrQRBdaeDT2cWIjMurN3Pc2nynW2qkg3t O8LNLcmuHBnWxPxnehF0W8hIiHI1+gW9ZGsDtYNOl1NDO4f6byfeGETwbIeDLvhW55 2545oC19IcxY2nFC0dXN1/yvQnJ78jMTuu8TkZ8c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 145/158] crypto: qat - remove dma_free_coherent() for RSA Date: Wed, 27 Jul 2022 18:13:29 +0200 Message-Id: <20220727161027.154827973@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 3dfaf0071ed74d7a9c6b3c9ea4df7a6f8e423c2a ] After commit f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP"), if the algorithms are enabled, the driver crashes with a BUG_ON while executing vunmap() in the context of a tasklet. This is due to the fact that the function dma_free_coherent() cannot be called in an interrupt context (see Documentation/core-api/dma-api-howto.rst). The functions qat_rsa_enc() and qat_rsa_dec() allocate memory with dma_alloc_coherent() if the source or the destination buffers are made of multiple flat buffers or of a size that is not compatible with the hardware. This memory is then freed with dma_free_coherent() in the context of a tasklet invoked to handle the response for the corresponding request. Replace allocations with dma_alloc_coherent() in the functions qat_rsa_enc() and qat_rsa_dec() with kmalloc() + dma_map_single(). Cc: stable@vger.kernel.org Fixes: a990532023b9 ("crypto: qat - Add support for RSA algorithm") Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 137 ++++++++---------- 1 file changed, 60 insertions(+), 77 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index 2bc02c75398e..b31372bddb96 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -529,25 +529,22 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *re= sp) =20 err =3D (err =3D=3D ICP_QAT_FW_COMN_STATUS_FLAG_OK) ? 0 : -EINVAL; =20 - if (req->src_align) - dma_free_coherent(dev, req->ctx.rsa->key_sz, req->src_align, - req->in.rsa.enc.m); - else - dma_unmap_single(dev, req->in.rsa.enc.m, req->ctx.rsa->key_sz, - DMA_TO_DEVICE); + kfree_sensitive(req->src_align); + + dma_unmap_single(dev, req->in.rsa.enc.m, req->ctx.rsa->key_sz, + DMA_TO_DEVICE); =20 areq->dst_len =3D req->ctx.rsa->key_sz; if (req->dst_align) { scatterwalk_map_and_copy(req->dst_align, areq->dst, 0, areq->dst_len, 1); =20 - dma_free_coherent(dev, req->ctx.rsa->key_sz, req->dst_align, - req->out.rsa.enc.c); - } else { - dma_unmap_single(dev, req->out.rsa.enc.c, req->ctx.rsa->key_sz, - DMA_FROM_DEVICE); + kfree_sensitive(req->dst_align); } =20 + dma_unmap_single(dev, req->out.rsa.enc.c, req->ctx.rsa->key_sz, + DMA_FROM_DEVICE); + dma_unmap_single(dev, req->phy_in, sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); dma_unmap_single(dev, req->phy_out, @@ -664,6 +661,7 @@ static int qat_rsa_enc(struct akcipher_request *req) struct qat_asym_request *qat_req =3D PTR_ALIGN(akcipher_request_ctx(req), 64); struct icp_qat_fw_pke_request *msg =3D &qat_req->req; + u8 *vaddr; int ret; =20 if (unlikely(!ctx->n || !ctx->e)) @@ -701,40 +699,39 @@ static int qat_rsa_enc(struct akcipher_request *req) */ if (sg_is_last(req->src) && req->src_len =3D=3D ctx->key_sz) { qat_req->src_align =3D NULL; - qat_req->in.rsa.enc.m =3D dma_map_single(dev, sg_virt(req->src), - req->src_len, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, qat_req->in.rsa.enc.m))) - return ret; - + vaddr =3D sg_virt(req->src); } else { int shift =3D ctx->key_sz - req->src_len; =20 - qat_req->src_align =3D dma_alloc_coherent(dev, ctx->key_sz, - &qat_req->in.rsa.enc.m, - GFP_KERNEL); + qat_req->src_align =3D kzalloc(ctx->key_sz, GFP_KERNEL); if (unlikely(!qat_req->src_align)) return ret; =20 scatterwalk_map_and_copy(qat_req->src_align + shift, req->src, 0, req->src_len, 0); + vaddr =3D qat_req->src_align; } - if (sg_is_last(req->dst) && req->dst_len =3D=3D ctx->key_sz) { - qat_req->dst_align =3D NULL; - qat_req->out.rsa.enc.c =3D dma_map_single(dev, sg_virt(req->dst), - req->dst_len, - DMA_FROM_DEVICE); =20 - if (unlikely(dma_mapping_error(dev, qat_req->out.rsa.enc.c))) - goto unmap_src; + qat_req->in.rsa.enc.m =3D dma_map_single(dev, vaddr, ctx->key_sz, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, qat_req->in.rsa.enc.m))) + goto unmap_src; =20 + if (sg_is_last(req->dst) && req->dst_len =3D=3D ctx->key_sz) { + qat_req->dst_align =3D NULL; + vaddr =3D sg_virt(req->dst); } else { - qat_req->dst_align =3D dma_alloc_coherent(dev, ctx->key_sz, - &qat_req->out.rsa.enc.c, - GFP_KERNEL); + qat_req->dst_align =3D kzalloc(ctx->key_sz, GFP_KERNEL); if (unlikely(!qat_req->dst_align)) goto unmap_src; - + vaddr =3D qat_req->dst_align; } + + qat_req->out.rsa.enc.c =3D dma_map_single(dev, vaddr, ctx->key_sz, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(dev, qat_req->out.rsa.enc.c))) + goto unmap_dst; + qat_req->in.rsa.in_tab[3] =3D 0; qat_req->out.rsa.out_tab[1] =3D 0; qat_req->phy_in =3D dma_map_single(dev, &qat_req->in.rsa.enc.m, @@ -772,21 +769,15 @@ static int qat_rsa_enc(struct akcipher_request *req) sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); unmap_dst: - if (qat_req->dst_align) - dma_free_coherent(dev, ctx->key_sz, qat_req->dst_align, - qat_req->out.rsa.enc.c); - else - if (!dma_mapping_error(dev, qat_req->out.rsa.enc.c)) - dma_unmap_single(dev, qat_req->out.rsa.enc.c, - ctx->key_sz, DMA_FROM_DEVICE); + if (!dma_mapping_error(dev, qat_req->out.rsa.enc.c)) + dma_unmap_single(dev, qat_req->out.rsa.enc.c, + ctx->key_sz, DMA_FROM_DEVICE); + kfree_sensitive(qat_req->dst_align); unmap_src: - if (qat_req->src_align) - dma_free_coherent(dev, ctx->key_sz, qat_req->src_align, - qat_req->in.rsa.enc.m); - else - if (!dma_mapping_error(dev, qat_req->in.rsa.enc.m)) - dma_unmap_single(dev, qat_req->in.rsa.enc.m, - ctx->key_sz, DMA_TO_DEVICE); + if (!dma_mapping_error(dev, qat_req->in.rsa.enc.m)) + dma_unmap_single(dev, qat_req->in.rsa.enc.m, ctx->key_sz, + DMA_TO_DEVICE); + kfree_sensitive(qat_req->src_align); return ret; } =20 @@ -799,6 +790,7 @@ static int qat_rsa_dec(struct akcipher_request *req) struct qat_asym_request *qat_req =3D PTR_ALIGN(akcipher_request_ctx(req), 64); struct icp_qat_fw_pke_request *msg =3D &qat_req->req; + u8 *vaddr; int ret; =20 if (unlikely(!ctx->n || !ctx->d)) @@ -846,40 +838,37 @@ static int qat_rsa_dec(struct akcipher_request *req) */ if (sg_is_last(req->src) && req->src_len =3D=3D ctx->key_sz) { qat_req->src_align =3D NULL; - qat_req->in.rsa.dec.c =3D dma_map_single(dev, sg_virt(req->src), - req->dst_len, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, qat_req->in.rsa.dec.c))) - return ret; - + vaddr =3D sg_virt(req->src); } else { int shift =3D ctx->key_sz - req->src_len; =20 - qat_req->src_align =3D dma_alloc_coherent(dev, ctx->key_sz, - &qat_req->in.rsa.dec.c, - GFP_KERNEL); + qat_req->src_align =3D kzalloc(ctx->key_sz, GFP_KERNEL); if (unlikely(!qat_req->src_align)) return ret; =20 scatterwalk_map_and_copy(qat_req->src_align + shift, req->src, 0, req->src_len, 0); + vaddr =3D qat_req->src_align; } - if (sg_is_last(req->dst) && req->dst_len =3D=3D ctx->key_sz) { - qat_req->dst_align =3D NULL; - qat_req->out.rsa.dec.m =3D dma_map_single(dev, sg_virt(req->dst), - req->dst_len, - DMA_FROM_DEVICE); =20 - if (unlikely(dma_mapping_error(dev, qat_req->out.rsa.dec.m))) - goto unmap_src; + qat_req->in.rsa.dec.c =3D dma_map_single(dev, vaddr, ctx->key_sz, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, qat_req->in.rsa.dec.c))) + goto unmap_src; =20 + if (sg_is_last(req->dst) && req->dst_len =3D=3D ctx->key_sz) { + qat_req->dst_align =3D NULL; + vaddr =3D sg_virt(req->dst); } else { - qat_req->dst_align =3D dma_alloc_coherent(dev, ctx->key_sz, - &qat_req->out.rsa.dec.m, - GFP_KERNEL); + qat_req->dst_align =3D kzalloc(ctx->key_sz, GFP_KERNEL); if (unlikely(!qat_req->dst_align)) goto unmap_src; - + vaddr =3D qat_req->dst_align; } + qat_req->out.rsa.dec.m =3D dma_map_single(dev, vaddr, ctx->key_sz, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(dev, qat_req->out.rsa.dec.m))) + goto unmap_dst; =20 if (ctx->crt_mode) qat_req->in.rsa.in_tab[6] =3D 0; @@ -925,21 +914,15 @@ static int qat_rsa_dec(struct akcipher_request *req) sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); unmap_dst: - if (qat_req->dst_align) - dma_free_coherent(dev, ctx->key_sz, qat_req->dst_align, - qat_req->out.rsa.dec.m); - else - if (!dma_mapping_error(dev, qat_req->out.rsa.dec.m)) - dma_unmap_single(dev, qat_req->out.rsa.dec.m, - ctx->key_sz, DMA_FROM_DEVICE); + if (!dma_mapping_error(dev, qat_req->out.rsa.dec.m)) + dma_unmap_single(dev, qat_req->out.rsa.dec.m, + ctx->key_sz, DMA_FROM_DEVICE); + kfree_sensitive(qat_req->dst_align); unmap_src: - if (qat_req->src_align) - dma_free_coherent(dev, ctx->key_sz, qat_req->src_align, - qat_req->in.rsa.dec.c); - else - if (!dma_mapping_error(dev, qat_req->in.rsa.dec.c)) - dma_unmap_single(dev, qat_req->in.rsa.dec.c, - ctx->key_sz, DMA_TO_DEVICE); + if (!dma_mapping_error(dev, qat_req->in.rsa.dec.c)) + dma_unmap_single(dev, qat_req->in.rsa.dec.c, ctx->key_sz, + DMA_TO_DEVICE); + kfree_sensitive(qat_req->src_align); return ret; } =20 --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A5B2C04A68 for ; Wed, 27 Jul 2022 17:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243091AbiG0Rpi (ORCPT ); Wed, 27 Jul 2022 13:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243191AbiG0Ro0 (ORCPT ); Wed, 27 Jul 2022 13:44:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D908B4AD; Wed, 27 Jul 2022 09:53:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5A4BAB821B9; Wed, 27 Jul 2022 16:53:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3AA9C433D6; Wed, 27 Jul 2022 16:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940779; bh=7upjMH8v1lO5gmKMhprbMT2ertIoz1OLzCcHbMIlJ5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=njj6EnXYBAkoJmRFcbQd+CJos5SYw0rUETE1fb81fSO219p2c8O7XxNSMH6L8UxOL CXwD0Tf1ucn0CLzEnGSMeZJeVaokgr0ATbD0u2KEab5mh4ryd+eDaZI3RTbL5R3SAk DMYC89FwzcPuNCptmMp/erlUm1I2kZyWyCMdC9N8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 146/158] crypto: qat - remove dma_free_coherent() for DH Date: Wed, 27 Jul 2022 18:13:30 +0200 Message-Id: <20220727161027.202774037@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 029aa4624a7fe35233bdd3d1354dc7be260380bf ] The functions qat_dh_compute_value() allocates memory with dma_alloc_coherent() if the source or the destination buffers are made of multiple flat buffers or of a size that is not compatible with the hardware. This memory is then freed with dma_free_coherent() in the context of a tasklet invoked to handle the response for the corresponding request. According to Documentation/core-api/dma-api-howto.rst, the function dma_free_coherent() cannot be called in an interrupt context. Replace allocations with dma_alloc_coherent() in the function qat_dh_compute_value() with kmalloc() + dma_map_single(). Cc: stable@vger.kernel.org Fixes: c9839143ebbf ("crypto: qat - Add DH support") Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 83 ++++++++----------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index b31372bddb96..25bbd22085c3 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -164,26 +164,21 @@ static void qat_dh_cb(struct icp_qat_fw_pke_resp *res= p) err =3D (err =3D=3D ICP_QAT_FW_COMN_STATUS_FLAG_OK) ? 0 : -EINVAL; =20 if (areq->src) { - if (req->src_align) - dma_free_coherent(dev, req->ctx.dh->p_size, - req->src_align, req->in.dh.in.b); - else - dma_unmap_single(dev, req->in.dh.in.b, - req->ctx.dh->p_size, DMA_TO_DEVICE); + dma_unmap_single(dev, req->in.dh.in.b, req->ctx.dh->p_size, + DMA_TO_DEVICE); + kfree_sensitive(req->src_align); } =20 areq->dst_len =3D req->ctx.dh->p_size; if (req->dst_align) { scatterwalk_map_and_copy(req->dst_align, areq->dst, 0, areq->dst_len, 1); - - dma_free_coherent(dev, req->ctx.dh->p_size, req->dst_align, - req->out.dh.r); - } else { - dma_unmap_single(dev, req->out.dh.r, req->ctx.dh->p_size, - DMA_FROM_DEVICE); + kfree_sensitive(req->dst_align); } =20 + dma_unmap_single(dev, req->out.dh.r, req->ctx.dh->p_size, + DMA_FROM_DEVICE); + dma_unmap_single(dev, req->phy_in, sizeof(struct qat_dh_input_params), DMA_TO_DEVICE); dma_unmap_single(dev, req->phy_out, @@ -231,6 +226,7 @@ static int qat_dh_compute_value(struct kpp_request *req) struct icp_qat_fw_pke_request *msg =3D &qat_req->req; int ret; int n_input_params =3D 0; + u8 *vaddr; =20 if (unlikely(!ctx->xa)) return -EINVAL; @@ -287,27 +283,24 @@ static int qat_dh_compute_value(struct kpp_request *r= eq) */ if (sg_is_last(req->src) && req->src_len =3D=3D ctx->p_size) { qat_req->src_align =3D NULL; - qat_req->in.dh.in.b =3D dma_map_single(dev, - sg_virt(req->src), - req->src_len, - DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, - qat_req->in.dh.in.b))) - return ret; - + vaddr =3D sg_virt(req->src); } else { int shift =3D ctx->p_size - req->src_len; =20 - qat_req->src_align =3D dma_alloc_coherent(dev, - ctx->p_size, - &qat_req->in.dh.in.b, - GFP_KERNEL); + qat_req->src_align =3D kzalloc(ctx->p_size, GFP_KERNEL); if (unlikely(!qat_req->src_align)) return ret; =20 scatterwalk_map_and_copy(qat_req->src_align + shift, req->src, 0, req->src_len, 0); + + vaddr =3D qat_req->src_align; } + + qat_req->in.dh.in.b =3D dma_map_single(dev, vaddr, ctx->p_size, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, qat_req->in.dh.in.b))) + goto unmap_src; } /* * dst can be of any size in valid range, but HW expects it to be the @@ -318,20 +311,18 @@ static int qat_dh_compute_value(struct kpp_request *r= eq) */ if (sg_is_last(req->dst) && req->dst_len =3D=3D ctx->p_size) { qat_req->dst_align =3D NULL; - qat_req->out.dh.r =3D dma_map_single(dev, sg_virt(req->dst), - req->dst_len, - DMA_FROM_DEVICE); - - if (unlikely(dma_mapping_error(dev, qat_req->out.dh.r))) - goto unmap_src; - + vaddr =3D sg_virt(req->dst); } else { - qat_req->dst_align =3D dma_alloc_coherent(dev, ctx->p_size, - &qat_req->out.dh.r, - GFP_KERNEL); + qat_req->dst_align =3D kzalloc(ctx->p_size, GFP_KERNEL); if (unlikely(!qat_req->dst_align)) goto unmap_src; + + vaddr =3D qat_req->dst_align; } + qat_req->out.dh.r =3D dma_map_single(dev, vaddr, ctx->p_size, + DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(dev, qat_req->out.dh.r))) + goto unmap_dst; =20 qat_req->in.dh.in_tab[n_input_params] =3D 0; qat_req->out.dh.out_tab[1] =3D 0; @@ -371,23 +362,17 @@ static int qat_dh_compute_value(struct kpp_request *r= eq) sizeof(struct qat_dh_input_params), DMA_TO_DEVICE); unmap_dst: - if (qat_req->dst_align) - dma_free_coherent(dev, ctx->p_size, qat_req->dst_align, - qat_req->out.dh.r); - else - if (!dma_mapping_error(dev, qat_req->out.dh.r)) - dma_unmap_single(dev, qat_req->out.dh.r, ctx->p_size, - DMA_FROM_DEVICE); + if (!dma_mapping_error(dev, qat_req->out.dh.r)) + dma_unmap_single(dev, qat_req->out.dh.r, ctx->p_size, + DMA_FROM_DEVICE); + kfree_sensitive(qat_req->dst_align); unmap_src: if (req->src) { - if (qat_req->src_align) - dma_free_coherent(dev, ctx->p_size, qat_req->src_align, - qat_req->in.dh.in.b); - else - if (!dma_mapping_error(dev, qat_req->in.dh.in.b)) - dma_unmap_single(dev, qat_req->in.dh.in.b, - ctx->p_size, - DMA_TO_DEVICE); + if (!dma_mapping_error(dev, qat_req->in.dh.in.b)) + dma_unmap_single(dev, qat_req->in.dh.in.b, + ctx->p_size, + DMA_TO_DEVICE); + kfree_sensitive(qat_req->src_align); } return ret; } --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C0A8C04A68 for ; Wed, 27 Jul 2022 17:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243081AbiG0Rpf (ORCPT ); Wed, 27 Jul 2022 13:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243130AbiG0RoT (ORCPT ); Wed, 27 Jul 2022 13:44:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746378AEC5; Wed, 27 Jul 2022 09:53:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1DE06B821C5; Wed, 27 Jul 2022 16:53:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8335FC433D6; Wed, 27 Jul 2022 16:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940781; bh=/0a/0Z9dUlo8grhA3fXLHeVFNp9BdkiWV92ue3bNBfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OmnNLWBC80H+L9HOSXmvjuHuOdjTp5a/vwb7lIc50XxFGGDxou6uX4NF+WazLY3fq +ccWtRhMhPs9jlQAaS+RUxC4CIk6soeG+WeqCp9y9zLVl+48QzOXKfJrHSFMGiym7W +MKB6Bsi6Kbxv7+k42MefpZ5WgbXgw/qkzwQrTA0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 147/158] crypto: qat - add param check for RSA Date: Wed, 27 Jul 2022 18:13:31 +0200 Message-Id: <20220727161027.247180664@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 9714061423b8b24b8afb31b8eb4df977c63f19c4 ] Reject requests with a source buffer that is bigger than the size of the key. This is to prevent a possible integer underflow that might happen when copying the source scatterlist into a linear buffer. Cc: stable@vger.kernel.org Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index 25bbd22085c3..947eeff181b4 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -656,6 +656,10 @@ static int qat_rsa_enc(struct akcipher_request *req) req->dst_len =3D ctx->key_sz; return -EOVERFLOW; } + + if (req->src_len > ctx->key_sz) + return -EINVAL; + memset(msg, '\0', sizeof(*msg)); ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr, ICP_QAT_FW_COMN_REQ_FLAG_SET); @@ -785,6 +789,10 @@ static int qat_rsa_dec(struct akcipher_request *req) req->dst_len =3D ctx->key_sz; return -EOVERFLOW; } + + if (req->src_len > ctx->key_sz) + return -EINVAL; + memset(msg, '\0', sizeof(*msg)); ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr, ICP_QAT_FW_COMN_REQ_FLAG_SET); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31B82C04A68 for ; Wed, 27 Jul 2022 17:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243117AbiG0Rps (ORCPT ); Wed, 27 Jul 2022 13:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243235AbiG0Rob (ORCPT ); Wed, 27 Jul 2022 13:44:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980198BA95; Wed, 27 Jul 2022 09:53:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0266C61743; Wed, 27 Jul 2022 16:53:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AA49C43146; Wed, 27 Jul 2022 16:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940784; bh=OGCj6S1xjd9XwIbJO81L93cBRcKmCDMbwE+p77sNUko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uTHv2fH7QC1f6m0UbnSlOY2v3qJPlXjE6HC2cuY+OVM4BzHfOG/i0vBj666aoJSVA HzPyWMVJZDTRbAcAfVLbHbha5aDLGjtfcyDUowB9TSXpOcIxniFFMkV0SdtjrXZ22m ZYkzspOOfxeppju6Yu5PHjFHtRLcQep6t/qPaEw0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 148/158] crypto: qat - add param check for DH Date: Wed, 27 Jul 2022 18:13:32 +0200 Message-Id: <20220727161027.286098097@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit 2acbb8771f6ac82422886e63832ee7a0f4b1635b ] Reject requests with a source buffer that is bigger than the size of the key. This is to prevent a possible integer underflow that might happen when copying the source scatterlist into a linear buffer. Cc: stable@vger.kernel.org Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto= /qat/qat_common/qat_asym_algs.c index 947eeff181b4..7173a2a0a484 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -235,6 +235,10 @@ static int qat_dh_compute_value(struct kpp_request *re= q) req->dst_len =3D ctx->p_size; return -EOVERFLOW; } + + if (req->src_len > ctx->p_size) + return -EINVAL; + memset(msg, '\0', sizeof(*msg)); ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr, ICP_QAT_FW_COMN_REQ_FLAG_SET); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F870C04A68 for ; Wed, 27 Jul 2022 17:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243150AbiG0RqE (ORCPT ); Wed, 27 Jul 2022 13:46:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243287AbiG0Roi (ORCPT ); Wed, 27 Jul 2022 13:44:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD40B8B4AA; Wed, 27 Jul 2022 09:53:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DCE7961777; Wed, 27 Jul 2022 16:53:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2FA6C433D6; Wed, 27 Jul 2022 16:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940787; bh=EbbtSP81SB/eEVBWm1PY22sD8gJOWt3K2bKK1nSe17I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPNfKlV9t9oPpzU3mGGs4OZhzo9DSynFdiyNS0gXmg6rqlCANBEzEYO2+5G7th83u 9axe0JYqKBaFQtgrs5c5OZLhHD9rK2WYh5WgqSTHlmHfByCWWXGJB2PNU8nt5MkDSY wly9H6oMcjLrOYY3cYUIaMI93b0oNWqnjW/kpsKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Marco Chiappero , Adam Guerin , Wojciech Ziemba , Herbert Xu , Sasha Levin Subject: [PATCH 5.18 149/158] crypto: qat - re-enable registration of algorithms Date: Wed, 27 Jul 2022 18:13:33 +0200 Message-Id: <20220727161027.319910171@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Giovanni Cabiddu [ Upstream commit d09144745959bf7852ccafd73243dd7d1eaeb163 ] Re-enable the registration of algorithms after fixes to (1) use pre-allocated buffers in the datapath and (2) support the CRYPTO_TFM_REQ_MAY_BACKLOG flag. This reverts commit 8893d27ffcaf6ec6267038a177cb87bcde4dd3de. Cc: stable@vger.kernel.org Signed-off-by: Giovanni Cabiddu Reviewed-by: Marco Chiappero Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/crypto/qat/qat_4xxx/adf_drv.c | 7 ------- drivers/crypto/qat/qat_common/qat_crypto.c | 7 ------- 2 files changed, 14 deletions(-) diff --git a/drivers/crypto/qat/qat_4xxx/adf_drv.c b/drivers/crypto/qat/qat= _4xxx/adf_drv.c index fa4c350c1bf9..a6c78b9c730b 100644 --- a/drivers/crypto/qat/qat_4xxx/adf_drv.c +++ b/drivers/crypto/qat/qat_4xxx/adf_drv.c @@ -75,13 +75,6 @@ static int adf_crypto_dev_config(struct adf_accel_dev *a= ccel_dev) if (ret) goto err; =20 - /* Temporarily set the number of crypto instances to zero to avoid - * registering the crypto algorithms. - * This will be removed when the algorithms will support the - * CRYPTO_TFM_REQ_MAY_BACKLOG flag - */ - instances =3D 0; - for (i =3D 0; i < instances; i++) { val =3D i; bank =3D i * 2; diff --git a/drivers/crypto/qat/qat_common/qat_crypto.c b/drivers/crypto/qa= t/qat_common/qat_crypto.c index 80d905ed102e..9341d892533a 100644 --- a/drivers/crypto/qat/qat_common/qat_crypto.c +++ b/drivers/crypto/qat/qat_common/qat_crypto.c @@ -161,13 +161,6 @@ int qat_crypto_dev_config(struct adf_accel_dev *accel_= dev) if (ret) goto err; =20 - /* Temporarily set the number of crypto instances to zero to avoid - * registering the crypto algorithms. - * This will be removed when the algorithms will support the - * CRYPTO_TFM_REQ_MAY_BACKLOG flag - */ - instances =3D 0; - for (i =3D 0; i < instances; i++) { val =3D i; snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_BANK_NUM, i); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45943C04A68 for ; Wed, 27 Jul 2022 17:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243124AbiG0Rpv (ORCPT ); Wed, 27 Jul 2022 13:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243240AbiG0Rob (ORCPT ); Wed, 27 Jul 2022 13:44:31 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59078BA98; Wed, 27 Jul 2022 09:53:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id CBB5FCE2309; Wed, 27 Jul 2022 16:53:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF712C433C1; Wed, 27 Jul 2022 16:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940790; bh=1QI/Q7cS/pyQ6EjE/gPkhbaMHoT+HkDV5b+WsHny1O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kvkmI6lAxjpeIM+i1TMHR1imk1v/9W77cHX5siei9+K71QU+0xzCqPxQVpfuhlffx 5nmqID3+tNNVRTbD8GecjUt1iLOoB90M+/MsJU2JO1qylfh96laBKWp8Ff7QWIUeyj H0CuXSnHkC1mVuXx5QvUZgE2TqP2vfMYr6sd5kBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuezhang Mo , Andy Wu , Aoyama Wataru , Daniel Palmer , Sungjong Seo , Namjae Jeon , Sasha Levin Subject: [PATCH 5.18 150/158] exfat: fix referencing wrong parent directory information after renaming Date: Wed, 27 Jul 2022 18:13:34 +0200 Message-Id: <20220727161027.359196060@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yuezhang Mo [ Upstream commit d8dad2588addd1d861ce19e7df3b702330f0c7e3 ] During renaming, the parent directory information maybe updated. But the file/directory still references to the old parent directory information. This bug will cause 2 problems. (1) The renamed file can not be written. [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : 7afd50e4= iblock : 0, err : -5) [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only ash: write error: Input/output error (2) Some dentries of the renamed file/directory are not set to deleted after removing the file/directory. exfat_update_parent_info() is a workaround for the wrong parent directory information being used after renaming. Now that bug is fixed, this is no longer needed, so remove it. Fixes: 5f2aa075070c ("exfat: add inode operations") Cc: stable@vger.kernel.org # v5.7+ Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Reviewed-by: Daniel Palmer Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- fs/exfat/namei.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index a02a04a993bf..76acc3721951 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1080,6 +1080,7 @@ static int exfat_rename_file(struct inode *inode, str= uct exfat_chain *p_dir, =20 exfat_remove_entries(inode, p_dir, oldentry, 0, num_old_entries); + ei->dir =3D *p_dir; ei->entry =3D newentry; } else { if (exfat_get_entry_type(epold) =3D=3D TYPE_FILE) { @@ -1167,28 +1168,6 @@ static int exfat_move_file(struct inode *inode, stru= ct exfat_chain *p_olddir, return 0; } =20 -static void exfat_update_parent_info(struct exfat_inode_info *ei, - struct inode *parent_inode) -{ - struct exfat_sb_info *sbi =3D EXFAT_SB(parent_inode->i_sb); - struct exfat_inode_info *parent_ei =3D EXFAT_I(parent_inode); - loff_t parent_isize =3D i_size_read(parent_inode); - - /* - * the problem that struct exfat_inode_info caches wrong parent info. - * - * because of flag-mismatch of ei->dir, - * there is abnormal traversing cluster chain. - */ - if (unlikely(parent_ei->flags !=3D ei->dir.flags || - parent_isize !=3D EXFAT_CLU_TO_B(ei->dir.size, sbi) || - parent_ei->start_clu !=3D ei->dir.dir)) { - exfat_chain_set(&ei->dir, parent_ei->start_clu, - EXFAT_B_TO_CLU_ROUND_UP(parent_isize, sbi), - parent_ei->flags); - } -} - /* rename or move a old file into a new file */ static int __exfat_rename(struct inode *old_parent_inode, struct exfat_inode_info *ei, struct inode *new_parent_inode, @@ -1219,8 +1198,6 @@ static int __exfat_rename(struct inode *old_parent_in= ode, return -ENOENT; } =20 - exfat_update_parent_info(ei, old_parent_inode); - exfat_chain_dup(&olddir, &ei->dir); dentry =3D ei->entry; =20 @@ -1241,8 +1218,6 @@ static int __exfat_rename(struct inode *old_parent_in= ode, goto out; } =20 - exfat_update_parent_info(new_ei, new_parent_inode); - p_dir =3D &(new_ei->dir); new_entry =3D new_ei->entry; ep =3D exfat_get_dentry(sb, p_dir, new_entry, &new_bh); --=20 2.35.1 From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF39C04A68 for ; Wed, 27 Jul 2022 17:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243142AbiG0Rp7 (ORCPT ); Wed, 27 Jul 2022 13:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243286AbiG0Roi (ORCPT ); Wed, 27 Jul 2022 13:44:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAADC8BAB8; Wed, 27 Jul 2022 09:53:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33672601CD; Wed, 27 Jul 2022 16:53:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FFDEC433D6; Wed, 27 Jul 2022 16:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940795; bh=eY89Sv1WVpiYZxJsO0SWrR/Cvqp5zjh5Yq3kUF8vR14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFxEhu5DwoV0LWqjjmRy2a6naudcl5StY13tEsBlbqPTIfQZGxS3WM830O2MamoHA Jwk+Ve4juMpi1QlyNdRSsDGG96EClYnLam2ZKv9AtlNPf72anU7AcQm5mzbAYnM2MS xHZMvZxEn75D9ZyiKO/eumm7lnY7+x6DblzO5zow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Yugui , Sungjong Seo , Namjae Jeon Subject: [PATCH 5.18 151/158] exfat: use updated exfat_chain directly during renaming Date: Wed, 27 Jul 2022 18:13:35 +0200 Message-Id: <20220727161027.397239317@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sungjong Seo commit 204e6ceaa1035cb7b92b156517e88842ebb4c7ff upstream. In order for a file to access its own directory entry set, exfat_inode_info(ei) has two copied values. One is ei->dir, which is a snapshot of exfat_chain of the parent directory, and the other is ei->entry, which is the offset of the start of the directory entry set in the parent directory. Since the parent directory can be updated after the snapshot point, it should be used only for accessing one's own directory entry set. However, as of now, during renaming, it could try to traverse or to allocate clusters via snapshot values, it does not make sense. This potential problem has been revealed when exfat_update_parent_info() was removed by commit d8dad2588add ("exfat: fix referencing wrong parent directory information after renaming"). However, I don't think it's good idea to bring exfat_update_parent_info() back. Instead, let's use the updated exfat_chain of parent directory diectly. Fixes: d8dad2588add ("exfat: fix referencing wrong parent directory informa= tion after renaming") Reported-by: Wang Yugui Signed-off-by: Sungjong Seo Tested-by: Wang Yugui Signed-off-by: Namjae Jeon Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- fs/exfat/namei.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1198,7 +1198,9 @@ static int __exfat_rename(struct inode * return -ENOENT; } =20 - exfat_chain_dup(&olddir, &ei->dir); + exfat_chain_set(&olddir, EXFAT_I(old_parent_inode)->start_clu, + EXFAT_B_TO_CLU_ROUND_UP(i_size_read(old_parent_inode), sbi), + EXFAT_I(old_parent_inode)->flags); dentry =3D ei->entry; =20 ep =3D exfat_get_dentry(sb, &olddir, dentry, &old_bh); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B653C04A68 for ; Wed, 27 Jul 2022 17:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243165AbiG0RqL (ORCPT ); Wed, 27 Jul 2022 13:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243318AbiG0Rol (ORCPT ); Wed, 27 Jul 2022 13:44:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E53B8C153; Wed, 27 Jul 2022 09:53:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0F0DEB821D7; Wed, 27 Jul 2022 16:53:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53D6BC433C1; Wed, 27 Jul 2022 16:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940798; bh=hgedp9WsWU6gyxMX4x+e4LsYusxnvmMwzm2vb72HzhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SraCPUtZDKSAFdA6sZ517BQ1RPSxQX5Qjt+X0yLA3bK3cIi55RFI1mA3Gb8a131bW o1vdOM7Qr69CssgpoxMZZu/eyto8lZWSH3A174dHBm3h+ZMaikmVoHThhwBnQfS0Yx WMGAlMnDqUACaCoEIdA8EKWnE9ZEUpl6dxY1QJWE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Borislav Petkov Subject: [PATCH 5.18 152/158] x86/amd: Use IBPB for firmware calls Date: Wed, 27 Jul 2022 18:13:36 +0200 Message-Id: <20220727161027.443092336@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peter Zijlstra commit 28a99e95f55c61855983d36a88c05c178d966bb7 upstream. On AMD IBRS does not prevent Retbleed; as such use IBPB before a firmware call to flush the branch history state. And because in order to do an EFI call, the kernel maps a whole lot of the kernel page table into the EFI page table, do an IBPB just in case in order to prevent the scenario of poisoning the BTB and causing an EFI call using the unprotected RET there. [ bp: Massage. ] Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20220715194550.793957-1-cascardo@canonical.= com Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/nospec-branch.h | 2 ++ arch/x86/kernel/cpu/bugs.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -301,6 +301,7 @@ #define X86_FEATURE_RETPOLINE_LFENCE (11*32+13) /* "" Use LFENCE for Spect= re variant 2 */ #define X86_FEATURE_RETHUNK (11*32+14) /* "" Use REturn THUNK */ #define X86_FEATURE_UNRET (11*32+15) /* "" AMD BTB untrain return */ +#define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime = firmware calls */ =20 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -297,6 +297,8 @@ do { \ alternative_msr_write(MSR_IA32_SPEC_CTRL, \ spec_ctrl_current() | SPEC_CTRL_IBRS, \ X86_FEATURE_USE_IBRS_FW); \ + alternative_msr_write(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, \ + X86_FEATURE_USE_IBPB_FW); \ } while (0) =20 #define firmware_restrict_branch_speculation_end() \ --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1512,7 +1512,16 @@ static void __init spectre_v2_select_mit * the CPU supports Enhanced IBRS, kernel might un-intentionally not * enable IBRS around firmware calls. */ - if (boot_cpu_has(X86_FEATURE_IBRS) && !spectre_v2_in_ibrs_mode(mode)) { + if (boot_cpu_has_bug(X86_BUG_RETBLEED) && + (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD || + boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_HYGON)) { + + if (retbleed_cmd !=3D RETBLEED_CMD_IBPB) { + setup_force_cpu_cap(X86_FEATURE_USE_IBPB_FW); + pr_info("Enabling Speculation Barrier for firmware calls\n"); + } + + } else if (boot_cpu_has(X86_FEATURE_IBRS) && !spectre_v2_in_ibrs_mode(mod= e)) { setup_force_cpu_cap(X86_FEATURE_USE_IBRS_FW); pr_info("Enabling Restricted Speculation for firmware calls\n"); } From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC30C04A68 for ; Wed, 27 Jul 2022 17:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242846AbiG0RqQ (ORCPT ); Wed, 27 Jul 2022 13:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243332AbiG0Ron (ORCPT ); Wed, 27 Jul 2022 13:44:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB2A8C160; Wed, 27 Jul 2022 09:53:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 10AD261748; Wed, 27 Jul 2022 16:53:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C42EC433C1; Wed, 27 Jul 2022 16:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940801; bh=jkT+4xjpS2LtUayr7DDs0NXC2QqliEHufZi6XOBMVyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lI1iSRvxV5y1jbBydqJUSliLcNOfXxIZZd8sJ8D7+Mf7kTVyaH0DeZAImdAz/OJVa rj+SN17XJa1mSCsAFCfYL3iWgE922CS7FyW04EdqxCdb6EyA6+eAI/t4sHHITPRqms kLJTCXJ8gXb2/i3BcT9lhrwRzGbLXkNqe4d+5ffc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Kees Cook Subject: [PATCH 5.18 153/158] x86/alternative: Report missing return thunk details Date: Wed, 27 Jul 2022 18:13:37 +0200 Message-Id: <20220727161027.482275746@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kees Cook commit 65cdf0d623bedf0e069bb64ed52e8bb20105e2ba upstream. Debugging missing return thunks is easier if we can see where they're happening. Suggested-by: Peter Zijlstra Signed-off-by: Kees Cook Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/lkml/Ys66hwtFcGbYmoiZ@hirez.programming.kicks= -ass.net/ Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/x86/kernel/alternative.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -555,7 +555,9 @@ void __init_or_module noinline apply_ret dest =3D addr + insn.length + insn.immediate.value; =20 if (__static_call_fixup(addr, op, dest) || - WARN_ON_ONCE(dest !=3D &__x86_return_thunk)) + WARN_ONCE(dest !=3D &__x86_return_thunk, + "missing return thunk: %pS-%pS: %*ph", + addr, dest, 5, addr)) continue; =20 DPRINTK("return thunk at: %pS (%px) len: %d to: %pS", From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99F9AC04A68 for ; Wed, 27 Jul 2022 17:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243108AbiG0Rqd (ORCPT ); Wed, 27 Jul 2022 13:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243084AbiG0Rpf (ORCPT ); Wed, 27 Jul 2022 13:45:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791298C3F5; Wed, 27 Jul 2022 09:53:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B158F61779; Wed, 27 Jul 2022 16:53:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0192C433C1; Wed, 27 Jul 2022 16:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940804; bh=5exRC9ZWkDq6oEH+b5CuSAr3y1/QIV6Vv3PMutqv/0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VlfXhHjd3agK4zNzoDUBhW+eDxP7zldRgecb+njEGvSbNWNtMZCpJIqrvqw5JIkYI lClGCoEyoBoiNk/BcCOM4U4fWp+l+ka+cTBsc/szzoU6aUh2OZbn8aQystrEx47qwi RdaZlR480hanacaD26hh+GcIBnhHtTncjJx2jPV4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Noam Rathaus , David Howells , Linus Torvalds Subject: [PATCH 5.18 154/158] watchqueue: make sure to serialize wqueue->defunct properly Date: Wed, 27 Jul 2022 18:13:38 +0200 Message-Id: <20220727161027.512532513@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Linus Torvalds commit 353f7988dd8413c47718f7ca79c030b6fb62cfe5 upstream. When the pipe is closed, we mark the associated watchqueue defunct by calling watch_queue_clear(). However, while that is protected by the watchqueue lock, new watchqueue entries aren't actually added under that lock at all: they use the pipe->rd_wait.lock instead, and looking up that pipe happens without any locking. The watchqueue code uses the RCU read-side section to make sure that the wqueue entry itself hasn't disappeared, but that does not protect the pipe_info in any way. So make sure to actually hold the wqueue lock when posting watch events, properly serializing against the pipe being torn down. Reported-by: Noam Rathaus Cc: Greg KH Cc: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- kernel/watch_queue.c | 53 +++++++++++++++++++++++++++++++++++-----------= ----- 1 file changed, 37 insertions(+), 16 deletions(-) --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -34,6 +34,27 @@ MODULE_LICENSE("GPL"); #define WATCH_QUEUE_NOTE_SIZE 128 #define WATCH_QUEUE_NOTES_PER_PAGE (PAGE_SIZE / WATCH_QUEUE_NOTE_SIZE) =20 +/* + * This must be called under the RCU read-lock, which makes + * sure that the wqueue still exists. It can then take the lock, + * and check that the wqueue hasn't been destroyed, which in + * turn makes sure that the notification pipe still exists. + */ +static inline bool lock_wqueue(struct watch_queue *wqueue) +{ + spin_lock_bh(&wqueue->lock); + if (unlikely(wqueue->defunct)) { + spin_unlock_bh(&wqueue->lock); + return false; + } + return true; +} + +static inline void unlock_wqueue(struct watch_queue *wqueue) +{ + spin_unlock_bh(&wqueue->lock); +} + static void watch_queue_pipe_buf_release(struct pipe_inode_info *pipe, struct pipe_buffer *buf) { @@ -69,6 +90,10 @@ static const struct pipe_buf_operations =20 /* * Post a notification to a watch queue. + * + * Must be called with the RCU lock for reading, and the + * watch_queue lock held, which guarantees that the pipe + * hasn't been released. */ static bool post_one_notification(struct watch_queue *wqueue, struct watch_notification *n) @@ -85,9 +110,6 @@ static bool post_one_notification(struct =20 spin_lock_irq(&pipe->rd_wait.lock); =20 - if (wqueue->defunct) - goto out; - mask =3D pipe->ring_size - 1; head =3D pipe->head; tail =3D pipe->tail; @@ -203,7 +225,10 @@ void __post_watch_notification(struct wa if (security_post_notification(watch->cred, cred, n) < 0) continue; =20 - post_one_notification(wqueue, n); + if (lock_wqueue(wqueue)) { + post_one_notification(wqueue, n); + unlock_wqueue(wqueue);; + } } =20 rcu_read_unlock(); @@ -462,11 +487,12 @@ int add_watch_to_object(struct watch *wa return -EAGAIN; } =20 - spin_lock_bh(&wqueue->lock); - kref_get(&wqueue->usage); - kref_get(&watch->usage); - hlist_add_head(&watch->queue_node, &wqueue->watches); - spin_unlock_bh(&wqueue->lock); + if (lock_wqueue(wqueue)) { + kref_get(&wqueue->usage); + kref_get(&watch->usage); + hlist_add_head(&watch->queue_node, &wqueue->watches); + unlock_wqueue(wqueue); + } =20 hlist_add_head(&watch->list_node, &wlist->watchers); return 0; @@ -520,20 +546,15 @@ found: =20 wqueue =3D rcu_dereference(watch->queue); =20 - /* We don't need the watch list lock for the next bit as RCU is - * protecting *wqueue from deallocation. - */ - if (wqueue) { + if (lock_wqueue(wqueue)) { post_one_notification(wqueue, &n.watch); =20 - spin_lock_bh(&wqueue->lock); - if (!hlist_unhashed(&watch->queue_node)) { hlist_del_init_rcu(&watch->queue_node); put_watch(watch); } =20 - spin_unlock_bh(&wqueue->lock); + unlock_wqueue(wqueue); } =20 if (wlist->release_watch) { From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8A38C04A68 for ; Wed, 27 Jul 2022 17:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243116AbiG0Rqg (ORCPT ); Wed, 27 Jul 2022 13:46:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243097AbiG0Rpm (ORCPT ); Wed, 27 Jul 2022 13:45:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 619348C3F3; Wed, 27 Jul 2022 09:53:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 26BA4B821B9; Wed, 27 Jul 2022 16:53:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76DD4C433D6; Wed, 27 Jul 2022 16:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940806; bh=8IAcbXVWHUwLLmGTrw55Bqlu6XMog/ZOQW9uxG73sIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/g36wBlPZUUt0vzvEUuuY4p6tHtM2hcSpnUXPNG19p7KO7CjFxwKBaO/zX7ziVAQ M6qyEXErAX8d1nWfbE7G5oI8k7V9sbrxSbPlT6y3o/FZGsSCXZvI+0wWmPAs+gjBoc LpGkBBpuOarA6Zd73cQU6TcCqwGmB3CTGGHXfxsg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Mark Brown Subject: [PATCH 5.18 155/158] ASoC: SOF: pm: add explicit behavior for ACPI S1 and S2 Date: Wed, 27 Jul 2022 18:13:39 +0200 Message-Id: <20220727161027.542365103@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart commit a933084558c61cac8c902d2474b39444d87fba46 upstream. The existing code only deals with S0 and S3, let's start adding S1 and S2. No functional change. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: P=C3=A9ter Ujfalusi Link: https://lore.kernel.org/r/20220616201818.130802-2-pierre-louis.bossar= t@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- sound/soc/sof/pm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -327,8 +327,18 @@ int snd_sof_prepare(struct device *dev) return 0; =20 #if defined(CONFIG_ACPI) - if (acpi_target_system_state() =3D=3D ACPI_STATE_S0) + switch (acpi_target_system_state()) { + case ACPI_STATE_S0: sdev->system_suspend_target =3D SOF_SUSPEND_S0IX; + break; + case ACPI_STATE_S1: + case ACPI_STATE_S2: + case ACPI_STATE_S3: + sdev->system_suspend_target =3D SOF_SUSPEND_S3; + break; + default: + break; + } #endif =20 return 0; From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48BC4C19F2B for ; Wed, 27 Jul 2022 17:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230019AbiG0RrM (ORCPT ); Wed, 27 Jul 2022 13:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243188AbiG0Rqe (ORCPT ); Wed, 27 Jul 2022 13:46:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BCEC8C775; Wed, 27 Jul 2022 09:53:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 27E20B821D7; Wed, 27 Jul 2022 16:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 507D5C433C1; Wed, 27 Jul 2022 16:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940809; bh=WsH6qdCjwRPejsJXtp/9b+oVzgQaxs/0Nr45MAGQSlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y7J0uVZ6/NQ1QdDkoyXUEvZwU2mbG+02ku+T0gv2NNf1VDv998CxY9unywUFuA7la PCCE4IHg6Q1oumZ9QoGzrQNBoLxoTISNvWqRG+kavUjUN4X5hywsPIIGIDZzJcsF21 OGEbcrsuhZxS4m6mYKyQlHDwN+EvANVOu7SvAPjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Mark Brown Subject: [PATCH 5.18 156/158] ASoC: SOF: pm: add definitions for S4 and S5 states Date: Wed, 27 Jul 2022 18:13:40 +0200 Message-Id: <20220727161027.581987180@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart commit 9d2d462713384538477703e68577b05131c7d97d upstream. We currently don't have a means to differentiate between S3, S4 and S5. Add definitions so that we have select different code paths depending on the target state in follow-up patches. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: P=C3=A9ter Ujfalusi Link: https://lore.kernel.org/r/20220616201818.130802-3-pierre-louis.bossar= t@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- sound/soc/sof/pm.c | 9 +++++++++ sound/soc/sof/sof-priv.h | 2 ++ 2 files changed, 11 insertions(+) --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -23,6 +23,9 @@ static u32 snd_sof_dsp_power_target(stru u32 target_dsp_state; =20 switch (sdev->system_suspend_target) { + case SOF_SUSPEND_S5: + case SOF_SUSPEND_S4: + /* DSP should be in D3 if the system is suspending to S3+ */ case SOF_SUSPEND_S3: /* DSP should be in D3 if the system is suspending to S3 */ target_dsp_state =3D SOF_DSP_PM_D3; @@ -336,6 +339,12 @@ int snd_sof_prepare(struct device *dev) case ACPI_STATE_S3: sdev->system_suspend_target =3D SOF_SUSPEND_S3; break; + case ACPI_STATE_S4: + sdev->system_suspend_target =3D SOF_SUSPEND_S4; + break; + case ACPI_STATE_S5: + sdev->system_suspend_target =3D SOF_SUSPEND_S5; + break; default: break; } --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -85,6 +85,8 @@ enum sof_system_suspend_state { SOF_SUSPEND_NONE =3D 0, SOF_SUSPEND_S0IX, SOF_SUSPEND_S3, + SOF_SUSPEND_S4, + SOF_SUSPEND_S5, }; =20 enum sof_dfsentry_type { From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14C6BC04A68 for ; Wed, 27 Jul 2022 17:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243157AbiG0Rqj (ORCPT ); Wed, 27 Jul 2022 13:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243137AbiG0Rp5 (ORCPT ); Wed, 27 Jul 2022 13:45:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CB648C591; Wed, 27 Jul 2022 09:53:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3B82961748; Wed, 27 Jul 2022 16:53:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 426F8C433C1; Wed, 27 Jul 2022 16:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940812; bh=bOoIJVJe4A9m72RfC667rC++3yP4biKNPinGYjYRcU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UdomxCRrc12C56RU19NePhPIKE+iO0PjDUMJ6mZAxkHwvHn9sZuHR5/J7lt1ICjJR Wd+vhYeQGL3A7fMVeW1kByKhV2jdzYyJrYXBDz1Pw3sUD9sHJe0oXHSScPXcmABFxw VOBytlPLWoGDBLN6n5zvVs65817Mlkz9Y0m5DzrA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , =?UTF-8?q?P=C3=A9ter=20Ujfalusi?= , Mark Brown Subject: [PATCH 5.18 157/158] ASoC: SOF: Intel: disable IMR boot when resuming from ACPI S4 and S5 states Date: Wed, 27 Jul 2022 18:13:41 +0200 Message-Id: <20220727161027.624641879@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart commit 391153522d186f19a008d824bb3a05950351ce6c upstream. The IMR was assumed to be preserved when suspending to S4 and S5 states, but community reports invalidate that assumption, the hardware seems to be powered off and the IMR memory content cleared. Make sure regular boot with firmware download is used for S4 and S5. BugLink: https://github.com/thesofproject/sof/issues/5892 Fixes: 5fb5f51185126 ("ASoC: SOF: Intel: hda-loader: add IMR restore suppor= t") Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: P=C3=A9ter Ujfalusi Link: https://lore.kernel.org/r/20220616201818.130802-4-pierre-louis.bossar= t@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- sound/soc/sof/intel/hda-loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/soc/sof/intel/hda-loader.c +++ b/sound/soc/sof/intel/hda-loader.c @@ -397,7 +397,8 @@ int hda_dsp_cl_boot_firmware(struct snd_ struct firmware stripped_firmware; int ret, ret1, i; =20 - if ((sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT) && + if ((sdev->system_suspend_target < SOF_SUSPEND_S4) && + (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT) && !(sof_debug_check_flag(SOF_DBG_IGNORE_D3_PERSISTENT)) && !sdev->first_boot) { dev_dbg(sdev->dev, "IMR restore supported, booting from IMR directly\n"); From nobody Wed Apr 15 02:54:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CABA3C19F2B for ; Wed, 27 Jul 2022 17:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238614AbiG0Rqs (ORCPT ); Wed, 27 Jul 2022 13:46:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242844AbiG0RqP (ORCPT ); Wed, 27 Jul 2022 13:46:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E158C59D; Wed, 27 Jul 2022 09:53:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AB58BB8200D; Wed, 27 Jul 2022 16:53:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0043CC433C1; Wed, 27 Jul 2022 16:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658940815; bh=Fu+RQZP2lBIVjrGU4m9Qhg1VGiP+0En1tD5IuKWsy6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GpzrzVwcUmn+29pAW3Y9wslbA8nZg+rvMj5ASp8V4zUzH9IJSNaZ881IlPHl/L4CO dM/UFVxP30bRJhB96gXY2vFBNtGbZ93d+mTUQ6f3kBC0nHj3E1JWGTCLE/UpXNu30O 1vnFcRFhC2HWOp+kRgmS36cGHF1YyyafMiJp5uDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sedat Dilek , Linus Torvalds Subject: [PATCH 5.18 158/158] watch-queue: remove spurious double semicolon Date: Wed, 27 Jul 2022 18:13:42 +0200 Message-Id: <20220727161027.658313194@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161021.428340041@linuxfoundation.org> References: <20220727161021.428340041@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Linus Torvalds commit 44e29e64cf1ac0cffb152e0532227ea6d002aa28 upstream. Sedat Dilek noticed that I had an extraneous semicolon at the end of a line in the previous patch. It's harmless, but unintentional, and while compilers just treat it as an extra empty statement, for all I know some other tooling might warn about it. So clean it up before other people notice too ;) Fixes: 353f7988dd84 ("watchqueue: make sure to serialize 'wqueue->defunct' = properly") Reported-by: Sedat Dilek Signed-off-by: Linus Torvalds Reported-by: Sedat Dilek Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Jiri Slaby Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- kernel/watch_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -227,7 +227,7 @@ void __post_watch_notification(struct wa =20 if (lock_wqueue(wqueue)) { post_one_notification(wqueue, n); - unlock_wqueue(wqueue);; + unlock_wqueue(wqueue); } }