From nobody Thu May 14 08:08:21 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 ECEEFC41535 for ; Tue, 12 Apr 2022 08:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348612AbiDLIQj (ORCPT ); Tue, 12 Apr 2022 04:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355283AbiDLH1X (ORCPT ); Tue, 12 Apr 2022 03:27:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C075A48E6F; Tue, 12 Apr 2022 00:07: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 14E28B81B50; Tue, 12 Apr 2022 07:07:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80AD0C385A8; Tue, 12 Apr 2022 07:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747241; bh=MaMuRVLYeWJvIEXFBlSue+ZzZeLHC/BTw0ChrLm0IUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CBdrUYH3cZvZLLcgr0TQNDTy9Gd3cb8pTi0Tqx2AgJoAZYizw0h1BMat4ydfEjsmV Aya1Y1RKYvFtOiCFNqG7vO1lriBOTkLRtxDnbIK/zW6MsFNRQKGr6WPmwpLwDNyFYl 8PRoR0CrAZPhWpgy2l256t1YF8Cw0K3u/prZicB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Bulwahn , Johannes Berg , Richard Weinberger , Sasha Levin Subject: [PATCH 5.17 001/343] lib/logic_iomem: correct fallback config references Date: Tue, 12 Apr 2022 08:26:59 +0200 Message-Id: <20220412062951.141994326@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Johannes Berg [ Upstream commit 2a6852cb8ff0c8c1363cac648d68489343813212 ] Due to some renaming, we ended up with the "indirect iomem" naming in Kconfig, following INDIRECT_PIO. However, clearly I missed following through on that in the ifdefs, but so far INDIRECT_IOMEM_FALLBACK isn't used by any architecture. Reported-by: Lukas Bulwahn Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)") Signed-off-by: Johannes Berg Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- lib/logic_iomem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c index 8c3365f26e51..b247d412ddef 100644 --- a/lib/logic_iomem.c +++ b/lib/logic_iomem.c @@ -68,7 +68,7 @@ int logic_iomem_add_region(struct resource *resource, } EXPORT_SYMBOL(logic_iomem_add_region); =20 -#ifndef CONFIG_LOGIC_IOMEM_FALLBACK +#ifndef CONFIG_INDIRECT_IOMEM_FALLBACK static void __iomem *real_ioremap(phys_addr_t offset, size_t size) { WARN(1, "invalid ioremap(0x%llx, 0x%zx)\n", @@ -81,7 +81,7 @@ static void real_iounmap(volatile void __iomem *addr) WARN(1, "invalid iounmap for addr 0x%llx\n", (unsigned long long)(uintptr_t __force)addr); } -#endif /* CONFIG_LOGIC_IOMEM_FALLBACK */ +#endif /* CONFIG_INDIRECT_IOMEM_FALLBACK */ =20 void __iomem *ioremap(phys_addr_t offset, size_t size) { @@ -168,7 +168,7 @@ void iounmap(volatile void __iomem *addr) } EXPORT_SYMBOL(iounmap); =20 -#ifndef CONFIG_LOGIC_IOMEM_FALLBACK +#ifndef CONFIG_INDIRECT_IOMEM_FALLBACK #define MAKE_FALLBACK(op, sz) \ static u##sz real_raw_read ## op(const volatile void __iomem *addr) \ { \ @@ -213,7 +213,7 @@ static void real_memcpy_toio(volatile void __iomem *add= r, const void *buffer, WARN(1, "Invalid memcpy_toio at address 0x%llx\n", (unsigned long long)(uintptr_t __force)addr); } -#endif /* CONFIG_LOGIC_IOMEM_FALLBACK */ +#endif /* CONFIG_INDIRECT_IOMEM_FALLBACK */ =20 #define MAKE_OP(op, sz) \ u##sz __raw_read ## op(const volatile void __iomem *addr) \ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7987FC35296 for ; Tue, 12 Apr 2022 08:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355756AbiDLIIv (ORCPT ); Tue, 12 Apr 2022 04:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355524AbiDLH1k (ORCPT ); Tue, 12 Apr 2022 03:27:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8F704EA39; Tue, 12 Apr 2022 00:07: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 dfw.source.kernel.org (Postfix) with ESMTPS id 73071616A9; Tue, 12 Apr 2022 07:07:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EA40C385A1; Tue, 12 Apr 2022 07:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747266; bh=LAxfqD32x6ZFr0TQ72MXLdGPukvlyZn5mmFfZ5YXYLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=04DJ7WyPfh0MQ9zadbxYynNpJ+5N3dkN9aFkRk9pA/ofbcZt6bp/1N2AWuQDqtxLo Cx1p8WUjBmlw6l4tIbhDAZv7iKBWXufil65SwBY4mbk657yNN5UCciJE8eJi+q2JDo kFxHr6wDyoiqumxNP4CnZll+lztUeA66wmqx59f8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Beichler , Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 5.17 002/343] um: fix and optimize xor select template for CONFIG64 and timetravel mode Date: Tue, 12 Apr 2022 08:27:00 +0200 Message-Id: <20220412062951.172858976@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Benjamin Beichler [ Upstream commit e3a33af812c611d99756e2ec61e9d7068d466bdf ] Due to dropped inclusion of asm-generic/xor.h, xor_block_8regs symbol is missing with CONFIG64 and break compilation, as the asm/xor_64.h also did not include it. The patch recreate the logic from arch/x86, which check whether AVX is available and add fallbacks for 32bit and 64bit config of um. A very minor additional "fix" is, the return of the macro parameter instead of NULL, as this is the original intent of the macro, but this does not change the actual behavior. Fixes: c0ecca6604b8 ("um: enable the use of optimized xor routines in UML") Signed-off-by: Benjamin Beichler Acked-By: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/um/include/asm/xor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/um/include/asm/xor.h b/arch/um/include/asm/xor.h index f512704a9ec7..22b39de73c24 100644 --- a/arch/um/include/asm/xor.h +++ b/arch/um/include/asm/xor.h @@ -4,8 +4,10 @@ =20 #ifdef CONFIG_64BIT #undef CONFIG_X86_32 +#define TT_CPU_INF_XOR_DEFAULT (AVX_SELECT(&xor_block_sse_pf64)) #else #define CONFIG_X86_32 1 +#define TT_CPU_INF_XOR_DEFAULT (AVX_SELECT(&xor_block_8regs)) #endif =20 #include @@ -16,7 +18,7 @@ #undef XOR_SELECT_TEMPLATE /* pick an arbitrary one - measuring isn't possible with inf-cpu */ #define XOR_SELECT_TEMPLATE(x) \ - (time_travel_mode =3D=3D TT_MODE_INFCPU ? &xor_block_8regs : NULL) + (time_travel_mode =3D=3D TT_MODE_INFCPU ? TT_CPU_INF_XOR_DEFAULT : x)) #endif =20 #endif --=20 2.35.1 From nobody Thu May 14 08:08:21 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 8E806C47084 for ; Tue, 12 Apr 2022 08:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355790AbiDLIIz (ORCPT ); Tue, 12 Apr 2022 04:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355586AbiDLH1p (ORCPT ); Tue, 12 Apr 2022 03:27:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BF34ECEA; Tue, 12 Apr 2022 00:07: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 dfw.source.kernel.org (Postfix) with ESMTPS id 25446616B9; Tue, 12 Apr 2022 07:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A081C385A6; Tue, 12 Apr 2022 07:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747269; bh=t0g3o+vjO6oyTmJLg+UH2gahFuYs6k7jNgBfmjGR/W4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bUGHfTCzqHhyzMFI9keWJqlUAHTn+lNt6y+GwYwYvFgmvJ4i6aQNOcCmBEu3jCXSl pUpDFb0zrgg5tM14LI6LTQb74b2eMqrIHtGx3hk1WtJYABtdsokmhDhxlUKHNbm+Rk SjUT6TmrS1qa1PlQysht4ldzFrntDzykHGC7b4zE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Charles Keepax , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.17 003/343] rtc: wm8350: Handle error for wm8350_register_irq Date: Tue, 12 Apr 2022 08:27:01 +0200 Message-Id: <20220412062951.199859086@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jiasheng Jiang [ Upstream commit 43f0269b6b89c1eec4ef83c48035608f4dcdd886 ] As the potential failure of the wm8350_register_irq(), it should be better to check it and return error if fails. Also, it need not free 'wm_rtc->rtc' since it will be freed automatically. Fixes: 077eaf5b40ec ("rtc: rtc-wm8350: add support for WM8350 RTC") Signed-off-by: Jiasheng Jiang Acked-by: Charles Keepax Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220303085030.291793-1-jiasheng@iscas.ac.cn Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/rtc/rtc-wm8350.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index 2018614f258f..6eaa9321c074 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c @@ -432,14 +432,21 @@ static int wm8350_rtc_probe(struct platform_device *p= dev) return ret; } =20 - wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC, + ret =3D wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC, wm8350_rtc_update_handler, 0, "RTC Seconds", wm8350); + if (ret) + return ret; + wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); =20 - wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM, + ret =3D wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM, wm8350_rtc_alarm_handler, 0, "RTC Alarm", wm8350); + if (ret) { + wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC, wm8350); + return ret; + } =20 return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 628A4C4707A for ; Tue, 12 Apr 2022 08:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378729AbiDLIMr (ORCPT ); Tue, 12 Apr 2022 04:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355654AbiDLH1w (ORCPT ); Tue, 12 Apr 2022 03:27:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A970E4EDE0; Tue, 12 Apr 2022 00:07: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 CAA70B81B54; Tue, 12 Apr 2022 07:07:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B69EC385A8; Tue, 12 Apr 2022 07:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747272; bh=GKounZqJS96t0E4wQdvhNBG6ZpQrjW2xlU2vl6Bc/jc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XG+ZwYWlmP+1S2M1aw2PYOvLDhl6NZuFYLDj+VXMGQsx1knlXo3/8LaUHjnG8VRJ+ 50Wxg+lhdHSrkNKmHzkOgP8U1Qk318ZRCNJ1wOFMS0hofzzFRe0GqvFexiXBzs0JHy mG8p0Q0Bgg2pGYAEazUYsPsrJ9EPjKxiMBWd3gOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheng Yongjun , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 004/343] net: dsa: felix: fix possible NULL pointer dereference Date: Tue, 12 Apr 2022 08:27:02 +0200 Message-Id: <20220412062951.228586224@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Zheng Yongjun [ Upstream commit 866b7a278cdb51eb158cd8513bc7438fc857804a ] As the possible failure of the allocation, kzalloc() may return NULL pointer. Therefore, it should be better to check the 'sgi' in order to prevent the dereference of NULL pointer. Fixes: 23ae3a7877718 ("net: dsa: felix: add stream gate settings for psfp"). Signed-off-by: Zheng Yongjun Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220329090800.130106-1-zhengyongjun3@huawe= i.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelo= t/felix_vsc9959.c index 33f0ceae381d..2875b5250856 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1940,6 +1940,10 @@ static int vsc9959_psfp_filter_add(struct ocelot *oc= elot, int port, case FLOW_ACTION_GATE: size =3D struct_size(sgi, entries, a->gate.num_entries); sgi =3D kzalloc(size, GFP_KERNEL); + if (!sgi) { + ret =3D -ENOMEM; + goto err; + } vsc9959_psfp_parse_gate(a, sgi); ret =3D vsc9959_psfp_sgi_table_add(ocelot, sgi); if (ret) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9A007C47080 for ; Tue, 12 Apr 2022 08:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378786AbiDLINK (ORCPT ); Tue, 12 Apr 2022 04:13:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351770AbiDLH14 (ORCPT ); Tue, 12 Apr 2022 03:27:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9556A4EDF2; Tue, 12 Apr 2022 00:08: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 9E582B81B4E; Tue, 12 Apr 2022 07:07:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2A56C385A1; Tue, 12 Apr 2022 07:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747275; bh=HPAQBXuqTfOzc6IvGtBWcF+pFVDLWJ32autnf6dHJeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxZERUlxojdDtdtxtbvjQQ/EEZWgLqRpYDY3RRzVNxpiQwTK/cOlPaRYw5BFV/0Tf kYVdopPtK8OQhyBehBITfOdMfcB9T57kByC1YP7uMzWD4MnSnz2T1SaAKnd1j1pUff 9jNsl0HTvOfNw/8md7+vC0gwkH5imvcQp1AiqwY0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muchun Song , Marco Elver , Roman Gushchin , Alexander Potapenko , Dmitry Vyukov , Xiongchun Duan , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.17 005/343] mm: kfence: fix objcgs vector allocation Date: Tue, 12 Apr 2022 08:27:03 +0200 Message-Id: <20220412062951.256840405@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Muchun Song [ Upstream commit 8f0b36497303487d5a32c75789c77859cc2ee895 ] If the kfence object is allocated to be used for objects vector, then this slot of the pool eventually being occupied permanently since the vector is never freed. The solutions could be (1) freeing vector when the kfence object is freed or (2) allocating all vectors statically. Since the memory consumption of object vectors is low, it is better to chose (2) to fix the issue and it is also can reduce overhead of vectors allocating in the future. Link: https://lkml.kernel.org/r/20220328132843.16624-1-songmuchun@bytedance= .com Fixes: d3fb45f370d9 ("mm, kfence: insert KFENCE hooks for SLAB") Signed-off-by: Muchun Song Reviewed-by: Marco Elver Reviewed-by: Roman Gushchin Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: Xiongchun Duan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- mm/kfence/core.c | 11 ++++++++++- mm/kfence/kfence.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 13128fa13062..d4c7978cd75e 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -555,6 +555,8 @@ static bool __init kfence_init_pool(void) * enters __slab_free() slow-path. */ for (i =3D 0; i < KFENCE_POOL_SIZE / PAGE_SIZE; i++) { + struct slab *slab =3D page_slab(&pages[i]); + if (!i || (i % 2)) continue; =20 @@ -562,7 +564,11 @@ static bool __init kfence_init_pool(void) if (WARN_ON(compound_head(&pages[i]) !=3D &pages[i])) goto err; =20 - __SetPageSlab(&pages[i]); + __folio_set_slab(slab_folio(slab)); +#ifdef CONFIG_MEMCG + slab->memcg_data =3D (unsigned long)&kfence_metadata[i / 2 - 1].objcg | + MEMCG_DATA_OBJCGS; +#endif } =20 /* @@ -938,6 +944,9 @@ void __kfence_free(void *addr) { struct kfence_metadata *meta =3D addr_to_metadata((unsigned long)addr); =20 +#ifdef CONFIG_MEMCG + KFENCE_WARN_ON(meta->objcg); +#endif /* * If the objects of the cache are SLAB_TYPESAFE_BY_RCU, defer freeing * the object, as the object page may be recycled for other-typed diff --git a/mm/kfence/kfence.h b/mm/kfence/kfence.h index 2a2d5de9d379..9a6c4b1b12a8 100644 --- a/mm/kfence/kfence.h +++ b/mm/kfence/kfence.h @@ -89,6 +89,9 @@ struct kfence_metadata { struct kfence_track free_track; /* For updating alloc_covered on frees. */ u32 alloc_stack_hash; +#ifdef CONFIG_MEMCG + struct obj_cgroup *objcg; +#endif }; =20 extern struct kfence_metadata kfence_metadata[CONFIG_KFENCE_NUM_OBJECTS]; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 85859C47092 for ; Tue, 12 Apr 2022 08:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378744AbiDLINC (ORCPT ); Tue, 12 Apr 2022 04:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355657AbiDLH1w (ORCPT ); Tue, 12 Apr 2022 03:27: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 061494EDE3; Tue, 12 Apr 2022 00:07: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 dfw.source.kernel.org (Postfix) with ESMTPS id A9D61616B2; Tue, 12 Apr 2022 07:07:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AECFCC385A1; Tue, 12 Apr 2022 07:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747278; bh=Izilb6B/7THa28ox0iEsc8os9I9I2KEyl0YBu3Tqam0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIqqSlxcUwhcIuZpQ6fgToA/RU77+hWgn5DIgiRz4H58g8gHNq8S+ZzCKJK+iNskh khU2/0Iu/nqi7iSpBgLzJG3gxQ9OTRiJWqhZ5oHVkY+PI43uDRWGw+Ur88ayOWemgq ZYAHBHHxdvuEc1dmWRBTVlvoZ5HC3bhAQdOV5Ibk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.17 006/343] KVM: x86/pmu: Use different raw event masks for AMD and Intel Date: Tue, 12 Apr 2022 08:27:04 +0200 Message-Id: <20220412062951.286087957@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jim Mattson [ Upstream commit 95b065bf5c431c06c68056a03a5853b660640ecc ] The third nybble of AMD's event select overlaps with Intel's IN_TX and IN_TXCP bits. Therefore, we can't use AMD64_RAW_EVENT_MASK on Intel platforms that support TSX. Declare a raw_event_mask in the kvm_pmu structure, initialize it in the vendor-specific pmu_refresh() functions, and use that mask for PERF_TYPE_RAW configurations in reprogram_gp_counter(). Fixes: 710c47651431 ("KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_= RAW") Signed-off-by: Jim Mattson Message-Id: <20220308012452.3468611-1-jmattson@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/pmu.c | 3 ++- arch/x86/kvm/svm/pmu.c | 1 + arch/x86/kvm/vmx/pmu_intel.c | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index ec9830d2aabf..17b4e1808b8e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -509,6 +509,7 @@ struct kvm_pmu { u64 global_ctrl_mask; u64 global_ovf_ctrl_mask; u64 reserved_bits; + u64 raw_event_mask; u8 version; struct kvm_pmc gp_counters[INTEL_PMC_MAX_GENERIC]; struct kvm_pmc fixed_counters[INTEL_PMC_MAX_FIXED]; diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index b1a02993782b..902b6d700215 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -185,6 +185,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 even= tsel) u32 type =3D PERF_TYPE_RAW; struct kvm *kvm =3D pmc->vcpu->kvm; struct kvm_pmu_event_filter *filter; + struct kvm_pmu *pmu =3D vcpu_to_pmu(pmc->vcpu); bool allow_event =3D true; =20 if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL) @@ -221,7 +222,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 even= tsel) } =20 if (type =3D=3D PERF_TYPE_RAW) - config =3D eventsel & AMD64_RAW_EVENT_MASK; + config =3D eventsel & pmu->raw_event_mask; =20 if (pmc->current_config =3D=3D eventsel && pmc_resume_counter(pmc)) return; diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c index 5aa45f13b16d..7cc664b4472a 100644 --- a/arch/x86/kvm/svm/pmu.c +++ b/arch/x86/kvm/svm/pmu.c @@ -284,6 +284,7 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu) =20 pmu->counter_bitmask[KVM_PMC_GP] =3D ((u64)1 << 48) - 1; pmu->reserved_bits =3D 0xfffffff000280000ull; + pmu->raw_event_mask =3D AMD64_RAW_EVENT_MASK; pmu->version =3D 1; /* not applicable to AMD; but clean them to prevent any fall out */ pmu->counter_bitmask[KVM_PMC_FIXED] =3D 0; diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 466d18fc0c5d..8ba12294a7c5 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -485,6 +485,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) pmu->counter_bitmask[KVM_PMC_FIXED] =3D 0; pmu->version =3D 0; pmu->reserved_bits =3D 0xffffffff00200000ull; + pmu->raw_event_mask =3D X86_RAW_EVENT_MASK; =20 entry =3D kvm_find_cpuid_entry(vcpu, 0xa, 0); if (!entry || !enable_pmu) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B64EEC4321E for ; Tue, 12 Apr 2022 08:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243281AbiDLIRW (ORCPT ); Tue, 12 Apr 2022 04:17:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351575AbiDLH2L (ORCPT ); Tue, 12 Apr 2022 03:28:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 283C84EF6E; Tue, 12 Apr 2022 00:08: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 ams.source.kernel.org (Postfix) with ESMTPS id 31F14B81B57; Tue, 12 Apr 2022 07:08:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96246C385A1; Tue, 12 Apr 2022 07:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747281; bh=0N2yIwdSXee9F6hKtUsnEzk1Wpq6MQKPHa6BD8iYw5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UaQP3jMSNrpHjWB4YIevRhsfrc74Hy4xzCyh+MpIoqHl9uj+GRfJghFHgJKL6kRS6 x0h57lW8a5Xa9jCZf5NVP5i8aZuSqG/rlY3iNZyBGuehD5x9Yl4KFfN1YDTxhq2jjH KK4+8Cd3eBsa8+TjOSDv5iBNfBK+E8vLySqBMAWI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , Sean Christopherson , kvm@vger.kernel.org, Peter Gonda , Sasha Levin Subject: [PATCH 5.17 007/343] KVM: SVM: Fix kvm_cache_regs.h inclusions for is_guest_mode() Date: Tue, 12 Apr 2022 08:27:05 +0200 Message-Id: <20220412062951.315041793@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Gonda [ Upstream commit 4a9e7b9ea252842bc8b14d495706ac6317fafd5d ] Include kvm_cache_regs.h to pick up the definition of is_guest_mode(), which is referenced by nested_svm_virtualize_tpr() in svm.h. Remove include from svm_onhpyerv.c which was done only because of lack of include in svm.h. Fixes: 883b0a91f41ab ("KVM: SVM: Move Nested SVM Implementation to nested.c= ") Cc: Paolo Bonzini Cc: Sean Christopherson Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Peter Gonda Message-Id: <20220304161032.2270688-1-pgonda@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/kvm/svm/svm.h | 2 ++ arch/x86/kvm/svm/svm_onhyperv.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index fa98d6844728..86bcfed6599e 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -22,6 +22,8 @@ #include #include =20 +#include "kvm_cache_regs.h" + #define __sme_page_pa(x) __sme_set(page_to_pfn(x) << PAGE_SHIFT) =20 #define IOPM_SIZE PAGE_SIZE * 3 diff --git a/arch/x86/kvm/svm/svm_onhyperv.c b/arch/x86/kvm/svm/svm_onhyper= v.c index 98aa981c04ec..8cdc62c74a96 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.c +++ b/arch/x86/kvm/svm/svm_onhyperv.c @@ -4,7 +4,6 @@ */ =20 #include -#include "kvm_cache_regs.h" =20 #include =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 63C24C3525B for ; Tue, 12 Apr 2022 08:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356861AbiDLIQ6 (ORCPT ); Tue, 12 Apr 2022 04:16:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351733AbiDLH2O (ORCPT ); Tue, 12 Apr 2022 03:28:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 549DB4F441; Tue, 12 Apr 2022 00:08: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 1264FB81B4F; Tue, 12 Apr 2022 07:08:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7203FC385AA; Tue, 12 Apr 2022 07:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747283; bh=ZwVlB8Plku3sRdnB7LcIRszBYxi8dkTfTjHNj36+0GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3F6kKPEMbHd14vFAj1Lm3ltPH03qMXQcl9CeAEbDa7fid9XNym7YmR2adlmq9VvY FGVryiAUVJbeRxXK06U0Eo727RVgL7ict7Aq7KZAJ9mDD9vWOlRpSNT1FjKpkEJrut e0ji9Hl2wQUKv3NVbUgujBHcyTKBS2LhBQFAR19E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lotus Fenn , Jim Mattson , Like Xu , David Dunn , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.17 008/343] KVM: x86/svm: Clear reserved bits written to PerfEvtSeln MSRs Date: Tue, 12 Apr 2022 08:27:06 +0200 Message-Id: <20220412062951.343821780@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jim Mattson [ Upstream commit 9b026073db2f1ad0e4d8b61c83316c8497981037 ] AMD EPYC CPUs never raise a #GP for a WRMSR to a PerfEvtSeln MSR. Some reserved bits are cleared, and some are not. Specifically, on Zen3/Milan, bits 19 and 42 are not cleared. When emulating such a WRMSR, KVM should not synthesize a #GP, regardless of which bits are set. However, undocumented bits should not be passed through to the hardware MSR. So, rather than checking for reserved bits and synthesizing a #GP, just clear the reserved bits. This may seem pedantic, but since KVM currently does not support the "Host/Guest Only" bits (41:40), it is necessary to clear these bits rather than synthesizing #GP, because some popular guests (e.g Linux) will set the "Host Only" bit even on CPUs that don't support EFER.SVME, and they don't expect a #GP. For example, root@Ubuntu1804:~# perf stat -e r26 -a sleep 1 Performance counter stats for 'system wide': 0 r26 1.001070977 seconds time elapsed Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379957] unchecked MSR access erro= r: WRMSR to 0xc0010200 (tried to write 0x0000020000130026) at rIP: 0xffffff= ff9b276a28 (native_write_msr+0x8/0x30) Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379958] Call Trace: Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379963] amd_pmu_disable_event+0x= 27/0x90 Fixes: ca724305a2b0 ("KVM: x86/vPMU: Implement AMD vPMU code for KVM") Reported-by: Lotus Fenn Signed-off-by: Jim Mattson Reviewed-by: Like Xu Reviewed-by: David Dunn Message-Id: <20220226234131.2167175-1-jmattson@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/kvm/svm/pmu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c index 7cc664b4472a..ba40b7fced5a 100644 --- a/arch/x86/kvm/svm/pmu.c +++ b/arch/x86/kvm/svm/pmu.c @@ -262,12 +262,10 @@ static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, str= uct msr_data *msr_info) /* MSR_EVNTSELn */ pmc =3D get_gp_pmc_amd(pmu, msr, PMU_TYPE_EVNTSEL); if (pmc) { - if (data =3D=3D pmc->eventsel) - return 0; - if (!(data & pmu->reserved_bits)) { + data &=3D ~pmu->reserved_bits; + if (data !=3D pmc->eventsel) reprogram_gp_counter(pmc, data); - return 0; - } + return 0; } =20 return 1; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 3A00FC46467 for ; Tue, 12 Apr 2022 08:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245485AbiDLIRQ (ORCPT ); Tue, 12 Apr 2022 04:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352344AbiDLH2d (ORCPT ); Tue, 12 Apr 2022 03:28:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 189674F452; Tue, 12 Apr 2022 00:08:10 -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 B3740B81B50; Tue, 12 Apr 2022 07:08:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CB5DC385A6; Tue, 12 Apr 2022 07:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747286; bh=2QzFLpKuDfKD58gEd49LRz6JCO86eIm3Yu/3IGO+lDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYc3/AHNnYNW7dDTYK71cURAqdz+cAVDghi4qsac88+vjciEtTKLR8/qPesMyDEsn yismtYqYsY742C2KD3TKK/E3IFspvozc5Y2AU3YO+8FdxO4EvmKbkuBFPZA9/z45T9 VFBD6HYG+ZIr8gTZm9yNdFv70PEnr2Wuj7FkbTQY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ravi Bangoria , Jim Mattson , Like Xu , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.17 009/343] KVM: x86/pmu: Fix and isolate TSX-specific performance event logic Date: Tue, 12 Apr 2022 08:27:07 +0200 Message-Id: <20220412062951.373345079@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Like Xu [ Upstream commit e644896f5106aa3f6d7e8c7adf2e4dc0fce53555 ] HSW_IN_TX* bits are used in generic code which are not supported on AMD. Worse, these bits overlap with AMD EventSelect[11:8] and hence using HSW_IN_TX* bits unconditionally in generic code is resulting in unintentional pmu behavior on AMD. For example, if EventSelect[11:8] is 0x2, pmc_reprogram_counter() wrongly assumes that HSW_IN_TX_CHECKPOINTED is set and thus forces sampling period to be 0. Also per the SDM, both bits 32 and 33 "may only be set if the processor supports HLE or RTM" and for "IN_TXCP (bit 33): this bit may only be set for IA32_PERFEVTSEL2." Opportunistically eliminate code redundancy, because if the HSW_IN_TX* bit is set in pmc->eventsel, it is already set in attr.config. Reported-by: Ravi Bangoria Reported-by: Jim Mattson Fixes: 103af0a98788 ("perf, kvm: Support the in_tx/in_tx_cp modifiers in KV= M arch perfmon emulation v5") Co-developed-by: Ravi Bangoria Signed-off-by: Ravi Bangoria Signed-off-by: Like Xu Message-Id: <20220309084257.88931-1-likexu@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/kvm/pmu.c | 15 +++++---------- arch/x86/kvm/vmx/pmu_intel.c | 13 ++++++++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index 902b6d700215..eca39f56c231 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -96,8 +96,7 @@ static void kvm_perf_overflow(struct perf_event *perf_eve= nt, =20 static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, u64 config, bool exclude_user, - bool exclude_kernel, bool intr, - bool in_tx, bool in_tx_cp) + bool exclude_kernel, bool intr) { struct perf_event *event; struct perf_event_attr attr =3D { @@ -116,16 +115,14 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc= , u32 type, =20 attr.sample_period =3D get_sample_period(pmc, pmc->counter); =20 - if (in_tx) - attr.config |=3D HSW_IN_TX; - if (in_tx_cp) { + if ((attr.config & HSW_IN_TX_CHECKPOINTED) && + guest_cpuid_is_intel(pmc->vcpu)) { /* * HSW_IN_TX_CHECKPOINTED is not supported with nonzero * period. Just clear the sample period so at least * allocating the counter doesn't fail. */ attr.sample_period =3D 0; - attr.config |=3D HSW_IN_TX_CHECKPOINTED; } =20 event =3D perf_event_create_kernel_counter(&attr, -1, current, @@ -233,9 +230,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 even= tsel) pmc_reprogram_counter(pmc, type, config, !(eventsel & ARCH_PERFMON_EVENTSEL_USR), !(eventsel & ARCH_PERFMON_EVENTSEL_OS), - eventsel & ARCH_PERFMON_EVENTSEL_INT, - (eventsel & HSW_IN_TX), - (eventsel & HSW_IN_TX_CHECKPOINTED)); + eventsel & ARCH_PERFMON_EVENTSEL_INT); } EXPORT_SYMBOL_GPL(reprogram_gp_counter); =20 @@ -271,7 +266,7 @@ void reprogram_fixed_counter(struct kvm_pmc *pmc, u8 ct= rl, int idx) kvm_x86_ops.pmu_ops->pmc_perf_hw_id(pmc), !(en_field & 0x2), /* exclude user */ !(en_field & 0x1), /* exclude kernel */ - pmi, false, false); + pmi); } EXPORT_SYMBOL_GPL(reprogram_fixed_counter); =20 diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 8ba12294a7c5..5fa3870b8988 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -389,6 +389,7 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, str= uct msr_data *msr_info) struct kvm_pmc *pmc; u32 msr =3D msr_info->index; u64 data =3D msr_info->data; + u64 reserved_bits; =20 switch (msr) { case MSR_CORE_PERF_FIXED_CTR_CTRL: @@ -443,7 +444,11 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, st= ruct msr_data *msr_info) } else if ((pmc =3D get_gp_pmc(pmu, msr, MSR_P6_EVNTSEL0))) { if (data =3D=3D pmc->eventsel) return 0; - if (!(data & pmu->reserved_bits)) { + reserved_bits =3D pmu->reserved_bits; + if ((pmc->idx =3D=3D 2) && + (pmu->raw_event_mask & HSW_IN_TX_CHECKPOINTED)) + reserved_bits ^=3D HSW_IN_TX_CHECKPOINTED; + if (!(data & reserved_bits)) { reprogram_gp_counter(pmc, data); return 0; } @@ -534,8 +539,10 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) entry =3D kvm_find_cpuid_entry(vcpu, 7, 0); if (entry && (boot_cpu_has(X86_FEATURE_HLE) || boot_cpu_has(X86_FEATURE_RTM)) && - (entry->ebx & (X86_FEATURE_HLE|X86_FEATURE_RTM))) - pmu->reserved_bits ^=3D HSW_IN_TX|HSW_IN_TX_CHECKPOINTED; + (entry->ebx & (X86_FEATURE_HLE|X86_FEATURE_RTM))) { + pmu->reserved_bits ^=3D HSW_IN_TX; + pmu->raw_event_mask |=3D (HSW_IN_TX|HSW_IN_TX_CHECKPOINTED); + } =20 bitmap_set(pmu->all_valid_pmc_idx, 0, pmu->nr_arch_gp_counters); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E283FC43217 for ; Tue, 12 Apr 2022 08:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346729AbiDLIP6 (ORCPT ); Tue, 12 Apr 2022 04:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355300AbiDLH1Z (ORCPT ); Tue, 12 Apr 2022 03:27:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD1C49250; Tue, 12 Apr 2022 00:07: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 CBDC5B81A8F; Tue, 12 Apr 2022 07:07:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42E16C385A1; Tue, 12 Apr 2022 07:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747244; bh=o4f5gXCbaB4CQFduw7VkVXm88MSd43BcGFbgkllltIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDt0lbraaGJc8atbTu4YI5M2N9nKrkrdJuxi6rTCWkzsLaJQjV7Bir70/kCVZmT0O G0HmwDUTF0SIKVfgP3rn0KyMufLA9ns+fWX9XOKsblZb0HE4yrqYB3IYtbvGT8ihM/ cWJSl6viH33xX3l3wnbznJRJg5+yxxXeyDWvmOUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Wenlong , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.17 010/343] KVM: x86/emulator: Emulate RDPID only if it is enabled in guest Date: Tue, 12 Apr 2022 08:27:08 +0200 Message-Id: <20220412062951.402249565@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hou Wenlong [ Upstream commit a836839cbfe60dc434c5476a7429cf2bae36415d ] When RDTSCP is supported but RDPID is not supported in host, RDPID emulation is available. However, __kvm_get_msr() would only fail when RDTSCP/RDPID both are disabled in guest, so the emulator wouldn't inject a #UD when RDPID is disabled but RDTSCP is enabled in guest. Fixes: fb6d4d340e05 ("KVM: x86: emulate RDPID") Signed-off-by: Hou Wenlong Message-Id: <1dfd46ae5b76d3ed87bde3154d51c64ea64c99c1.1646226788.git.houwen= long.hwl@antgroup.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/kvm/emulate.c | 4 +++- arch/x86/kvm/kvm_emulate.h | 1 + arch/x86/kvm/x86.c | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 02d061a06aa1..de9d8a27387c 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3523,8 +3523,10 @@ static int em_rdpid(struct x86_emulate_ctxt *ctxt) { u64 tsc_aux =3D 0; =20 - if (ctxt->ops->get_msr(ctxt, MSR_TSC_AUX, &tsc_aux)) + if (!ctxt->ops->guest_has_rdpid(ctxt)) return emulate_ud(ctxt); + + ctxt->ops->get_msr(ctxt, MSR_TSC_AUX, &tsc_aux); ctxt->dst.val =3D tsc_aux; return X86EMUL_CONTINUE; } diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h index 39eded2426ff..a2a7654d8ace 100644 --- a/arch/x86/kvm/kvm_emulate.h +++ b/arch/x86/kvm/kvm_emulate.h @@ -226,6 +226,7 @@ struct x86_emulate_ops { bool (*guest_has_long_mode)(struct x86_emulate_ctxt *ctxt); bool (*guest_has_movbe)(struct x86_emulate_ctxt *ctxt); bool (*guest_has_fxsr)(struct x86_emulate_ctxt *ctxt); + bool (*guest_has_rdpid)(struct x86_emulate_ctxt *ctxt); =20 void (*set_nmi_mask)(struct x86_emulate_ctxt *ctxt, bool masked); =20 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9b6166348c94..c81ec70197fb 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7675,6 +7675,11 @@ static bool emulator_guest_has_fxsr(struct x86_emula= te_ctxt *ctxt) return guest_cpuid_has(emul_to_vcpu(ctxt), X86_FEATURE_FXSR); } =20 +static bool emulator_guest_has_rdpid(struct x86_emulate_ctxt *ctxt) +{ + return guest_cpuid_has(emul_to_vcpu(ctxt), X86_FEATURE_RDPID); +} + static ulong emulator_read_gpr(struct x86_emulate_ctxt *ctxt, unsigned reg) { return kvm_register_read_raw(emul_to_vcpu(ctxt), reg); @@ -7757,6 +7762,7 @@ static const struct x86_emulate_ops emulate_ops =3D { .guest_has_long_mode =3D emulator_guest_has_long_mode, .guest_has_movbe =3D emulator_guest_has_movbe, .guest_has_fxsr =3D emulator_guest_has_fxsr, + .guest_has_rdpid =3D emulator_guest_has_rdpid, .set_nmi_mask =3D emulator_set_nmi_mask, .get_hflags =3D emulator_get_hflags, .exiting_smm =3D emulator_exiting_smm, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4B4BBC47085 for ; Tue, 12 Apr 2022 08:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355647AbiDLIIl (ORCPT ); Tue, 12 Apr 2022 04:08:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355301AbiDLH1Z (ORCPT ); Tue, 12 Apr 2022 03:27:25 -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 E70664925A; Tue, 12 Apr 2022 00:07:28 -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 0BCE76146F; Tue, 12 Apr 2022 07:07:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19D90C385A6; Tue, 12 Apr 2022 07:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747247; bh=/uKbheoXCqGmE+l6GjoWxiFv0SNKT75bIlepXGZFYGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IxAOVIySsfxypIR4Nc8w/NKrM8sDgmc5zrIqpF3LLYiqce6xCvY0YTZUt7kp9lRtk rtW1ZemjtiB4qKlHy6qTNKpMT8IW8qu0aTvrFT2pDqFs0HJ/XsOvoldEY8PXvz8Nj9 5jZYFOGSC5uR9bbrTomesLGvZotQe2BrsMkCbVcg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anisse Astier , Hans de Goede , Jani Nikula , Sasha Levin Subject: [PATCH 5.17 011/343] drm: Add orientation quirk for GPD Win Max Date: Tue, 12 Apr 2022 08:27:09 +0200 Message-Id: <20220412062951.430895063@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Anisse Astier [ Upstream commit 0b464ca3e0dd3cec65f28bc6d396d82f19080f69 ] Panel is 800x1280, but mounted on a laptop form factor, sideways. Signed-off-by: Anisse Astier Reviewed-by: Hans de Goede Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20211229222200.53128-3-= anisse@astier.eu Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/d= rm/drm_panel_orientation_quirks.c index b910978d3e48..4e853acfd1e8 100644 --- a/drivers/gpu/drm/drm_panel_orientation_quirks.c +++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c @@ -180,6 +180,12 @@ static const struct dmi_system_id orientation_data[] = =3D { DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"), }, .driver_data =3D (void *)&lcd720x1280_rightside_up, + }, { /* GPD Win Max */ + .matches =3D { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"), + }, + .driver_data =3D (void *)&lcd800x1280_rightside_up, }, { /* * GPD Pocket, note that the the DMI data is less generic then * it seems, devices with a board-vendor of "AMI Corporation" --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2EEC2C433F5 for ; Tue, 12 Apr 2022 08:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346570AbiDLIOn (ORCPT ); Tue, 12 Apr 2022 04:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355371AbiDLH1d (ORCPT ); Tue, 12 Apr 2022 03:27:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D928496A4; Tue, 12 Apr 2022 00:07: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 A0795B81B5E; Tue, 12 Apr 2022 07:07:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8118C385A8; Tue, 12 Apr 2022 07:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747250; bh=0zKCbHAONkY/vd2WJvNTYAVZp3uGT2GXWGlXpIL/qew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZsoVXMsTVx/M5pzZXwVmUbufhSKfJukQGftOVE7p4GawT6FwED2OEOv/y7z9HmJGe bTjCe8BQ0nIuWyBBMs1wfcYNn8X6j/VcOgMTBQ6BwZPmR6v9QOUz2rnFsgP+jBnkPU O34ZZZANDJH3ksZRBYOPLyeZObuE9VU9A/1txSh0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.17 012/343] Bluetooth: hci_sync: Fix compilation warning Date: Tue, 12 Apr 2022 08:27:10 +0200 Message-Id: <20220412062951.459437651@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Luiz Augusto von Dentz [ Upstream commit 89a0b8b98f49ae34886e67624208c2898e1e4d7f ] This fixes the following warning: net/bluetooth/hci_sync.c:5143:5: warning: no previous prototype for =E2=80=98hci_le_ext_create_conn_sync=E2=80=99 [-Wmissing-prototypes] Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/bluetooth/hci_sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 405d48c3e63e..48c837530a11 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5156,8 +5156,8 @@ static void set_ext_conn_params(struct hci_conn *conn, p->max_ce_len =3D cpu_to_le16(0x0000); } =20 -int hci_le_ext_create_conn_sync(struct hci_dev *hdev, struct hci_conn *con= n, - u8 own_addr_type) +static int hci_le_ext_create_conn_sync(struct hci_dev *hdev, + struct hci_conn *conn, u8 own_addr_type) { struct hci_cp_le_ext_create_conn *cp; struct hci_cp_le_ext_conn_param *p; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 98C4BC433FE for ; Tue, 12 Apr 2022 08:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237958AbiDLIOG (ORCPT ); Tue, 12 Apr 2022 04:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355380AbiDLH1d (ORCPT ); Tue, 12 Apr 2022 03:27:33 -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 7F21249902; Tue, 12 Apr 2022 00:07: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 dfw.source.kernel.org (Postfix) with ESMTPS id 93527616DC; Tue, 12 Apr 2022 07:07:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A08DFC385B1; Tue, 12 Apr 2022 07:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747253; bh=R9mjCXueA1qBXKoLhaHdg7MAgOdRuTR951goVImsFDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPipMCrSguw44NbJucDDeivMHTs5OO5+k2t8Osh10wQIEajbRBJJoN2U4yFyyVe9n 54eFyI9GoVY1hj9v3YVsJE7rRjqo0HpSed7+eaudFC5AilK3yCwE8/tvCJdaLeLXUO tPSXz6huw/0W7s/0ZlRS1r9MQ9EI49mdxXtPbadI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brendan Dolan-Gavitt , Zekun Shen , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 013/343] ath5k: fix OOB in ath5k_eeprom_read_pcal_info_5111 Date: Tue, 12 Apr 2022 08:27:11 +0200 Message-Id: <20220412062951.488256178@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Zekun Shen [ Upstream commit 564d4eceb97eaf381dd6ef6470b06377bb50c95a ] The bug was found during fuzzing. Stacktrace locates it in ath5k_eeprom_convert_pcal_info_5111. When none of the curve is selected in the loop, idx can go up to AR5K_EEPROM_N_PD_CURVES. The line makes pd out of bound. pd =3D &chinfo[pier].pd_curves[idx]; There are many OOB writes using pd later in the code. So I added a sanity check for idx. Checks for other loops involving AR5K_EEPROM_N_PD_CURVES are not needed as the loop index is not used outside the loops. The patch is NOT tested with real device. The following is the fuzzing report BUG: KASAN: slab-out-of-bounds in ath5k_eeprom_read_pcal_info_5111+0x126a/0= x1390 [ath5k] Write of size 1 at addr ffff8880174a4d60 by task modprobe/214 CPU: 0 PID: 214 Comm: modprobe Not tainted 5.6.0 #1 Call Trace: dump_stack+0x76/0xa0 print_address_description.constprop.0+0x16/0x200 ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] __kasan_report.cold+0x37/0x7c ? ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] kasan_report+0xe/0x20 ath5k_eeprom_read_pcal_info_5111+0x126a/0x1390 [ath5k] ? apic_timer_interrupt+0xa/0x20 ? ath5k_eeprom_init_11a_pcal_freq+0xbc0/0xbc0 [ath5k] ? ath5k_pci_eeprom_read+0x228/0x3c0 [ath5k] ath5k_eeprom_init+0x2513/0x6290 [ath5k] ? ath5k_eeprom_init_11a_pcal_freq+0xbc0/0xbc0 [ath5k] ? usleep_range+0xb8/0x100 ? apic_timer_interrupt+0xa/0x20 ? ath5k_eeprom_read_pcal_info_2413+0x2f20/0x2f20 [ath5k] ath5k_hw_init+0xb60/0x1970 [ath5k] ath5k_init_ah+0x6fe/0x2530 [ath5k] ? kasprintf+0xa6/0xe0 ? ath5k_stop+0x140/0x140 [ath5k] ? _dev_notice+0xf6/0xf6 ? apic_timer_interrupt+0xa/0x20 ath5k_pci_probe.cold+0x29a/0x3d6 [ath5k] ? ath5k_pci_eeprom_read+0x3c0/0x3c0 [ath5k] ? mutex_lock+0x89/0xd0 ? ath5k_pci_eeprom_read+0x3c0/0x3c0 [ath5k] local_pci_probe+0xd3/0x160 pci_device_probe+0x23f/0x3e0 ? pci_device_remove+0x280/0x280 ? pci_device_remove+0x280/0x280 really_probe+0x209/0x5d0 Reported-by: Brendan Dolan-Gavitt Signed-off-by: Zekun Shen Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/YckvDdj3mtCkDRIt@a-10-27-26-18.dynapool.vpn= .nyu.edu Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/ath/ath5k/eeprom.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless= /ath/ath5k/eeprom.c index 1fbc2c19848f..d444b3d70ba2 100644 --- a/drivers/net/wireless/ath/ath5k/eeprom.c +++ b/drivers/net/wireless/ath/ath5k/eeprom.c @@ -746,6 +746,9 @@ ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah= , int mode, } } =20 + if (idx =3D=3D AR5K_EEPROM_N_PD_CURVES) + goto err_out; + ee->ee_pd_gains[mode] =3D 1; =20 pd =3D &chinfo[pier].pd_curves[idx]; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 80EB3C47096 for ; Tue, 12 Apr 2022 08:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233872AbiDLIN1 (ORCPT ); Tue, 12 Apr 2022 04:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355398AbiDLH1e (ORCPT ); Tue, 12 Apr 2022 03:27:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BEA4993E; Tue, 12 Apr 2022 00:07: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 465BB616AB; Tue, 12 Apr 2022 07:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58A4FC385AB; Tue, 12 Apr 2022 07:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747255; bh=ZuW3LbMRkPBggKInlOR/HRj2jRcbYPd7tb9NvbuI2Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CDzW+jcCguy0DGeeJZNxCThE9rwWYQZ+P6SPm8bjPopNUj/iJ1Nykime7hwU4O+wi u9fkIEqIA/7XeB8CCPWS6q6OUchQgbiIJhcWk8PiilYDLA1Cr+DJGQW8xYjjKBBKnv XDzunFVL4XPmAJ0ko0p/906jZwp+S4cIv+JmLD9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soenke Huster , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.17 014/343] Bluetooth: fix null ptr deref on hci_sync_conn_complete_evt Date: Tue, 12 Apr 2022 08:27:12 +0200 Message-Id: <20220412062951.516538389@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Soenke Huster [ Upstream commit 3afee2118132e93e5f6fa636dfde86201a860ab3 ] This event is just specified for SCO and eSCO link types. On the reception of a HCI_Synchronous_Connection_Complete for a BDADDR of an existing LE connection, LE link type and a status that triggers the second case of the packet processing a NULL pointer dereference happens, as conn->link is NULL. Signed-off-by: Soenke Huster Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/bluetooth/hci_event.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a105b7317560..519f5906ee98 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4661,6 +4661,19 @@ static void hci_sync_conn_complete_evt(struct hci_de= v *hdev, void *data, struct hci_ev_sync_conn_complete *ev =3D data; struct hci_conn *conn; =20 + switch (ev->link_type) { + case SCO_LINK: + case ESCO_LINK: + break; + default: + /* As per Core 5.3 Vol 4 Part E 7.7.35 (p.2219), Link_Type + * for HCI_Synchronous_Connection_Complete is limited to + * either SCO or eSCO + */ + bt_dev_err(hdev, "Ignoring connect complete event for invalid link type"= ); + return; + } + bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); =20 hci_dev_lock(hdev); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C5320C47094 for ; Tue, 12 Apr 2022 08:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378809AbiDLINT (ORCPT ); Tue, 12 Apr 2022 04:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355436AbiDLH1f (ORCPT ); Tue, 12 Apr 2022 03:27:35 -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 2314849F1C; Tue, 12 Apr 2022 00:07: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 164AA6146F; Tue, 12 Apr 2022 07:07:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22349C385AB; Tue, 12 Apr 2022 07:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747258; bh=170bG5praSpHQNEq1iCLQmGJb3DPfjckjteNSg+nmAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I7tsFjtmiQyGkKf32kUOOo5Las9tvaFa9A9yKiEI2RCy/+9tNOZ0GKRF8/4aHKZjl 2d7HDLZJjnT6yB3b8WIS1D3bIcGP777NwwLGrL8MLIofVp0sZgvLk+FrPhnYibaMtK p/DTDWvlUrt4mi8y15t2Ah15ZXE17j2altXNFBLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aric Cyr , Wayne Lin , Dale Zhao , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 015/343] drm/amd/display: Add signal type check when verify stream backends same Date: Tue, 12 Apr 2022 08:27:13 +0200 Message-Id: <20220412062951.546729223@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Dale Zhao [ Upstream commit 047db281c026de5971cedb5bb486aa29bd16a39d ] [Why] For allow eDP hot-plug feature, the stream signal may change to VIRTUAL when plug-out and back to eDP when plug-in. OS will still setPathMode with same timing for each plugging, but eDP gets no stream update as we don't check signal type changing back as keeping it VIRTUAL. It's also unsafe for future cases that stream signal is switched with same timing. [How] Check stream signal type change include previous HDMI signal case. Reviewed-by: Aric Cyr Acked-by: Wayne Lin Signed-off-by: Dale Zhao Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gp= u/drm/amd/display/dc/core/dc_resource.c index 18757c158523..ac3071e38e4a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -1640,6 +1640,9 @@ static bool are_stream_backends_same( if (is_timing_changed(stream_a, stream_b)) return false; =20 + if (stream_a->signal !=3D stream_b->signal) + return false; + if (stream_a->dpms_off !=3D stream_b->dpms_off) return false; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 01EF7C4321E for ; Tue, 12 Apr 2022 08:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379130AbiDLIUE (ORCPT ); Tue, 12 Apr 2022 04:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355510AbiDLH1j (ORCPT ); Tue, 12 Apr 2022 03:27:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44BB74EA2A; Tue, 12 Apr 2022 00:07: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 ams.source.kernel.org (Postfix) with ESMTPS id 8E780B81B51; Tue, 12 Apr 2022 07:07:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05B0EC385A6; Tue, 12 Apr 2022 07:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747261; bh=89MrKhqbU4iUBu1mBVmX/Pf+qMpToYtQOMbN23scytw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X0ZmSGPE7Zv0/nt/N2gSgcEQGBJbK9dlpbdDaIiMBXsC9c55hwZnd4epHNUEXstB7 5mPGkulCAiQdbbnJwTTHddlyxHyjIv6qCdjf3Y8eSeUbWHK1HoBlaEgeaWwTCzxtHm kvIZWxGCQ17fUnVuKgGYglFNzr/Iz7lR9lIzdLB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Huang , Alex Deucher , Felix Kuehling , Sasha Levin Subject: [PATCH 5.17 016/343] drm/amdkfd: enable heavy-weight TLB flush on Arcturus Date: Tue, 12 Apr 2022 08:27:14 +0200 Message-Id: <20220412062951.573763904@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Huang [ Upstream commit f61c40c0757a79bcf744314df606c2bc8ae6a729 ] SDMA FW fixes the hang issue for adding heavy-weight TLB flush on Arcturus, so we can enable it. Signed-off-by: Eric Huang Acked-by: Alex Deucher Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 ------ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu= /drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index f9bab963a948..5df387c4d7fb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1813,12 +1813,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( true); ret =3D unreserve_bo_and_vms(&ctx, false, false); =20 - /* Only apply no TLB flush on Aldebaran to - * workaround regressions on other Asics. - */ - if (table_freed && (adev->asic_type !=3D CHIP_ALDEBARAN)) - *table_freed =3D true; - goto out; =20 out_unreserve: diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd= /amdkfd/kfd_chardev.c index 4bfc0c8ab764..337953af7c2f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1416,6 +1416,12 @@ static int kfd_ioctl_free_memory_of_gpu(struct file = *filep, return ret; } =20 +static bool kfd_flush_tlb_after_unmap(struct kfd_dev *dev) { + return KFD_GC_VERSION(dev) =3D=3D IP_VERSION(9, 4, 2) || + (KFD_GC_VERSION(dev) =3D=3D IP_VERSION(9, 4, 1) && + dev->adev->sdma.instance[0].fw_version >=3D 18); +} + static int kfd_ioctl_map_memory_to_gpu(struct file *filep, struct kfd_process *p, void *data) { @@ -1503,7 +1509,7 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *f= ilep, } =20 /* Flush TLBs after waiting for the page table updates to complete */ - if (table_freed) { + if (table_freed || !kfd_flush_tlb_after_unmap(dev)) { for (i =3D 0; i < args->n_devices; i++) { peer =3D kfd_device_by_id(devices_arr[i]); if (WARN_ON_ONCE(!peer)) @@ -1603,7 +1609,7 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct fil= e *filep, } mutex_unlock(&p->mutex); =20 - if (KFD_GC_VERSION(dev) =3D=3D IP_VERSION(9, 4, 2)) { + if (kfd_flush_tlb_after_unmap(dev)) { err =3D amdgpu_amdkfd_gpuvm_sync_memory(dev->adev, (struct kgd_mem *) mem, true); if (err) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 64B58C352A1 for ; Tue, 12 Apr 2022 08:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355672AbiDLIIq (ORCPT ); Tue, 12 Apr 2022 04:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355521AbiDLH1k (ORCPT ); Tue, 12 Apr 2022 03:27: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 2E88F4EA2E; Tue, 12 Apr 2022 00:07: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 dfw.source.kernel.org (Postfix) with ESMTPS id ADAFB616B3; Tue, 12 Apr 2022 07:07:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC52FC385A1; Tue, 12 Apr 2022 07:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747264; bh=Jc8pgUnbZ/NjC/Hkh90e39VVKCwDKbAPR4E0Lwf2MiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGDel+mcFdBDfdXD7/lMwjuQ0dGVzKub17cMKKzRxO4BZnci57tu/BdN7ri83yx0p 6asPeIEUgHxTrh+aoR2KA6GAw9LZbFqZi9X55OSafs2oYbjSSLVtiYn52EDMwQGI1E V6iWcgmOhxIjPT9o2MmAHmVvHraA6VAyAAtGIMDU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , Jani Nikula , Sasha Levin Subject: [PATCH 5.17 017/343] drm/edid: remove non_desktop quirk for HPN-3515 and LEN-B800. Date: Tue, 12 Apr 2022 08:27:15 +0200 Message-Id: <20220412062951.602588791@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Philipp Zabel [ Upstream commit 50dc95d561a2552b0d76a9f91b38005195bf2974 ] Now that there is support for the Microsoft VSDB for HMDs, remove the non-desktop quirk for two devices that are verified to contain it in their EDID: HPN-3515 and LEN-B800. Presumably most of the other Windows Mixed Reality headsets contain it as well, but there are ACR-7FCE and SEC-5194 devices without it. Tested with LEN-B800. Signed-off-by: Philipp Zabel Reviewed-by: Jani Nikula Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20220123101653.147333-2= -philipp.zabel@gmail.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/drm_edid.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index b8f5419e514a..a71b82668a98 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -212,9 +212,7 @@ static const struct edid_quirk { =20 /* Windows Mixed Reality Headsets */ EDID_QUIRK('A', 'C', 'R', 0x7fce, EDID_QUIRK_NON_DESKTOP), - EDID_QUIRK('H', 'P', 'N', 0x3515, EDID_QUIRK_NON_DESKTOP), EDID_QUIRK('L', 'E', 'N', 0x0408, EDID_QUIRK_NON_DESKTOP), - EDID_QUIRK('L', 'E', 'N', 0xb800, EDID_QUIRK_NON_DESKTOP), EDID_QUIRK('F', 'U', 'J', 0x1970, EDID_QUIRK_NON_DESKTOP), EDID_QUIRK('D', 'E', 'L', 0x7fce, EDID_QUIRK_NON_DESKTOP), EDID_QUIRK('S', 'E', 'C', 0x144a, EDID_QUIRK_NON_DESKTOP), --=20 2.35.1 From nobody Thu May 14 08:08:21 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 400B4C35294 for ; Tue, 12 Apr 2022 08:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383529AbiDLIhP (ORCPT ); Tue, 12 Apr 2022 04:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356750AbiDLHjS (ORCPT ); Tue, 12 Apr 2022 03:39:18 -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 422D352B12; Tue, 12 Apr 2022 00:10: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 73991616B2; Tue, 12 Apr 2022 07:10:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84DFBC385A5; Tue, 12 Apr 2022 07:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747407; bh=smfjITSV1YHK4/bfAMDR+H6NLc2WvBO/3LmrqMnJXJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bbSTray6srJJXYmltFOYyt55lObJ/qypjDtiR2R5nLxIrbtKz6uGE9ElSkXdNEp2Z 9G46+ZKdrypFxf3VlEDWeIjKQuW32/U5phcUw0EpwUKft96aqlex3ZXWSmrFI4PLYK Fz1LvSFZDC6ys4y4TIx5kl2e7zuT6K2ypVgsKP9k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , Jani Nikula , Sasha Levin Subject: [PATCH 5.17 018/343] drm/edid: improve non-desktop quirk logging Date: Tue, 12 Apr 2022 08:27:16 +0200 Message-Id: <20220412062951.631036259@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jani Nikula [ Upstream commit ce99534e978d4a36787dbe5e5c57749d12e6bf4a ] Improve non-desktop quirk logging if the EDID indicates non-desktop. If both are set, note about redundant quirk. If there's no quirk but the EDID indicates non-desktop, don't log non-desktop is set to 0. Cc: Philipp Zabel Signed-off-by: Jani Nikula Reviewed-by: Philipp Zabel Tested-by: Philipp Zabel Link: https://patchwork.freedesktop.org/patch/msgid/20211228101051.317989-1= -jani.nikula@intel.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/drm_edid.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index a71b82668a98..83e5c115e754 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -5325,17 +5325,13 @@ u32 drm_add_display_info(struct drm_connector *conn= ector, const struct edid *edi info->width_mm =3D edid->width_cm * 10; info->height_mm =3D edid->height_cm * 10; =20 - info->non_desktop =3D !!(quirks & EDID_QUIRK_NON_DESKTOP); - drm_get_monitor_range(connector, edid); =20 - DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop); - if (edid->revision < 3) - return quirks; + goto out; =20 if (!(edid->input & DRM_EDID_INPUT_DIGITAL)) - return quirks; + goto out; =20 info->color_formats |=3D DRM_COLOR_FORMAT_RGB444; drm_parse_cea_ext(connector, edid); @@ -5356,7 +5352,7 @@ u32 drm_add_display_info(struct drm_connector *connec= tor, const struct edid *edi =20 /* Only defined for 1.4 with digital displays */ if (edid->revision < 4) - return quirks; + goto out; =20 switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) { case DRM_EDID_DIGITAL_DEPTH_6: @@ -5393,6 +5389,13 @@ u32 drm_add_display_info(struct drm_connector *conne= ctor, const struct edid *edi =20 drm_update_mso(connector, edid); =20 +out: + if (quirks & EDID_QUIRK_NON_DESKTOP) { + drm_dbg_kms(connector->dev, "Non-desktop display%s\n", + info->non_desktop ? " (redundant quirk)" : ""); + info->non_desktop =3D true; + } + return quirks; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7244AC433EF for ; Tue, 12 Apr 2022 08:25:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244301AbiDLIRb (ORCPT ); Tue, 12 Apr 2022 04:17:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355717AbiDLH3G (ORCPT ); Tue, 12 Apr 2022 03:29:06 -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 03B6A4F470; Tue, 12 Apr 2022 00:08: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 B8361B81A8F; Tue, 12 Apr 2022 07:08:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27397C385A1; Tue, 12 Apr 2022 07:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747292; bh=uow/9Fxm7VelvSN98UYvC4nbs7sPXNUk8zotZfIsCTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnhExByO+jtlRvjz6TsPKgEk+JIRwHcyEkqCtBvmsDrlOxfHQ8K7b/3yyM1DYzQU1 JdQLTDY/GCCGQvbzLNN2J+DRcDi2jia8cGt4dD6AXAUw4dgVqAqEPK2UmEfn2mtmAu W9gwEE6Xtb70ImTaS4GNGLNSdI3nw1xZP878rt3I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soenke Huster , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.17 019/343] Bluetooth: hci_event: Ignore multiple conn complete events Date: Tue, 12 Apr 2022 08:27:17 +0200 Message-Id: <20220412062951.659122282@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Soenke Huster [ Upstream commit d5ebaa7c5f6f688959e8d40840b2249ede63b8ed ] When one of the three connection complete events is received multiple times for the same handle, the device is registered multiple times which leads to memory corruptions. Therefore, consequent events for a single connection are ignored. The conn->state can hold different values, therefore HCI_CONN_HANDLE_UNSET is introduced to identify new connections. To make sure the events do not contain this or another invalid handle HCI_CONN_HANDLE_MAX and checks are introduced. Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=3D215497 Signed-off-by: Soenke Huster Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/net/bluetooth/hci_core.h | 3 ++ net/bluetooth/hci_conn.c | 1 + net/bluetooth/hci_event.c | 63 ++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_c= ore.h index e336e9c1dda4..36d727f94ac2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -294,6 +294,9 @@ struct adv_monitor { =20 #define HCI_MAX_SHORT_NAME_LENGTH 10 =20 +#define HCI_CONN_HANDLE_UNSET 0xffff +#define HCI_CONN_HANDLE_MAX 0x0eff + /* Min encryption key size to match with SMP */ #define HCI_MIN_ENC_KEY_SIZE 7 =20 diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 3bb2b3b6a1c9..84312c836549 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -691,6 +691,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int= type, bdaddr_t *dst, =20 bacpy(&conn->dst, dst); bacpy(&conn->src, &hdev->bdaddr); + conn->handle =3D HCI_CONN_HANDLE_UNSET; conn->hdev =3D hdev; conn->type =3D type; conn->role =3D role; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 519f5906ee98..63b925921c87 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3068,6 +3068,11 @@ static void hci_conn_complete_evt(struct hci_dev *hd= ev, void *data, struct hci_ev_conn_complete *ev =3D data; struct hci_conn *conn; =20 + if (__le16_to_cpu(ev->handle) > HCI_CONN_HANDLE_MAX) { + bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for invalid handle"); + return; + } + bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); =20 hci_dev_lock(hdev); @@ -3106,6 +3111,17 @@ static void hci_conn_complete_evt(struct hci_dev *hd= ev, void *data, } } =20 + /* The HCI_Connection_Complete event is only sent once per connection. + * Processing it more than once per connection can corrupt kernel memory. + * + * As the connection handle is set here for the first time, it indicates + * whether the connection is already set up. + */ + if (conn->handle !=3D HCI_CONN_HANDLE_UNSET) { + bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connecti= on"); + goto unlock; + } + if (!ev->status) { conn->handle =3D __le16_to_cpu(ev->handle); =20 @@ -4674,6 +4690,11 @@ static void hci_sync_conn_complete_evt(struct hci_de= v *hdev, void *data, return; } =20 + if (__le16_to_cpu(ev->handle) > HCI_CONN_HANDLE_MAX) { + bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete for invalid handle"); + return; + } + bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); =20 hci_dev_lock(hdev); @@ -4697,23 +4718,19 @@ static void hci_sync_conn_complete_evt(struct hci_d= ev *hdev, void *data, goto unlock; } =20 + /* The HCI_Synchronous_Connection_Complete event is only sent once per co= nnection. + * Processing it more than once per connection can corrupt kernel memory. + * + * As the connection handle is set here for the first time, it indicates + * whether the connection is already set up. + */ + if (conn->handle !=3D HCI_CONN_HANDLE_UNSET) { + bt_dev_err(hdev, "Ignoring HCI_Sync_Conn_Complete event for existing con= nection"); + goto unlock; + } + switch (ev->status) { case 0x00: - /* The synchronous connection complete event should only be - * sent once per new connection. Receiving a successful - * complete event when the connection status is already - * BT_CONNECTED means that the device is misbehaving and sent - * multiple complete event packets for the same new connection. - * - * Registering the device more than once can corrupt kernel - * memory, hence upon detecting this invalid event, we report - * an error and ignore the packet. - */ - if (conn->state =3D=3D BT_CONNECTED) { - bt_dev_err(hdev, "Ignoring connect complete event for existing connecti= on"); - goto unlock; - } - conn->handle =3D __le16_to_cpu(ev->handle); conn->state =3D BT_CONNECTED; conn->type =3D ev->link_type; @@ -5509,6 +5526,11 @@ static void le_conn_complete_evt(struct hci_dev *hde= v, u8 status, struct smp_irk *irk; u8 addr_type; =20 + if (handle > HCI_CONN_HANDLE_MAX) { + bt_dev_err(hdev, "Ignoring HCI_LE_Connection_Complete for invalid handle= "); + return; + } + hci_dev_lock(hdev); =20 /* All controllers implicitly stop advertising in the event of a @@ -5550,6 +5572,17 @@ static void le_conn_complete_evt(struct hci_dev *hde= v, u8 status, cancel_delayed_work(&conn->le_conn_timeout); } =20 + /* The HCI_LE_Connection_Complete event is only sent once per connection. + * Processing it more than once per connection can corrupt kernel memory. + * + * As the connection handle is set here for the first time, it indicates + * whether the connection is already set up. + */ + if (conn->handle !=3D HCI_CONN_HANDLE_UNSET) { + bt_dev_err(hdev, "Ignoring HCI_Connection_Complete for existing connecti= on"); + goto unlock; + } + le_conn_update_addr(conn, bdaddr, bdaddr_type, local_rpa); =20 /* Lookup the identity address from the stored connection --=20 2.35.1 From nobody Thu May 14 08:08:21 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 085AAC433F5 for ; Tue, 12 Apr 2022 08:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380328AbiDLIVl (ORCPT ); Tue, 12 Apr 2022 04:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352037AbiDLHdZ (ORCPT ); Tue, 12 Apr 2022 03:33:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58D6506CE; Tue, 12 Apr 2022 00:08: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 52A89616AB; Tue, 12 Apr 2022 07:08:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FADDC385A8; Tue, 12 Apr 2022 07:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747322; bh=sudFEqS6dpe/HG8e9ahoivSgy9PiKVCGBgOMtkhdPug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ptchrCJEek9USlvn3fvwPFAXNcg6tnTz3jV1BL/Y+zeSyI8xDGeQ4ztqDVKlPzJ5K 6eMiBeaOfehBPJqO/Y+Rceas82SA6ZhEkUfo3PtbQX5AnK10fXK7I6ZgXKOMwKCX/9 NlZ+ynK66w6lKFGhhhUyBBPTZ5d0op11MWOSVhro= 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?= , Xin Xiong , Xin Tan , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 020/343] drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj Date: Tue, 12 Apr 2022 08:27:18 +0200 Message-Id: <20220412062951.687668471@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xin Xiong [ Upstream commit dfced44f122c500004a48ecc8db516bb6a295a1b ] This issue takes place in an error path in amdgpu_cs_fence_to_handle_ioctl(). When `info->in.what` falls into default case, the function simply returns -EINVAL, forgetting to decrement the reference count of a dma_fence obj, which is bumped earlier by amdgpu_cs_get_fence(). This may result in reference count leaks. Fix it by decreasing the refcount of specific object before returning the error code. Reviewed-by: Christian K=C3=B6nig Signed-off-by: Xin Xiong Signed-off-by: Xin Tan Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/a= mdgpu/amdgpu_cs.c index 06d07502a1f6..a34be65c9eaa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1509,6 +1509,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device= *dev, void *data, return 0; =20 default: + dma_fence_put(fence); return -EINVAL; } } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7B333C4167E for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383097AbiDLIfl (ORCPT ); Tue, 12 Apr 2022 04:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356346AbiDLHfS (ORCPT ); Tue, 12 Apr 2022 03:35:18 -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 AA75050E24; Tue, 12 Apr 2022 00:09: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 DCA20B81B51; Tue, 12 Apr 2022 07:09:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 556B5C385A1; Tue, 12 Apr 2022 07:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747352; bh=7pOdQWKzUDCKJ7sgaD3ytN5PTOJyYMvtQeItrScDXFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f5BSIgzL5mBI84Yos0vwB/ZP7BLgPDB4q5Ldl9tds+7ka4t/d5L20qNH8VoKhaYx0 NJ+fms6ax4eIkHK5lbWmRG2yrEmSuHaoUZGgbTACxgg1Pu/sohk75Z21N+LtyqS+FJ CXI2SH3//48c6vPIxIuhFvtw6JQK93CTU1vaPp/s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harry Wentland , Yongzhi Liu , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 021/343] drm/amd/display: Fix memory leak Date: Tue, 12 Apr 2022 08:27:19 +0200 Message-Id: <20220412062951.716479156@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yongzhi Liu [ Upstream commit 5d5c6dba2b43e28845d7d7ed32a36802329a5f52 ] [why] Resource release is needed on the error handling path to prevent memory leak. [how] Fix this by adding kfree on the error handling path. Reviewed-by: Harry Wentland Signed-off-by: Yongzhi Liu Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 80 ++++++++++++++----- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/dr= ivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c index 26719efa5396..12d437d9a0e4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -227,8 +227,10 @@ static ssize_t dp_link_settings_read(struct file *f, c= har __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -389,8 +391,10 @@ static ssize_t dp_phy_settings_read(struct file *f, ch= ar __user *buf, break; =20 r =3D put_user((*(rd_buf + result)), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -1359,8 +1363,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, = char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -1376,8 +1382,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, = char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -1546,8 +1554,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *= f, char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -1563,8 +1573,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *= f, char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -1731,8 +1743,10 @@ static ssize_t dp_dsc_slice_height_read(struct file = *f, char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -1748,8 +1762,10 @@ static ssize_t dp_dsc_slice_height_read(struct file = *f, char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -1912,8 +1928,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct fil= e *f, char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -1929,8 +1947,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct fil= e *f, char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -2088,8 +2108,10 @@ static ssize_t dp_dsc_pic_width_read(struct file *f,= char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -2105,8 +2127,10 @@ static ssize_t dp_dsc_pic_width_read(struct file *f,= char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -2145,8 +2169,10 @@ static ssize_t dp_dsc_pic_height_read(struct file *f= , char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -2162,8 +2188,10 @@ static ssize_t dp_dsc_pic_height_read(struct file *f= , char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -2217,8 +2245,10 @@ static ssize_t dp_dsc_chunk_size_read(struct file *f= , char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -2234,8 +2264,10 @@ static ssize_t dp_dsc_chunk_size_read(struct file *f= , char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -2289,8 +2321,10 @@ static ssize_t dp_dsc_slice_bpg_offset_read(struct f= ile *f, char __user *buf, break; } =20 - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } =20 dsc =3D pipe_ctx->stream_res.dsc; if (dsc) @@ -2306,8 +2340,10 @@ static ssize_t dp_dsc_slice_bpg_offset_read(struct f= ile *f, char __user *buf, break; =20 r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } =20 buf +=3D 1; size -=3D 1; @@ -3459,8 +3495,10 @@ static ssize_t dcc_en_bits_read( dc->hwss.get_dcc_en_bits(dc, dcc_en_bits); =20 rd_buf =3D kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL); - if (!rd_buf) + if (!rd_buf) { + kfree(dcc_en_bits); return -ENOMEM; + } =20 for (i =3D 0; i < num_pipes; i++) offset +=3D snprintf(rd_buf + offset, rd_buf_size - offset, @@ -3473,8 +3511,10 @@ static ssize_t dcc_en_bits_read( if (*pos >=3D rd_buf_size) break; r =3D put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r =3D -EFAULT */ + } buf +=3D 1; size -=3D 1; *pos +=3D 1; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 41235C4708E for ; Tue, 12 Apr 2022 09:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389737AbiDLJYF (ORCPT ); Tue, 12 Apr 2022 05:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353953AbiDLHiB (ORCPT ); Tue, 12 Apr 2022 03:38: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 16B59517FB; Tue, 12 Apr 2022 00:09: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 28762B81B58; Tue, 12 Apr 2022 07:09:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EA20C385A5; Tue, 12 Apr 2022 07:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747382; bh=P+yUphLekVSunkS4tg37Dl51JfFmmML9Ddy2YUNFXgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVSbDotQ2ZQGegzHkqIf6/5qmcyeOu9wdKSeM8V1OF70F5ttKbBemoGjZ6Ca+4le+ PqDARmzG0zXQ1DBOA0Zb8+ViZOvCtR4KzRnDgXG00CVHRsL4YSY6XX5e8lfExaDVMu mudkRonCJVVjyrVl06v7zmGkT8sDkXtTAxAAngm4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Wheeler , Anthony Koo , Rodrigo Siqueira , Nicholas Kazlauskas , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 022/343] drm/amd/display: Use PSR version selected during set_psr_caps Date: Tue, 12 Apr 2022 08:27:20 +0200 Message-Id: <20220412062951.745001905@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Nicholas Kazlauskas [ Upstream commit b80ddeb29d9df449f875f0b6f5de08d7537c02b8 ] [Why] If the DPCD caps specifies a PSR version newer than PSR_VERSION_1 then we fallback to using PSR_VERSION_1 in amdgpu_dm_set_psr_caps. This gets overriden with the raw DPCD value in amdgpu_dm_link_setup_psr, which can result in DMCUB hanging if we pass in an unsupported PSR version number. [How] Fix the hang by using link->psr_settings.psr_version directly during amdgpu_dm_link_setup_psr. Tested-by: Daniel Wheeler Reviewed-by: Anthony Koo Acked-by: Rodrigo Siqueira Signed-off-by: Nicholas Kazlauskas Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c b/driver= s/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c index c510638b4f99..a009fc654ac9 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c @@ -149,10 +149,8 @@ bool amdgpu_dm_link_setup_psr(struct dc_stream_state *= stream) =20 link =3D stream->link; =20 - psr_config.psr_version =3D link->dpcd_caps.psr_caps.psr_version; - - if (psr_config.psr_version > 0) { - psr_config.psr_exit_link_training_required =3D 0x1; + if (link->psr_settings.psr_version !=3D DC_PSR_VERSION_UNSUPPORTED) { + psr_config.psr_version =3D link->psr_settings.psr_version; psr_config.psr_frame_capture_indication_req =3D 0; psr_config.psr_rfb_setup_time =3D 0x37; psr_config.psr_sdp_transmit_line_num_deadline =3D 0x20; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 50B28C35296 for ; Tue, 12 Apr 2022 09:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385142AbiDLJV1 (ORCPT ); Tue, 12 Apr 2022 05:21:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356592AbiDLHjB (ORCPT ); Tue, 12 Apr 2022 03:39:01 -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 A312151E47; Tue, 12 Apr 2022 00:09: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 dfw.source.kernel.org (Postfix) with ESMTPS id A4E536153F; Tue, 12 Apr 2022 07:09:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6CA4C385A5; Tue, 12 Apr 2022 07:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747394; bh=H87OD+Fcr4idMU55Do5g6ZPpGOYvTKeKoP/lzF4+dV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EbU/qJ6OhU250XGDIXN/0x1Nnouq8a/Hnd4pb6Sk0mf1wepS78VXjCpRL4IVW/Vzc 3K6vIYqPhA4kN2ag9XfNg4X2v3vKsYVpfNZOPqNe+jYi122RvFH+KOWgIg8vcZDt53 92Zl/BwVufCVVqsJr/T8/TngGdCi2PdmCNd7DeH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wayne Chang , Sasha Levin Subject: [PATCH 5.17 023/343] usb: gadget: tegra-xudc: Do not program SPARAM Date: Tue, 12 Apr 2022 08:27:21 +0200 Message-Id: <20220412062951.773199417@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Wayne Chang [ Upstream commit 62fb61580eb48fc890b7bc9fb5fd263367baeca8 ] According to the Tegra Technical Reference Manual, SPARAM is a read-only register and should not be programmed in the driver. The change removes the wrong SPARAM usage. Signed-off-by: Wayne Chang Link: https://lore.kernel.org/r/20220107090443.149021-1-waynec@nvidia.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/gadget/udc/tegra-xudc.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/t= egra-xudc.c index 43f1b0d461c1..716d9ab2d2ff 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -32,9 +32,6 @@ #include =20 /* XUSB_DEV registers */ -#define SPARAM 0x000 -#define SPARAM_ERSTMAX_MASK GENMASK(20, 16) -#define SPARAM_ERSTMAX(x) (((x) << 16) & SPARAM_ERSTMAX_MASK) #define DB 0x004 #define DB_TARGET_MASK GENMASK(15, 8) #define DB_TARGET(x) (((x) << 8) & DB_TARGET_MASK) @@ -3295,11 +3292,6 @@ static void tegra_xudc_init_event_ring(struct tegra_= xudc *xudc) unsigned int i; u32 val; =20 - val =3D xudc_readl(xudc, SPARAM); - val &=3D ~(SPARAM_ERSTMAX_MASK); - val |=3D SPARAM_ERSTMAX(XUDC_NR_EVENT_RINGS); - xudc_writel(xudc, val, SPARAM); - for (i =3D 0; i < ARRAY_SIZE(xudc->event_ring); i++) { memset(xudc->event_ring[i], 0, XUDC_EVENT_RING_SIZE * sizeof(*xudc->event_ring[i])); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1BA1CC3525B for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382283AbiDLJVQ (ORCPT ); Tue, 12 Apr 2022 05:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356664AbiDLHjL (ORCPT ); Tue, 12 Apr 2022 03: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 918A9527D6; Tue, 12 Apr 2022 00:09: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 15BAAB81B5E; Tue, 12 Apr 2022 07:09:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E520C385B8; Tue, 12 Apr 2022 07:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747396; bh=CWMqiwxtlvgKbd+NivmB/OV5GOd11UOQAsCVPwOiIpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBkE0I0Mfgs7EsLoBXx9+XgopXKusHMedbEWzw3Et2p7Zyn5mprdwPlj7Nmx4Hr7I MUUx47IgD0vIEgpA2DaQXHL82+4Yo1LXBgb/+WGSrfPcPqSHnVtYqoSgZnb/pkBrTU UdZAg/07axexTsQF+1hnH3IsoCZr5W4WGMmwlwwo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wayne Chang , Sasha Levin Subject: [PATCH 5.17 024/343] usb: gadget: tegra-xudc: Fix control endpoints definitions Date: Tue, 12 Apr 2022 08:27:22 +0200 Message-Id: <20220412062951.801989962@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Wayne Chang [ Upstream commit 7bd42fb95eb4f98495ccadf467ad15124208ec49 ] According to the Tegra Technical Reference Manual, the seq_num field of control endpoint is not [31:24] but [31:27]. Bit 24 is reserved and bit 26 is splitxstate. The change fixes the wrong control endpoint's definitions. Signed-off-by: Wayne Chang Link: https://lore.kernel.org/r/20220107091349.149798-1-waynec@nvidia.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/gadget/udc/tegra-xudc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/t= egra-xudc.c index 716d9ab2d2ff..be76f891b9c5 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -272,8 +272,10 @@ BUILD_EP_CONTEXT_RW(deq_hi, deq_hi, 0, 0xffffffff) BUILD_EP_CONTEXT_RW(avg_trb_len, tx_info, 0, 0xffff) BUILD_EP_CONTEXT_RW(max_esit_payload, tx_info, 16, 0xffff) BUILD_EP_CONTEXT_RW(edtla, rsvd[0], 0, 0xffffff) -BUILD_EP_CONTEXT_RW(seq_num, rsvd[0], 24, 0xff) +BUILD_EP_CONTEXT_RW(rsvd, rsvd[0], 24, 0x1) BUILD_EP_CONTEXT_RW(partial_td, rsvd[0], 25, 0x1) +BUILD_EP_CONTEXT_RW(splitxstate, rsvd[0], 26, 0x1) +BUILD_EP_CONTEXT_RW(seq_num, rsvd[0], 27, 0x1f) BUILD_EP_CONTEXT_RW(cerrcnt, rsvd[1], 18, 0x3) BUILD_EP_CONTEXT_RW(data_offset, rsvd[2], 0, 0x1ffff) BUILD_EP_CONTEXT_RW(numtrbs, rsvd[2], 22, 0x1f) @@ -1554,6 +1556,9 @@ static int __tegra_xudc_ep_set_halt(struct tegra_xudc= _ep *ep, bool halt) ep_reload(xudc, ep->index); =20 ep_ctx_write_state(ep->context, EP_STATE_RUNNING); + ep_ctx_write_rsvd(ep->context, 0); + ep_ctx_write_partial_td(ep->context, 0); + ep_ctx_write_splitxstate(ep->context, 0); ep_ctx_write_seq_num(ep->context, 0); =20 ep_reload(xudc, ep->index); @@ -2809,7 +2814,10 @@ static void tegra_xudc_reset(struct tegra_xudc *xudc) xudc->setup_seq_num =3D 0; xudc->queued_setup_packet =3D false; =20 - ep_ctx_write_seq_num(ep0->context, xudc->setup_seq_num); + ep_ctx_write_rsvd(ep0->context, 0); + ep_ctx_write_partial_td(ep0->context, 0); + ep_ctx_write_splitxstate(ep0->context, 0); + ep_ctx_write_seq_num(ep0->context, 0); =20 deq_ptr =3D trb_virt_to_phys(ep0, &ep0->transfer_ring[ep0->deq_ptr]); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 01647C433FE for ; Tue, 12 Apr 2022 09:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380822AbiDLJVN (ORCPT ); Tue, 12 Apr 2022 05:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356684AbiDLHjN (ORCPT ); Tue, 12 Apr 2022 03:39:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 899DB4A925; Tue, 12 Apr 2022 00:10: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 dfw.source.kernel.org (Postfix) with ESMTPS id 24BD1616DC; Tue, 12 Apr 2022 07:10:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31E84C385A5; Tue, 12 Apr 2022 07:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747399; bh=r87p0gAl0psPBghiE0BCtzVxgcqDSlyjIthS9cyDlkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQIYVMrGkqc9AE7peY9LLI8DXonDRR5otMb098rV1nqfA7EQhRoRNEb22D8CgnHz1 fxXBOmbNzIr5orvEcDX5ZCogXlYT6GrrUTmmOZlY+bGrUI6zwctcIuQAyxzS2yGY8Z z4WAfgjikhmDxXZlWWH/ASC71kDbS6IfcsmHJGuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Pawel Laszczak , Sasha Levin Subject: [PATCH 5.17 025/343] usb: cdnsp: fix cdnsp_decode_trb function to properly handle ret value Date: Tue, 12 Apr 2022 08:27:23 +0200 Message-Id: <20220412062951.831094947@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pawel Laszczak [ Upstream commit 03db9289b5ab59437e42a111a34545a7cedb5190 ] Variable ret in function cdnsp_decode_trb is initialized but not used. To fix this compiler warning patch adds checking whether the data buffer has not been overflowed. Reported-by: kernel test robot Signed-off-by: Pawel Laszczak Link: https://lore.kernel.org/r/20220112053237.14309-1-pawell@gli-login.cad= ence.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/cdns3/cdnsp-debug.h | 305 ++++++++++++++++---------------- 1 file changed, 154 insertions(+), 151 deletions(-) diff --git a/drivers/usb/cdns3/cdnsp-debug.h b/drivers/usb/cdns3/cdnsp-debu= g.h index a8776df2d4e0..f0ca865cce2a 100644 --- a/drivers/usb/cdns3/cdnsp-debug.h +++ b/drivers/usb/cdns3/cdnsp-debug.h @@ -182,208 +182,211 @@ static inline const char *cdnsp_decode_trb(char *st= r, size_t size, u32 field0, int ep_id =3D TRB_TO_EP_INDEX(field3) - 1; int type =3D TRB_FIELD_TO_TYPE(field3); unsigned int ep_num; - int ret =3D 0; + int ret; u32 temp; =20 ep_num =3D DIV_ROUND_UP(ep_id, 2); =20 switch (type) { case TRB_LINK: - ret +=3D snprintf(str, size, - "LINK %08x%08x intr %ld type '%s' flags %c:%c:%c:%c", - field1, field0, GET_INTR_TARGET(field2), - cdnsp_trb_type_string(type), - field3 & TRB_IOC ? 'I' : 'i', - field3 & TRB_CHAIN ? 'C' : 'c', - field3 & TRB_TC ? 'T' : 't', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "LINK %08x%08x intr %ld type '%s' flags %c:%c:%c:%c", + field1, field0, GET_INTR_TARGET(field2), + cdnsp_trb_type_string(type), + field3 & TRB_IOC ? 'I' : 'i', + field3 & TRB_CHAIN ? 'C' : 'c', + field3 & TRB_TC ? 'T' : 't', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_TRANSFER: case TRB_COMPLETION: case TRB_PORT_STATUS: case TRB_HC_EVENT: - ret +=3D snprintf(str, size, - "ep%d%s(%d) type '%s' TRB %08x%08x status '%s'" - " len %ld slot %ld flags %c:%c", - ep_num, ep_id % 2 ? "out" : "in", - TRB_TO_EP_INDEX(field3), - cdnsp_trb_type_string(type), field1, field0, - cdnsp_trb_comp_code_string(GET_COMP_CODE(field2)), - EVENT_TRB_LEN(field2), TRB_TO_SLOT_ID(field3), - field3 & EVENT_DATA ? 'E' : 'e', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "ep%d%s(%d) type '%s' TRB %08x%08x status '%s'" + " len %ld slot %ld flags %c:%c", + ep_num, ep_id % 2 ? "out" : "in", + TRB_TO_EP_INDEX(field3), + cdnsp_trb_type_string(type), field1, field0, + cdnsp_trb_comp_code_string(GET_COMP_CODE(field2)), + EVENT_TRB_LEN(field2), TRB_TO_SLOT_ID(field3), + field3 & EVENT_DATA ? 'E' : 'e', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_MFINDEX_WRAP: - ret +=3D snprintf(str, size, "%s: flags %c", - cdnsp_trb_type_string(type), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, "%s: flags %c", + cdnsp_trb_type_string(type), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_SETUP: - ret +=3D snprintf(str, size, - "type '%s' bRequestType %02x bRequest %02x " - "wValue %02x%02x wIndex %02x%02x wLength %d " - "length %ld TD size %ld intr %ld Setup ID %ld " - "flags %c:%c:%c", - cdnsp_trb_type_string(type), - field0 & 0xff, - (field0 & 0xff00) >> 8, - (field0 & 0xff000000) >> 24, - (field0 & 0xff0000) >> 16, - (field1 & 0xff00) >> 8, - field1 & 0xff, - (field1 & 0xff000000) >> 16 | - (field1 & 0xff0000) >> 16, - TRB_LEN(field2), GET_TD_SIZE(field2), - GET_INTR_TARGET(field2), - TRB_SETUPID_TO_TYPE(field3), - field3 & TRB_IDT ? 'D' : 'd', - field3 & TRB_IOC ? 'I' : 'i', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "type '%s' bRequestType %02x bRequest %02x " + "wValue %02x%02x wIndex %02x%02x wLength %d " + "length %ld TD size %ld intr %ld Setup ID %ld " + "flags %c:%c:%c", + cdnsp_trb_type_string(type), + field0 & 0xff, + (field0 & 0xff00) >> 8, + (field0 & 0xff000000) >> 24, + (field0 & 0xff0000) >> 16, + (field1 & 0xff00) >> 8, + field1 & 0xff, + (field1 & 0xff000000) >> 16 | + (field1 & 0xff0000) >> 16, + TRB_LEN(field2), GET_TD_SIZE(field2), + GET_INTR_TARGET(field2), + TRB_SETUPID_TO_TYPE(field3), + field3 & TRB_IDT ? 'D' : 'd', + field3 & TRB_IOC ? 'I' : 'i', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_DATA: - ret +=3D snprintf(str, size, - "type '%s' Buffer %08x%08x length %ld TD size %ld " - "intr %ld flags %c:%c:%c:%c:%c:%c:%c", - cdnsp_trb_type_string(type), - field1, field0, TRB_LEN(field2), - GET_TD_SIZE(field2), - GET_INTR_TARGET(field2), - field3 & TRB_IDT ? 'D' : 'i', - field3 & TRB_IOC ? 'I' : 'i', - field3 & TRB_CHAIN ? 'C' : 'c', - field3 & TRB_NO_SNOOP ? 'S' : 's', - field3 & TRB_ISP ? 'I' : 'i', - field3 & TRB_ENT ? 'E' : 'e', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "type '%s' Buffer %08x%08x length %ld TD size %ld " + "intr %ld flags %c:%c:%c:%c:%c:%c:%c", + cdnsp_trb_type_string(type), + field1, field0, TRB_LEN(field2), + GET_TD_SIZE(field2), + GET_INTR_TARGET(field2), + field3 & TRB_IDT ? 'D' : 'i', + field3 & TRB_IOC ? 'I' : 'i', + field3 & TRB_CHAIN ? 'C' : 'c', + field3 & TRB_NO_SNOOP ? 'S' : 's', + field3 & TRB_ISP ? 'I' : 'i', + field3 & TRB_ENT ? 'E' : 'e', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_STATUS: - ret +=3D snprintf(str, size, - "Buffer %08x%08x length %ld TD size %ld intr" - "%ld type '%s' flags %c:%c:%c:%c", - field1, field0, TRB_LEN(field2), - GET_TD_SIZE(field2), - GET_INTR_TARGET(field2), - cdnsp_trb_type_string(type), - field3 & TRB_IOC ? 'I' : 'i', - field3 & TRB_CHAIN ? 'C' : 'c', - field3 & TRB_ENT ? 'E' : 'e', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "Buffer %08x%08x length %ld TD size %ld intr" + "%ld type '%s' flags %c:%c:%c:%c", + field1, field0, TRB_LEN(field2), + GET_TD_SIZE(field2), + GET_INTR_TARGET(field2), + cdnsp_trb_type_string(type), + field3 & TRB_IOC ? 'I' : 'i', + field3 & TRB_CHAIN ? 'C' : 'c', + field3 & TRB_ENT ? 'E' : 'e', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_NORMAL: case TRB_ISOC: case TRB_EVENT_DATA: case TRB_TR_NOOP: - ret +=3D snprintf(str, size, - "type '%s' Buffer %08x%08x length %ld " - "TD size %ld intr %ld " - "flags %c:%c:%c:%c:%c:%c:%c:%c:%c", - cdnsp_trb_type_string(type), - field1, field0, TRB_LEN(field2), - GET_TD_SIZE(field2), - GET_INTR_TARGET(field2), - field3 & TRB_BEI ? 'B' : 'b', - field3 & TRB_IDT ? 'T' : 't', - field3 & TRB_IOC ? 'I' : 'i', - field3 & TRB_CHAIN ? 'C' : 'c', - field3 & TRB_NO_SNOOP ? 'S' : 's', - field3 & TRB_ISP ? 'I' : 'i', - field3 & TRB_ENT ? 'E' : 'e', - field3 & TRB_CYCLE ? 'C' : 'c', - !(field3 & TRB_EVENT_INVALIDATE) ? 'V' : 'v'); + ret =3D snprintf(str, size, + "type '%s' Buffer %08x%08x length %ld " + "TD size %ld intr %ld " + "flags %c:%c:%c:%c:%c:%c:%c:%c:%c", + cdnsp_trb_type_string(type), + field1, field0, TRB_LEN(field2), + GET_TD_SIZE(field2), + GET_INTR_TARGET(field2), + field3 & TRB_BEI ? 'B' : 'b', + field3 & TRB_IDT ? 'T' : 't', + field3 & TRB_IOC ? 'I' : 'i', + field3 & TRB_CHAIN ? 'C' : 'c', + field3 & TRB_NO_SNOOP ? 'S' : 's', + field3 & TRB_ISP ? 'I' : 'i', + field3 & TRB_ENT ? 'E' : 'e', + field3 & TRB_CYCLE ? 'C' : 'c', + !(field3 & TRB_EVENT_INVALIDATE) ? 'V' : 'v'); break; case TRB_CMD_NOOP: case TRB_ENABLE_SLOT: - ret +=3D snprintf(str, size, "%s: flags %c", - cdnsp_trb_type_string(type), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, "%s: flags %c", + cdnsp_trb_type_string(type), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_DISABLE_SLOT: - ret +=3D snprintf(str, size, "%s: slot %ld flags %c", - cdnsp_trb_type_string(type), - TRB_TO_SLOT_ID(field3), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, "%s: slot %ld flags %c", + cdnsp_trb_type_string(type), + TRB_TO_SLOT_ID(field3), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_ADDR_DEV: - ret +=3D snprintf(str, size, - "%s: ctx %08x%08x slot %ld flags %c:%c", - cdnsp_trb_type_string(type), field1, field0, - TRB_TO_SLOT_ID(field3), - field3 & TRB_BSR ? 'B' : 'b', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "%s: ctx %08x%08x slot %ld flags %c:%c", + cdnsp_trb_type_string(type), field1, field0, + TRB_TO_SLOT_ID(field3), + field3 & TRB_BSR ? 'B' : 'b', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_CONFIG_EP: - ret +=3D snprintf(str, size, - "%s: ctx %08x%08x slot %ld flags %c:%c", - cdnsp_trb_type_string(type), field1, field0, - TRB_TO_SLOT_ID(field3), - field3 & TRB_DC ? 'D' : 'd', - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "%s: ctx %08x%08x slot %ld flags %c:%c", + cdnsp_trb_type_string(type), field1, field0, + TRB_TO_SLOT_ID(field3), + field3 & TRB_DC ? 'D' : 'd', + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_EVAL_CONTEXT: - ret +=3D snprintf(str, size, - "%s: ctx %08x%08x slot %ld flags %c", - cdnsp_trb_type_string(type), field1, field0, - TRB_TO_SLOT_ID(field3), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "%s: ctx %08x%08x slot %ld flags %c", + cdnsp_trb_type_string(type), field1, field0, + TRB_TO_SLOT_ID(field3), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_RESET_EP: case TRB_HALT_ENDPOINT: case TRB_FLUSH_ENDPOINT: - ret +=3D snprintf(str, size, - "%s: ep%d%s(%d) ctx %08x%08x slot %ld flags %c", - cdnsp_trb_type_string(type), - ep_num, ep_id % 2 ? "out" : "in", - TRB_TO_EP_INDEX(field3), field1, field0, - TRB_TO_SLOT_ID(field3), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "%s: ep%d%s(%d) ctx %08x%08x slot %ld flags %c", + cdnsp_trb_type_string(type), + ep_num, ep_id % 2 ? "out" : "in", + TRB_TO_EP_INDEX(field3), field1, field0, + TRB_TO_SLOT_ID(field3), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_STOP_RING: - ret +=3D snprintf(str, size, - "%s: ep%d%s(%d) slot %ld sp %d flags %c", - cdnsp_trb_type_string(type), - ep_num, ep_id % 2 ? "out" : "in", - TRB_TO_EP_INDEX(field3), - TRB_TO_SLOT_ID(field3), - TRB_TO_SUSPEND_PORT(field3), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "%s: ep%d%s(%d) slot %ld sp %d flags %c", + cdnsp_trb_type_string(type), + ep_num, ep_id % 2 ? "out" : "in", + TRB_TO_EP_INDEX(field3), + TRB_TO_SLOT_ID(field3), + TRB_TO_SUSPEND_PORT(field3), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_SET_DEQ: - ret +=3D snprintf(str, size, - "%s: ep%d%s(%d) deq %08x%08x stream %ld slot %ld flags %c", - cdnsp_trb_type_string(type), - ep_num, ep_id % 2 ? "out" : "in", - TRB_TO_EP_INDEX(field3), field1, field0, - TRB_TO_STREAM_ID(field2), - TRB_TO_SLOT_ID(field3), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, + "%s: ep%d%s(%d) deq %08x%08x stream %ld slot %ld flags %c", + cdnsp_trb_type_string(type), + ep_num, ep_id % 2 ? "out" : "in", + TRB_TO_EP_INDEX(field3), field1, field0, + TRB_TO_STREAM_ID(field2), + TRB_TO_SLOT_ID(field3), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_RESET_DEV: - ret +=3D snprintf(str, size, "%s: slot %ld flags %c", - cdnsp_trb_type_string(type), - TRB_TO_SLOT_ID(field3), - field3 & TRB_CYCLE ? 'C' : 'c'); + ret =3D snprintf(str, size, "%s: slot %ld flags %c", + cdnsp_trb_type_string(type), + TRB_TO_SLOT_ID(field3), + field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_ENDPOINT_NRDY: - temp =3D TRB_TO_HOST_STREAM(field2); - - ret +=3D snprintf(str, size, - "%s: ep%d%s(%d) H_SID %x%s%s D_SID %lx flags %c:%c", - cdnsp_trb_type_string(type), - ep_num, ep_id % 2 ? "out" : "in", - TRB_TO_EP_INDEX(field3), temp, - temp =3D=3D STREAM_PRIME_ACK ? "(PRIME)" : "", - temp =3D=3D STREAM_REJECTED ? "(REJECTED)" : "", - TRB_TO_DEV_STREAM(field0), - field3 & TRB_STAT ? 'S' : 's', - field3 & TRB_CYCLE ? 'C' : 'c'); + temp =3D TRB_TO_HOST_STREAM(field2); + + ret =3D snprintf(str, size, + "%s: ep%d%s(%d) H_SID %x%s%s D_SID %lx flags %c:%c", + cdnsp_trb_type_string(type), + ep_num, ep_id % 2 ? "out" : "in", + TRB_TO_EP_INDEX(field3), temp, + temp =3D=3D STREAM_PRIME_ACK ? "(PRIME)" : "", + temp =3D=3D STREAM_REJECTED ? "(REJECTED)" : "", + TRB_TO_DEV_STREAM(field0), + field3 & TRB_STAT ? 'S' : 's', + field3 & TRB_CYCLE ? 'C' : 'c'); break; default: - ret +=3D snprintf(str, size, - "type '%s' -> raw %08x %08x %08x %08x", - cdnsp_trb_type_string(type), - field0, field1, field2, field3); + ret =3D snprintf(str, size, + "type '%s' -> raw %08x %08x %08x %08x", + cdnsp_trb_type_string(type), + field0, field1, field2, field3); } =20 + if (ret >=3D size) + pr_info("CDNSP: buffer overflowed.\n"); + return str; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C86B8C4332F for ; Tue, 12 Apr 2022 08:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386630AbiDLI6s (ORCPT ); Tue, 12 Apr 2022 04:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356795AbiDLHjW (ORCPT ); Tue, 12 Apr 2022 03:39:22 -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 30FF44A90F; Tue, 12 Apr 2022 00:10: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 A9DAFB81895; Tue, 12 Apr 2022 07:10:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 040E3C385A1; Tue, 12 Apr 2022 07:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747402; bh=qjaUBTBW20T7UWuTxWW0iMkCQ6k2PxjPtqmtjDEux3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rPjY24McQugeI9KabaFlSOFZtmjjlsGoh23RydPkfWvlnveMCVFJ5NNDeUxeLLjqa SFzH7cTxN+COJEnOxGBScC3Q9rQEwhs9ouaUmTaAEoYI9JbdNGaJQIO8/yRYpFj/Cv zPcfCD7DspQMxgZ7dbxWGp13CYIBwnib1A/nI9H0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , Yang Guang , David Yang , Richard Cochran , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 026/343] ptp: replace snprintf with sysfs_emit Date: Tue, 12 Apr 2022 08:27:24 +0200 Message-Id: <20220412062951.859246979@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yang Guang [ Upstream commit e2cf07654efb0fd7bbcb475c6f74be7b5755a8fd ] coccinelle report: ./drivers/ptp/ptp_sysfs.c:17:8-16: WARNING: use scnprintf or sprintf ./drivers/ptp/ptp_sysfs.c:390:8-16: WARNING: use scnprintf or sprintf Use sysfs_emit instead of scnprintf or sprintf makes more sense. Reported-by: Zeal Robot Signed-off-by: Yang Guang Signed-off-by: David Yang Acked-by: Richard Cochran Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/ptp/ptp_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c index 41b92dc2f011..9233bfedeb17 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -14,7 +14,7 @@ static ssize_t clock_name_show(struct device *dev, struct device_attribute *attr, char *page) { struct ptp_clock *ptp =3D dev_get_drvdata(dev); - return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name); + return sysfs_emit(page, "%s\n", ptp->info->name); } static DEVICE_ATTR_RO(clock_name); =20 @@ -387,7 +387,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct = device_attribute *attr, =20 mutex_unlock(&ptp->pincfg_mux); =20 - return snprintf(page, PAGE_SIZE, "%u %u\n", func, chan); + return sysfs_emit(page, "%u %u\n", func, chan); } =20 static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *= attr, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 84D95C352A1 for ; Tue, 12 Apr 2022 08:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383616AbiDLIhb (ORCPT ); Tue, 12 Apr 2022 04:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356782AbiDLHjV (ORCPT ); Tue, 12 Apr 2022 03:39:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413A852B05; Tue, 12 Apr 2022 00:10: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 ams.source.kernel.org (Postfix) with ESMTPS id 8AA6FB81B4F; Tue, 12 Apr 2022 07:10:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3015C385A5; Tue, 12 Apr 2022 07:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747405; bh=fFmeQeLVr78bZio484MKOB9cuQ1QBglk5UFyOuYQChI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qwY+aVRq2rWCnwB8yjGYA/k2opQ2GfdOGGGlj+Og8KVkDFDMde7kvwrH9pQLxxFGp HC3u/3auJqfLSztKzGL9LYZBIJyq954TE37w3Y+r4vWjgRDc4Jt/kQHpEHWuDcXVVq 48NqXhniDWn4G13UOlYPGFaYz+ZbAw592UPKhGeo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.17 027/343] Bluetooth: hci_sync: Fix queuing commands when HCI_UNREGISTER is set Date: Tue, 12 Apr 2022 08:27:25 +0200 Message-Id: <20220412062951.888710019@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Luiz Augusto von Dentz [ Upstream commit 0b94f2651f56b9e4aa5f012b0d7eb57308c773cf ] hci_cmd_sync_queue shall return an error if HCI_UNREGISTER flag has been set as that means hci_unregister_dev has been called so it will likely cause a uaf after the timeout as the hdev will be freed. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/bluetooth/hci_sync.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 48c837530a11..8f4c5698913d 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -379,6 +379,9 @@ int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sy= nc_work_func_t func, { struct hci_cmd_sync_work_entry *entry; =20 + if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) + return -ENODEV; + entry =3D kmalloc(sizeof(*entry), GFP_KERNEL); if (!entry) return -ENOMEM; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B7C8BC43219 for ; Tue, 12 Apr 2022 08:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357364AbiDLISb (ORCPT ); Tue, 12 Apr 2022 04:18:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355747AbiDLH3S (ORCPT ); Tue, 12 Apr 2022 03:29:18 -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 478694F477; Tue, 12 Apr 2022 00:08: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 dfw.source.kernel.org (Postfix) with ESMTPS id C9008616B3; Tue, 12 Apr 2022 07:08:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D39FEC385A6; Tue, 12 Apr 2022 07:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747295; bh=sKVhV7fgBd8sxwJqL0C6kTu4zyY3fj413l1HQZdr/vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YK6DsxmbL+UZXcMeOYeLj9TXuY5nQjwVznlY/STaQBI73YLxNwNOOnI9RpupuSyGi 6dj9hES1bifPoX3ZB7H5yJsEz1b/jz0coQX3iYsutljShzelMHkBKEqjtFGqRsdj4n rGvkbgtFnaUlKggSm7tpuY7Ydui+JN4v6C6FWYIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , Magnus Karlsson , Daniel Borkmann , John Fastabend , Sasha Levin Subject: [PATCH 5.17 028/343] selftests, xsk: Fix bpf_res cleanup test Date: Tue, 12 Apr 2022 08:27:26 +0200 Message-Id: <20220412062951.918237990@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Magnus Karlsson [ Upstream commit 3b22523bca02b0d5618c08b93d8fd1fb578e1cc3 ] After commit 710ad98c363a ("veth: Do not record rx queue hint in veth_xmit"= ), veth no longer receives traffic on the same queue as it was sent on. This breaks the bpf_res test for the AF_XDP selftests as the socket tied to queue 1 will not receive traffic anymore. Modify the test so that two sockets are tied to queue id 0 using a shared umem instead. When killing the first socket enter the second socket into the xskmap so that traffic will flow to it. This will still test that the resources are not cleaned up until after the second socket dies, without having to rely on veth supporting rx_queue hints. Reported-by: Maciej Fijalkowski Signed-off-by: Magnus Karlsson Signed-off-by: Daniel Borkmann Reviewed-by: Maciej Fijalkowski Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20220125082945.26179-1-magnus.karlsson@gm= ail.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/bpf/xdpxceiver.c | 80 +++++++++++++++--------- tools/testing/selftests/bpf/xdpxceiver.h | 2 +- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selft= ests/bpf/xdpxceiver.c index ffa5502ad95e..5f8296d29e77 100644 --- a/tools/testing/selftests/bpf/xdpxceiver.c +++ b/tools/testing/selftests/bpf/xdpxceiver.c @@ -266,22 +266,24 @@ static int xsk_configure_umem(struct xsk_umem_info *u= mem, void *buffer, u64 size } =20 static int xsk_configure_socket(struct xsk_socket_info *xsk, struct xsk_um= em_info *umem, - struct ifobject *ifobject, u32 qid) + struct ifobject *ifobject, bool shared) { - struct xsk_socket_config cfg; + struct xsk_socket_config cfg =3D {}; struct xsk_ring_cons *rxr; struct xsk_ring_prod *txr; =20 xsk->umem =3D umem; cfg.rx_size =3D xsk->rxqsize; cfg.tx_size =3D XSK_RING_PROD__DEFAULT_NUM_DESCS; - cfg.libbpf_flags =3D 0; + cfg.libbpf_flags =3D XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD; cfg.xdp_flags =3D ifobject->xdp_flags; cfg.bind_flags =3D ifobject->bind_flags; + if (shared) + cfg.bind_flags |=3D XDP_SHARED_UMEM; =20 txr =3D ifobject->tx_on ? &xsk->tx : NULL; rxr =3D ifobject->rx_on ? &xsk->rx : NULL; - return xsk_socket__create(&xsk->xsk, ifobject->ifname, qid, umem->umem, r= xr, txr, &cfg); + return xsk_socket__create(&xsk->xsk, ifobject->ifname, 0, umem->umem, rxr= , txr, &cfg); } =20 static struct option long_options[] =3D { @@ -387,7 +389,6 @@ static void __test_spec_init(struct test_spec *test, st= ruct ifobject *ifobj_tx, for (i =3D 0; i < MAX_INTERFACES; i++) { struct ifobject *ifobj =3D i ? ifobj_rx : ifobj_tx; =20 - ifobj->umem =3D &ifobj->umem_arr[0]; ifobj->xsk =3D &ifobj->xsk_arr[0]; ifobj->use_poll =3D false; ifobj->pacing_on =3D true; @@ -401,11 +402,12 @@ static void __test_spec_init(struct test_spec *test, = struct ifobject *ifobj_tx, ifobj->tx_on =3D false; } =20 + memset(ifobj->umem, 0, sizeof(*ifobj->umem)); + ifobj->umem->num_frames =3D DEFAULT_UMEM_BUFFERS; + ifobj->umem->frame_size =3D XSK_UMEM__DEFAULT_FRAME_SIZE; + for (j =3D 0; j < MAX_SOCKETS; j++) { - memset(&ifobj->umem_arr[j], 0, sizeof(ifobj->umem_arr[j])); memset(&ifobj->xsk_arr[j], 0, sizeof(ifobj->xsk_arr[j])); - ifobj->umem_arr[j].num_frames =3D DEFAULT_UMEM_BUFFERS; - ifobj->umem_arr[j].frame_size =3D XSK_UMEM__DEFAULT_FRAME_SIZE; ifobj->xsk_arr[j].rxqsize =3D XSK_RING_CONS__DEFAULT_NUM_DESCS; } } @@ -950,7 +952,10 @@ static void tx_stats_validate(struct ifobject *ifobjec= t) =20 static void thread_common_ops(struct test_spec *test, struct ifobject *ifo= bject) { + u64 umem_sz =3D ifobject->umem->num_frames * ifobject->umem->frame_size; int mmap_flags =3D MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE; + int ret, ifindex; + void *bufs; u32 i; =20 ifobject->ns_fd =3D switch_namespace(ifobject->nsname); @@ -958,23 +963,20 @@ static void thread_common_ops(struct test_spec *test,= struct ifobject *ifobject) if (ifobject->umem->unaligned_mode) mmap_flags |=3D MAP_HUGETLB; =20 - for (i =3D 0; i < test->nb_sockets; i++) { - u64 umem_sz =3D ifobject->umem->num_frames * ifobject->umem->frame_size; - u32 ctr =3D 0; - void *bufs; - int ret; + bufs =3D mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, 0); + if (bufs =3D=3D MAP_FAILED) + exit_with_error(errno); =20 - bufs =3D mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, 0); - if (bufs =3D=3D MAP_FAILED) - exit_with_error(errno); + ret =3D xsk_configure_umem(ifobject->umem, bufs, umem_sz); + if (ret) + exit_with_error(-ret); =20 - ret =3D xsk_configure_umem(&ifobject->umem_arr[i], bufs, umem_sz); - if (ret) - exit_with_error(-ret); + for (i =3D 0; i < test->nb_sockets; i++) { + u32 ctr =3D 0; =20 while (ctr++ < SOCK_RECONF_CTR) { - ret =3D xsk_configure_socket(&ifobject->xsk_arr[i], &ifobject->umem_arr= [i], - ifobject, i); + ret =3D xsk_configure_socket(&ifobject->xsk_arr[i], ifobject->umem, + ifobject, !!i); if (!ret) break; =20 @@ -985,8 +987,22 @@ static void thread_common_ops(struct test_spec *test, = struct ifobject *ifobject) } } =20 - ifobject->umem =3D &ifobject->umem_arr[0]; ifobject->xsk =3D &ifobject->xsk_arr[0]; + + if (!ifobject->rx_on) + return; + + ifindex =3D if_nametoindex(ifobject->ifname); + if (!ifindex) + exit_with_error(errno); + + ret =3D xsk_setup_xdp_prog(ifindex, &ifobject->xsk_map_fd); + if (ret) + exit_with_error(-ret); + + ret =3D xsk_socket__update_xskmap(ifobject->xsk->xsk, ifobject->xsk_map_f= d); + if (ret) + exit_with_error(-ret); } =20 static void testapp_cleanup_xsk_res(struct ifobject *ifobj) @@ -1142,14 +1158,16 @@ static void testapp_bidi(struct test_spec *test) =20 static void swap_xsk_resources(struct ifobject *ifobj_tx, struct ifobject = *ifobj_rx) { + int ret; + xsk_socket__delete(ifobj_tx->xsk->xsk); - xsk_umem__delete(ifobj_tx->umem->umem); xsk_socket__delete(ifobj_rx->xsk->xsk); - xsk_umem__delete(ifobj_rx->umem->umem); - ifobj_tx->umem =3D &ifobj_tx->umem_arr[1]; ifobj_tx->xsk =3D &ifobj_tx->xsk_arr[1]; - ifobj_rx->umem =3D &ifobj_rx->umem_arr[1]; ifobj_rx->xsk =3D &ifobj_rx->xsk_arr[1]; + + ret =3D xsk_socket__update_xskmap(ifobj_rx->xsk->xsk, ifobj_rx->xsk_map_f= d); + if (ret) + exit_with_error(-ret); } =20 static void testapp_bpf_res(struct test_spec *test) @@ -1408,13 +1426,13 @@ static struct ifobject *ifobject_create(void) if (!ifobj->xsk_arr) goto out_xsk_arr; =20 - ifobj->umem_arr =3D calloc(MAX_SOCKETS, sizeof(*ifobj->umem_arr)); - if (!ifobj->umem_arr) - goto out_umem_arr; + ifobj->umem =3D calloc(1, sizeof(*ifobj->umem)); + if (!ifobj->umem) + goto out_umem; =20 return ifobj; =20 -out_umem_arr: +out_umem: free(ifobj->xsk_arr); out_xsk_arr: free(ifobj); @@ -1423,7 +1441,7 @@ static struct ifobject *ifobject_create(void) =20 static void ifobject_delete(struct ifobject *ifobj) { - free(ifobj->umem_arr); + free(ifobj->umem); free(ifobj->xsk_arr); free(ifobj); } diff --git a/tools/testing/selftests/bpf/xdpxceiver.h b/tools/testing/selft= ests/bpf/xdpxceiver.h index 2f705f44b748..62a3e6388632 100644 --- a/tools/testing/selftests/bpf/xdpxceiver.h +++ b/tools/testing/selftests/bpf/xdpxceiver.h @@ -125,10 +125,10 @@ struct ifobject { struct xsk_socket_info *xsk; struct xsk_socket_info *xsk_arr; struct xsk_umem_info *umem; - struct xsk_umem_info *umem_arr; thread_func_t func_ptr; struct pkt_stream *pkt_stream; int ns_fd; + int xsk_map_fd; u32 dst_ip; u32 src_ip; u32 xdp_flags; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1321CC4167B for ; Tue, 12 Apr 2022 08:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378906AbiDLIT1 (ORCPT ); Tue, 12 Apr 2022 04:19:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355770AbiDLH3U (ORCPT ); Tue, 12 Apr 2022 03:29:20 -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 09D064F9D0; Tue, 12 Apr 2022 00:08: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 dfw.source.kernel.org (Postfix) with ESMTPS id 89E846153F; Tue, 12 Apr 2022 07:08:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91CDEC385AA; Tue, 12 Apr 2022 07:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747297; bh=TLcidT5nSdUPWRTJlzEe0XdgaB1ECW1jsaCBputjuLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHOCr6OcODzo7Z6OF/xcXOMTaTAEsm17JpJWG7M3hW2Ui5KQ/fEj4TYJ3UrtmeiqH BcyfbQVyyMThxarP9uU56CAn+ThvV8N/CIKEuuXSmqdTavjbvgDqbUBleswBjR6H+Y sj1CkJlpKV8kI0901j36Sat2517jblXZJJO3kUR0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roi Dayan , Oz Shlomo , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.17 029/343] net/mlx5e: TC, Hold sample_attr on stack instead of pointer Date: Tue, 12 Apr 2022 08:27:27 +0200 Message-Id: <20220412062951.946882878@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Roi Dayan [ Upstream commit eeed226ed110ed40598e60e29b66643012277be7 ] In later commit we are going to instantiate multiple attr instances for flow instead of single attr. Parsing TC sample allocates a new memory but there is no symmetric cleanup in the infrastructure. To avoid asymmetric alloc/free use sample_attr as part of the flow attr and not allocated and held as a pointer. This will avoid a cleanup leak when sample action is not on the first attr. Signed-off-by: Roi Dayan Reviewed-by: Oz Shlomo Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- .../net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c | 7 +------ drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c | 10 +++++----- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 +- .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 6 +++--- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c b/d= rivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c index 6699bdf5cf01..b895c378cfaf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c @@ -27,11 +27,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *par= se_state, struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) { - struct mlx5e_sample_attr *sample_attr; - - sample_attr =3D kzalloc(sizeof(*attr->sample_attr), GFP_KERNEL); - if (!sample_attr) - return -ENOMEM; + struct mlx5e_sample_attr *sample_attr =3D &attr->sample_attr; =20 sample_attr->rate =3D act->sample.rate; sample_attr->group_num =3D act->sample.psample_group->group_num; @@ -39,7 +35,6 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *pars= e_state, if (act->sample.truncate) sample_attr->trunc_size =3D act->sample.trunc_size; =20 - attr->sample_attr =3D sample_attr; flow_flag_set(parse_state->flow, SAMPLE); =20 return 0; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c b/drive= rs/net/ethernet/mellanox/mlx5/core/en/tc/sample.c index ff4b4f8a5a9d..0faaf9a4b531 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c @@ -513,7 +513,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psa= mple, sample_flow =3D kzalloc(sizeof(*sample_flow), GFP_KERNEL); if (!sample_flow) return ERR_PTR(-ENOMEM); - sample_attr =3D attr->sample_attr; + sample_attr =3D &attr->sample_attr; sample_attr->sample_flow =3D sample_flow; =20 /* For NICs with reg_c_preserve support or decap action, use @@ -546,6 +546,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psa= mple, err =3D PTR_ERR(sample_flow->sampler); goto err_sampler; } + sample_attr->sampler_id =3D sample_flow->sampler->sampler_id; =20 /* Create an id mapping reg_c0 value to sample object. */ restore_obj.type =3D MLX5_MAPPED_OBJ_SAMPLE; @@ -585,8 +586,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psa= mple, pre_attr->outer_match_level =3D attr->outer_match_level; pre_attr->chain =3D attr->chain; pre_attr->prio =3D attr->prio; - pre_attr->sample_attr =3D attr->sample_attr; - sample_attr->sampler_id =3D sample_flow->sampler->sampler_id; + pre_attr->sample_attr =3D *sample_attr; pre_esw_attr =3D pre_attr->esw_attr; pre_esw_attr->in_mdev =3D esw_attr->in_mdev; pre_esw_attr->in_rep =3D esw_attr->in_rep; @@ -633,11 +633,11 @@ mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc= _psample, * will hit fw syndromes. */ esw =3D tc_psample->esw; - sample_flow =3D attr->sample_attr->sample_flow; + sample_flow =3D attr->sample_attr.sample_flow; mlx5_eswitch_del_offloaded_rule(esw, sample_flow->pre_rule, sample_flow->= pre_attr); =20 sample_restore_put(tc_psample, sample_flow->restore); - mapping_remove(esw->offloads.reg_c0_obj_pool, attr->sample_attr->restore_= obj_id); + mapping_remove(esw->offloads.reg_c0_obj_pool, attr->sample_attr.restore_o= bj_id); sampler_put(tc_psample, sample_flow->sampler); if (sample_flow->post_act_handle) mlx5e_tc_post_act_del(tc_psample->post_act, sample_flow->post_act_handle= ); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_tc.c index b27532a9301e..7e5c00349ccf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -1634,7 +1634,6 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *= priv, if (flow_flag_test(flow, L3_TO_L2_DECAP)) mlx5e_detach_decap(priv, flow); =20 - kfree(attr->sample_attr); kvfree(attr->esw_attr->rx_tun_attr); kvfree(attr->parse_attr); kfree(flow->attr); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/= ethernet/mellanox/mlx5/core/en_tc.h index 5ffae9b13066..2f09e34db9ff 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h @@ -71,7 +71,7 @@ struct mlx5_flow_attr { struct mlx5_fc *counter; struct mlx5_modify_hdr *modify_hdr; struct mlx5_ct_attr ct_attr; - struct mlx5e_sample_attr *sample_attr; + struct mlx5e_sample_attr sample_attr; struct mlx5e_tc_flow_parse_attr *parse_attr; u32 chain; u16 prio; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/d= rivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index cfcd72bad9af..e7e7b4b0dcdb 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c @@ -201,12 +201,12 @@ esw_cleanup_decap_indir(struct mlx5_eswitch *esw, static int esw_setup_sampler_dest(struct mlx5_flow_destination *dest, struct mlx5_flow_act *flow_act, - struct mlx5_flow_attr *attr, + u32 sampler_id, int i) { flow_act->flags |=3D FLOW_ACT_IGNORE_FLOW_LEVEL; dest[i].type =3D MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER; - dest[i].sampler_id =3D attr->sample_attr->sampler_id; + dest[i].sampler_id =3D sampler_id; =20 return 0; } @@ -466,7 +466,7 @@ esw_setup_dests(struct mlx5_flow_destination *dest, attr->flags |=3D MLX5_ESW_ATTR_FLAG_SRC_REWRITE; =20 if (attr->flags & MLX5_ESW_ATTR_FLAG_SAMPLE) { - esw_setup_sampler_dest(dest, flow_act, attr, *i); + esw_setup_sampler_dest(dest, flow_act, attr->sample_attr.sampler_id, *i); (*i)++; } else if (attr->dest_ft) { esw_setup_ft_dest(dest, flow_act, esw, attr, spec, *i); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 0DA64C4332F for ; Tue, 12 Apr 2022 08:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379493AbiDLIUf (ORCPT ); Tue, 12 Apr 2022 04:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355801AbiDLH3W (ORCPT ); Tue, 12 Apr 2022 03:29:22 -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 0EF0D4F9EF; Tue, 12 Apr 2022 00:08: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 566B7616E3; Tue, 12 Apr 2022 07:08:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68861C385A1; Tue, 12 Apr 2022 07:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747300; bh=Me+BbeK8TrKlngWFOxZmgxcvmrkuXu2Fd9tMqyMU6Vc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i8x0AJugTPnB/HS95WhbGJO86qaRJx6ZNNFWlxj7wd1YOA4PLVXORmrCiUeTnwOQd iU8P3+CDaV8MYxWmopNYcvaJsWbY6yFGFjREG5/G8VUkDWmhhacJJ4z3yH51WbQf7y cAxvJo6lH7GGnt1D2wfFiUci1OYhmN+VOqX8yQJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philip Yang , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 030/343] drm/amdkfd: Dont take process mutex for svm ioctls Date: Tue, 12 Apr 2022 08:27:28 +0200 Message-Id: <20220412062951.975802742@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Philip Yang [ Upstream commit ac7c48c0cce00d03b3c95fddcccb0a45257e33e3 ] SVM ioctls take proper svms->lock to handle race conditions, don't need take process mutex to serialize ioctls. This also fixes circular locking warning: WARNING: possible circular locking dependency detected Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((work_completion)(&svms->deferred_list_work)); lock(&process->mutex); lock((work_completion)(&svms->deferred_list_work)); lock(&process->mutex); *** DEADLOCK *** Signed-off-by: Philip Yang Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd= /amdkfd/kfd_chardev.c index 337953af7c2f..70122978bdd0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1846,13 +1846,9 @@ static int kfd_ioctl_svm(struct file *filep, struct = kfd_process *p, void *data) if (!args->start_addr || !args->size) return -EINVAL; =20 - mutex_lock(&p->mutex); - r =3D svm_ioctl(p, args->op, args->start_addr, args->size, args->nattr, args->attrs); =20 - mutex_unlock(&p->mutex); - return r; } #else --=20 2.35.1 From nobody Thu May 14 08:08:21 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 50E09C3527B for ; Tue, 12 Apr 2022 08:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379444AbiDLIUb (ORCPT ); Tue, 12 Apr 2022 04:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355863AbiDLH3b (ORCPT ); Tue, 12 Apr 2022 03:29: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 D76CC4FC4E; Tue, 12 Apr 2022 00:08: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 dfw.source.kernel.org (Postfix) with ESMTPS id 0A88F616C5; Tue, 12 Apr 2022 07:08:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DA69C385A1; Tue, 12 Apr 2022 07:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747303; bh=uvmvK5G4Vh3vydzA/XSSQgtsGxMG1xvRkHz1oUWROgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1kf8i/TBlbV5LdNnS5aw6QXIdeXrZBoSzhiz8U6hp9wVVy8aMuxH2yYnrInxn5vW4 GBvji5V1SY7MOKT5T/cVp+a9wqqLl4gmO62ibe0d2CgA54WzFnF23arYXU5YlZpM75 EWkcw72dU+ebfaEE1qQ1PJyDxIrQ6jVSbA2UdgHg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philip Yang , Ruili Ji , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 031/343] drm/amdkfd: Ensure mm remain valid in svm deferred_list work Date: Tue, 12 Apr 2022 08:27:29 +0200 Message-Id: <20220412062952.004344561@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Philip Yang [ Upstream commit 367c9b0f1b8750a704070e7ae85234d591290434 ] svm_deferred_list work should continue to handle deferred_range_list which maybe split to child range to avoid child range leak, and remove ranges mmu interval notifier to avoid mm mm_count leak. So taking mm reference when adding range to deferred list, to ensure mm is valid in the scheduled deferred_list_work, and drop the mm referrence after range is handled. Signed-off-by: Philip Yang Reported-by: Ruili Ji Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 62 ++++++++++++++++------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amd= kfd/kfd_svm.c index f2805ba74c80..225affcddbc1 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1985,10 +1985,9 @@ svm_range_update_notifier_and_interval_tree(struct m= m_struct *mm, } =20 static void -svm_range_handle_list_op(struct svm_range_list *svms, struct svm_range *pr= ange) +svm_range_handle_list_op(struct svm_range_list *svms, struct svm_range *pr= ange, + struct mm_struct *mm) { - struct mm_struct *mm =3D prange->work_item.mm; - switch (prange->work_item.op) { case SVM_OP_NULL: pr_debug("NULL OP 0x%p prange 0x%p [0x%lx 0x%lx]\n", @@ -2071,34 +2070,41 @@ static void svm_range_deferred_list_work(struct wor= k_struct *work) pr_debug("enter svms 0x%p\n", svms); =20 p =3D container_of(svms, struct kfd_process, svms); - /* Avoid mm is gone when inserting mmu notifier */ - mm =3D get_task_mm(p->lead_thread); - if (!mm) { - pr_debug("svms 0x%p process mm gone\n", svms); - return; - } -retry: - mmap_write_lock(mm); - - /* Checking for the need to drain retry faults must be inside - * mmap write lock to serialize with munmap notifiers. - */ - if (unlikely(atomic_read(&svms->drain_pagefaults))) { - mmap_write_unlock(mm); - svm_range_drain_retry_fault(svms); - goto retry; - } =20 spin_lock(&svms->deferred_list_lock); while (!list_empty(&svms->deferred_range_list)) { prange =3D list_first_entry(&svms->deferred_range_list, struct svm_range, deferred_list); - list_del_init(&prange->deferred_list); spin_unlock(&svms->deferred_list_lock); =20 pr_debug("prange 0x%p [0x%lx 0x%lx] op %d\n", prange, prange->start, prange->last, prange->work_item.op); =20 + mm =3D prange->work_item.mm; +retry: + mmap_write_lock(mm); + + /* Checking for the need to drain retry faults must be inside + * mmap write lock to serialize with munmap notifiers. + */ + if (unlikely(atomic_read(&svms->drain_pagefaults))) { + mmap_write_unlock(mm); + svm_range_drain_retry_fault(svms); + goto retry; + } + + /* Remove from deferred_list must be inside mmap write lock, for + * two race cases: + * 1. unmap_from_cpu may change work_item.op and add the range + * to deferred_list again, cause use after free bug. + * 2. svm_range_list_lock_and_flush_work may hold mmap write + * lock and continue because deferred_list is empty, but + * deferred_list work is actually waiting for mmap lock. + */ + spin_lock(&svms->deferred_list_lock); + list_del_init(&prange->deferred_list); + spin_unlock(&svms->deferred_list_lock); + mutex_lock(&svms->lock); mutex_lock(&prange->migrate_mutex); while (!list_empty(&prange->child_list)) { @@ -2109,19 +2115,20 @@ static void svm_range_deferred_list_work(struct wor= k_struct *work) pr_debug("child prange 0x%p op %d\n", pchild, pchild->work_item.op); list_del_init(&pchild->child_list); - svm_range_handle_list_op(svms, pchild); + svm_range_handle_list_op(svms, pchild, mm); } mutex_unlock(&prange->migrate_mutex); =20 - svm_range_handle_list_op(svms, prange); + svm_range_handle_list_op(svms, prange, mm); mutex_unlock(&svms->lock); + mmap_write_unlock(mm); + + /* Pairs with mmget in svm_range_add_list_work */ + mmput(mm); =20 spin_lock(&svms->deferred_list_lock); } spin_unlock(&svms->deferred_list_lock); - - mmap_write_unlock(mm); - mmput(mm); pr_debug("exit svms 0x%p\n", svms); } =20 @@ -2139,6 +2146,9 @@ svm_range_add_list_work(struct svm_range_list *svms, = struct svm_range *prange, prange->work_item.op =3D op; } else { prange->work_item.op =3D op; + + /* Pairs with mmput in deferred_list_work */ + mmget(mm); prange->work_item.mm =3D mm; list_add_tail(&prange->deferred_list, &prange->svms->deferred_range_list); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1F674C433F5 for ; Tue, 12 Apr 2022 08:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379386AbiDLIU0 (ORCPT ); Tue, 12 Apr 2022 04:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356022AbiDLHaV (ORCPT ); Tue, 12 Apr 2022 03:30: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 9FF044FC6F; Tue, 12 Apr 2022 00:08: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 E0084616A9; Tue, 12 Apr 2022 07:08:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE465C385A8; Tue, 12 Apr 2022 07:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747306; bh=e4Q/swAJT5i/cd9ObonPjAQOyqAx6WFs2Yug5hfJQ+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChTcI1CP8hoS45uUu5p9SQrEScY/4dfCRglilhYp0g4u5gkqdteAEyxniQvxeOWIq p+ML6z0Up3MeUqxZXRROz4AMX0Rg1sSjrSPYSEitlvF0Jl1Sgc1NIstLAZEeu9D6WQ EP6aXu/nvpx9VDnIyahDEnynAnCEcJ8anM/0vXQw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philip Yang , Ruili Ji , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 032/343] drm/amdkfd: svm range restore work deadlock when process exit Date: Tue, 12 Apr 2022 08:27:30 +0200 Message-Id: <20220412062952.033715124@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Philip Yang [ Upstream commit 6225bb3a88d22594aacea2485dc28ca12d596721 ] kfd_process_notifier_release flush svm_range_restore_work which calls svm_range_list_lock_and_flush_work to flush deferred_list work, but if deferred_list work mmput release the last user, it will call exit_mmap -> notifier_release, it is deadlock with below backtrace. Move flush svm_range_restore_work to kfd_process_wq_release to avoid deadlock. Then svm_range_restore_work take task->mm ref to avoid mm is gone while validating and mapping ranges to GPU. Workqueue: events svm_range_deferred_list_work [amdgpu] Call Trace: wait_for_completion+0x94/0x100 __flush_work+0x12a/0x1e0 __cancel_work_timer+0x10e/0x190 cancel_delayed_work_sync+0x13/0x20 kfd_process_notifier_release+0x98/0x2a0 [amdgpu] __mmu_notifier_release+0x74/0x1f0 exit_mmap+0x170/0x200 mmput+0x5d/0x130 svm_range_deferred_list_work+0x104/0x230 [amdgpu] process_one_work+0x220/0x3c0 Signed-off-by: Philip Yang Reported-by: Ruili Ji Tested-by: Ruili Ji Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 1 - drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd= /amdkfd/kfd_process.c index d1145da5348f..74f162887d3b 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1150,7 +1150,6 @@ static void kfd_process_notifier_release(struct mmu_n= otifier *mn, =20 cancel_delayed_work_sync(&p->eviction_work); cancel_delayed_work_sync(&p->restore_work); - cancel_delayed_work_sync(&p->svms.restore_work); =20 mutex_lock(&p->mutex); =20 diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amd= kfd/kfd_svm.c index 225affcddbc1..1cf9041c9727 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1643,13 +1643,14 @@ static void svm_range_restore_work(struct work_stru= ct *work) =20 pr_debug("restore svm ranges\n"); =20 - /* kfd_process_notifier_release destroys this worker thread. So during - * the lifetime of this thread, kfd_process and mm will be valid. - */ p =3D container_of(svms, struct kfd_process, svms); - mm =3D p->mm; - if (!mm) + + /* Keep mm reference when svm_range_validate_and_map ranges */ + mm =3D get_task_mm(p->lead_thread); + if (!mm) { + pr_debug("svms 0x%p process mm gone\n", svms); return; + } =20 svm_range_list_lock_and_flush_work(svms, mm); mutex_lock(&svms->lock); @@ -1703,6 +1704,7 @@ static void svm_range_restore_work(struct work_struct= *work) out_reschedule: mutex_unlock(&svms->lock); mmap_write_unlock(mm); + mmput(mm); =20 /* If validation failed, reschedule another attempt */ if (evicted_ranges) { @@ -2840,6 +2842,8 @@ void svm_range_list_fini(struct kfd_process *p) =20 pr_debug("pasid 0x%x svms 0x%p\n", p->pasid, &p->svms); =20 + cancel_delayed_work_sync(&p->svms.restore_work); + /* Ensure list work is finished before process is destroyed */ flush_work(&p->svms.deferred_list_work); =20 @@ -2850,7 +2854,6 @@ void svm_range_list_fini(struct kfd_process *p) atomic_inc(&p->svms.drain_pagefaults); svm_range_drain_retry_fault(&p->svms); =20 - list_for_each_entry_safe(prange, next, &p->svms.list, list) { svm_range_unlink(prange); svm_range_remove_notifier(prange); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 91BA2C35295 for ; Tue, 12 Apr 2022 08:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379831AbiDLIVA (ORCPT ); Tue, 12 Apr 2022 04:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345177AbiDLHbX (ORCPT ); Tue, 12 Apr 2022 03:31:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE86150058; Tue, 12 Apr 2022 00:08: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 47248B81B4E; Tue, 12 Apr 2022 07:08:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3A1BC385B7; Tue, 12 Apr 2022 07:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747309; bh=h1/zFxNl/9AODl5mu6g3Vx4iIcbiKVoR2kXvfkVY7UY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ql95LVOiyFF2/zHywtuAjRI5hKez0WuxzvkSpVlZsaWbKO1Q8PrynGrt18cd/kxiS Ek8XTf0nPDuH9pUpTe1XkWg2wYOafxCf696CapApNIPKSO1bndvDz75QsA4h5AAGa1 /tHwrkjoEqGkLQ1Iu0y7TlZFJcTCrPpH2BthYafY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Kuehling , Yang Wang , "Tianci.Yin" , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 033/343] drm/amdgpu: Fix an error message in rmmod Date: Tue, 12 Apr 2022 08:27:31 +0200 Message-Id: <20220412062952.062299541@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Tianci.Yin [ Upstream commit 7270e8957eb9aacf5914605d04865f3829a14bce ] [why] In rmmod procedure, kfd sends cp a dequeue request, but the request does not get response, then an error message "cp queue pipe 4 queue 0 preemption failed" printed. [how] Performing kfd suspending after disabling gfxoff can fix it. Acked-by: Felix Kuehling Reviewed-by: Yang Wang Signed-off-by: Tianci.Yin Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_device.c index f18c698137a6..b87dca6d09fa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2723,11 +2723,11 @@ static int amdgpu_device_ip_fini_early(struct amdgp= u_device *adev) } } =20 - amdgpu_amdkfd_suspend(adev, false); - amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE); amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE); =20 + amdgpu_amdkfd_suspend(adev, false); + /* Workaroud for ASICs need to disable SMC first */ amdgpu_device_smu_fini_early(adev); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 825D9C433F5 for ; Tue, 12 Apr 2022 08:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379872AbiDLIVC (ORCPT ); Tue, 12 Apr 2022 04:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245320AbiDLHbY (ORCPT ); Tue, 12 Apr 2022 03:31:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66A7650065; Tue, 12 Apr 2022 00:08: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 76D7D616AB; Tue, 12 Apr 2022 07:08:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84CC7C385AA; Tue, 12 Apr 2022 07:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747311; bh=2RL/6Vk9/VoLUPC2ZoIE0F7QDbm1lVmRjfWSo7BJRow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RAZRSv0Oa8s8r1aTjsVmHcwj3LYEe3U6Fdned62Jn8SOTAjiXRs9MvUtD6C5nfQFu Rnkv7350HzMrphB03rTAfNUfJGTxHOrQCH1R0phdNlwF5cqKK8Y1kw9FpZ1EVL4HVj s1I0qQAwlilrmjPYMqBgRVZ9KkA6IxWU9E3dPvTY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amit Cohen , Ido Schimmel , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 034/343] mlxsw: spectrum: Guard against invalid local ports Date: Tue, 12 Apr 2022 08:27:32 +0200 Message-Id: <20220412062952.090939489@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Amit Cohen [ Upstream commit bcdfd615f83b4bd04678109bf18022d1476e4bbf ] When processing events generated by the device's firmware, the driver protects itself from events reported for non-existent local ports, but not for the CPU port (local port 0), which exists, but does not have all the fields as any local port. This can result in a NULL pointer dereference when trying access 'struct mlxsw_sp_port' fields which are not initialized for CPU port. Commit 63b08b1f6834 ("mlxsw: spectrum: Protect driver from buggy firmware") already handled such issue by bailing early when processing a PUDE event reported for the CPU port. Generalize the approach by moving the check to a common function and making use of it in all relevant places. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 +--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 7 +++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 3 +-- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 +-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/e= thernet/mellanox/mlxsw/spectrum.c index aa411dec62f0..eb1319d63613 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2148,13 +2148,11 @@ static void mlxsw_sp_pude_event_func(const struct m= lxsw_reg_info *reg, struct mlxsw_sp *mlxsw_sp =3D priv; struct mlxsw_sp_port *mlxsw_sp_port; enum mlxsw_reg_pude_oper_status status; - unsigned int max_ports; u16 local_port; =20 - max_ports =3D mlxsw_core_max_ports(mlxsw_sp->core); local_port =3D mlxsw_reg_pude_local_port_get(pude_pl); =20 - if (WARN_ON_ONCE(!local_port || local_port >=3D max_ports)) + if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) return; mlxsw_sp_port =3D mlxsw_sp->ports[local_port]; if (!mlxsw_sp_port) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/e= thernet/mellanox/mlxsw/spectrum.h index bb2442e1f705..30942b6ffcf9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -481,6 +481,13 @@ int mlxsw_sp_port_vlan_classification_set(struct mlxsw_sp_port *mlxsw_sp_port, bool is_8021ad_tagged, bool is_8021q_tagged); +static inline bool +mlxsw_sp_local_port_is_valid(struct mlxsw_sp *mlxsw_sp, u16 local_port) +{ + unsigned int max_ports =3D mlxsw_core_max_ports(mlxsw_sp->core); + + return local_port < max_ports && local_port; +} =20 /* spectrum_buffers.c */ struct mlxsw_sp_hdroom_prio { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c b/drivers/n= et/ethernet/mellanox/mlxsw/spectrum_ptp.c index 0ff163fbc775..35422e64d89f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c @@ -568,12 +568,11 @@ void mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlx= sw_sp, bool ingress, u8 domain_number, u16 sequence_id, u64 timestamp) { - unsigned int max_ports =3D mlxsw_core_max_ports(mlxsw_sp->core); struct mlxsw_sp_port *mlxsw_sp_port; struct mlxsw_sp1_ptp_key key; u8 types; =20 - if (WARN_ON_ONCE(local_port >=3D max_ports)) + if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) return; mlxsw_sp_port =3D mlxsw_sp->ports[local_port]; if (!mlxsw_sp_port) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/dri= vers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 65c1724c63b0..bffdb41fc4ed 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -2616,7 +2616,6 @@ static void mlxsw_sp_fdb_notify_mac_process(struct ml= xsw_sp *mlxsw_sp, char *sfn_pl, int rec_index, bool adding) { - unsigned int max_ports =3D mlxsw_core_max_ports(mlxsw_sp->core); struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; struct mlxsw_sp_bridge_device *bridge_device; struct mlxsw_sp_bridge_port *bridge_port; @@ -2630,7 +2629,7 @@ static void mlxsw_sp_fdb_notify_mac_process(struct ml= xsw_sp *mlxsw_sp, =20 mlxsw_reg_sfn_mac_unpack(sfn_pl, rec_index, mac, &fid, &local_port); =20 - if (WARN_ON_ONCE(local_port >=3D max_ports)) + if (WARN_ON_ONCE(!mlxsw_sp_local_port_is_valid(mlxsw_sp, local_port))) return; mlxsw_sp_port =3D mlxsw_sp->ports[local_port]; if (!mlxsw_sp_port) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 41CD3C433FE for ; Tue, 12 Apr 2022 08:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379917AbiDLIVE (ORCPT ); Tue, 12 Apr 2022 04:21:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351194AbiDLHb3 (ORCPT ); Tue, 12 Apr 2022 03:31:29 -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 E169750452; Tue, 12 Apr 2022 00:08: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 2E565616C5; Tue, 12 Apr 2022 07:08:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A50AC385A1; Tue, 12 Apr 2022 07:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747314; bh=KeggjO9hLyIRfB/b4st72OMc/DjgSW6YL7AfplDtUUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IYF+gRpVCpwnha8J0yXS1JBCuPr1c7hSiLN4Dxory3c8jtRy1Oxr1+7I+8QxVl8Ed begU3xufJPyTuELkjwEA7tbvvog/HEtvc5lgmGy+T/8GyV570m9NrlyS7LtkIMd5jB 12R2bK1arW2USuqj/ODQCAPP+S9L6CqH9a3l5ubw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Aleksei Marov , Md Haris Iqbal , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.17 035/343] RDMA/rtrs-clt: Do stop and failover outside reconnect work. Date: Tue, 12 Apr 2022 08:27:33 +0200 Message-Id: <20220412062952.119446078@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jack Wang [ Upstream commit c1289d5d8502d62e5bc50ff066c9d6daabfc3264 ] We can't do instant reconnect, not to DDoS server, but we should stop and failover earlier, so there is less service interruption. To avoid deadlock, as error_recovery is called from different callback like rdma event or hb error handler, add a new err recovery_work. Link: https://lore.kernel.org/r/20220114154753.983568-6-haris.iqbal@ionos.c= om Signed-off-by: Jack Wang Reviewed-by: Aleksei Marov Reviewed-by: Md Haris Iqbal Signed-off-by: Md Haris Iqbal Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 40 ++++++++++++++------------ drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 + 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ul= p/rtrs/rtrs-clt.c index 759b85f03331..df4d06d4d183 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -297,6 +297,7 @@ static bool rtrs_clt_change_state_from_to(struct rtrs_c= lt_path *clt_path, return changed; } =20 +static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path= ); static void rtrs_rdma_error_recovery(struct rtrs_clt_con *con) { struct rtrs_clt_path *clt_path =3D to_clt_path(con->c.path); @@ -304,16 +305,7 @@ static void rtrs_rdma_error_recovery(struct rtrs_clt_c= on *con) if (rtrs_clt_change_state_from_to(clt_path, RTRS_CLT_CONNECTED, RTRS_CLT_RECONNECTING)) { - struct rtrs_clt_sess *clt =3D clt_path->clt; - unsigned int delay_ms; - - /* - * Normal scenario, reconnect if we were successfully connected - */ - delay_ms =3D clt->reconnect_delay_sec * 1000; - queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, - msecs_to_jiffies(delay_ms + - prandom_u32() % RTRS_RECONNECT_SEED)); + queue_work(rtrs_wq, &clt_path->err_recovery_work); } else { /* * Error can happen just on establishing new connection, @@ -1511,6 +1503,22 @@ static void rtrs_clt_init_hb(struct rtrs_clt_path *c= lt_path) static void rtrs_clt_reconnect_work(struct work_struct *work); static void rtrs_clt_close_work(struct work_struct *work); =20 +static void rtrs_clt_err_recovery_work(struct work_struct *work) +{ + struct rtrs_clt_path *clt_path; + struct rtrs_clt_sess *clt; + int delay_ms; + + clt_path =3D container_of(work, struct rtrs_clt_path, err_recovery_work); + clt =3D clt_path->clt; + delay_ms =3D clt->reconnect_delay_sec * 1000; + rtrs_clt_stop_and_destroy_conns(clt_path); + queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, + msecs_to_jiffies(delay_ms + + prandom_u32() % + RTRS_RECONNECT_SEED)); +} + static struct rtrs_clt_path *alloc_path(struct rtrs_clt_sess *clt, const struct rtrs_addr *path, size_t con_num, u32 nr_poll_queues) @@ -1562,6 +1570,7 @@ static struct rtrs_clt_path *alloc_path(struct rtrs_c= lt_sess *clt, clt_path->state =3D RTRS_CLT_CONNECTING; atomic_set(&clt_path->connected_cnt, 0); INIT_WORK(&clt_path->close_work, rtrs_clt_close_work); + INIT_WORK(&clt_path->err_recovery_work, rtrs_clt_err_recovery_work); INIT_DELAYED_WORK(&clt_path->reconnect_dwork, rtrs_clt_reconnect_work); rtrs_clt_init_hb(clt_path); =20 @@ -2326,6 +2335,7 @@ static void rtrs_clt_close_work(struct work_struct *w= ork) =20 clt_path =3D container_of(work, struct rtrs_clt_path, close_work); =20 + cancel_work_sync(&clt_path->err_recovery_work); cancel_delayed_work_sync(&clt_path->reconnect_dwork); rtrs_clt_stop_and_destroy_conns(clt_path); rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CLOSED, NULL); @@ -2638,7 +2648,6 @@ static void rtrs_clt_reconnect_work(struct work_struc= t *work) { struct rtrs_clt_path *clt_path; struct rtrs_clt_sess *clt; - unsigned int delay_ms; int err; =20 clt_path =3D container_of(to_delayed_work(work), struct rtrs_clt_path, @@ -2655,8 +2664,6 @@ static void rtrs_clt_reconnect_work(struct work_struc= t *work) } clt_path->reconnect_attempts++; =20 - /* Stop everything */ - rtrs_clt_stop_and_destroy_conns(clt_path); msleep(RTRS_RECONNECT_BACKOFF); if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING, NULL)) { err =3D init_path(clt_path); @@ -2669,11 +2676,7 @@ static void rtrs_clt_reconnect_work(struct work_stru= ct *work) reconnect_again: if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_RECONNECTING, NULL))= { clt_path->stats->reconnects.fail_cnt++; - delay_ms =3D clt->reconnect_delay_sec * 1000; - queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, - msecs_to_jiffies(delay_ms + - prandom_u32() % - RTRS_RECONNECT_SEED)); + queue_work(rtrs_wq, &clt_path->err_recovery_work); } } =20 @@ -2908,6 +2911,7 @@ int rtrs_clt_reconnect_from_sysfs(struct rtrs_clt_pat= h *clt_path) &old_state); if (changed) { clt_path->reconnect_attempts =3D 0; + rtrs_clt_stop_and_destroy_conns(clt_path); queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork, 0); } if (changed || old_state =3D=3D RTRS_CLT_RECONNECTING) { diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ul= p/rtrs/rtrs-clt.h index d1b18a154ae0..f848c0392d98 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -134,6 +134,7 @@ struct rtrs_clt_path { struct rtrs_clt_io_req *reqs; struct delayed_work reconnect_dwork; struct work_struct close_work; + struct work_struct err_recovery_work; unsigned int reconnect_attempts; bool established; struct rtrs_rbuf *rbufs; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 EC5FDC433EF for ; Tue, 12 Apr 2022 08:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380239AbiDLIVe (ORCPT ); Tue, 12 Apr 2022 04:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351823AbiDLHdP (ORCPT ); Tue, 12 Apr 2022 03:33:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880605047E; Tue, 12 Apr 2022 00:08: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 9994AB81B4F; Tue, 12 Apr 2022 07:08:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6BF8C385A1; Tue, 12 Apr 2022 07:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747317; bh=qb7dqHmgbsiv+Ny1LN80N+oGMfAJtZMtoivBEsSk6XI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qaraylGNIbNu3nO+XIEm0WrlTS3cYARaEisi/ieyrkzOcRChP12LQVbMimcdL7One qQpQ81UJCar+7ccoPrB9asRtqZCKMAK1kdWvVSdmKw93bp1Lc7FP9ZYJhUxeYQZAwe JDTKPbMBUcwYjsHubAVbbEkdIiNT2w67i+auJ4Bc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Sachin Sant , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 036/343] powerpc/xive: Export XIVE IPI information for online-only processors. Date: Tue, 12 Apr 2022 08:27:34 +0200 Message-Id: <20220412062952.149337635@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sachin Sant [ Upstream commit 279d1a72c0f8021520f68ddb0a1346ff9ba1ea8c ] C=C3=A9dric pointed out that XIVE IPI information exported via sysfs (debug/powerpc/xive) display empty lines for processors which are not online. Switch to using for_each_online_cpu() so that information is displayed for online-only processors. Reported-by: C=C3=A9dric Le Goater Signed-off-by: Sachin Sant Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/164146703333.19039.10920919226094771665.sen= dpatchset@MacBook-Pro.local Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/sysdev/xive/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/c= ommon.c index 89c86f32aff8..bb5bda6b2357 100644 --- a/arch/powerpc/sysdev/xive/common.c +++ b/arch/powerpc/sysdev/xive/common.c @@ -1791,7 +1791,7 @@ static int xive_ipi_debug_show(struct seq_file *m, vo= id *private) if (xive_ops->debug_show) xive_ops->debug_show(m, private); =20 - for_each_possible_cpu(cpu) + for_each_online_cpu(cpu) xive_debug_show_ipi(m, cpu); return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1EB15C433F5 for ; Tue, 12 Apr 2022 08:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380279AbiDLIVh (ORCPT ); Tue, 12 Apr 2022 04:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351981AbiDLHdY (ORCPT ); Tue, 12 Apr 2022 03:33:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 104A6506C4; Tue, 12 Apr 2022 00:08: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 42C0FB81B50; Tue, 12 Apr 2022 07:08:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC346C385A6; Tue, 12 Apr 2022 07:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747320; bh=Y4PFYmdYR2WjNP0fkjHUgXF9wtFrae+g7GdxMfughyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BZq+KfL0wF8eemamMOkiiuToXGYGw+1E6QSrwcFTiNNqwe7K+hn40kXFG8H40Mlym oU7UjSobPJCwjd0AaNbqDnZ7TNPYOxvep0jqNiREru7hEIhE2vw9nme6C8bj1oNZOu nBZCFQDO/lo/FHXGNAep8lgPhIF4Oh3o1zlXHqL4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Kiselev , Maxim Kochetkov , Vladimir Oltean , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 037/343] powerpc: dts: t104xrdb: fix phy type for FMAN 4/5 Date: Tue, 12 Apr 2022 08:27:35 +0200 Message-Id: <20220412062952.177770405@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maxim Kiselev [ Upstream commit 17846485dff91acce1ad47b508b633dffc32e838 ] T1040RDB has two RTL8211E-VB phys which requires setting of internal delays for correct work. Changing the phy-connection-type property to `rgmii-id` will fix this issue. Signed-off-by: Maxim Kiselev Reviewed-by: Maxim Kochetkov Reviewed-by: Vladimir Oltean Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20211230151123.1258321-1-bigunclemax@gmail.= com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/boot/dts/fsl/t104xrdb.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi b/arch/powerpc/boot/dt= s/fsl/t104xrdb.dtsi index 099a598c74c0..bfe1ed5be337 100644 --- a/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi +++ b/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi @@ -139,12 +139,12 @@ fman@400000 { ethernet@e6000 { phy-handle =3D <&phy_rgmii_0>; - phy-connection-type =3D "rgmii"; + phy-connection-type =3D "rgmii-id"; }; =20 ethernet@e8000 { phy-handle =3D <&phy_rgmii_1>; - phy-connection-type =3D "rgmii"; + phy-connection-type =3D "rgmii-id"; }; =20 mdio0: mdio@fc000 { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4C325C433F5 for ; Tue, 12 Apr 2022 08:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356022AbiDLI1A (ORCPT ); Tue, 12 Apr 2022 04:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352630AbiDLHd1 (ORCPT ); Tue, 12 Apr 2022 03:33:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F24506E1; Tue, 12 Apr 2022 00:08: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 9C33AB81B51; Tue, 12 Apr 2022 07:08:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 173CEC385A1; Tue, 12 Apr 2022 07:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747325; bh=RgR/bhlckyUFWZryIL/9PaFrl2riAKvcRqAMLZbrrAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=184PYKKrWsIgQ6UwWFtTzfW4l+qG8nSmcZYEJak6GuQ3mLB19sw/tCrakFBiNSIKf d34ecgr/O6IDcRCz9iZt1OZx6s00cn7arcHC2mv+CVlGnGez0trwuEEcrFpb+oMOW8 QLisf22/MD8qqxRHsG6twe5ugpTmAy8BMzrHLMwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Venkateswara Naralasetty , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 038/343] ath11k: fix kernel panic during unload/load ath11k modules Date: Tue, 12 Apr 2022 08:27:36 +0200 Message-Id: <20220412062952.206665601@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Venkateswara Naralasetty [ Upstream commit 22b59cb965f79ee1accf83172441c9ca0ecb632a ] Call netif_napi_del() from ath11k_ahb_free_ext_irq() to fix the following kernel panic when unload/load ath11k modules for few iterations. [ 971.201365] Unable to handle kernel paging request at virtual address 6d= 97a208 [ 971.204227] pgd =3D 594c2919 [ 971.211478] [6d97a208] *pgd=3D00000000 [ 971.214120] Internal error: Oops: 5 [#1] PREEMPT SMP ARM [ 971.412024] CPU: 2 PID: 4435 Comm: insmod Not tainted 5.4.89 #0 [ 971.434256] Hardware name: Generic DT based system [ 971.440165] PC is at napi_by_id+0x10/0x40 [ 971.445019] LR is at netif_napi_add+0x160/0x1dc [ 971.743127] (napi_by_id) from [<807d89a0>] (netif_napi_add+0x160/0x1dc) [ 971.751295] (netif_napi_add) from [<7f1209ac>] (ath11k_ahb_config_irq+0x= f8/0x414 [ath11k_ahb]) [ 971.759164] (ath11k_ahb_config_irq [ath11k_ahb]) from [<7f12135c>] (ath1= 1k_ahb_probe+0x40c/0x51c [ath11k_ahb]) [ 971.768567] (ath11k_ahb_probe [ath11k_ahb]) from [<80666864>] (platform_= drv_probe+0x48/0x94) [ 971.779670] (platform_drv_probe) from [<80664718>] (really_probe+0x1c8/0= x450) [ 971.789389] (really_probe) from [<80664cc4>] (driver_probe_device+0x15c/= 0x1b8) [ 971.797547] (driver_probe_device) from [<80664f60>] (device_driver_attac= h+0x44/0x60) [ 971.805795] (device_driver_attach) from [<806650a0>] (__driver_attach+0x= 124/0x140) [ 971.814822] (__driver_attach) from [<80662adc>] (bus_for_each_dev+0x58/0= xa4) [ 971.823328] (bus_for_each_dev) from [<80663a2c>] (bus_add_driver+0xf0/0x= 1e8) [ 971.831662] (bus_add_driver) from [<806658a4>] (driver_register+0xa8/0xf= 0) [ 971.839822] (driver_register) from [<8030269c>] (do_one_initcall+0x78/0x= 1ac) [ 971.847638] (do_one_initcall) from [<80392524>] (do_init_module+0x54/0x2= 00) [ 971.855968] (do_init_module) from [<803945b0>] (load_module+0x1e30/0x1ff= c) [ 971.864126] (load_module) from [<803948b0>] (sys_init_module+0x134/0x17c) [ 971.871852] (sys_init_module) from [<80301000>] (ret_fast_syscall+0x0/0x= 50) Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.6.0.1-00760-QCAHKSWPL_SILICONZ-1 Signed-off-by: Venkateswara Naralasetty Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/1642583973-21599-1-git-send-email-quic_vnar= alas@quicinc.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/ath/ath11k/ahb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/a= th/ath11k/ahb.c index 3fb0aa000825..24bd0520926b 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -391,6 +391,8 @@ static void ath11k_ahb_free_ext_irq(struct ath11k_base = *ab) =20 for (j =3D 0; j < irq_grp->num_irq; j++) free_irq(ab->irq_num[irq_grp->irqs[j]], irq_grp); + + netif_napi_del(&irq_grp->napi); } } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B7A05C43217 for ; Tue, 12 Apr 2022 08:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237159AbiDLIZh (ORCPT ); Tue, 12 Apr 2022 04:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352633AbiDLHd1 (ORCPT ); Tue, 12 Apr 2022 03:33: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 20CC5506E8; Tue, 12 Apr 2022 00:08: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 dfw.source.kernel.org (Postfix) with ESMTPS id B01D6616A9; Tue, 12 Apr 2022 07:08:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1583C385A8; Tue, 12 Apr 2022 07:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747328; bh=JgppqWRUyXdsicdWdBjhfW92wG3rlJRV4xebFgNWe6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O0x7iKe6+m02OVgGSGA7gQiPeNiJj/f2KHteYCcDi5vBk1wf9jCZNsD4fj8RiS+tu ACkZvzMryQDXyo/j5TjbE/+N+og47ak4oQ6JXPCpAHIPYoKMDsPiT0eFmSMNd/ByyG iD7FMRfS7DL/+Q3KRrtVjvcJRLAl7vTCDbZOZ9GM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mario Limonciello , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 039/343] ath11k: pci: fix crash on suspend if board file is not found Date: Tue, 12 Apr 2022 08:27:37 +0200 Message-Id: <20220412062952.235086999@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kalle Valo [ Upstream commit b4f4c56459a5c744f7f066b9fc2b54ea995030c5 ] Mario reported that the kernel was crashing on suspend if ath11k was not ab= le to find a board file: [ 473.693286] PM: Suspending system (s2idle) [ 473.693291] printk: Suspending console(s) (use no_console_suspend to deb= ug) [ 474.407787] BUG: unable to handle page fault for address: 00000000000020= 70 [ 474.407791] #PF: supervisor read access in kernel mode [ 474.407794] #PF: error_code(0x0000) - not-present page [ 474.407798] PGD 0 P4D 0 [ 474.407801] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 474.407805] CPU: 2 PID: 2350 Comm: kworker/u32:14 Tainted: G W = 5.16.0 #248 [...] [ 474.407868] Call Trace: [ 474.407870] [ 474.407874] ? _raw_spin_lock_irqsave+0x2a/0x60 [ 474.407882] ? lock_timer_base+0x72/0xa0 [ 474.407889] ? _raw_spin_unlock_irqrestore+0x29/0x3d [ 474.407892] ? try_to_del_timer_sync+0x54/0x80 [ 474.407896] ath11k_dp_rx_pktlog_stop+0x49/0xc0 [ath11k] [ 474.407912] ath11k_core_suspend+0x34/0x130 [ath11k] [ 474.407923] ath11k_pci_pm_suspend+0x1b/0x50 [ath11k_pci] [ 474.407928] pci_pm_suspend+0x7e/0x170 [ 474.407935] ? pci_pm_freeze+0xc0/0xc0 [ 474.407939] dpm_run_callback+0x4e/0x150 [ 474.407947] __device_suspend+0x148/0x4c0 [ 474.407951] async_suspend+0x20/0x90 dmesg-efi-164255130401001: Oops#1 Part1 [ 474.407955] async_run_entry_fn+0x33/0x120 [ 474.407959] process_one_work+0x220/0x3f0 [ 474.407966] worker_thread+0x4a/0x3d0 [ 474.407971] kthread+0x17a/0x1a0 [ 474.407975] ? process_one_work+0x3f0/0x3f0 [ 474.407979] ? set_kthread_struct+0x40/0x40 [ 474.407983] ret_from_fork+0x22/0x30 [ 474.407991] The issue here is that board file loading happens after ath11k_pci_probe() succesfully returns (ath11k initialisation happends asynchronously) and the suspend handler is still enabled, of course failing as ath11k is not proper= ly initialised. Fix this by checking ATH11K_FLAG_QMI_FAIL during both suspend = and resume. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_L= ITE-2 Reported-by: Mario Limonciello Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D215504 Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220127090117.2024-1-kvalo@kernel.org Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/ath/ath11k/pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/a= th/ath11k/pci.c index de71ad594f34..903758751c99 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -1571,6 +1571,11 @@ static __maybe_unused int ath11k_pci_pm_suspend(stru= ct device *dev) struct ath11k_base *ab =3D dev_get_drvdata(dev); int ret; =20 + if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) { + ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot skipping pci suspend as qmi is not= initialised\n"); + return 0; + } + ret =3D ath11k_core_suspend(ab); if (ret) ath11k_warn(ab, "failed to suspend core: %d\n", ret); @@ -1583,6 +1588,11 @@ static __maybe_unused int ath11k_pci_pm_resume(struc= t device *dev) struct ath11k_base *ab =3D dev_get_drvdata(dev); int ret; =20 + if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) { + ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot skipping pci resume as qmi is not = initialised\n"); + return 0; + } + ret =3D ath11k_core_resume(ab); if (ret) ath11k_warn(ab, "failed to resume core: %d\n", ret); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 71D1FC433FE for ; Tue, 12 Apr 2022 08:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382658AbiDLI1O (ORCPT ); Tue, 12 Apr 2022 04:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352827AbiDLHd3 (ORCPT ); Tue, 12 Apr 2022 03:33: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 9E9A750B0D; Tue, 12 Apr 2022 00:08: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 1A7D3B81B35; Tue, 12 Apr 2022 07:08:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76154C385A5; Tue, 12 Apr 2022 07:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747330; bh=Vf6HXp2o6siqms0powfgo1NYut8pL70zZ1Z5B3Sdjwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ocB2mqh7QBDnNkR+zJDIG0oAtJo5gkx4gPfzrQoZZuSm3aGbTiKybxj0Gth4r1qUB sK7Znf5bKn/Ic9U3X1TGPrUHoNSk4T/i1JDTE8sBPaaSi1pAd6TzCfNVhY/21EyhVo mCy9rUWUtb4Usmxc4OQ8YGVMXpEmk9eQlNEYcY6Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kalle Valo , Sasha Levin Subject: [PATCH 5.17 040/343] ath11k: mhi: use mhi_sync_power_up() Date: Tue, 12 Apr 2022 08:27:38 +0200 Message-Id: <20220412062952.263379510@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kalle Valo [ Upstream commit 3df6d74aedfdca919cca475d15dfdbc8b05c9e5d ] If amss.bin was missing ath11k would crash during 'rmmod ath11k_pci'. The reason for that was that we were using mhi_async_power_up() which does not check any errors. But mhi_sync_power_up() on the other hand does check for errors so let's use that to fix the crash. I was not able to find a reason why an async version was used. ath11k_mhi_start() (which enables state ATH11K_MHI_POWER_ON) is called from ath11k_hif_power_up(), which can sleep. So sync version should be safe to u= se here. [ 145.569731] general protection fault, probably for non-canonical address= 0xdffffc0000000000: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC KASAN PTI [ 145.569789] KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000= 000000007] [ 145.569843] CPU: 2 PID: 1628 Comm: rmmod Kdump: loaded Tainted: G = W 5.16.0-wt-ath+ #567 [ 145.569898] Hardware name: Intel(R) Client Systems NUC8i7HVK/NUC8i7HVB, = BIOS HNKBLi70.86A.0067.2021.0528.1339 05/28/2021 [ 145.569956] RIP: 0010:ath11k_hal_srng_access_begin+0xb5/0x2b0 [ath11k] [ 145.570028] Code: df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 ec 01 00 00 = 48 8b ab a8 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 ea 48 c1 ea 03 <0f= > b6 14 02 48 89 e8 83 e0 07 83 c0 03 45 85 ed 75 48 38 d0 7c 08 [ 145.570089] RSP: 0018:ffffc900025d7ac0 EFLAGS: 00010246 [ 145.570144] RAX: dffffc0000000000 RBX: ffff88814fca2dd8 RCX: 1ffffffff50= cb455 [ 145.570196] RDX: 0000000000000000 RSI: ffff88814fca2dd8 RDI: ffff88814fc= a2e80 [ 145.570252] RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffffa86= 59497 [ 145.570329] R10: fffffbfff50cb292 R11: 0000000000000001 R12: ffff88814fc= a0000 [ 145.570410] R13: 0000000000000000 R14: ffff88814fca2798 R15: ffff88814fc= a2dd8 [ 145.570465] FS: 00007fa399988540(0000) GS:ffff888233e00000(0000) knlGS:= 0000000000000000 [ 145.570519] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 145.570571] CR2: 00007fa399b51421 CR3: 0000000137898002 CR4: 00000000003= 706e0 [ 145.570623] Call Trace: [ 145.570675] [ 145.570727] ? ath11k_ce_tx_process_cb+0x34b/0x860 [ath11k] [ 145.570797] ath11k_ce_tx_process_cb+0x356/0x860 [ath11k] [ 145.570864] ? tasklet_init+0x150/0x150 [ 145.570919] ? ath11k_ce_alloc_pipes+0x280/0x280 [ath11k] [ 145.570986] ? tasklet_clear_sched+0x42/0xe0 [ 145.571042] ? tasklet_kill+0xe9/0x1b0 [ 145.571095] ? tasklet_clear_sched+0xe0/0xe0 [ 145.571148] ? irq_has_action+0x120/0x120 [ 145.571202] ath11k_ce_cleanup_pipes+0x45a/0x580 [ath11k] [ 145.571270] ? ath11k_pci_stop+0x10e/0x170 [ath11k_pci] [ 145.571345] ath11k_core_stop+0x8a/0xc0 [ath11k] [ 145.571434] ath11k_core_deinit+0x9e/0x150 [ath11k] [ 145.571499] ath11k_pci_remove+0xd2/0x260 [ath11k_pci] [ 145.571553] pci_device_remove+0x9a/0x1c0 [ 145.571605] __device_release_driver+0x332/0x660 [ 145.571659] driver_detach+0x1e7/0x2c0 [ 145.571712] bus_remove_driver+0xe2/0x2d0 [ 145.571772] pci_unregister_driver+0x21/0x250 [ 145.571826] __do_sys_delete_module+0x30a/0x4b0 [ 145.571879] ? free_module+0xac0/0xac0 [ 145.571933] ? lockdep_hardirqs_on_prepare.part.0+0x18c/0x370 [ 145.571986] ? syscall_enter_from_user_mode+0x1d/0x50 [ 145.572039] ? lockdep_hardirqs_on+0x79/0x100 [ 145.572097] do_syscall_64+0x3b/0x90 [ 145.572153] entry_SYSCALL_64_after_hwframe+0x44/0xae Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03003-QCAHSPSWPL_V1_V2_SILICONZ_L= ITE-2 Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220127090117.2024-2-kvalo@kernel.org Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/ath/ath11k/mhi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath11k/mhi.c b/drivers/net/wireless/a= th/ath11k/mhi.c index cccaa348cf21..8b2143802816 100644 --- a/drivers/net/wireless/ath/ath11k/mhi.c +++ b/drivers/net/wireless/ath/ath11k/mhi.c @@ -561,7 +561,7 @@ static int ath11k_mhi_set_state(struct ath11k_pci *ab_p= ci, ret =3D 0; break; case ATH11K_MHI_POWER_ON: - ret =3D mhi_async_power_up(ab_pci->mhi_ctrl); + ret =3D mhi_sync_power_up(ab_pci->mhi_ctrl); break; case ATH11K_MHI_POWER_OFF: mhi_power_down(ab_pci->mhi_ctrl, true); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6167CC433FE for ; Tue, 12 Apr 2022 08:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382677AbiDLI1W (ORCPT ); Tue, 12 Apr 2022 04:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353124AbiDLHdk (ORCPT ); Tue, 12 Apr 2022 03:33:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C2050B05; Tue, 12 Apr 2022 00:08: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 AFF00B81B4F; Tue, 12 Apr 2022 07:08:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20485C385A1; Tue, 12 Apr 2022 07:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747333; bh=R+OxrBqZV7ygX3E3Xvoy9v1rAvn5mARN24vjLcFSEoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZPyUrNc1zUifUOlf+DT6yu4viDa/bYXX3i04IX+tSGgGfANlLrIPkHeZlEuZ6iWo zFhKwFEC2fs+d71N9WQzYACO62apU4of3rAxuLElfQIGau/Ujz8kqyhBlJeo0pNtvc SzWpeCs03y+7WlmV6vebFrRBdvsxCVWM7DfG1QX8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 041/343] net/smc: Send directly when TCP_CORK is cleared Date: Tue, 12 Apr 2022 08:27:39 +0200 Message-Id: <20220412062952.292562944@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Lu [ Upstream commit ea785a1a573b390a150010b3c5b81e1ccd8c98a8 ] According to the man page of TCP_CORK [1], if set, don't send out partial frames. All queued partial frames are sent when option is cleared again. When applications call setsockopt to disable TCP_CORK, this call is protected by lock_sock(), and tries to mod_delayed_work() to 0, in order to send pending data right now. However, the delayed work smc_tx_work is also protected by lock_sock(). There introduces lock contention for sending data. To fix it, send pending data directly which acts like TCP, without lock_sock() protected in the context of setsockopt (already lock_sock()ed), and cancel unnecessary dealyed work, which is protected by lock. [1] https://linux.die.net/man/7/tcp Signed-off-by: Tony Lu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/smc/af_smc.c | 4 ++-- net/smc/smc_tx.c | 25 +++++++++++++++---------- net/smc/smc_tx.h | 1 + 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 284befa90967..67fc72047c9c 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2636,8 +2636,8 @@ static int smc_setsockopt(struct socket *sock, int le= vel, int optname, sk->sk_state !=3D SMC_CLOSED) { if (!val) { SMC_STAT_INC(smc, cork_cnt); - mod_delayed_work(smc->conn.lgr->tx_wq, - &smc->conn.tx_work, 0); + smc_tx_pending(&smc->conn); + cancel_delayed_work(&smc->conn.tx_work); } } break; diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index be241d53020f..7b0b6e24582f 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c @@ -597,27 +597,32 @@ int smc_tx_sndbuf_nonempty(struct smc_connection *con= n) return rc; } =20 -/* Wakeup sndbuf consumers from process context - * since there is more data to transmit - */ -void smc_tx_work(struct work_struct *work) +void smc_tx_pending(struct smc_connection *conn) { - struct smc_connection *conn =3D container_of(to_delayed_work(work), - struct smc_connection, - tx_work); struct smc_sock *smc =3D container_of(conn, struct smc_sock, conn); int rc; =20 - lock_sock(&smc->sk); if (smc->sk.sk_err) - goto out; + return; =20 rc =3D smc_tx_sndbuf_nonempty(conn); if (!rc && conn->local_rx_ctrl.prod_flags.write_blocked && !atomic_read(&conn->bytes_to_rcv)) conn->local_rx_ctrl.prod_flags.write_blocked =3D 0; +} + +/* Wakeup sndbuf consumers from process context + * since there is more data to transmit + */ +void smc_tx_work(struct work_struct *work) +{ + struct smc_connection *conn =3D container_of(to_delayed_work(work), + struct smc_connection, + tx_work); + struct smc_sock *smc =3D container_of(conn, struct smc_sock, conn); =20 -out: + lock_sock(&smc->sk); + smc_tx_pending(conn); release_sock(&smc->sk); } =20 diff --git a/net/smc/smc_tx.h b/net/smc/smc_tx.h index 07e6ad76224a..a59f370b8b43 100644 --- a/net/smc/smc_tx.h +++ b/net/smc/smc_tx.h @@ -27,6 +27,7 @@ static inline int smc_tx_prepared_sends(struct smc_connec= tion *conn) return smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep); } =20 +void smc_tx_pending(struct smc_connection *conn); void smc_tx_work(struct work_struct *work); void smc_tx_init(struct smc_sock *smc); int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1B095C4167B for ; Tue, 12 Apr 2022 08:26:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345328AbiDLI2E (ORCPT ); Tue, 12 Apr 2022 04:28:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353130AbiDLHdk (ORCPT ); Tue, 12 Apr 2022 03:33:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381C849F05; Tue, 12 Apr 2022 00:08: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 A82CC6153F; Tue, 12 Apr 2022 07:08:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFEF2C385A1; Tue, 12 Apr 2022 07:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747336; bh=nFWpWCPbOaoMAwUpLix+4mXkQpbORA6GkI7rlenqrL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vwot+Ao/sKdz2BreXJqDj1tX4r8HP4VMf83JSszmYG2i5Ql22kPwJ59V0YjKvizrf dB4Vxg3rwqh1EbaLAza4jLOzc6bOU32YtbtelDSNUbmYZWLZKQF0fGZs6hcdnvMhlZ RQ08EWHXNCeBhpYZNP2YKt/Jf7huKqjAsYDPq+K0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yongzhi Liu , Laurent Pinchart , Robert Foss , Sasha Levin Subject: [PATCH 5.17 042/343] drm/bridge: Add missing pm_runtime_put_sync Date: Tue, 12 Apr 2022 08:27:40 +0200 Message-Id: <20220412062952.321103313@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yongzhi Liu [ Upstream commit 46f47807738441e354873546dde0b000106c068a ] pm_runtime_get_sync() will increase the rumtime PM counter even when it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Besides, a matching decrement is needed on the error handling path to keep the counter balanced. Signed-off-by: Yongzhi Liu Reviewed-by: Laurent Pinchart Signed-off-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/1643008835-73961-1-git-= send-email-lyz_cs@pku.edu.cn Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/bridge/nwl-dsi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-= dsi.c index 6e484d836cfe..691039aba87f 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -861,18 +861,19 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode)); drm_mode_debug_printmodeline(adjusted_mode); =20 - pm_runtime_get_sync(dev); + if (pm_runtime_resume_and_get(dev) < 0) + return; =20 if (clk_prepare_enable(dsi->lcdif_clk) < 0) - return; + goto runtime_put; if (clk_prepare_enable(dsi->core_clk) < 0) - return; + goto runtime_put; =20 /* Step 1 from DSI reset-out instructions */ ret =3D reset_control_deassert(dsi->rst_pclk); if (ret < 0) { DRM_DEV_ERROR(dev, "Failed to deassert PCLK: %d\n", ret); - return; + goto runtime_put; } =20 /* Step 2 from DSI reset-out instructions */ @@ -882,13 +883,18 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, ret =3D reset_control_deassert(dsi->rst_esc); if (ret < 0) { DRM_DEV_ERROR(dev, "Failed to deassert ESC: %d\n", ret); - return; + goto runtime_put; } ret =3D reset_control_deassert(dsi->rst_byte); if (ret < 0) { DRM_DEV_ERROR(dev, "Failed to deassert BYTE: %d\n", ret); - return; + goto runtime_put; } + + return; + +runtime_put: + pm_runtime_put_sync(dev); } =20 static void --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1C44DC3527C for ; Tue, 12 Apr 2022 08:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359344AbiDLId0 (ORCPT ); Tue, 12 Apr 2022 04:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354788AbiDLHeG (ORCPT ); Tue, 12 Apr 2022 03:34:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF9B49F9B; Tue, 12 Apr 2022 00:09: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 dfw.source.kernel.org (Postfix) with ESMTPS id 6FD93616AB; Tue, 12 Apr 2022 07:08:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F2C3C385A5; Tue, 12 Apr 2022 07:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747338; bh=544pZh+MuYtqKjVkhTsjQTV5ihsjgTsy4DhO/PGIKcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o1RE26BYuXQKef0skNaYjAnP+rXWleHv4eAo3rZZcpGSytXax73wPx1qVDz5A4NUl nuRRiMWsmsnzb5A6teX9HQFAZ5KOFiL8jkmO5+nwNZB/L+0Nw4XCcGXObI05gqFGm/ H17qOIsKHff50nrL4q2lGThiq83NCdjCakmYjZa4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Menglong Dong , Jakub Sitnicki , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.17 043/343] bpf: Make dst_port field in struct bpf_sock 16-bit wide Date: Tue, 12 Apr 2022 08:27:41 +0200 Message-Id: <20220412062952.349558761@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Sitnicki [ Upstream commit 4421a582718ab81608d8486734c18083b822390d ] Menglong Dong reports that the documentation for the dst_port field in struct bpf_sock is inaccurate and confusing. From the BPF program PoV, the field is a zero-padded 16-bit integer in network byte order. The value appears to the BPF user as if laid out in memory as so: offsetof(struct bpf_sock, dst_port) + 0 + 8 +16 0x00 +24 0x00 32-, 16-, and 8-bit wide loads from the field are all allowed, but only if the offset into the field is 0. 32-bit wide loads from dst_port are especially confusing. The loaded value, after converting to host byte order with bpf_ntohl(dst_port), contains the port number in the upper 16-bits. Remove the confusion by splitting the field into two 16-bit fields. For backward compatibility, allow 32-bit wide loads from offsetof(struct bpf_sock, dst_port). While at it, allow loads 8-bit loads at offset [0] and [1] from dst_port. Reported-by: Menglong Dong Signed-off-by: Jakub Sitnicki Link: https://lore.kernel.org/r/20220130115518.213259-2-jakub@cloudflare.com Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/uapi/linux/bpf.h | 3 ++- net/core/filter.c | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 015bfec0dbfd..51b0f899424a 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -5500,7 +5500,8 @@ struct bpf_sock { __u32 src_ip4; __u32 src_ip6[4]; __u32 src_port; /* host byte order */ - __u32 dst_port; /* network byte order */ + __be16 dst_port; /* network byte order */ + __u16 :16; /* zero padding */ __u32 dst_ip4; __u32 dst_ip6[4]; __u32 state; diff --git a/net/core/filter.c b/net/core/filter.c index 9eb785842258..82fcb7533663 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -8033,6 +8033,7 @@ bool bpf_sock_is_valid_access(int off, int size, enum= bpf_access_type type, struct bpf_insn_access_aux *info) { const int size_default =3D sizeof(__u32); + int field_size; =20 if (off < 0 || off >=3D sizeof(struct bpf_sock)) return false; @@ -8044,7 +8045,6 @@ bool bpf_sock_is_valid_access(int off, int size, enum= bpf_access_type type, case offsetof(struct bpf_sock, family): case offsetof(struct bpf_sock, type): case offsetof(struct bpf_sock, protocol): - case offsetof(struct bpf_sock, dst_port): case offsetof(struct bpf_sock, src_port): case offsetof(struct bpf_sock, rx_queue_mapping): case bpf_ctx_range(struct bpf_sock, src_ip4): @@ -8053,6 +8053,14 @@ bool bpf_sock_is_valid_access(int off, int size, enu= m bpf_access_type type, case bpf_ctx_range_till(struct bpf_sock, dst_ip6[0], dst_ip6[3]): bpf_ctx_record_field_size(info, size_default); return bpf_ctx_narrow_access_ok(off, size, size_default); + case bpf_ctx_range(struct bpf_sock, dst_port): + field_size =3D size =3D=3D size_default ? + size_default : sizeof_field(struct bpf_sock, dst_port); + bpf_ctx_record_field_size(info, field_size); + return bpf_ctx_narrow_access_ok(off, size, field_size); + case offsetofend(struct bpf_sock, dst_port) ... + offsetof(struct bpf_sock, dst_ip4) - 1: + return false; } =20 return size =3D=3D size_default; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 979B3C35280 for ; Tue, 12 Apr 2022 08:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382848AbiDLIeS (ORCPT ); Tue, 12 Apr 2022 04:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356166AbiDLHeh (ORCPT ); Tue, 12 Apr 2022 03:34:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E6BCBA5; Tue, 12 Apr 2022 00:09: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 ams.source.kernel.org (Postfix) with ESMTPS id E15FCB81B4D; Tue, 12 Apr 2022 07:09:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36AC9C385AD; Tue, 12 Apr 2022 07:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747341; bh=hta54ajdwmJh2NBKG/lZbC1dBvxycmRgwzA6FsJy5NI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sZqJ7Bf0an92O1vFqLLVmswGcCgcS7FbWfnrOjlpscMbteS9D8NFSHpd1/JMJBlcK IdeTi2spABwLx2PzLWKRyqHz3ZRB6edg4m571gHOyFtqBhtkfWvCVZz50qu3zxSjis F+iE1Qt84NbBuScf0Rra/CDeeebxF/2u81ygPo7w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , Yang Guang , David Yang , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 044/343] scsi: mvsas: Replace snprintf() with sysfs_emit() Date: Tue, 12 Apr 2022 08:27:42 +0200 Message-Id: <20220412062952.379075022@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yang Guang [ Upstream commit 0ad3867b0f13e45cfee5a1298bfd40eef096116c ] coccinelle report: ./drivers/scsi/mvsas/mv_init.c:699:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/mvsas/mv_init.c:747:8-16: WARNING: use scnprintf or sprintf Use sysfs_emit() instead of scnprintf() or sprintf(). Link: https://lore.kernel.org/r/c1711f7cf251730a8ceb5bdfc313bf85662b3395.16= 43182948.git.yang.guang5@zte.com.cn Reported-by: Zeal Robot Signed-off-by: Yang Guang Signed-off-by: David Yang Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/mvsas/mv_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index dcae2d4464f9..44df7c03aab8 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -696,7 +696,7 @@ static struct pci_driver mvs_pci_driver =3D { static ssize_t driver_version_show(struct device *cdev, struct device_attribute *attr, char *buffer) { - return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION); + return sysfs_emit(buffer, "%s\n", DRV_VERSION); } =20 static DEVICE_ATTR_RO(driver_version); @@ -744,7 +744,7 @@ static ssize_t interrupt_coalescing_store(struct device= *cdev, static ssize_t interrupt_coalescing_show(struct device *cdev, struct device_attribute *attr, char *buffer) { - return snprintf(buffer, PAGE_SIZE, "%d\n", interrupt_coalescing); + return sysfs_emit(buffer, "%d\n", interrupt_coalescing); } =20 static DEVICE_ATTR_RW(interrupt_coalescing); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2F932C43219 for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383024AbiDLIfT (ORCPT ); Tue, 12 Apr 2022 04:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356181AbiDLHek (ORCPT ); Tue, 12 Apr 2022 03:34:40 -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 6317C2BC9; Tue, 12 Apr 2022 00:09: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 ams.source.kernel.org (Postfix) with ESMTPS id C5CF3B81B50; Tue, 12 Apr 2022 07:09:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20982C385A1; Tue, 12 Apr 2022 07:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747344; bh=Kis1m7DCiAim8AJzs0Ba0MT9e/Dm3ojhWqjSSvMIge8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cosjB9MYnHXM0EOYYlwdBnWgAG6uAhrSlBINC88iEXnV6W/Ic6qpGtQvuKFrcRQJ+ I6/xUgQDaGuS6GmL8s5dDaa2J5AJh2AGe7wGpiWFyjMjSiy9usrjwxrYmgaVZgqkKh ZWJDDURzbbQ6K31M6ODRoWFpMxwgB8c4BslMKhf0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , Yang Guang , David Yang , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 045/343] scsi: bfa: Replace snprintf() with sysfs_emit() Date: Tue, 12 Apr 2022 08:27:43 +0200 Message-Id: <20220412062952.407996838@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yang Guang [ Upstream commit 2245ea91fd3a04cafbe2f54911432a8657528c3b ] coccinelle report: ./drivers/scsi/bfa/bfad_attr.c:908:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:860:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:888:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:853:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:808:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:728:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:822:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:927:9-17: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:900:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:874:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:714:8-16: WARNING: use scnprintf or sprintf ./drivers/scsi/bfa/bfad_attr.c:839:8-16: WARNING: use scnprintf or sprintf Use sysfs_emit() instead of scnprintf() or sprintf(). Link: https://lore.kernel.org/r/def83ff75faec64ba592b867a8499b1367bae303.16= 43181468.git.yang.guang5@zte.com.cn Reported-by: Zeal Robot Signed-off-by: Yang Guang Signed-off-by: David Yang Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/bfa/bfad_attr.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c index f46989bd083c..5a85401e9e2d 100644 --- a/drivers/scsi/bfa/bfad_attr.c +++ b/drivers/scsi/bfa/bfad_attr.c @@ -711,7 +711,7 @@ bfad_im_serial_num_show(struct device *dev, struct devi= ce_attribute *attr, char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; =20 bfa_get_adapter_serial_num(&bfad->bfa, serial_num); - return snprintf(buf, PAGE_SIZE, "%s\n", serial_num); + return sysfs_emit(buf, "%s\n", serial_num); } =20 static ssize_t @@ -725,7 +725,7 @@ bfad_im_model_show(struct device *dev, struct device_at= tribute *attr, char model[BFA_ADAPTER_MODEL_NAME_LEN]; =20 bfa_get_adapter_model(&bfad->bfa, model); - return snprintf(buf, PAGE_SIZE, "%s\n", model); + return sysfs_emit(buf, "%s\n", model); } =20 static ssize_t @@ -805,7 +805,7 @@ bfad_im_model_desc_show(struct device *dev, struct devi= ce_attribute *attr, snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN, "Invalid Model"); =20 - return snprintf(buf, PAGE_SIZE, "%s\n", model_descr); + return sysfs_emit(buf, "%s\n", model_descr); } =20 static ssize_t @@ -819,7 +819,7 @@ bfad_im_node_name_show(struct device *dev, struct devic= e_attribute *attr, u64 nwwn; =20 nwwn =3D bfa_fcs_lport_get_nwwn(port->fcs_port); - return snprintf(buf, PAGE_SIZE, "0x%llx\n", cpu_to_be64(nwwn)); + return sysfs_emit(buf, "0x%llx\n", cpu_to_be64(nwwn)); } =20 static ssize_t @@ -836,7 +836,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct d= evice_attribute *attr, bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr); strlcpy(symname, port_attr.port_cfg.sym_name.symname, BFA_SYMNAME_MAXLEN); - return snprintf(buf, PAGE_SIZE, "%s\n", symname); + return sysfs_emit(buf, "%s\n", symname); } =20 static ssize_t @@ -850,14 +850,14 @@ bfad_im_hw_version_show(struct device *dev, struct de= vice_attribute *attr, char hw_ver[BFA_VERSION_LEN]; =20 bfa_get_pci_chip_rev(&bfad->bfa, hw_ver); - return snprintf(buf, PAGE_SIZE, "%s\n", hw_ver); + return sysfs_emit(buf, "%s\n", hw_ver); } =20 static ssize_t bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_VERSION); + return sysfs_emit(buf, "%s\n", BFAD_DRIVER_VERSION); } =20 static ssize_t @@ -871,7 +871,7 @@ bfad_im_optionrom_version_show(struct device *dev, char optrom_ver[BFA_VERSION_LEN]; =20 bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver); - return snprintf(buf, PAGE_SIZE, "%s\n", optrom_ver); + return sysfs_emit(buf, "%s\n", optrom_ver); } =20 static ssize_t @@ -885,7 +885,7 @@ bfad_im_fw_version_show(struct device *dev, struct devi= ce_attribute *attr, char fw_ver[BFA_VERSION_LEN]; =20 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); - return snprintf(buf, PAGE_SIZE, "%s\n", fw_ver); + return sysfs_emit(buf, "%s\n", fw_ver); } =20 static ssize_t @@ -897,7 +897,7 @@ bfad_im_num_of_ports_show(struct device *dev, struct de= vice_attribute *attr, (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad =3D im_port->bfad; =20 - return snprintf(buf, PAGE_SIZE, "%d\n", + return sysfs_emit(buf, "%d\n", bfa_get_nports(&bfad->bfa)); } =20 @@ -905,7 +905,7 @@ static ssize_t bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME); + return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME); } =20 static ssize_t @@ -924,14 +924,14 @@ bfad_im_num_of_discovered_ports_show(struct device *d= ev, rports =3D kcalloc(nrports, sizeof(struct bfa_rport_qualifier_s), GFP_ATOMIC); if (rports =3D=3D NULL) - return snprintf(buf, PAGE_SIZE, "Failed\n"); + return sysfs_emit(buf, "Failed\n"); =20 spin_lock_irqsave(&bfad->bfad_lock, flags); bfa_fcs_lport_get_rport_quals(port->fcs_port, rports, &nrports); spin_unlock_irqrestore(&bfad->bfad_lock, flags); kfree(rports); =20 - return snprintf(buf, PAGE_SIZE, "%d\n", nrports); + return sysfs_emit(buf, "%d\n", nrports); } =20 static DEVICE_ATTR(serial_number, S_IRUGO, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 AFEA4C3525B for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383169AbiDLIgB (ORCPT ); Tue, 12 Apr 2022 04:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356353AbiDLHfS (ORCPT ); Tue, 12 Apr 2022 03:35:18 -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 E777649F99; Tue, 12 Apr 2022 00:09: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 6FAB0B81B54; Tue, 12 Apr 2022 07:09:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDDABC385A5; Tue, 12 Apr 2022 07:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747347; bh=tOio+VmNko1UzUjmLWTcQDjPm3ck2VQexHps4VvQ8wM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIBVYePR2RCdel2wN2t4j74OOIcz8cfFSpzP+vIevGoYhVrABxh26vKrYzE3+OXj/ Z04/dVh2HTodKYR6B5Qgh3zsqqKs1N0o1PBCZKeaGD+pWGkTFvu0hQpGPiqoJsZOpq mkOvo3bdmMOFq/O5W6f8atqmDpFWIom3zVSpYhh4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yongzhi Liu , Melissa Wen , Melissa Wen , Sasha Levin Subject: [PATCH 5.17 046/343] drm/v3d: fix missing unlock Date: Tue, 12 Apr 2022 08:27:44 +0200 Message-Id: <20220412062952.436777574@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yongzhi Liu [ Upstream commit e57c1a3bd5e8e0c7181f65ae55581f0236a8f284 ] [why] Unlock is needed on the error handling path to prevent dead lock. v3d_submit_cl_ioctl and v3d_submit_csd_ioctl is missing unlock. [how] Fix this by changing goto target on the error handling path. So changing the goto to target an error handling path that includes drm_gem_unlock reservations. Signed-off-by: Yongzhi Liu Reviewed-by: Melissa Wen Signed-off-by: Melissa Wen Link: https://patchwork.freedesktop.org/patch/msgid/1643377262-109975-1-git= -send-email-lyz_cs@pku.edu.cn Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/v3d/v3d_gem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c index c7ed2e1cbab6..92bc0faee84f 100644 --- a/drivers/gpu/drm/v3d/v3d_gem.c +++ b/drivers/gpu/drm/v3d/v3d_gem.c @@ -798,7 +798,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, =20 if (!render->base.perfmon) { ret =3D -ENOENT; - goto fail; + goto fail_perfmon; } } =20 @@ -847,6 +847,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, =20 fail_unreserve: mutex_unlock(&v3d->sched_lock); +fail_perfmon: drm_gem_unlock_reservations(last_job->bo, last_job->bo_count, &acquire_ctx); fail: @@ -1027,7 +1028,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *da= ta, args->perfmon_id); if (!job->base.perfmon) { ret =3D -ENOENT; - goto fail; + goto fail_perfmon; } } =20 @@ -1056,6 +1057,7 @@ v3d_submit_csd_ioctl(struct drm_device *dev, void *da= ta, =20 fail_unreserve: mutex_unlock(&v3d->sched_lock); +fail_perfmon: drm_gem_unlock_reservations(clean_job->bo, clean_job->bo_count, &acquire_ctx); fail: --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6B7D2C4321E for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383076AbiDLIff (ORCPT ); Tue, 12 Apr 2022 04:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356334AbiDLHfR (ORCPT ); Tue, 12 Apr 2022 03:35:17 -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 61FDD4DF45; Tue, 12 Apr 2022 00:09: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 35118B81B4D; Tue, 12 Apr 2022 07:09:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0C36C385A6; Tue, 12 Apr 2022 07:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747350; bh=gRNOeKX3UpDJ2UTk1snAD3IFc3HXFcB2VDj/JDji+rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mbrg81fbksp2emUIROrhMOLhf9K+WdRPKnmIUbJ88jJ95lT0D9YdKT/3HAukUdZ3t xo4mXbXZ69CM36Hsoe5hIGwi3NDycTT5u2tLsdvbHOr7TZtD8FzcNf39H2/be2tncK QErjUlWFgFp9RlbzaJ1zQLKBNshKbF4MZJG4YJoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeny Boger , Chen-Yu Tsai , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.17 047/343] power: supply: axp20x_battery: properly report current when discharging Date: Tue, 12 Apr 2022 08:27:45 +0200 Message-Id: <20220412062952.465740359@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Evgeny Boger [ Upstream commit d4f408cdcd26921c1268cb8dcbe8ffb6faf837f3 ] As stated in [1], negative current values are used for discharging batteries. AXP PMICs internally have two different ADC channels for shunt current measurement: one used during charging and one during discharging. The values reported by these ADCs are unsigned. While the driver properly selects ADC channel to get the data from, it doesn't apply negative sign when reporting discharging current. [1] Documentation/ABI/testing/sysfs-class-power Signed-off-by: Evgeny Boger Acked-by: Chen-Yu Tsai Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/power/supply/axp20x_battery.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/a= xp20x_battery.c index 5d197141f476..9106077c0dbb 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -186,7 +186,6 @@ static int axp20x_battery_get_prop(struct power_supply = *psy, union power_supply_propval *val) { struct axp20x_batt_ps *axp20x_batt =3D power_supply_get_drvdata(psy); - struct iio_channel *chan; int ret =3D 0, reg, val1; =20 switch (psp) { @@ -266,12 +265,12 @@ static int axp20x_battery_get_prop(struct power_suppl= y *psy, if (ret) return ret; =20 - if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) - chan =3D axp20x_batt->batt_chrg_i; - else - chan =3D axp20x_batt->batt_dischrg_i; - - ret =3D iio_read_channel_processed(chan, &val->intval); + if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) { + ret =3D iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intv= al); + } else { + ret =3D iio_read_channel_processed(axp20x_batt->batt_dischrg_i, &val1); + val->intval =3D -val1; + } if (ret) return ret; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2FC2FC47081 for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383111AbiDLIfq (ORCPT ); Tue, 12 Apr 2022 04:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356333AbiDLHfR (ORCPT ); Tue, 12 Apr 2022 03:35:17 -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 7F11E50E0C; Tue, 12 Apr 2022 00:09: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 ams.source.kernel.org (Postfix) with ESMTPS id D9133B81B50; Tue, 12 Apr 2022 07:09:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E65BC385A6; Tue, 12 Apr 2022 07:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747355; bh=PavfG5KJ6cWoEDDVC5lfDN5ZmM9XXHm3w/O0k/krWlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mfNyjZYQp6oopjpH8Uel+YHE4IDXf8Rhphgm0Za6bhC5ZOrshx+i0oyf0dyNl6uxK 7RDsG6An401VbtnbPsI5AaHwDU5DHutXb1dn4LgeFrWk429keGI2k0dgECAtRRbVn8 /cVVdcVJovbUl1eNXBYjQGSqGMZOsDGgs/vg9fDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Greear , Felix Fietkau , Sasha Levin Subject: [PATCH 5.17 048/343] mt76: mt7921: fix crash when startup fails. Date: Tue, 12 Apr 2022 08:27:46 +0200 Message-Id: <20220412062952.493639313@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Greear [ Upstream commit 827e7799c61b978fbc2cc9dac66cb62401b2b3f0 ] If the nic fails to start, it is possible that the reset_work has already been scheduled. Ensure the work item is canceled so we do not have use-after-free crash in case cleanup is called before the work item is executed. This fixes crash on my x86_64 apu2 when mt7921k radio fails to work. Radio still fails, but OS does not crash. Signed-off-by: Ben Greear Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net= /wireless/mediatek/mt76/mt7921/main.c index 7a8d2596c226..4abb7a6e775a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -273,6 +273,7 @@ static void mt7921_stop(struct ieee80211_hw *hw) =20 cancel_delayed_work_sync(&dev->pm.ps_work); cancel_work_sync(&dev->pm.wake_work); + cancel_work_sync(&dev->reset_work); mt76_connac_free_pending_tx_skbs(&dev->pm, NULL); =20 mt7921_mutex_acquire(dev); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CF7EDC3527B for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383210AbiDLIgR (ORCPT ); Tue, 12 Apr 2022 04:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356336AbiDLHfR (ORCPT ); Tue, 12 Apr 2022 03:35:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9CFB50E20; Tue, 12 Apr 2022 00:09: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 dfw.source.kernel.org (Postfix) with ESMTPS id E833A6153F; Tue, 12 Apr 2022 07:09:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 093B9C385A6; Tue, 12 Apr 2022 07:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747358; bh=7LWiAcws8u/HCNTAdXqZaaR6yiyYCFrCrnQVnBHB8RU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujeUn78oruZlw4jcnE9faSYoojcL2G6In2SRG+WPHp17/qgPE93VfX/7m34d9NZPU mHF++FUxgRJjBihUvY76CPFwh87o8MJGQJgnu1zTqBNoUO7PNvtSqW8L3BGvWSnT0+ sVOTZrfDsZ3GUfGsFLew+iu5r4txqxaokjGF3ZTc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.17 049/343] mt76: dma: initialize skip_unmap in mt76_dma_rx_fill Date: Tue, 12 Apr 2022 08:27:47 +0200 Message-Id: <20220412062952.522211251@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Lorenzo Bianconi [ Upstream commit 577298ec55dfc8b9aece54520f0258c3f93a6573 ] Even if it is only a false-positive since skip_buf0/skip_buf1 are only used in mt76_dma_tx_cleanup_idx routine, initialize skip_unmap in mt76_dma_rx_fill in order to fix the following UBSAN report: [ 13.924906] UBSAN: invalid-load in linux-5.15.0/drivers/net/wireless/med= iatek/mt76/dma.c:162:13 [ 13.924909] load of value 225 is not a valid value for type '_Bool' [ 13.924912] CPU: 9 PID: 672 Comm: systemd-udevd Not tainted 5.15.0-18-ge= neric #18-Ubuntu [ 13.924914] Hardware name: LENOVO 21A0000CMX/21A0000CMX, BIOS R1MET43W (= 1.13 ) 11/05/2021 [ 13.924915] Call Trace: [ 13.924917] [ 13.924920] show_stack+0x52/0x58 [ 13.924925] dump_stack_lvl+0x4a/0x5f [ 13.924931] dump_stack+0x10/0x12 [ 13.924932] ubsan_epilogue+0x9/0x45 [ 13.924934] __ubsan_handle_load_invalid_value.cold+0x44/0x49 [ 13.924935] ? __iommu_dma_map+0x84/0xf0 [ 13.924939] mt76_dma_add_buf.constprop.0.cold+0x23/0x85 [mt76] [ 13.924949] mt76_dma_rx_fill.isra.0+0x102/0x1f0 [mt76] [ 13.924954] mt76_dma_init+0xc9/0x150 [mt76] [ 13.924959] ? mt7921_dma_enable+0x110/0x110 [mt7921e] [ 13.924966] mt7921_dma_init+0x1e3/0x260 [mt7921e] [ 13.924970] mt7921_register_device+0x29d/0x510 [mt7921e] [ 13.924975] mt7921_pci_probe.part.0+0x17f/0x1b0 [mt7921e] [ 13.924980] mt7921_pci_probe+0x43/0x60 [mt7921e] [ 13.924984] local_pci_probe+0x4b/0x90 [ 13.924987] pci_device_probe+0x115/0x1f0 [ 13.924989] really_probe+0x21e/0x420 [ 13.924992] __driver_probe_device+0x115/0x190 [ 13.924994] driver_probe_device+0x23/0xc0 [ 13.924996] __driver_attach+0xbd/0x1d0 [ 13.924998] ? __device_attach_driver+0x110/0x110 [ 13.924999] bus_for_each_dev+0x7e/0xc0 [ 13.925001] driver_attach+0x1e/0x20 [ 13.925003] bus_add_driver+0x135/0x200 [ 13.925005] driver_register+0x95/0xf0 [ 13.925008] ? 0xffffffffc0766000 [ 13.925010] __pci_register_driver+0x68/0x70 [ 13.925011] mt7921_pci_driver_init+0x23/0x1000 [mt7921e] [ 13.925015] do_one_initcall+0x48/0x1d0 [ 13.925019] ? kmem_cache_alloc_trace+0x19e/0x2e0 [ 13.925022] do_init_module+0x62/0x280 [ 13.925025] load_module+0xac9/0xbb0 [ 13.925027] __do_sys_finit_module+0xbf/0x120 [ 13.925029] __x64_sys_finit_module+0x18/0x20 [ 13.925030] do_syscall_64+0x5c/0xc0 [ 13.925033] ? do_syscall_64+0x69/0xc0 [ 13.925034] ? sysvec_reschedule_ipi+0x78/0xe0 [ 13.925036] ? asm_sysvec_reschedule_ipi+0xa/0x20 [ 13.925039] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 13.925040] RIP: 0033:0x7fbf2b90f94d [ 13.925045] RSP: 002b:00007ffe2ec7e5d8 EFLAGS: 00000246 ORIG_RAX: 000000= 0000000139 [ 13.925047] RAX: ffffffffffffffda RBX: 000056106b0634e0 RCX: 00007fbf2b9= 0f94d [ 13.925048] RDX: 0000000000000000 RSI: 00007fbf2baa3441 RDI: 00000000000= 00013 [ 13.925049] RBP: 0000000000020000 R08: 0000000000000000 R09: 00000000000= 00002 [ 13.925050] R10: 0000000000000013 R11: 0000000000000246 R12: 00007fbf2ba= a3441 [ 13.925051] R13: 000056106b062620 R14: 000056106b0610c0 R15: 000056106b0= 640d0 [ 13.925053] Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/mediatek/mt76/dma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireles= s/mediatek/mt76/dma.c index 3a9af8931c35..3d644925a4e0 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -465,6 +465,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queu= e *q) =20 qbuf.addr =3D addr + offset; qbuf.len =3D len - offset; + qbuf.skip_unmap =3D false; mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, NULL); frames++; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 8AD4AC4167D for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383126AbiDLIft (ORCPT ); Tue, 12 Apr 2022 04:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356345AbiDLHfS (ORCPT ); Tue, 12 Apr 2022 03:35:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB88F50E2E; Tue, 12 Apr 2022 00:09: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9B978616E3; Tue, 12 Apr 2022 07:09:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A961EC385A5; Tue, 12 Apr 2022 07:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747361; bh=ml72iPm2ujhvVrlOqTzu2cWjMgaiiwbonFftTOGfFDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hlVC9e2XmEh927T042mUJOUbm5p/5D2pagEdHpCaJ9C5TJHcfFKebNEbykHc9qfys bIfcMPcps75ZCC+heaUdX2gk+dmtce7GBEZMF/yu60qeHcD2KkhcFiLmJscn0sw0m9 5UMaCWGezafkDKIAXyFw1UQvYMhKQoRzOh5ERHO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Witold Fijalkowski , Jedrzej Jagielski , Gurucharan G , Tony Nguyen , Sasha Levin Subject: [PATCH 5.17 050/343] i40e: Add sending commands in atomic context Date: Tue, 12 Apr 2022 08:27:48 +0200 Message-Id: <20220412062952.550900069@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jedrzej Jagielski [ Upstream commit 59b3d7350ff35c939b8e173eb2eecac80a5ee046 ] Change functions: - i40e_aq_add_macvlan - i40e_aq_remove_macvlan - i40e_aq_delete_element - i40e_aq_add_vsi - i40e_aq_update_vsi_params to explicitly use i40e_asq_send_command_atomic(..., true) instead of i40e_asq_send_command, as they use mutexes and do some work in an atomic context. Without this change setting vlan via netdev will fail with call trace cased by bug "BUG: scheduling while atomic". Signed-off-by: Witold Fijalkowski Signed-off-by: Jedrzej Jagielski Tested-by: Gurucharan G Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/i40e/i40e_common.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/et= hernet/intel/i40e/i40e_common.c index 9ddeb015eb7e..e830987a8c6d 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_common.c +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c @@ -1899,8 +1899,9 @@ i40e_status i40e_aq_add_vsi(struct i40e_hw *hw, =20 desc.flags |=3D cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); =20 - status =3D i40e_asq_send_command(hw, &desc, &vsi_ctx->info, - sizeof(vsi_ctx->info), cmd_details); + status =3D i40e_asq_send_command_atomic(hw, &desc, &vsi_ctx->info, + sizeof(vsi_ctx->info), + cmd_details, true); =20 if (status) goto aq_add_vsi_exit; @@ -2287,8 +2288,9 @@ i40e_status i40e_aq_update_vsi_params(struct i40e_hw = *hw, =20 desc.flags |=3D cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD)); =20 - status =3D i40e_asq_send_command(hw, &desc, &vsi_ctx->info, - sizeof(vsi_ctx->info), cmd_details); + status =3D i40e_asq_send_command_atomic(hw, &desc, &vsi_ctx->info, + sizeof(vsi_ctx->info), + cmd_details, true); =20 vsi_ctx->vsis_allocated =3D le16_to_cpu(resp->vsi_used); vsi_ctx->vsis_unallocated =3D le16_to_cpu(resp->vsi_free); @@ -2673,8 +2675,8 @@ i40e_status i40e_aq_add_macvlan(struct i40e_hw *hw, u= 16 seid, if (buf_size > I40E_AQ_LARGE_BUF) desc.flags |=3D cpu_to_le16((u16)I40E_AQ_FLAG_LB); =20 - status =3D i40e_asq_send_command(hw, &desc, mv_list, buf_size, - cmd_details); + status =3D i40e_asq_send_command_atomic(hw, &desc, mv_list, buf_size, + cmd_details, true); =20 return status; } @@ -2715,8 +2717,8 @@ i40e_status i40e_aq_remove_macvlan(struct i40e_hw *hw= , u16 seid, if (buf_size > I40E_AQ_LARGE_BUF) desc.flags |=3D cpu_to_le16((u16)I40E_AQ_FLAG_LB); =20 - status =3D i40e_asq_send_command(hw, &desc, mv_list, buf_size, - cmd_details); + status =3D i40e_asq_send_command_atomic(hw, &desc, mv_list, buf_size, + cmd_details, true); =20 return status; } @@ -3868,7 +3870,8 @@ i40e_status i40e_aq_delete_element(struct i40e_hw *hw= , u16 seid, =20 cmd->seid =3D cpu_to_le16(seid); =20 - status =3D i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details); + status =3D i40e_asq_send_command_atomic(hw, &desc, NULL, 0, + cmd_details, true); =20 return status; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9AA2DC41535 for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383147AbiDLIfy (ORCPT ); Tue, 12 Apr 2022 04:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356388AbiDLHfZ (ORCPT ); Tue, 12 Apr 2022 03:35:25 -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 B927D5131D; Tue, 12 Apr 2022 00:09: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 ams.source.kernel.org (Postfix) with ESMTPS id 04DBEB81B5D; Tue, 12 Apr 2022 07:09:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 576B8C385A5; Tue, 12 Apr 2022 07:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747363; bh=VVkldtKKzVFjq87XcXUHMuOaGul0Zrdrv27o1u0BB7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqU7WWCp1b4g3PADaizDXE24t7gHrut7xQY7GkEfNOWiMwstr81+HhpZfCiYCkMUm sRtZNc9JZ9silF0iepHOpB+/J88dngCzlNGmil7xBtrWVBNrj3/Pr28Ps/PATLIMIb /de5V5EFqj+zHEyLFBS5crWFKBj8E3Ug4NqkIw0w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Avraham Stern , Luca Coelho , Johannes Berg , Sasha Levin Subject: [PATCH 5.17 051/343] cfg80211: dont add non transmitted BSS to 6GHz scanned channels Date: Tue, 12 Apr 2022 08:27:49 +0200 Message-Id: <20220412062952.579111880@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Avraham Stern [ Upstream commit 5666ee154f4696c011dfa8544aaf5591b6b87515 ] When adding 6GHz channels to scan request based on reported co-located APs, don't add channels that have only APs with "non-transmitted" BSSes if they only match the wildcard SSID since they will be found by probing the "transmitted" BSS. Signed-off-by: Avraham Stern Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20220202104617.f6ddf099f934.I231e55= 885d3644f292d00dfe0f42653269f2559e@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/wireless/scan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index b888522f133b..b2fdac96bab0 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -700,8 +700,12 @@ static bool cfg80211_find_ssid_match(struct cfg80211_c= olocated_ap *ap, =20 for (i =3D 0; i < request->n_ssids; i++) { /* wildcard ssid in the scan request */ - if (!request->ssids[i].ssid_len) + if (!request->ssids[i].ssid_len) { + if (ap->multi_bss && !ap->transmitted_bssid) + continue; + return true; + } =20 if (ap->ssid_len && ap->ssid_len =3D=3D request->ssids[i].ssid_len) { @@ -827,6 +831,9 @@ static int cfg80211_scan_6ghz(struct cfg80211_registere= d_device *rdev) !cfg80211_find_ssid_match(ap, request)) continue; =20 + if (!request->n_ssids && ap->multi_bss && !ap->transmitted_bssid) + continue; + cfg80211_scan_req_add_chan(request, chan, true); memcpy(scan_6ghz_params->bssid, ap->bssid, ETH_ALEN); scan_6ghz_params->short_ssid =3D ap->short_ssid; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E09DCC4707A for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383225AbiDLIgW (ORCPT ); Tue, 12 Apr 2022 04:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356455AbiDLHfz (ORCPT ); Tue, 12 Apr 2022 03:35:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2240E5158B; Tue, 12 Apr 2022 00:09: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 B6BADB81B4E; Tue, 12 Apr 2022 07:09:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CFDAC385A1; Tue, 12 Apr 2022 07:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747366; bh=wDcLxwej26NS4LB06tWq4HGyqInkKqDEgOV0hiCt7+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tJI7SrZaf3JY9oRraKiogqmVBPD2mGnJfLGxc1d54VqHWzDnwE5j+3wK91g3yOU+o ANMnShUhH4WvyIBMKMoy2W7E2lrt+jADVQuOB/w4RnI2taqn8dKPzakc8TiymURKy9 vL0T6R5O/a9aVQse9G5eWu7TfMflejSrIWUuWnqY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Delyan Kratunov , Yonghong Song , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.17 052/343] libbpf: Fix build issue with llvm-readelf Date: Tue, 12 Apr 2022 08:27:50 +0200 Message-Id: <20220412062952.607814356@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yonghong Song [ Upstream commit 0908a66ad1124c1634c33847ac662106f7f2c198 ] There are cases where clang compiler is packaged in a way readelf is a symbolic link to llvm-readelf. In such cases, llvm-readelf will be used instead of default binutils readelf, and the following error will appear during libbpf build: # Warning: Num of global symbols in # /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/= sharedobjs/libbpf-in.o (367) # does NOT match with num of versioned symbols in # /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/= libbpf.so libbpf.map (383). # Please make sure all LIBBPF_API symbols are versioned in libbpf.map. # --- /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libb= pf/libbpf_global_syms.tmp ... # +++ /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libb= pf/libbpf_versioned_syms.tmp ... # @@ -324,6 +324,22 @@ # btf__str_by_offset # btf__type_by_id # btf__type_cnt # +LIBBPF_0.0.1 # +LIBBPF_0.0.2 # +LIBBPF_0.0.3 # +LIBBPF_0.0.4 # +LIBBPF_0.0.5 # +LIBBPF_0.0.6 # +LIBBPF_0.0.7 # +LIBBPF_0.0.8 # +LIBBPF_0.0.9 # +LIBBPF_0.1.0 # +LIBBPF_0.2.0 # +LIBBPF_0.3.0 # +LIBBPF_0.4.0 # +LIBBPF_0.5.0 # +LIBBPF_0.6.0 # +LIBBPF_0.7.0 # libbpf_attach_type_by_name # libbpf_find_kernel_btf # libbpf_find_vmlinux_btf_id # make[2]: *** [Makefile:184: check_abi] Error 1 # make[1]: *** [Makefile:140: all] Error 2 The above failure is due to different printouts for some ABS versioned symbols. For example, with the same libbpf.so, $ /bin/readelf --dyn-syms --wide tools/lib/bpf/libbpf.so | grep "LIBBPF" = | grep ABS 134: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LIBBPF_0.5.0 202: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LIBBPF_0.6.0 ... $ /opt/llvm/bin/readelf --dyn-syms --wide tools/lib/bpf/libbpf.so | grep = "LIBBPF" | grep ABS 134: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LIBBPF_0.5.0@= @LIBBPF_0.5.0 202: 0000000000000000 0 OBJECT GLOBAL DEFAULT ABS LIBBPF_0.6.0@= @LIBBPF_0.6.0 ... The binutils readelf doesn't print out the symbol LIBBPF_* version and llvm= -readelf does. Such a difference caused libbpf build failure with llvm-readelf. The proposed fix filters out all ABS symbols as they are not part of the co= mparison. This works for both binutils readelf and llvm-readelf. Reported-by: Delyan Kratunov Signed-off-by: Yonghong Song Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220204214355.502108-1-yhs@fb.com Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/lib/bpf/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -131,7 +131,7 @@ GLOBAL_SYM_COUNT =3D $(shell readelf -s -- sort -u | wc -l) VERSIONED_SYM_COUNT =3D $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.= so | \ sed 's/\[.*\]//' | \ - awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | \ + awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \ grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l) =20 CMD_TARGETS =3D $(LIB_TARGET) $(PC_FILE) @@ -194,7 +194,7 @@ check_abi: $(OUTPUT)libbpf.so $(VERSION_ sort -u > $(OUTPUT)libbpf_global_syms.tmp; \ readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \ sed 's/\[.*\]//' | \ - awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'| \ + awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}'| \ grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \ sort -u > $(OUTPUT)libbpf_versioned_syms.tmp; \ diff -u $(OUTPUT)libbpf_global_syms.tmp \ From nobody Thu May 14 08:08:21 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 EF90BC3527C for ; Tue, 12 Apr 2022 08:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383240AbiDLIg2 (ORCPT ); Tue, 12 Apr 2022 04:36:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356468AbiDLHgA (ORCPT ); Tue, 12 Apr 2022 03:36:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B76F51593; Tue, 12 Apr 2022 00:09:30 -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 ABBB4616B2; Tue, 12 Apr 2022 07:09:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7075C385A5; Tue, 12 Apr 2022 07:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747369; bh=EhKLdnK32sN+KL08v3VGfLz6sRmN0hyklQFXg4QHiUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=grT319c2ujLtfGksgFJhMKirqqkUQlbVoNP0okN2ctBI203pwiR4cEIALjZjXLV0Q 8MxgU3N+29H/97h5nkUMDO3+c73wI5mZhDE2n6LGgWdcuGmg4a9Gp2aHGLa4Qwed7O co1MtbeTqv1QkGsnykSrbG0pjpuH+gUfsEAYy0Yo= 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.17 053/343] ipv6: make mc_forwarding atomic Date: Tue, 12 Apr 2022 08:27:51 +0200 Message-Id: <20220412062952.636807042@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 145c7a793838add5e004e7d49a67654dc7eba147 ] This fixes minor data-races in ip6_mc_input() and batadv_mcast_mla_rtr_flags_softif_get_ipv6() Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/linux/ipv6.h | 2 +- net/batman-adv/multicast.c | 2 +- net/ipv6/addrconf.c | 4 ++-- net/ipv6/ip6_input.c | 2 +- net/ipv6/ip6mr.c | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index a59d25f19385..b8641dc0ee66 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -51,7 +51,7 @@ struct ipv6_devconf { __s32 use_optimistic; #endif #ifdef CONFIG_IPV6_MROUTE - __s32 mc_forwarding; + atomic_t mc_forwarding; #endif __s32 disable_ipv6; __s32 drop_unicast_in_l2_multicast; diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index f4004cf0ff6f..9f311fddfaf9 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -134,7 +134,7 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get_ipv6(st= ruct net_device *dev) { struct inet6_dev *in6_dev =3D __in6_dev_get(dev); =20 - if (in6_dev && in6_dev->cnf.mc_forwarding) + if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding)) return BATADV_NO_FLAGS; else return BATADV_MCAST_WANT_NO_RTR6; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index f908e2fd30b2..4df84013c4e6 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -554,7 +554,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *s= kb, int ifindex, #ifdef CONFIG_IPV6_MROUTE if ((all || type =3D=3D NETCONFA_MC_FORWARDING) && nla_put_s32(skb, NETCONFA_MC_FORWARDING, - devconf->mc_forwarding) < 0) + atomic_read(&devconf->mc_forwarding)) < 0) goto nla_put_failure; #endif if ((all || type =3D=3D NETCONFA_PROXY_NEIGH) && @@ -5539,7 +5539,7 @@ static inline void ipv6_store_devconf(struct ipv6_dev= conf *cnf, array[DEVCONF_USE_OPTIMISTIC] =3D cnf->use_optimistic; #endif #ifdef CONFIG_IPV6_MROUTE - array[DEVCONF_MC_FORWARDING] =3D cnf->mc_forwarding; + array[DEVCONF_MC_FORWARDING] =3D atomic_read(&cnf->mc_forwarding); #endif array[DEVCONF_DISABLE_IPV6] =3D cnf->disable_ipv6; array[DEVCONF_ACCEPT_DAD] =3D cnf->accept_dad; diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 80256717868e..d4b1e2c5aa76 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -508,7 +508,7 @@ int ip6_mc_input(struct sk_buff *skb) /* * IPv6 multicast router mode is now supported ;) */ - if (dev_net(skb->dev)->ipv6.devconf_all->mc_forwarding && + if (atomic_read(&dev_net(skb->dev)->ipv6.devconf_all->mc_forwarding) && !(ipv6_addr_type(&hdr->daddr) & (IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL)) && likely(!(IP6CB(skb)->flags & IP6SKB_FORWARDED))) { diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 8a2db926b5eb..e3c884678dbe 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -734,7 +734,7 @@ static int mif6_delete(struct mr_table *mrt, int vifi, = int notify, =20 in6_dev =3D __in6_dev_get(dev); if (in6_dev) { - in6_dev->cnf.mc_forwarding--; + atomic_dec(&in6_dev->cnf.mc_forwarding); inet6_netconf_notify_devconf(dev_net(dev), RTM_NEWNETCONF, NETCONFA_MC_FORWARDING, dev->ifindex, &in6_dev->cnf); @@ -902,7 +902,7 @@ static int mif6_add(struct net *net, struct mr_table *m= rt, =20 in6_dev =3D __in6_dev_get(dev); if (in6_dev) { - in6_dev->cnf.mc_forwarding++; + atomic_inc(&in6_dev->cnf.mc_forwarding); inet6_netconf_notify_devconf(dev_net(dev), RTM_NEWNETCONF, NETCONFA_MC_FORWARDING, dev->ifindex, &in6_dev->cnf); @@ -1553,7 +1553,7 @@ static int ip6mr_sk_init(struct mr_table *mrt, struct= sock *sk) } else { rcu_assign_pointer(mrt->mroute_sk, sk); sock_set_flag(sk, SOCK_RCU_FREE); - net->ipv6.devconf_all->mc_forwarding++; + atomic_inc(&net->ipv6.devconf_all->mc_forwarding); } write_unlock_bh(&mrt_lock); =20 @@ -1586,7 +1586,7 @@ int ip6mr_sk_done(struct sock *sk) * so the RCU grace period before sk freeing * is guaranteed by sk_destruct() */ - net->ipv6.devconf_all->mc_forwarding--; + atomic_dec(&net->ipv6.devconf_all->mc_forwarding); write_unlock_bh(&mrt_lock); inet6_netconf_notify_devconf(net, RTM_NEWNETCONF, NETCONFA_MC_FORWARDING, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 10EBEC4707E for ; Tue, 12 Apr 2022 08:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383285AbiDLIgj (ORCPT ); Tue, 12 Apr 2022 04:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356480AbiDLHgA (ORCPT ); Tue, 12 Apr 2022 03:36:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD7E54A3EE; Tue, 12 Apr 2022 00:09: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 6370C6146F; Tue, 12 Apr 2022 07:09:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76B25C385A6; Tue, 12 Apr 2022 07:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747371; bh=3XFV5biq5OKl0CczAPZ36nRwmNhb5XFyF+xyv26CnHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ASj+6bU47RexSFOwbVrYwVfvtDi5eOn4VC+z5zwI0GyOdrDk4FqfUSCVbQPIjLgur 5ZD7M5xDvyzOskl95Nqy5sb9sHI35EunVF3au4tptGszQyjWMgCHhUJMMGzj5JShiK PdZ5FfU+GRX/YRRDY6BlDk9CIn8omRTKn5xx210E= 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.17 054/343] ref_tracker: implement use-after-free detection Date: Tue, 12 Apr 2022 08:27:52 +0200 Message-Id: <20220412062952.665386470@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 e3ececfe668facd87d920b608349a32607060e66 ] Whenever ref_tracker_dir_init() is called, mark the struct ref_tracker_dir as dead. Test the dead status from ref_tracker_alloc() and ref_tracker_free() This should detect buggy dev_put()/dev_hold() happening too late in netdevice dismantle process. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/linux/ref_tracker.h | 2 ++ lib/ref_tracker.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h index 60f3453be23e..a443abda937d 100644 --- a/include/linux/ref_tracker.h +++ b/include/linux/ref_tracker.h @@ -13,6 +13,7 @@ struct ref_tracker_dir { spinlock_t lock; unsigned int quarantine_avail; refcount_t untracked; + bool dead; struct list_head list; /* List of active trackers */ struct list_head quarantine; /* List of dead trackers */ #endif @@ -26,6 +27,7 @@ static inline void ref_tracker_dir_init(struct ref_tracke= r_dir *dir, INIT_LIST_HEAD(&dir->quarantine); spin_lock_init(&dir->lock); dir->quarantine_avail =3D quarantine_count; + dir->dead =3D false; refcount_set(&dir->untracked, 1); stack_depot_init(); } diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c index a6789c0c626b..32ff6bd497f8 100644 --- a/lib/ref_tracker.c +++ b/lib/ref_tracker.c @@ -20,6 +20,7 @@ void ref_tracker_dir_exit(struct ref_tracker_dir *dir) unsigned long flags; bool leak =3D false; =20 + dir->dead =3D true; spin_lock_irqsave(&dir->lock, flags); list_for_each_entry_safe(tracker, n, &dir->quarantine, head) { list_del(&tracker->head); @@ -72,6 +73,8 @@ int ref_tracker_alloc(struct ref_tracker_dir *dir, gfp_t gfp_mask =3D gfp; unsigned long flags; =20 + WARN_ON_ONCE(dir->dead); + if (gfp & __GFP_DIRECT_RECLAIM) gfp_mask |=3D __GFP_NOFAIL; *trackerp =3D tracker =3D kzalloc(sizeof(*tracker), gfp_mask); @@ -100,6 +103,8 @@ int ref_tracker_free(struct ref_tracker_dir *dir, unsigned int nr_entries; unsigned long flags; =20 + WARN_ON_ONCE(dir->dead); + if (!tracker) { refcount_dec(&dir->untracked); return -EEXIST; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 35C52C4707F for ; Tue, 12 Apr 2022 08:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383383AbiDLIgv (ORCPT ); Tue, 12 Apr 2022 04:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353143AbiDLHhY (ORCPT ); Tue, 12 Apr 2022 03:37:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB600515BD; Tue, 12 Apr 2022 00:09: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 56C3B6153F; Tue, 12 Apr 2022 07:09:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 610DBC385A1; Tue, 12 Apr 2022 07:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747374; bh=T7TznzvdMqlaPzkJUDKOMgqBHtIEXvib62hGt+9AWGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zssfWWqBEnE/+/z2gGPC1AupRIQv3zhHgggnR82Ez+3rvN8WE82rMnr6BYoTga8ah lBVmqGea0masUEa3LQl5btM+rQnrKRfj0iE/EfQHQjUUtEzWyy6ZJHeuhzjJygW7Ix B2bvloZOH1RYqHSLTxBJhuH1Oq/PeO43o8rG7MWQ= 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.17 055/343] net: initialize init_net earlier Date: Tue, 12 Apr 2022 08:27:53 +0200 Message-Id: <20220412062952.693254073@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 9c1be1935fb68b2413796cdc03d019b8cf35ab51 ] While testing a patch that will follow later ("net: add netns refcount tracker to struct nsproxy") I found that devtmpfs_init() was called before init_net was initialized. This is a bug, because devtmpfs_setup() calls ksys_unshare(CLONE_NEWNS); This has the effect of increasing init_net refcount, which will be later overwritten to 1, as part of setup_net(&init_net) We had too many prior patches [1] trying to work around the root cause. Really, make sure init_net is in BSS section, and that net_ns_init() is called earlier at boot time. Note that another patch ("vfs: add netns refcount tracker to struct fs_context") also will need net_ns_init() being called before vfs_caches_init() As a bonus, this patch saves around 4KB in .data section. [1] f8c46cb39079 ("netns: do not call pernet ops for not yet set up init_net na= mespace") b5082df8019a ("net: Initialise init_net.count to 1") 734b65417b24 ("net: Statically initialize init_net.dev_base_head") v2: fixed a build error reported by kernel build bots (CONFIG_NET=3Dn) Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/net/net_namespace.h | 6 ++++++ init/main.c | 2 ++ net/core/dev.c | 3 +-- net/core/net_namespace.c | 17 +++++------------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 5b61c462e534..374cc7b260fc 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -513,4 +513,10 @@ static inline void fnhe_genid_bump(struct net *net) atomic_inc(&net->fnhe_genid); } =20 +#ifdef CONFIG_NET +void net_ns_init(void); +#else +static inline void net_ns_init(void) {} +#endif + #endif /* __NET_NET_NAMESPACE_H */ diff --git a/init/main.c b/init/main.c index 65fa2e41a9c0..ada50f5a15e4 100644 --- a/init/main.c +++ b/init/main.c @@ -99,6 +99,7 @@ #include #include #include +#include =20 #include #include @@ -1116,6 +1117,7 @@ asmlinkage __visible void __init __no_sanitize_addres= s start_kernel(void) key_init(); security_init(); dbg_late_init(); + net_ns_init(); vfs_caches_init(); pagecache_init(); signals_init(); diff --git a/net/core/dev.c b/net/core/dev.c index 1baab07820f6..91cf709c98b3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10732,8 +10732,7 @@ static int __net_init netdev_init(struct net *net) BUILD_BUG_ON(GRO_HASH_BUCKETS > 8 * sizeof_field(struct napi_struct, gro_bitmask)); =20 - if (net !=3D &init_net) - INIT_LIST_HEAD(&net->dev_base_head); + INIT_LIST_HEAD(&net->dev_base_head); =20 net->dev_name_head =3D netdev_create_hash(); if (net->dev_name_head =3D=3D NULL) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index a5b5bb99c644..212e65add951 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -44,13 +44,7 @@ EXPORT_SYMBOL_GPL(net_rwsem); static struct key_tag init_net_key_domain =3D { .usage =3D REFCOUNT_INIT(1= ) }; #endif =20 -struct net init_net =3D { - .ns.count =3D REFCOUNT_INIT(1), - .dev_base_head =3D LIST_HEAD_INIT(init_net.dev_base_head), -#ifdef CONFIG_KEYS - .key_domain =3D &init_net_key_domain, -#endif -}; +struct net init_net; EXPORT_SYMBOL(init_net); =20 static bool init_net_initialized; @@ -1084,7 +1078,7 @@ static void rtnl_net_notifyid(struct net *net, int cm= d, int id, u32 portid, rtnl_set_sk_err(net, RTNLGRP_NSID, err); } =20 -static int __init net_ns_init(void) +void __init net_ns_init(void) { struct net_generic *ng; =20 @@ -1105,6 +1099,9 @@ static int __init net_ns_init(void) =20 rcu_assign_pointer(init_net.gen, ng); =20 +#ifdef CONFIG_KEYS + init_net.key_domain =3D &init_net_key_domain; +#endif down_write(&pernet_ops_rwsem); if (setup_net(&init_net, &init_user_ns)) panic("Could not setup the initial network namespace"); @@ -1119,12 +1116,8 @@ static int __init net_ns_init(void) RTNL_FLAG_DOIT_UNLOCKED); rtnl_register(PF_UNSPEC, RTM_GETNSID, rtnl_net_getid, rtnl_net_dumpid, RTNL_FLAG_DOIT_UNLOCKED); - - return 0; } =20 -pure_initcall(net_ns_init); - static void free_exit_list(struct pernet_operations *ops, struct list_head= *net_exit_list) { ops_pre_exit_list(ops, net_exit_list); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 21BCAC3527D for ; Tue, 12 Apr 2022 08:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383351AbiDLIgq (ORCPT ); Tue, 12 Apr 2022 04:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352185AbiDLHhN (ORCPT ); Tue, 12 Apr 2022 03:37:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6760517C5; Tue, 12 Apr 2022 00:09: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 0F82E61701; Tue, 12 Apr 2022 07:09:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CC69C385A1; Tue, 12 Apr 2022 07:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747377; bh=0e/d5D+R6S4UcwLPGQgbNjXmPk3xN2N8EX8QHHUO7/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dO4MxluPah4l814KyKPL5YFZKsZpG3dU374S5ApNJ8vDYiB6ede+4ZG788Vsx6KFD XmG0eTIecErjeAn/BCLRsfpZcCc17CoxR+shGfGCdNzlngblJyUcMn/qnFax6a7gLR s2RqF1jtvE6/KPkfBg/B2k6lFaKNjMYQeeew9uSc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abdul haleem , Sourabh Jain , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 056/343] powerpc: Set crashkernel offset to mid of RMA region Date: Tue, 12 Apr 2022 08:27:54 +0200 Message-Id: <20220412062952.721929501@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sourabh Jain [ Upstream commit 7c5ed82b800d8615cdda00729e7b62e5899f0b13 ] On large config LPARs (having 192 and more cores), Linux fails to boot due to insufficient memory in the first memblock. It is due to the memory reservation for the crash kernel which starts at 128MB offset of the first memblock. This memory reservation for the crash kernel doesn't leave enough space in the first memblock to accommodate other essential system resources. The crash kernel start address was set to 128MB offset by default to ensure that the crash kernel get some memory below the RMA region which is used to be of size 256MB. But given that the RMA region size can be 512MB or more, setting the crash kernel offset to mid of RMA size will leave enough space for the kernel to allocate memory for other system resources. Since the above crash kernel offset change is only applicable to the LPAR platform, the LPAR feature detection is pushed before the crash kernel reservation. The rest of LPAR specific initialization will still be done during pseries_probe_fw_features as usual. This patch is dependent on changes to paca allocation for boot CPU. It expect boot CPU to discover 1T segment support which is introduced by the patch posted here: https://lists.ozlabs.org/pipermail/linuxppc-dev/2022-January/239175.html Reported-by: Abdul haleem Signed-off-by: Sourabh Jain Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220204085601.107257-1-sourabhjain@linux.i= bm.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/kernel/rtas.c | 6 ++++++ arch/powerpc/kexec/core.c | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index 733e6ef36758..1f42aabbbab3 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -1313,6 +1313,12 @@ int __init early_init_dt_scan_rtas(unsigned long nod= e, entryp =3D of_get_flat_dt_prop(node, "linux,rtas-entry", NULL); sizep =3D of_get_flat_dt_prop(node, "rtas-size", NULL); =20 +#ifdef CONFIG_PPC64 + /* need this feature to decide the crashkernel offset */ + if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL)) + powerpc_firmware_features |=3D FW_FEATURE_LPAR; +#endif + if (basep && entryp && sizep) { rtas.base =3D *basep; rtas.entry =3D *entryp; diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c index 8b68d9f91a03..abf5897ae88c 100644 --- a/arch/powerpc/kexec/core.c +++ b/arch/powerpc/kexec/core.c @@ -134,11 +134,18 @@ void __init reserve_crashkernel(void) if (!crashk_res.start) { #ifdef CONFIG_PPC64 /* - * On 64bit we split the RMO in half but cap it at half of - * a small SLB (128MB) since the crash kernel needs to place - * itself and some stacks to be in the first segment. + * On the LPAR platform place the crash kernel to mid of + * RMA size (512MB or more) to ensure the crash kernel + * gets enough space to place itself and some stack to be + * in the first segment. At the same time normal kernel + * also get enough space to allocate memory for essential + * system resource in the first segment. Keep the crash + * kernel starts at 128MB offset on other platforms. */ - crashk_res.start =3D min(0x8000000ULL, (ppc64_rma_size / 2)); + if (firmware_has_feature(FW_FEATURE_LPAR)) + crashk_res.start =3D ppc64_rma_size / 2; + else + crashk_res.start =3D min(0x8000000ULL, (ppc64_rma_size / 2)); #else crashk_res.start =3D KDUMP_KERNELBASE; #endif --=20 2.35.1 From nobody Thu May 14 08:08:21 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 73C8FC352A1 for ; Tue, 12 Apr 2022 09:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388063AbiDLJVj (ORCPT ); Tue, 12 Apr 2022 05:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353948AbiDLHiB (ORCPT ); Tue, 12 Apr 2022 03:38: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 75D044A3FA; Tue, 12 Apr 2022 00:09: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 65040B81895; Tue, 12 Apr 2022 07:09:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3023C385A5; Tue, 12 Apr 2022 07:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747380; bh=7wBqRQkm8iDz7yZUpQFEIepvC8UX5wh7fIbjx6WS1j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K3RedlXJwCFMlVKitQf1Acecbgx/pxoKcDcEMLcM4bJFYD/sL3FlmP1vOSCt9ebgg az/DjBgNvUxcGsssSDOuTjR3mWdV/II8gR42if5ZjcnC1CxumJZJVrSEJSo0rbnsUP zkUHQupl69jnTvIJ9jJHpbz86fy0cHu16+4yAMQ4= 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?= , Felix Kuehling , Alex Deucher , Rajneesh Bhardwaj , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 057/343] drm/amdgpu: Fix recursive locking warning Date: Tue, 12 Apr 2022 08:27:55 +0200 Message-Id: <20220412062952.750524080@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Rajneesh Bhardwaj [ Upstream commit 447c7997b62a5115ba4da846dcdee4fc12298a6a ] Noticed the below warning while running a pytorch workload on vega10 GPUs. Change to trylock to avoid conflicts with already held reservation locks. [ +0.000003] WARNING: possible recursive locking detected [ +0.000003] 5.13.0-kfd-rajneesh #1030 Not tainted [ +0.000004] -------------------------------------------- [ +0.000002] python/4822 is trying to acquire lock: [ +0.000004] ffff932cd9a259f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000203] but task is already holding lock: [ +0.000003] ffff932cbb7181f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: ttm_eu_reserve_buffers+0x270/0x470 [ttm] [ +0.000017] other info that might help us debug this: [ +0.000002] Possible unsafe locking scenario: [ +0.000003] CPU0 [ +0.000002] ---- [ +0.000002] lock(reservation_ww_class_mutex); [ +0.000004] lock(reservation_ww_class_mutex); [ +0.000003] *** DEADLOCK *** [ +0.000002] May be due to missing lock nesting notation [ +0.000003] 7 locks held by python/4822: [ +0.000003] #0: ffff932c4ac028d0 (&process->mutex){+.+.}-{3:3}, at: kfd_ioctl_map_memory_to_gpu+0x10b/0x320 [amdgpu] [ +0.000232] #1: ffff932c55e830a8 (&info->lock#2){+.+.}-{3:3}, at: amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0x64/0xf60 [amdgpu] [ +0.000241] #2: ffff932cc45b5e68 (&(*mem)->lock){+.+.}-{3:3}, at: amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0xdf/0xf60 [amdgpu] [ +0.000236] #3: ffffb2b35606fd28 (reservation_ww_class_acquire){+.+.}-{0:0}, at: amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0x232/0xf60 [amdgpu] [ +0.000235] #4: ffff932cbb7181f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: ttm_eu_reserve_buffers+0x270/0x470 [ttm] [ +0.000015] #5: ffffffffc045f700 (*(sspp++)){....}-{0:0}, at: drm_dev_enter+0x5/0xa0 [drm] [ +0.000038] #6: ffff932c52da7078 (&vm->eviction_lock){+.+.}-{3:3}, at: amdgpu_vm_bo_update_mapping+0xd5/0x4f0 [amdgpu] [ +0.000195] stack backtrace: [ +0.000003] CPU: 11 PID: 4822 Comm: python Not tainted 5.13.0-kfd-rajneesh #1030 [ +0.000005] Hardware name: GIGABYTE MZ01-CE0-00/MZ01-CE0-00, BIOS F02 08/29/2018 [ +0.000003] Call Trace: [ +0.000003] dump_stack+0x6d/0x89 [ +0.000010] __lock_acquire+0xb93/0x1a90 [ +0.000009] lock_acquire+0x25d/0x2d0 [ +0.000005] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000184] ? lock_is_held_type+0xa2/0x110 [ +0.000006] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000184] __ww_mutex_lock.constprop.17+0xca/0x1060 [ +0.000007] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000183] ? lock_release+0x13f/0x270 [ +0.000005] ? lock_is_held_type+0xa2/0x110 [ +0.000006] ? amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000183] amdgpu_bo_release_notify+0xc4/0x160 [amdgpu] [ +0.000185] ttm_bo_release+0x4c6/0x580 [ttm] [ +0.000010] amdgpu_bo_unref+0x1a/0x30 [amdgpu] [ +0.000183] amdgpu_vm_free_table+0x76/0xa0 [amdgpu] [ +0.000189] amdgpu_vm_free_pts+0xb8/0xf0 [amdgpu] [ +0.000189] amdgpu_vm_update_ptes+0x411/0x770 [amdgpu] [ +0.000191] amdgpu_vm_bo_update_mapping+0x324/0x4f0 [amdgpu] [ +0.000191] amdgpu_vm_bo_update+0x251/0x610 [amdgpu] [ +0.000191] update_gpuvm_pte+0xcc/0x290 [amdgpu] [ +0.000229] ? amdgpu_vm_bo_map+0xd7/0x130 [amdgpu] [ +0.000190] amdgpu_amdkfd_gpuvm_map_memory_to_gpu+0x912/0xf60 [amdgpu] [ +0.000234] kfd_ioctl_map_memory_to_gpu+0x182/0x320 [amdgpu] [ +0.000218] kfd_ioctl+0x2b9/0x600 [amdgpu] [ +0.000216] ? kfd_ioctl_unmap_memory_from_gpu+0x270/0x270 [amdgpu] [ +0.000216] ? lock_release+0x13f/0x270 [ +0.000006] ? __fget_files+0x107/0x1e0 [ +0.000007] __x64_sys_ioctl+0x8b/0xd0 [ +0.000007] do_syscall_64+0x36/0x70 [ +0.000004] entry_SYSCALL_64_after_hwframe+0x44/0xae [ +0.000007] RIP: 0033:0x7fbff90a7317 [ +0.000004] Code: b3 66 90 48 8b 05 71 4b 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 41 4b 2d 00 f7 d8 64 89 01 48 [ +0.000005] RSP: 002b:00007fbe301fe648 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ +0.000006] RAX: ffffffffffffffda RBX: 00007fbcc402d820 RCX: 00007fbff90a7317 [ +0.000003] RDX: 00007fbe301fe690 RSI: 00000000c0184b18 RDI: 0000000000000004 [ +0.000003] RBP: 00007fbe301fe690 R08: 0000000000000000 R09: 00007fbcc402d880 [ +0.000003] R10: 0000000002001000 R11: 0000000000000246 R12: 00000000c0184b18 [ +0.000003] R13: 0000000000000004 R14: 00007fbf689593a0 R15: 00007fbcc402d820 Cc: Christian K=C3=B6nig Cc: Felix Kuehling Cc: Alex Deucher Reviewed-by: Christian K=C3=B6nig Reviewed-by: Felix Kuehling Signed-off-by: Rajneesh Bhardwaj Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_object.c index 5661b82d84d4..dda53fe30975 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1303,7 +1303,8 @@ void amdgpu_bo_release_notify(struct ttm_buffer_objec= t *bo) !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) return; =20 - dma_resv_lock(bo->base.resv, NULL); + if (WARN_ON_ONCE(!dma_resv_trylock(bo->base.resv))) + return; =20 r =3D amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->base.resv, &fence); if (!WARN_ON(r)) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 AC0D3C433FE for ; Tue, 12 Apr 2022 08:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383423AbiDLIhA (ORCPT ); Tue, 12 Apr 2022 04:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238011AbiDLHiR (ORCPT ); Tue, 12 Apr 2022 03:38:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B127E515A9; Tue, 12 Apr 2022 00:09: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 dfw.source.kernel.org (Postfix) with ESMTPS id 60AEB6153F; Tue, 12 Apr 2022 07:09:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C019C385A5; Tue, 12 Apr 2022 07:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747385; bh=RPqEzanMnDxC24UF3o+CM9LqcNRSJxwgPiVt2BV2MzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgOlE61HCwMqTGIyC1LbUpHuPgt0PNzq9h6AoBjM3OtkJF098dn33k/RoOT8Awl5z Cwop/C+fD+qZOYcRX5r0EYc3QvjPNCsXUUimamgCtgmCzD3cnHkMjZbcl/mj/dEvmX Yfkyq27+GVuAOG9FmZg002cNRL8DiAWwE78i2sRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Scott Benesh , Scott Teel , Kevin Barnett , Don Brace , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 058/343] scsi: smartpqi: Fix rmmod stack trace Date: Tue, 12 Apr 2022 08:27:56 +0200 Message-Id: <20220412062952.778376433@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Don Brace [ Upstream commit c4ff687d25c05919382a759503bd3821689f4e2f ] Prevent "BUG: scheduling while atomic: rmmod" stack trace. Stop setting spin_locks before calling OS functions to remove devices. Link: https://lore.kernel.org/r/164375207296.440833.4996145011193819683.stg= it@brunhilda.pdev.net Reviewed-by: Scott Benesh Reviewed-by: Scott Teel Reviewed-by: Kevin Barnett Signed-off-by: Don Brace Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/smartpqi/smartpqi_init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/= smartpqi_init.c index f0897d587454..2db9f874cc51 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -2513,17 +2513,15 @@ static void pqi_remove_all_scsi_devices(struct pqi_= ctrl_info *ctrl_info) struct pqi_scsi_dev *device; struct pqi_scsi_dev *next; =20 - spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags); - list_for_each_entry_safe(device, next, &ctrl_info->scsi_device_list, scsi_device_list_entry) { if (pqi_is_device_added(device)) pqi_remove_device(ctrl_info, device); + spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags); list_del(&device->scsi_device_list_entry); pqi_free_device(device); + spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags); } - - spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags); } =20 static int pqi_scan_scsi_devices(struct pqi_ctrl_info *ctrl_info) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BED4BC35280 for ; Tue, 12 Apr 2022 08:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383462AbiDLIhC (ORCPT ); Tue, 12 Apr 2022 04:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356564AbiDLHi7 (ORCPT ); Tue, 12 Apr 2022 03:38: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 6201D51E7A; Tue, 12 Apr 2022 00:09: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 ams.source.kernel.org (Postfix) with ESMTPS id C3E69B81895; Tue, 12 Apr 2022 07:09:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DDC7C385A1; Tue, 12 Apr 2022 07:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747388; bh=bWbmMtCwHDj7WBYZ7MqbFUn8n+43IBiBL0oK60/Kaac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HMmD4RYpWx98hxu+iNxAY4G898m1R1d++ziNHP3HVFgMZoAM9T0jP2GYdVDkkuz+8 TWoXDMdu0oGF0TaVmSMK7+e02Ul7STx5EoVqH11uPulGoCL4psgXHJdIN2Y8GBgCUa y+upIq3aETTVMkECZMGtbCOLA58p0Ys8UwbRBkSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Barnett , Scott Benesh , Scott Teel , Mahesh Rajashekhara , Don Brace , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 059/343] scsi: smartpqi: Fix kdump issue when controller is locked up Date: Tue, 12 Apr 2022 08:27:57 +0200 Message-Id: <20220412062952.806610574@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Mahesh Rajashekhara [ Upstream commit 3ada501d602abf02353445c03bb3258146445d90 ] Avoid dropping into shell if the controller is in locked up state. Driver issues SIS soft reset to bring back the controller to SIS mode while OS boots into kdump mode. If the controller is in lockup state, SIS soft reset does not work. Since the controller lockup code has not been cleared, driver considers the firmware is no longer up and running. Driver returns back an error code to OS and the kdump fails. Link: https://lore.kernel.org/r/164375212337.440833.11955356190354940369.st= git@brunhilda.pdev.net Reviewed-by: Kevin Barnett Reviewed-by: Scott Benesh Reviewed-by: Scott Teel Signed-off-by: Mahesh Rajashekhara Signed-off-by: Don Brace Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/smartpqi/smartpqi_init.c | 39 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/= smartpqi_init.c index 2db9f874cc51..f3749e508673 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -7855,6 +7855,21 @@ static int pqi_force_sis_mode(struct pqi_ctrl_info *= ctrl_info) return pqi_revert_to_sis_mode(ctrl_info); } =20 +static void pqi_perform_lockup_action(void) +{ + switch (pqi_lockup_action) { + case PANIC: + panic("FATAL: Smart Family Controller lockup detected"); + break; + case REBOOT: + emergency_restart(); + break; + case NONE: + default: + break; + } +} + static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info) { int rc; @@ -7879,8 +7894,15 @@ static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_= info) * commands. */ rc =3D sis_wait_for_ctrl_ready(ctrl_info); - if (rc) + if (rc) { + if (reset_devices) { + dev_err(&ctrl_info->pci_dev->dev, + "kdump init failed with error %d\n", rc); + pqi_lockup_action =3D REBOOT; + pqi_perform_lockup_action(); + } return rc; + } =20 /* * Get the controller properties. This allows us to determine @@ -8605,21 +8627,6 @@ static int pqi_ofa_ctrl_restart(struct pqi_ctrl_info= *ctrl_info, unsigned int de return pqi_ctrl_init_resume(ctrl_info); } =20 -static void pqi_perform_lockup_action(void) -{ - switch (pqi_lockup_action) { - case PANIC: - panic("FATAL: Smart Family Controller lockup detected"); - break; - case REBOOT: - emergency_restart(); - break; - case NONE: - default: - break; - } -} - static struct pqi_raid_error_info pqi_ctrl_offline_raid_error_info =3D { .data_out_result =3D PQI_DATA_IN_OUT_HARDWARE_ERROR, .status =3D SAM_STAT_CHECK_CONDITION, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 09FB1C433EF for ; Tue, 12 Apr 2022 08:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383498AbiDLIhE (ORCPT ); Tue, 12 Apr 2022 04:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356566AbiDLHi7 (ORCPT ); Tue, 12 Apr 2022 03:38:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE67851E7E; Tue, 12 Apr 2022 00:09: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 dfw.source.kernel.org (Postfix) with ESMTPS id DF07A6171D; Tue, 12 Apr 2022 07:09:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9EE8C385A6; Tue, 12 Apr 2022 07:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747391; bh=zAEdai6cbaxAvjJX+0dGNKGh6l0UBG2suy9fMVtv2wY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nw7vQFuoqFQb3b09+C/zI2W1IPxntRAM7+QT4VcTBJdFmEscFmWoZWRmH33zAEfDP HfZiL6qdbNQdyeD6E2/3QQ89wtnQy7Ggvm/k5PVz+E89qyAfnnOkP/VXvjsvGylzgO ij9/kuxjqYxihzUtun1yC+duDTrUfUNC4xz3RPJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Lorenzo Pieralisi , Sasha Levin Subject: [PATCH 5.17 060/343] PCI: aardvark: Fix support for MSI interrupts Date: Tue, 12 Apr 2022 08:27:58 +0200 Message-Id: <20220412062952.835560550@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pali Roh=C3=A1r [ Upstream commit b0b0b8b897f8e12b2368e868bd7cdc5742d5c5a9 ] Aardvark hardware supports Multi-MSI and MSI_FLAG_MULTI_PCI_MSI is already set for the MSI chip. But when allocating MSI interrupt numbers for Multi-MSI, the numbers need to be properly aligned, otherwise endpoint devices send MSI interrupt with incorrect numbers. Fix this issue by using function bitmap_find_free_region() instead of bitmap_find_next_zero_area(). To ensure that aligned MSI interrupt numbers are used by endpoint devices, we cannot use Linux virtual irq numbers (as they are random and not properly aligned). Instead we need to use the aligned hwirq numbers. This change fixes receiving MSI interrupts on Armada 3720 boards and allows using NVMe disks which use Multi-MSI feature with 3 interrupts. Without this NVMe disks freeze booting as linux nvme-core.c is waiting 60s for an interrupt. Link: https://lore.kernel.org/r/20220110015018.26359-4-kabel@kernel.org Signed-off-by: Pali Roh=C3=A1r Signed-off-by: Marek Beh=C3=BAn Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/pci/controller/pci-aardvark.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller= /pci-aardvark.c index 82e2c618d532..15348be1a8aa 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1186,7 +1186,7 @@ static void advk_msi_irq_compose_msi_msg(struct irq_d= ata *data, =20 msg->address_lo =3D lower_32_bits(msi_msg); msg->address_hi =3D upper_32_bits(msi_msg); - msg->data =3D data->irq; + msg->data =3D data->hwirq; } =20 static int advk_msi_set_affinity(struct irq_data *irq_data, @@ -1203,15 +1203,11 @@ static int advk_msi_irq_domain_alloc(struct irq_dom= ain *domain, int hwirq, i; =20 mutex_lock(&pcie->msi_used_lock); - hwirq =3D bitmap_find_next_zero_area(pcie->msi_used, MSI_IRQ_NUM, - 0, nr_irqs, 0); - if (hwirq >=3D MSI_IRQ_NUM) { - mutex_unlock(&pcie->msi_used_lock); - return -ENOSPC; - } - - bitmap_set(pcie->msi_used, hwirq, nr_irqs); + hwirq =3D bitmap_find_free_region(pcie->msi_used, MSI_IRQ_NUM, + order_base_2(nr_irqs)); mutex_unlock(&pcie->msi_used_lock); + if (hwirq < 0) + return -ENOSPC; =20 for (i =3D 0; i < nr_irqs; i++) irq_domain_set_info(domain, virq + i, hwirq + i, @@ -1229,7 +1225,7 @@ static void advk_msi_irq_domain_free(struct irq_domai= n *domain, struct advk_pcie *pcie =3D domain->host_data; =20 mutex_lock(&pcie->msi_used_lock); - bitmap_clear(pcie->msi_used, d->hwirq, nr_irqs); + bitmap_release_region(pcie->msi_used, d->hwirq, order_base_2(nr_irqs)); mutex_unlock(&pcie->msi_used_lock); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 86D4FC4321E for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383950AbiDLIim (ORCPT ); Tue, 12 Apr 2022 04:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357106AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39: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 F2DC060E9; Tue, 12 Apr 2022 00:12:11 -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 B35E9B81A8F; Tue, 12 Apr 2022 07:12:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BA4CC385A6; Tue, 12 Apr 2022 07:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747529; bh=qLmXZONcjAfLhV8Fgzrg3A5r3faqxtmtZPA9U6hBnwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7Z+sPsiwR7nxvtj+MAvAm0ar8ORz3M3FwsFM/jDwMOyEdnErt+G8RaAXoSyN7+VS X88w6CQB6j3cWLy8E2NaWJlS1D5ctRJTihQGWWvLufXXScGEBz8Tjr9a+NmwqeLIQi 8CnImrzVllEwj3K+oAYtYPacLr3P2Jcnebj+wFGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Reiji Watanabe , Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 5.17 061/343] kvm: selftests: aarch64: fix assert in gicv3_access_reg Date: Tue, 12 Apr 2022 08:27:59 +0200 Message-Id: <20220412062952.863589103@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ricardo Koller [ Upstream commit cc94d47ce16d4147d546e47c8248e8bd12ba5fe5 ] The val argument in gicv3_access_reg can have any value when used for a read, not necessarily 0. Fix the assert by checking val only for writes. Signed-off-by: Ricardo Koller Reported-by: Reiji Watanabe Cc: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127030858.3269036-2-ricarkol@google.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/kvm/lib/aarch64/gic_v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c b/tools/testi= ng/selftests/kvm/lib/aarch64/gic_v3.c index 00f613c0583c..e4945fe66620 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c +++ b/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c @@ -159,7 +159,7 @@ static void gicv3_access_reg(uint32_t intid, uint64_t o= ffset, uint32_t cpu_or_dist; =20 GUEST_ASSERT(bits_per_field <=3D reg_bits); - GUEST_ASSERT(*val < (1U << bits_per_field)); + GUEST_ASSERT(!write || *val < (1U << bits_per_field)); /* Some registers like IROUTER are 64 bit long. Those are currently not * supported by readl nor writel, so just asserting here until then. */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 651EAC35296 for ; Tue, 12 Apr 2022 08:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383596AbiDLIh0 (ORCPT ); Tue, 12 Apr 2022 04:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356786AbiDLHjW (ORCPT ); Tue, 12 Apr 2022 03:39:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C4E852B27; Tue, 12 Apr 2022 00:10:11 -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 28451616AB; Tue, 12 Apr 2022 07:10:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 360CCC385A5; Tue, 12 Apr 2022 07:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747410; bh=UAk1/Hdbn8RRHBz5aFkzey4goUKMCj9JeYfNWYuPX58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ie/t0It/Wc87IJ42DIek7FguFazDg/iO2ENeX5Up1mE/KAjZsGODNL0IZHrIeJ+dR B/NCvnGi0Mx0ptRwpwib8fAi4XKHe9DlD3yPNW8GVixpalMCjxyXS9CQceLdWWtYvR sAm6Weuvo+UMsDr3SfWCs1RUOL6qG/ZaQKk5WnCY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Reiji Watanabe , Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 5.17 062/343] kvm: selftests: aarch64: pass vgic_irq guest args as a pointer Date: Tue, 12 Apr 2022 08:28:00 +0200 Message-Id: <20220412062952.892696936@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ricardo Koller [ Upstream commit 11024a7a0ac26dd31ddfa0f6590e158bdf9ab858 ] The guest in vgic_irq gets its arguments in a struct. This struct used to fit nicely in a single register so vcpu_args_set() was able to pass it by value by setting x0 with it. Unfortunately, this args struct grew after some commits and some guest args became random (specically kvm_supports_irqfd). Fix this by passing the guest args as a pointer (after allocating some guest memory for it). Signed-off-by: Ricardo Koller Reported-by: Reiji Watanabe Cc: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127030858.3269036-3-ricarkol@google.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- .../testing/selftests/kvm/aarch64/vgic_irq.c | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing= /selftests/kvm/aarch64/vgic_irq.c index 7eca97799917..7f3afee5cc00 100644 --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c @@ -472,10 +472,10 @@ static void test_restore_active(struct test_args *arg= s, struct kvm_inject_desc * guest_restore_active(args, MIN_SPI, 4, f->cmd); } =20 -static void guest_code(struct test_args args) +static void guest_code(struct test_args *args) { - uint32_t i, nr_irqs =3D args.nr_irqs; - bool level_sensitive =3D args.level_sensitive; + uint32_t i, nr_irqs =3D args->nr_irqs; + bool level_sensitive =3D args->level_sensitive; struct kvm_inject_desc *f, *inject_fns; =20 gic_init(GIC_V3, 1, dist, redist); @@ -484,11 +484,11 @@ static void guest_code(struct test_args args) gic_irq_enable(i); =20 for (i =3D MIN_SPI; i < nr_irqs; i++) - gic_irq_set_config(i, !args.level_sensitive); + gic_irq_set_config(i, !level_sensitive); =20 - gic_set_eoi_split(args.eoi_split); + gic_set_eoi_split(args->eoi_split); =20 - reset_priorities(&args); + reset_priorities(args); gic_set_priority_mask(CPU_PRIO_MASK); =20 inject_fns =3D level_sensitive ? inject_level_fns @@ -497,17 +497,17 @@ static void guest_code(struct test_args args) local_irq_enable(); =20 /* Start the tests. */ - for_each_supported_inject_fn(&args, inject_fns, f) { - test_injection(&args, f); - test_preemption(&args, f); - test_injection_failure(&args, f); + for_each_supported_inject_fn(args, inject_fns, f) { + test_injection(args, f); + test_preemption(args, f); + test_injection_failure(args, f); } =20 /* Restore the active state of IRQs. This would happen when live * migrating IRQs in the middle of being handled. */ - for_each_supported_activate_fn(&args, set_active_fns, f) - test_restore_active(&args, f); + for_each_supported_activate_fn(args, set_active_fns, f) + test_restore_active(args, f); =20 GUEST_DONE(); } @@ -739,6 +739,7 @@ static void test_vgic(uint32_t nr_irqs, bool level_sens= itive, bool eoi_split) int gic_fd; struct kvm_vm *vm; struct kvm_inject_args inject_args; + vm_vaddr_t args_gva; =20 struct test_args args =3D { .nr_irqs =3D nr_irqs, @@ -757,7 +758,9 @@ static void test_vgic(uint32_t nr_irqs, bool level_sens= itive, bool eoi_split) vcpu_init_descriptor_tables(vm, VCPU_ID); =20 /* Setup the guest args page (so it gets the args). */ - vcpu_args_set(vm, 0, 1, args); + args_gva =3D vm_vaddr_alloc_page(vm); + memcpy(addr_gva2hva(vm, args_gva), &args, sizeof(args)); + vcpu_args_set(vm, 0, 1, args_gva); =20 gic_fd =3D vgic_v3_setup(vm, 1, nr_irqs, GICD_BASE_GPA, GICR_BASE_GPA); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 42368C47081 for ; Tue, 12 Apr 2022 09:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359584AbiDLJUb (ORCPT ); Tue, 12 Apr 2022 05:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356998AbiDLHjj (ORCPT ); Tue, 12 Apr 2022 03:39:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4925E13D7E; Tue, 12 Apr 2022 00:10: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 DD48CB81B5D; Tue, 12 Apr 2022 07:10:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E891C385A8; Tue, 12 Apr 2022 07:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747440; bh=X3zK7TOo5YU38lUQfqqw5eqP95X751iVUWcD1uQ09Fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoPyGBgsGbM8uqL8BInylp+IoNIMKe6Zgmcs/txuirbflAZHPuv3CeFc2k7TwO3C4 T8mzr8wHIGCIH1N8lAZ8q3Qc9FePvSFUNumcDFhbD76622SMxtX5HogI7pSG8UgIt4 +vbtJV9oVeC5cPS4mpZS5IGUrCi6EtU8yFgxK7AI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Reiji Watanabe , Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 5.17 063/343] kvm: selftests: aarch64: fix the failure check in kvm_set_gsi_routing_irqchip_check Date: Tue, 12 Apr 2022 08:28:01 +0200 Message-Id: <20220412062952.921289965@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ricardo Koller [ Upstream commit 5b7898648f02083012900e48d063e51ccbdad165 ] kvm_set_gsi_routing_irqchip_check(expect_failure=3Dtrue) is used to check the error code returned by the kernel when trying to setup an invalid gsi routing table. The ioctl fails if "pin >=3D KVM_IRQCHIP_NUM_PINS", so kvm_set_gsi_routing_irqchip_check() should test the error only when "intid >=3D KVM_IRQCHIP_NUM_PINS+32". The issue is that the test check is "intid >=3D KVM_IRQCHIP_NUM_PINS", so for a case like "intid =3D KVM_IRQCHIP_NUM_PINS" the test wrongly assumes that the kernel will return an error. Fix this by using the right check. Signed-off-by: Ricardo Koller Reported-by: Reiji Watanabe Cc: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127030858.3269036-4-ricarkol@google.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/kvm/aarch64/vgic_irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing= /selftests/kvm/aarch64/vgic_irq.c index 7f3afee5cc00..48e43e24d240 100644 --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c @@ -573,8 +573,8 @@ static void kvm_set_gsi_routing_irqchip_check(struct kv= m_vm *vm, kvm_gsi_routing_write(vm, routing); } else { ret =3D _kvm_gsi_routing_write(vm, routing); - /* The kernel only checks for KVM_IRQCHIP_NUM_PINS. */ - if (intid >=3D KVM_IRQCHIP_NUM_PINS) + /* The kernel only checks e->irqchip.pin >=3D KVM_IRQCHIP_NUM_PINS */ + if (((uint64_t)intid + num - 1 - MIN_SPI) >=3D KVM_IRQCHIP_NUM_PINS) TEST_ASSERT(ret !=3D 0 && errno =3D=3D EINVAL, "Bad intid %u did not cause KVM_SET_GSI_ROUTING " "error: rc: %i errno: %i", intid, ret, errno); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 8DAF7C43217 for ; Tue, 12 Apr 2022 08:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383736AbiDLIiH (ORCPT ); Tue, 12 Apr 2022 04:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357060AbiDLHjp (ORCPT ); Tue, 12 Apr 2022 03:39:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57231BF6F; Tue, 12 Apr 2022 00:11: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 AEB9461701; Tue, 12 Apr 2022 07:11:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFB41C385A5; Tue, 12 Apr 2022 07:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747472; bh=yLn6bZ4He80CPFSWZpCphVsn2it17qouwBsuhYYoByg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PACBWbcfw3/BgTXMAXfVG5OqScxsCB1trDZtmvWwm5ThcF1mhYSZquUjwB5gNIxpO b/SwNJX2UPVwCNbpaMnMDhGXTRZE2tW8sjc+bgRMdsWlpsyv4H0bwgcDick8cRTKuG RGyjqKt7Wn/FSHLF9YYkDF/R9fuq33+fvbSPfbO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Reiji Watanabe , Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 5.17 064/343] kvm: selftests: aarch64: fix some vgic related comments Date: Tue, 12 Apr 2022 08:28:02 +0200 Message-Id: <20220412062952.952216614@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ricardo Koller [ Upstream commit a5cd38fd9c47b23abc6df08d6ee6a71b39038185 ] Fix the formatting of some comments and the wording of one of them (in gicv3_access_reg). Signed-off-by: Ricardo Koller Reported-by: Reiji Watanabe Cc: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127030858.3269036-5-ricarkol@google.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/kvm/aarch64/vgic_irq.c | 12 ++++++++---- tools/testing/selftests/kvm/lib/aarch64/gic_v3.c | 10 ++++++---- tools/testing/selftests/kvm/lib/aarch64/vgic.c | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing= /selftests/kvm/aarch64/vgic_irq.c index 48e43e24d240..554ca649d470 100644 --- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c +++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c @@ -306,7 +306,8 @@ static void guest_restore_active(struct test_args *args, uint32_t prio, intid, ap1r; int i; =20 - /* Set the priorities of the first (KVM_NUM_PRIOS - 1) IRQs + /* + * Set the priorities of the first (KVM_NUM_PRIOS - 1) IRQs * in descending order, so intid+1 can preempt intid. */ for (i =3D 0, prio =3D (num - 1) * 8; i < num; i++, prio -=3D 8) { @@ -315,7 +316,8 @@ static void guest_restore_active(struct test_args *args, gic_set_priority(intid, prio); } =20 - /* In a real migration, KVM would restore all GIC state before running + /* + * In a real migration, KVM would restore all GIC state before running * guest code. */ for (i =3D 0; i < num; i++) { @@ -503,7 +505,8 @@ static void guest_code(struct test_args *args) test_injection_failure(args, f); } =20 - /* Restore the active state of IRQs. This would happen when live + /* + * Restore the active state of IRQs. This would happen when live * migrating IRQs in the middle of being handled. */ for_each_supported_activate_fn(args, set_active_fns, f) @@ -844,7 +847,8 @@ int main(int argc, char **argv) } } =20 - /* If the user just specified nr_irqs and/or gic_version, then run all + /* + * If the user just specified nr_irqs and/or gic_version, then run all * combinations. */ if (default_args) { diff --git a/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c b/tools/testi= ng/selftests/kvm/lib/aarch64/gic_v3.c index e4945fe66620..263bf3ed8fd5 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c +++ b/tools/testing/selftests/kvm/lib/aarch64/gic_v3.c @@ -19,7 +19,7 @@ struct gicv3_data { unsigned int nr_spis; }; =20 -#define sgi_base_from_redist(redist_base) (redist_base + SZ_64K) +#define sgi_base_from_redist(redist_base) (redist_base + SZ_64K) #define DIST_BIT (1U << 31) =20 enum gicv3_intid_range { @@ -105,7 +105,8 @@ static void gicv3_set_eoi_split(bool split) { uint32_t val; =20 - /* All other fields are read-only, so no need to read CTLR first. In + /* + * All other fields are read-only, so no need to read CTLR first. In * fact, the kernel does the same. */ val =3D split ? (1U << 1) : 0; @@ -160,8 +161,9 @@ static void gicv3_access_reg(uint32_t intid, uint64_t o= ffset, =20 GUEST_ASSERT(bits_per_field <=3D reg_bits); GUEST_ASSERT(!write || *val < (1U << bits_per_field)); - /* Some registers like IROUTER are 64 bit long. Those are currently not - * supported by readl nor writel, so just asserting here until then. + /* + * This function does not support 64 bit accesses. Just asserting here + * until we implement readq/writeq. */ GUEST_ASSERT(reg_bits =3D=3D 32); =20 diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing= /selftests/kvm/lib/aarch64/vgic.c index f5cd0c536d85..7c876ccf9294 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c @@ -152,7 +152,8 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid, attr +=3D SZ_64K; } =20 - /* All calls will succeed, even with invalid intid's, as long as the + /* + * All calls will succeed, even with invalid intid's, as long as the * addr part of the attr is within 32 bits (checked above). An invalid * intid will just make the read/writes point to above the intended * register space (i.e., ICPENDR after ISPENDR). --=20 2.35.1 From nobody Thu May 14 08:08:21 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 63083C433FE for ; Tue, 12 Apr 2022 09:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389286AbiDLJXf (ORCPT ); Tue, 12 Apr 2022 05:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357093AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9FB79FC8; Tue, 12 Apr 2022 00:11: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 54F35616E7; Tue, 12 Apr 2022 07:11:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66F1CC385A1; Tue, 12 Apr 2022 07:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747501; bh=Msr4Gq3pyulIUEyqR8XNczKHQK4bAvQ9hTJeI+N2L84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csbulciRzku8ISBLutWHHcyr1LLb7Pnc5Iaa/SLLyNTaX/1CRT3jK123MTvlVBFe3 QEtpwC/NMBjtVI8P9NqkwFL6kUcU7EY5SflAP9LWOvYeSdeCd+qqQ2q1ie4KlptOGr 19NO/IefEEsyUe9pMXcJt1py6I/XJ8c8f2q4HSlc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Koller , Reiji Watanabe , Andrew Jones , Marc Zyngier , Sasha Levin Subject: [PATCH 5.17 065/343] kvm: selftests: aarch64: use a tighter assert in vgic_poke_irq() Date: Tue, 12 Apr 2022 08:28:03 +0200 Message-Id: <20220412062952.980826571@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ricardo Koller [ Upstream commit b53de63a89244c196d8a2ea76b6754e3fdb4b626 ] vgic_poke_irq() checks that the attr argument passed to the vgic device ioctl is sane. Make this check tighter by moving it to after the last attr update. Signed-off-by: Ricardo Koller Reported-by: Reiji Watanabe Cc: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127030858.3269036-6-ricarkol@google.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/kvm/lib/aarch64/vgic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing= /selftests/kvm/lib/aarch64/vgic.c index 7c876ccf9294..5d45046c1b80 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c +++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c @@ -140,9 +140,6 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid, uint64_t val; bool intid_is_private =3D INTID_IS_SGI(intid) || INTID_IS_PPI(intid); =20 - /* Check that the addr part of the attr is within 32 bits. */ - assert(attr <=3D KVM_DEV_ARM_VGIC_OFFSET_MASK); - uint32_t group =3D intid_is_private ? KVM_DEV_ARM_VGIC_GRP_REDIST_REGS : KVM_DEV_ARM_VGIC_GRP_DIST_REGS; =20 @@ -152,6 +149,9 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid, attr +=3D SZ_64K; } =20 + /* Check that the addr part of the attr is within 32 bits. */ + assert((attr & ~KVM_DEV_ARM_VGIC_OFFSET_MASK) =3D=3D 0); + /* * All calls will succeed, even with invalid intid's, as long as the * addr part of the attr is within 32 bits (checked above). An invalid --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1DA02C3527B for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384078AbiDLIjD (ORCPT ); Tue, 12 Apr 2022 04:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357097AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89122BCAE; Tue, 12 Apr 2022 00:11: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 dfw.source.kernel.org (Postfix) with ESMTPS id 22BDB6171C; Tue, 12 Apr 2022 07:11:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AED2C385A6; Tue, 12 Apr 2022 07:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747515; bh=4Vz7YePsGVbWEpiTw4saS9KDNTEfxvNmGWIgTtvmbZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkWShEaw3FgIdijqFps3QdJVo7eFjR/x6WzJEu77iAXpIFB7mFOGcQirTLLiuOsiE 1d6ClOnvmOzBnUNBeB9slqVjJ4YW41a7y4NKd4ImYj51Evw4qEYqEFFBLKDA+2sQV0 nsthqWOG2RuLaw+AHmpdmHnzjPJZ2Ak7BXlXHfzY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Guanghui , Will Deacon , Sasha Levin Subject: [PATCH 5.17 066/343] iommu/arm-smmu-v3: fix event handling soft lockup Date: Tue, 12 Apr 2022 08:28:04 +0200 Message-Id: <20220412062953.009043383@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Zhou Guanghui [ Upstream commit 30de2b541af98179780054836b48825fcfba4408 ] During event processing, events are read from the event queue one by one until the queue is empty.If the master device continuously requests address access at the same time and the SMMU generates events, the cyclic processing of the event takes a long time and softlockup warnings may be reported. arm-smmu-v3 arm-smmu-v3.34.auto: event 0x0a received: arm-smmu-v3 arm-smmu-v3.34.auto: 0x00007f220000280a arm-smmu-v3 arm-smmu-v3.34.auto: 0x000010000000007e arm-smmu-v3 arm-smmu-v3.34.auto: 0x00000000034e8670 watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [irq/268-arm-smm:247] Call trace: _dev_info+0x7c/0xa0 arm_smmu_evtq_thread+0x1c0/0x230 irq_thread_fn+0x30/0x80 irq_thread+0x128/0x210 kthread+0x134/0x138 ret_from_fork+0x10/0x1c Kernel panic - not syncing: softlockup: hung tasks Fix this by calling cond_resched() after the event information is printed. Signed-off-by: Zhou Guanghui Link: https://lore.kernel.org/r/20220119070754.26528-1-zhouguanghui1@huawei= .com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 6dc6d8b6b368..f60381cdf1c4 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1558,6 +1558,7 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void= *dev) dev_info(smmu->dev, "\t0x%016llx\n", (unsigned long long)evt[i]); =20 + cond_resched(); } =20 /* --=20 2.35.1 From nobody Thu May 14 08:08:21 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 DBACCC41535 for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383995AbiDLIiz (ORCPT ); Tue, 12 Apr 2022 04:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357103AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E79ABCB6; Tue, 12 Apr 2022 00:11: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 dfw.source.kernel.org (Postfix) with ESMTPS id BD38D61701; Tue, 12 Apr 2022 07:11:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2100C385A5; Tue, 12 Apr 2022 07:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747518; bh=KyppwBAxf1ZILb2cK4QcPAex7NnhClg9RsYTWWUiftI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Syt/QEs5kqPbfj/4Z/tA6rv75n+BqLTnnUMjd21L9sp3krZCBw5OeVUYG/rY9M1NA XMG28CWJEZWlwlFcowVYXzZsZPtmH2Vih9LfgIW14qhwk9fxDr/zb/pqyYTsPyISB+ QYlwyWAAP6bSq09OVZbpZCMoxhz3YvkBjrlw6yW0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Neal Liu , Sasha Levin Subject: [PATCH 5.17 067/343] usb: ehci: add pci device support for Aspeed platforms Date: Tue, 12 Apr 2022 08:28:05 +0200 Message-Id: <20220412062953.037709591@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Neal Liu [ Upstream commit c3c9cee592828528fd228b01d312c7526c584a42 ] Enable Aspeed quirks in commit 7f2d73788d90 ("usb: ehci: handshake CMD_RUN instead of STS_HALT") to support Aspeed ehci-pci device. Acked-by: Alan Stern Signed-off-by: Neal Liu Link: https://lore.kernel.org/r/20220208101657.76459-1-neal_liu@aspeedtech.= com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/host/ehci-pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index e87cf3a00fa4..638f03b89739 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -21,6 +21,9 @@ static const char hcd_name[] =3D "ehci-pci"; /* defined here to avoid adding to pci_ids.h for single instance use */ #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 =20 +#define PCI_VENDOR_ID_ASPEED 0x1a03 +#define PCI_DEVICE_ID_ASPEED_EHCI 0x2603 + /*------------------------------------------------------------------------= -*/ #define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 static inline bool is_intel_quark_x1000(struct pci_dev *pdev) @@ -222,6 +225,12 @@ static int ehci_pci_setup(struct usb_hcd *hcd) ehci->has_synopsys_hc_bug =3D 1; } break; + case PCI_VENDOR_ID_ASPEED: + if (pdev->device =3D=3D PCI_DEVICE_ID_ASPEED_EHCI) { + ehci_info(ehci, "applying Aspeed HC workaround\n"); + ehci->is_aspeed =3D 1; + } + break; } =20 /* optional debug port, normally in the first BAR */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B0AECC433F5 for ; Tue, 12 Apr 2022 09:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358111AbiDLJBY (ORCPT ); Tue, 12 Apr 2022 05:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357101AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39: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 323B7BE11; Tue, 12 Apr 2022 00:12: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 dfw.source.kernel.org (Postfix) with ESMTPS id B04316103A; Tue, 12 Apr 2022 07:12:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7FFBC385A1; Tue, 12 Apr 2022 07:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747521; bh=6BkhvsDQaPwwUOomzHYlSBCe/6+7AFRdPB1xOKiYIbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYIR2jwHtNb/rw5L+vtIKuLevVWs79abhx5Zm6bxBiVABlVSt5J/vKXCMcuSpcEnE 055QSjwW5iKwPmJd64lR0hNIPSFxWrnkxw55LwTaAsAC3Z3EJk4irFhUuaHr7Xtg+V xl0Kf9YFK0+Sjp5quAsRjiKoUCTz7rkZC1FA//vw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Alexandru Elisei , Sasha Levin Subject: [PATCH 5.17 068/343] KVM: arm64: Do not change the PMU event filter after a VCPU has run Date: Tue, 12 Apr 2022 08:28:06 +0200 Message-Id: <20220412062953.066116719@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Zyngier [ Upstream commit 5177fe91e4cf78a659aada2c9cf712db4d788481 ] Userspace can specify which events a guest is allowed to use with the KVM_ARM_VCPU_PMU_V3_FILTER attribute. The list of allowed events can be identified by a guest from reading the PMCEID{0,1}_EL0 registers. Changing the PMU event filter after a VCPU has run can cause reads of the registers performed before the filter is changed to return different values than reads performed with the new event filter in place. The architecture defines the two registers as read-only, and this behaviour contradicts that. Keep track when the first VCPU has run and deny changes to the PMU event filter to prevent this from happening. Signed-off-by: Marc Zyngier [ Alexandru E: Added commit message, updated ioctl documentation ] Signed-off-by: Alexandru Elisei Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220127161759.53553-2-alexandru.elisei@arm= .com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- Documentation/virt/kvm/devices/vcpu.rst | 2 +- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 4 +++ arch/arm64/kvm/pmu-emul.c | 33 +++++++++++++++---------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Documentation/virt/kvm/devices/vcpu.rst b/Documentation/virt/k= vm/devices/vcpu.rst index 60a29972d3f1..d063aaee5bb7 100644 --- a/Documentation/virt/kvm/devices/vcpu.rst +++ b/Documentation/virt/kvm/devices/vcpu.rst @@ -70,7 +70,7 @@ irqchip. -ENODEV PMUv3 not supported or GIC not initialized -ENXIO PMUv3 not properly configured or in-kernel irqchip not configured as required prior to calling this attribute - -EBUSY PMUv3 already initialized + -EBUSY PMUv3 already initialized or a VCPU has already run -EINVAL Invalid filter range =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 =20 diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm= _host.h index 031e3a2537fc..8234626a945a 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -136,6 +136,7 @@ struct kvm_arch { =20 /* Memory Tagging Extension enabled for the guest */ bool mte_enabled; + bool ran_once; }; =20 struct kvm_vcpu_fault_info { diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 4dca6ffd03d4..85a2a75f4498 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -634,6 +634,10 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu) if (kvm_vm_is_protected(kvm)) kvm_call_hyp_nvhe(__pkvm_vcpu_init_traps, vcpu); =20 + mutex_lock(&kvm->lock); + kvm->arch.ran_once =3D true; + mutex_unlock(&kvm->lock); + return ret; } =20 diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c index fbcfd4ec6f92..bc771bc1a041 100644 --- a/arch/arm64/kvm/pmu-emul.c +++ b/arch/arm64/kvm/pmu-emul.c @@ -924,6 +924,8 @@ static bool pmu_irq_is_valid(struct kvm *kvm, int irq) =20 int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr = *attr) { + struct kvm *kvm =3D vcpu->kvm; + if (!kvm_vcpu_has_pmu(vcpu)) return -ENODEV; =20 @@ -941,7 +943,7 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, stru= ct kvm_device_attr *attr) int __user *uaddr =3D (int __user *)(long)attr->addr; int irq; =20 - if (!irqchip_in_kernel(vcpu->kvm)) + if (!irqchip_in_kernel(kvm)) return -EINVAL; =20 if (get_user(irq, uaddr)) @@ -951,7 +953,7 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, stru= ct kvm_device_attr *attr) if (!(irq_is_ppi(irq) || irq_is_spi(irq))) return -EINVAL; =20 - if (!pmu_irq_is_valid(vcpu->kvm, irq)) + if (!pmu_irq_is_valid(kvm, irq)) return -EINVAL; =20 if (kvm_arm_pmu_irq_initialized(vcpu)) @@ -966,7 +968,7 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, stru= ct kvm_device_attr *attr) struct kvm_pmu_event_filter filter; int nr_events; =20 - nr_events =3D kvm_pmu_event_mask(vcpu->kvm) + 1; + nr_events =3D kvm_pmu_event_mask(kvm) + 1; =20 uaddr =3D (struct kvm_pmu_event_filter __user *)(long)attr->addr; =20 @@ -978,12 +980,17 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, st= ruct kvm_device_attr *attr) filter.action !=3D KVM_PMU_EVENT_DENY)) return -EINVAL; =20 - mutex_lock(&vcpu->kvm->lock); + mutex_lock(&kvm->lock); + + if (kvm->arch.ran_once) { + mutex_unlock(&kvm->lock); + return -EBUSY; + } =20 - if (!vcpu->kvm->arch.pmu_filter) { - vcpu->kvm->arch.pmu_filter =3D bitmap_alloc(nr_events, GFP_KERNEL_ACCOU= NT); - if (!vcpu->kvm->arch.pmu_filter) { - mutex_unlock(&vcpu->kvm->lock); + if (!kvm->arch.pmu_filter) { + kvm->arch.pmu_filter =3D bitmap_alloc(nr_events, GFP_KERNEL_ACCOUNT); + if (!kvm->arch.pmu_filter) { + mutex_unlock(&kvm->lock); return -ENOMEM; } =20 @@ -994,17 +1001,17 @@ int kvm_arm_pmu_v3_set_attr(struct kvm_vcpu *vcpu, s= truct kvm_device_attr *attr) * events, the default is to allow. */ if (filter.action =3D=3D KVM_PMU_EVENT_ALLOW) - bitmap_zero(vcpu->kvm->arch.pmu_filter, nr_events); + bitmap_zero(kvm->arch.pmu_filter, nr_events); else - bitmap_fill(vcpu->kvm->arch.pmu_filter, nr_events); + bitmap_fill(kvm->arch.pmu_filter, nr_events); } =20 if (filter.action =3D=3D KVM_PMU_EVENT_ALLOW) - bitmap_set(vcpu->kvm->arch.pmu_filter, filter.base_event, filter.nevent= s); + bitmap_set(kvm->arch.pmu_filter, filter.base_event, filter.nevents); else - bitmap_clear(vcpu->kvm->arch.pmu_filter, filter.base_event, filter.neve= nts); + bitmap_clear(kvm->arch.pmu_filter, filter.base_event, filter.nevents); =20 - mutex_unlock(&vcpu->kvm->lock); + mutex_unlock(&kvm->lock); =20 return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BC569C4167D for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383980AbiDLIiw (ORCPT ); Tue, 12 Apr 2022 04:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357102AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DDEFBE16; Tue, 12 Apr 2022 00:12: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 3F3F0B81B55; Tue, 12 Apr 2022 07:12:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8900EC385A5; Tue, 12 Apr 2022 07:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747523; bh=AipMkh4r+PEC3Hg3oKtel1W8x7XdUXLF+5yYy1OyNVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KwX/wXObYj8PNEpbpCFM0fMx32V4VTrA/fZ8lpiwkWgA4tX9bxPbdY7pg6ULExqK8 5B3f1APor5mYe9f2h4iVfIIqjoTI0BIA9RF34UUkInHwsHq5+HAQH1mKv/PGFL0aTi 5pFOrkTLXZn7H2zo4zlvFiZvS2Q4lf36Q1hfIKtc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Ilya Leoshkevich , Andrii Nakryiko , "Naveen N. Rao" , Sasha Levin Subject: [PATCH 5.17 069/343] libbpf: Fix accessing syscall arguments on powerpc Date: Tue, 12 Apr 2022 08:28:07 +0200 Message-Id: <20220412062953.094373741@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ilya Leoshkevich [ Upstream commit f07f1503469b11b739892d50c836992ffbe026ee ] powerpc does not select ARCH_HAS_SYSCALL_WRAPPER, so its syscall handlers take "unpacked" syscall arguments. Indicate this to libbpf using PT_REGS_SYSCALL_REGS macro. Reported-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich Signed-off-by: Andrii Nakryiko Tested-by: Naveen N. Rao Link: https://lore.kernel.org/bpf/20220209021745.2215452-5-iii@linux.ibm.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/lib/bpf/bpf_tracing.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index e1b505606882..41f5f3149875 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -178,6 +178,8 @@ #define __PT_RC_REG gpr[3] #define __PT_SP_REG sp #define __PT_IP_REG nip +/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER. */ +#define PT_REGS_SYSCALL_REGS(ctx) ctx =20 #elif defined(bpf_target_sparc) =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 34A6BC46467 for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384112AbiDLIjM (ORCPT ); Tue, 12 Apr 2022 04:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357104AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39: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 989DEDEA4; Tue, 12 Apr 2022 00:12: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 dfw.source.kernel.org (Postfix) with ESMTPS id 34EA56153F; Tue, 12 Apr 2022 07:12:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 415B6C385A6; Tue, 12 Apr 2022 07:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747526; bh=LiN4xAlbtOMQmCAMYa+oEGTr4Vv1YS5mZ2fgoK15uO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FD04ZgobCRENG1h0YSZ8DxEEIh42Ch/PugylS6e0nx0q5OQoq1SHDWgVZCGI+sZIO 4gvf4GbcoZz8T2bi1qS/GbHY150u5zURoSZKYY2ktW9LK8f4+eMiHZN+h2qT1PIjdx l8+dQT2oss2r8eTkZk1Y/5+D0kjIDHL/j8FIpGQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Ilya Leoshkevich , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.17 070/343] libbpf: Fix accessing the first syscall argument on arm64 Date: Tue, 12 Apr 2022 08:28:08 +0200 Message-Id: <20220412062953.123150338@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ilya Leoshkevich [ Upstream commit fbca4a2f649730b67488a8b36140ce4d2cf13c63 ] On arm64, the first syscall argument should be accessed via orig_x0 (see arch/arm64/include/asm/syscall.h). Currently regs[0] is used instead, leading to bpf_syscall_macro test failure. orig_x0 cannot be added to struct user_pt_regs, since its layout is a part of the ABI. Therefore provide access to it only through PT_REGS_PARM1_CORE_SYSCALL() by using a struct pt_regs flavor. Reported-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220209021745.2215452-10-iii@linux.ibm.c= om Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/lib/bpf/bpf_tracing.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index 41f5f3149875..bed07c35b8de 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -140,6 +140,10 @@ =20 #elif defined(bpf_target_arm64) =20 +struct pt_regs___arm64 { + unsigned long orig_x0; +}; + /* arm64 provides struct user_pt_regs instead of struct pt_regs to userspa= ce */ #define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x)) #define __PT_PARM1_REG regs[0] @@ -152,6 +156,8 @@ #define __PT_RC_REG regs[0] #define __PT_SP_REG sp #define __PT_IP_REG pc +#define PT_REGS_PARM1_SYSCALL(x) ({ _Pragma("GCC error \"use PT_REGS_PARM1= _CORE_SYSCALL() instead\""); 0l; }) +#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ((const struct pt_regs_= __arm64 *)(x), orig_x0) =20 #elif defined(bpf_target_mips) =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 580ECC43217 for ; Tue, 12 Apr 2022 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376993AbiDLJVD (ORCPT ); Tue, 12 Apr 2022 05:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356816AbiDLHjX (ORCPT ); Tue, 12 Apr 2022 03:39:23 -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 DF0FB52E41; Tue, 12 Apr 2022 00:10: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 CD62061777; Tue, 12 Apr 2022 07:10:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDEF4C385A5; Tue, 12 Apr 2022 07:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747413; bh=ayE9bQn03oHjrYkBNK20LwGv7y3GHRuAaspjxBcF8hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmT7hwsQdNypdIvkm1KxKSU5QNEiySS8mA2a4Sim+jINyn8MswF3YJvl8dkeSKeur Mj1TX9fz0IoEojcYSvtpElnTJ+otaGDXDz01GN1Dd6H0x4mWaYYvZID/DE3a5zD35V waRzHmkXCQLHJOn7svOXhznJwEPuNd1dpxQZAMLw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Ilya Leoshkevich , Sasha Levin Subject: [PATCH 5.17 071/343] libbpf: Fix accessing the first syscall argument on s390 Date: Tue, 12 Apr 2022 08:28:09 +0200 Message-Id: <20220412062953.151195049@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ilya Leoshkevich [ Upstream commit 1f22a6f9f9a0f50218a11a0554709fd34a821fa3 ] On s390, the first syscall argument should be accessed via orig_gpr2 (see arch/s390/include/asm/syscall.h). Currently gpr[2] is used instead, leading to bpf_syscall_macro test failure. orig_gpr2 cannot be added to user_pt_regs, since its layout is a part of the ABI. Therefore provide access to it only through PT_REGS_PARM1_CORE_SYSCALL() by using a struct pt_regs flavor. Reported-by: Andrii Nakryiko Signed-off-by: Ilya Leoshkevich Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220209021745.2215452-11-iii@linux.ibm.c= om Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/lib/bpf/bpf_tracing.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index bed07c35b8de..122d79c8f4b4 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -112,6 +112,10 @@ =20 #elif defined(bpf_target_s390) =20 +struct pt_regs___s390 { + unsigned long orig_gpr2; +}; + /* s390 provides user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const user_pt_regs *)(x)) #define __PT_PARM1_REG gprs[2] @@ -124,6 +128,8 @@ #define __PT_RC_REG gprs[2] #define __PT_SP_REG gprs[15] #define __PT_IP_REG psw.addr +#define PT_REGS_PARM1_SYSCALL(x) ({ _Pragma("GCC error \"use PT_REGS_PARM1= _CORE_SYSCALL() instead\""); 0l; }) +#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ((const struct pt_regs_= __s390 *)(x), orig_gpr2) =20 #elif defined(bpf_target_arm) =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E143AC35280 for ; Tue, 12 Apr 2022 08:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386642AbiDLI6v (ORCPT ); Tue, 12 Apr 2022 04:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356826AbiDLHjX (ORCPT ); Tue, 12 Apr 2022 03:39:23 -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 587B452E69; Tue, 12 Apr 2022 00:10: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 851DC616B2; Tue, 12 Apr 2022 07:10:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 961D1C385A5; Tue, 12 Apr 2022 07:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747416; bh=/w61AelEsbUjYwIL6ru1+o8XctAGMaB5iEznL38kFIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdUVsh661K5zz1unvhDrMu7KU+wuKK7tXdAaCxm8ZA6iNHnxC5p+1AdYchXc6xSzv 3NTYlzONclVW6RRLkin3o3ZFeyo2+og45czQqiBZxztGFaPelVEYlqPCDVOyXW3ENz c4EpgUs6HNQEx0+vFREPjVwOaalpdgdvnfBJO5uc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Zhiqiang , Lorenzo Pieralisi , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 5.17 072/343] PCI: endpoint: Fix alignment fault error in copy tests Date: Tue, 12 Apr 2022 08:28:10 +0200 Message-Id: <20220412062953.179936107@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hou Zhiqiang [ Upstream commit 829cc0e2ea2d61fb6c54bc3f8a17f86c56e11864 ] The copy test uses the memcpy() to copy data between IO memory spaces. This can trigger an alignment fault error (pasted the error logs below) because memcpy() may use unaligned accesses on a mapped memory that is just IO, which does not support unaligned memory accesses. Fix it by using the correct memcpy API to copy from/to IO memory. Alignment fault error logs: Unable to handle kernel paging request at virtual address ffff8000101cd3= c1 Mem abort info: ESR =3D 0x96000021 EC =3D 0x25: DABT (current EL), IL =3D 32 bits SET =3D 0, FnV =3D 0 EA =3D 0, S1PTW =3D 0 FSC =3D 0x21: alignment fault Data abort info: ISV =3D 0, ISS =3D 0x00000021 CM =3D 0, WnR =3D 0 swapper pgtable: 4k pages, 48-bit VAs, pgdp=3D0000000081773000 [ffff8000101cd3c1] pgd=3D1000000082410003, p4d=3D1000000082410003, pud= =3D1000000082411003, pmd=3D1000000082412003, pte=3D0068004000001f13 Internal error: Oops: 96000021 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 6 Comm: kworker/0:0H Not tainted 5.15.0-rc1-next-20210914-di= rty #2 Hardware name: LS1012A RDB Board (DT) Workqueue: kpcitest pci_epf_test_cmd_handler pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=3D--) pc : __memcpy+0x168/0x230 lr : pci_epf_test_cmd_handler+0x6f0/0xa68 sp : ffff80001003bce0 x29: ffff80001003bce0 x28: ffff800010135000 x27: ffff8000101e5000 x26: ffff8000101cd000 x25: ffff6cda941cf6c8 x24: 0000000000000000 x23: ffff6cda863f2000 x22: ffff6cda9096c800 x21: ffff800010135000 x20: ffff6cda941cf680 x19: ffffaf39fd999000 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: ffffaf39fd2b6000 x14: 0000000000000000 x13: 15f5c8fa2f984d57 x12: 604d132b60275454 x11: 065cee5e5fb428b6 x10: aae662eb17d0cf3e x9 : 1d97c9a1b4ddef37 x8 : 7541b65edebf928c x7 : e71937c4fc595de0 x6 : b8a0e09562430d1c x5 : ffff8000101e5401 x4 : ffff8000101cd401 x3 : ffff8000101e5380 x2 : fffffffffffffff1 x1 : ffff8000101cd3c0 x0 : ffff8000101e5000 Call trace: __memcpy+0x168/0x230 process_one_work+0x1ec/0x370 worker_thread+0x44/0x478 kthread+0x154/0x160 ret_from_fork+0x10/0x20 Code: a984346c a9c4342c f1010042 54fffee8 (a97c3c8e) ---[ end trace 568c28c7b6336335 ]--- Link: https://lore.kernel.org/r/20211217094708.28678-1-Zhiqiang.Hou@nxp.com Signed-off-by: Hou Zhiqiang Signed-off-by: Lorenzo Pieralisi Reviewed-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/pci/endpoint/functions/pci-epf-test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/en= dpoint/functions/pci-epf-test.c index 90d84d3bc868..c7e45633beaf 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -285,7 +285,17 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_= test) if (ret) dev_err(dev, "Data transfer failed\n"); } else { - memcpy(dst_addr, src_addr, reg->size); + void *buf; + + buf =3D kzalloc(reg->size, GFP_KERNEL); + if (!buf) { + ret =3D -ENOMEM; + goto err_map_addr; + } + + memcpy_fromio(buf, src_addr, reg->size); + memcpy_toio(dst_addr, buf, reg->size); + kfree(buf); } ktime_get_ts64(&end); pci_epf_test_print_rate("COPY", reg->size, &start, &end, use_dma); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 18F55C35280 for ; Tue, 12 Apr 2022 09:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359727AbiDLJUk (ORCPT ); Tue, 12 Apr 2022 05:20:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356897AbiDLHjc (ORCPT ); Tue, 12 Apr 2022 03:39:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79354532C1; Tue, 12 Apr 2022 00:10: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 ams.source.kernel.org (Postfix) with ESMTPS id C8355B81B55; Tue, 12 Apr 2022 07:10:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46844C385A5; Tue, 12 Apr 2022 07:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747418; bh=RUwbLHotjbX+UqZxx8hmxHOaCEpsBQyNX+ZzVXZ4Gls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ty+DWUsm7NbNwdAU0XROdA+WO8CYdw5FIczrDinBiKzR+k2w8GKpjlLPZztQLOZ06 MHCa8wQFdeTStubqKKBhTxGusOHldQxd/GuVt2hjzSy88JC6brPHjXYcAkAgjVh8sO nslpecqJvkMkI5GNKZrVJgtUHl1y2vevz3AFjvYA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Galbraith , Sebastian Andrzej Siewior , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 073/343] tcp: Dont acquire inet_listen_hashbucket::lock with disabled BH. Date: Tue, 12 Apr 2022 08:28:11 +0200 Message-Id: <20220412062953.208339537@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sebastian Andrzej Siewior [ Upstream commit 4f9bf2a2f5aacf988e6d5e56b961ba45c5a25248 ] Commit 9652dc2eb9e40 ("tcp: relax listening_hash operations") removed the need to disable bottom half while acquiring listening_hash.lock. There are still two callers left which disable bottom half before the lock is acquired. On PREEMPT_RT the softirqs are preemptible and local_bh_disable() acts as a lock to ensure that resources, that are protected by disabling bottom halves, remain protected. This leads to a circular locking dependency if the lock acquired with disabled bottom halves is also acquired with enabled bottom halves followed by disabling bottom halves. This is the reverse locking order. It has been observed with inet_listen_hashbucket::lock: local_bh_disable() + spin_lock(&ilb->lock): inet_listen() inet_csk_listen_start() sk->sk_prot->hash() :=3D inet_hash() local_bh_disable() __inet_hash() spin_lock(&ilb->lock); acquire(&ilb->lock); Reverse order: spin_lock(&ilb2->lock) + local_bh_disable(): tcp_seq_next() listening_get_next() spin_lock(&ilb2->lock); acquire(&ilb2->lock); tcp4_seq_show() get_tcp4_sock() sock_i_ino() read_lock_bh(&sk->sk_callback_lock); acquire(softirq_ctrl) // <---- whoops acquire(&sk->sk_callback_lock) Drop local_bh_disable() around __inet_hash() which acquires listening_hash->lock. Split inet_unhash() and acquire the listen_hashbucket lock without disabling bottom halves; the inet_ehash lock with disabled bottom halves. Reported-by: Mike Galbraith Signed-off-by: Sebastian Andrzej Siewior Link: https://lkml.kernel.org/r/12d6f9879a97cd56c09fb53dee343cbb14f7f1f7.ca= mel@gmx.de Link: https://lkml.kernel.org/r/X9CheYjuXWc75Spa@hirez.programming.kicks-as= s.net Link: https://lore.kernel.org/r/YgQOebeZ10eNx1W6@linutronix.de Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/ipv4/inet_hashtables.c | 53 ++++++++++++++++++++++--------------- net/ipv6/inet6_hashtables.c | 5 +--- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 30ab717ff1b8..17440840a791 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -637,7 +637,9 @@ int __inet_hash(struct sock *sk, struct sock *osk) int err =3D 0; =20 if (sk->sk_state !=3D TCP_LISTEN) { + local_bh_disable(); inet_ehash_nolisten(sk, osk, NULL); + local_bh_enable(); return 0; } WARN_ON(!sk_unhashed(sk)); @@ -669,45 +671,54 @@ int inet_hash(struct sock *sk) { int err =3D 0; =20 - if (sk->sk_state !=3D TCP_CLOSE) { - local_bh_disable(); + if (sk->sk_state !=3D TCP_CLOSE) err =3D __inet_hash(sk, NULL); - local_bh_enable(); - } =20 return err; } EXPORT_SYMBOL_GPL(inet_hash); =20 -void inet_unhash(struct sock *sk) +static void __inet_unhash(struct sock *sk, struct inet_listen_hashbucket *= ilb) { - struct inet_hashinfo *hashinfo =3D sk->sk_prot->h.hashinfo; - struct inet_listen_hashbucket *ilb =3D NULL; - spinlock_t *lock; - if (sk_unhashed(sk)) return; =20 - if (sk->sk_state =3D=3D TCP_LISTEN) { - ilb =3D &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; - lock =3D &ilb->lock; - } else { - lock =3D inet_ehash_lockp(hashinfo, sk->sk_hash); - } - spin_lock_bh(lock); - if (sk_unhashed(sk)) - goto unlock; - if (rcu_access_pointer(sk->sk_reuseport_cb)) reuseport_stop_listen_sock(sk); if (ilb) { + struct inet_hashinfo *hashinfo =3D sk->sk_prot->h.hashinfo; + inet_unhash2(hashinfo, sk); ilb->count--; } __sk_nulls_del_node_init_rcu(sk); sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); -unlock: - spin_unlock_bh(lock); +} + +void inet_unhash(struct sock *sk) +{ + struct inet_hashinfo *hashinfo =3D sk->sk_prot->h.hashinfo; + + if (sk_unhashed(sk)) + return; + + if (sk->sk_state =3D=3D TCP_LISTEN) { + struct inet_listen_hashbucket *ilb; + + ilb =3D &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; + /* Don't disable bottom halves while acquiring the lock to + * avoid circular locking dependency on PREEMPT_RT. + */ + spin_lock(&ilb->lock); + __inet_unhash(sk, ilb); + spin_unlock(&ilb->lock); + } else { + spinlock_t *lock =3D inet_ehash_lockp(hashinfo, sk->sk_hash); + + spin_lock_bh(lock); + __inet_unhash(sk, NULL); + spin_unlock_bh(lock); + } } EXPORT_SYMBOL_GPL(inet_unhash); =20 diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 4514444e96c8..4740afecf7c6 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c @@ -333,11 +333,8 @@ int inet6_hash(struct sock *sk) { int err =3D 0; =20 - if (sk->sk_state !=3D TCP_CLOSE) { - local_bh_disable(); + if (sk->sk_state !=3D TCP_CLOSE) err =3D __inet_hash(sk, NULL); - local_bh_enable(); - } =20 return err; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B17EEC433F5 for ; Tue, 12 Apr 2022 09:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376447AbiDLJUv (ORCPT ); Tue, 12 Apr 2022 05:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356884AbiDLHjb (ORCPT ); Tue, 12 Apr 2022 03:39: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 0DFCB4AE0A; Tue, 12 Apr 2022 00:10: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 9FB69B81A8F; Tue, 12 Apr 2022 07:10:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF773C385A5; Tue, 12 Apr 2022 07:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747421; bh=JgWjmrDTOJos8NVOPw83gcBgwqQRunXW+dnqIQpg6OI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l8LJirYkw9uiXAoxV/Dc38XYnqR8R0UcpsfVI8B0bYcB/pRm3lgxp8+kibPATwfDL CWPxGDYfoCct4sbveLiowVDOuTJdxYafS27sYkgtIgbWeCE4czFFHM1KuhFu2lo0ke wsJDCAcJDhs0t8OY2dF072r7WmQvNggVkICvKVN0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manivannan Sadhasivam , Bjorn Helgaas , Sasha Levin Subject: [PATCH 5.17 074/343] PCI: pciehp: Add Qualcomm quirk for Command Completed erratum Date: Tue, 12 Apr 2022 08:28:12 +0200 Message-Id: <20220412062953.236867554@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Manivannan Sadhasivam [ Upstream commit 9f72d4757cbe4d1ed669192f6d23817c9e437c4b ] The Qualcomm PCI bridge device (Device ID 0x0110) found in chipsets such as SM8450 does not set the Command Completed bit unless writes to the Slot Command register change "Control" bits. This results in timeouts like below: pcieport 0001:00:00.0: pciehp: Timeout on hotplug command 0x03c0 (issued = 2020 msec ago) Add the device to the Command Completed quirk to mark commands "completed" immediately unless they change the "Control" bits. Link: https://lore.kernel.org/r/20220210145003.135907-1-manivannan.sadhasiv= am@linaro.org Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/pci/hotplug/pciehp_hpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_= hpc.c index 85dce560831a..040ae076ec0e 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -1086,6 +1086,8 @@ static void quirk_cmd_compl(struct pci_dev *pdev) } DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl); +DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0110, + PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl); DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0400, PCI_CLASS_BRIDGE_PCI, 8, quirk_cmd_compl); DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_QCOM, 0x0401, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A55E6C47081 for ; Tue, 12 Apr 2022 08:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383630AbiDLIhg (ORCPT ); Tue, 12 Apr 2022 04:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356912AbiDLHjd (ORCPT ); Tue, 12 Apr 2022 03:39: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 E5DDC4AE18; Tue, 12 Apr 2022 00:10: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 ams.source.kernel.org (Postfix) with ESMTPS id 639C6B81B4F; Tue, 12 Apr 2022 07:10:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFF6EC385A1; Tue, 12 Apr 2022 07:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747424; bh=orY96oY5zBi4Mw6ib00BZeppDyNc/Z+f7495WgzDBYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8ESX7tNjhzBllmcWVtoBOcBOCDciGs8dm4KqtMc614+U6oe0whO5eV6VNsqPh/sR rkwlSrZ0jNG7Xha0IDKbaCx3kWWew8/KCMqSA9+O6aCXtP430L8OmNo558MU0LjEYV RzEGD0+1wxoAfB6kG4B7wM6ejps5SXLaKzHQFlsM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sreekanth Reddy , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 075/343] scsi: mpi3mr: Fix deadlock while canceling the fw event Date: Tue, 12 Apr 2022 08:28:13 +0200 Message-Id: <20220412062953.265790600@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sreekanth Reddy [ Upstream commit 580e6742205efe6b0bfa5a6a6079f509d99168e0 ] During controller reset, the driver tries to flush all the pending firmware event works from worker queue that are queued prior to the reset. However, if any work is waiting for device addition/removal operation to be completed at the SML, then a deadlock is observed. This is due to the controller reset waiting for the device addition/removal to be completed and the device/addition removal is waiting for the controller reset to be completed. To limit this deadlock, continue with the controller reset handling without canceling the work which is waiting for device addition/removal operation to complete at SML. Link: https://lore.kernel.org/r/20220210095817.22828-2-sreekanth.reddy@broa= dcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/mpi3mr/mpi3mr.h | 4 ++ drivers/scsi/mpi3mr/mpi3mr_fw.c | 2 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 106 ++++++++++++++++++++++++++------ 3 files changed, 91 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index fc4eaf6d1e47..d892ade421bf 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -866,6 +866,8 @@ struct mpi3mr_ioc { * @send_ack: Event acknowledgment required or not * @process_evt: Bottomhalf processing required or not * @evt_ctx: Event context to send in Ack + * @pending_at_sml: waiting for device add/remove API to complete + * @discard: discard this event * @ref_count: kref count * @event_data: Actual MPI3 event data */ @@ -877,6 +879,8 @@ struct mpi3mr_fwevt { bool send_ack; bool process_evt; u32 evt_ctx; + bool pending_at_sml; + bool discard; struct kref ref_count; char event_data[0] __aligned(4); }; diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_f= w.c index 15bdc21ead66..7193b983ee3b 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -4353,8 +4353,8 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrio= c, memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz); memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz); memset(mrioc->evtack_cmds_bitmap, 0, mrioc->evtack_cmds_bitmap_sz); - mpi3mr_cleanup_fwevt_list(mrioc); mpi3mr_flush_host_io(mrioc); + mpi3mr_cleanup_fwevt_list(mrioc); mpi3mr_invalidate_devhandles(mrioc); if (mrioc->prepare_for_reset) { mrioc->prepare_for_reset =3D 0; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_o= s.c index 284117da9086..d205354be63a 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -285,6 +285,35 @@ static struct mpi3mr_fwevt *mpi3mr_dequeue_fwevt( return fwevt; } =20 +/** + * mpi3mr_cancel_work - cancel firmware event + * @fwevt: fwevt object which needs to be canceled + * + * Return: Nothing. + */ +static void mpi3mr_cancel_work(struct mpi3mr_fwevt *fwevt) +{ + /* + * Wait on the fwevt to complete. If this returns 1, then + * the event was never executed. + * + * If it did execute, we wait for it to finish, and the put will + * happen from mpi3mr_process_fwevt() + */ + if (cancel_work_sync(&fwevt->work)) { + /* + * Put fwevt reference count after + * dequeuing it from worker queue + */ + mpi3mr_fwevt_put(fwevt); + /* + * Put fwevt reference count to neutralize + * kref_init increment + */ + mpi3mr_fwevt_put(fwevt); + } +} + /** * mpi3mr_cleanup_fwevt_list - Cleanup firmware event list * @mrioc: Adapter instance reference @@ -302,28 +331,25 @@ void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mri= oc) !mrioc->fwevt_worker_thread) return; =20 - while ((fwevt =3D mpi3mr_dequeue_fwevt(mrioc)) || - (fwevt =3D mrioc->current_event)) { + while ((fwevt =3D mpi3mr_dequeue_fwevt(mrioc))) + mpi3mr_cancel_work(fwevt); + + if (mrioc->current_event) { + fwevt =3D mrioc->current_event; /* - * Wait on the fwevt to complete. If this returns 1, then - * the event was never executed, and we need a put for the - * reference the work had on the fwevt. - * - * If it did execute, we wait for it to finish, and the put will - * happen from mpi3mr_process_fwevt() + * Don't call cancel_work_sync() API for the + * fwevt work if the controller reset is + * get called as part of processing the + * same fwevt work (or) when worker thread is + * waiting for device add/remove APIs to complete. + * Otherwise we will see deadlock. */ - if (cancel_work_sync(&fwevt->work)) { - /* - * Put fwevt reference count after - * dequeuing it from worker queue - */ - mpi3mr_fwevt_put(fwevt); - /* - * Put fwevt reference count to neutralize - * kref_init increment - */ - mpi3mr_fwevt_put(fwevt); + if (current_work() =3D=3D &fwevt->work || fwevt->pending_at_sml) { + fwevt->discard =3D 1; + return; } + + mpi3mr_cancel_work(fwevt); } } =20 @@ -690,6 +716,24 @@ static struct mpi3mr_tgt_dev *__mpi3mr_get_tgtdev_fro= m_tgtpriv( return tgtdev; } =20 +/** + * mpi3mr_print_device_event_notice - print notice related to post process= ing of + * device event after controller reset. + * + * @mrioc: Adapter instance reference + * @device_add: true for device add event and false for device removal eve= nt + * + * Return: None. + */ +static void mpi3mr_print_device_event_notice(struct mpi3mr_ioc *mrioc, + bool device_add) +{ + ioc_notice(mrioc, "Device %s was in progress before the reset and\n", + (device_add ? "addition" : "removal")); + ioc_notice(mrioc, "completed after reset, verify whether the exposed devi= ces\n"); + ioc_notice(mrioc, "are matched with attached devices for correctness\n"); +} + /** * mpi3mr_remove_tgtdev_from_host - Remove dev from upper layers * @mrioc: Adapter instance reference @@ -714,8 +758,17 @@ static void mpi3mr_remove_tgtdev_from_host(struct mpi3= mr_ioc *mrioc, } =20 if (tgtdev->starget) { + if (mrioc->current_event) + mrioc->current_event->pending_at_sml =3D 1; scsi_remove_target(&tgtdev->starget->dev); tgtdev->host_exposed =3D 0; + if (mrioc->current_event) { + mrioc->current_event->pending_at_sml =3D 0; + if (mrioc->current_event->discard) { + mpi3mr_print_device_event_notice(mrioc, false); + return; + } + } } ioc_info(mrioc, "%s :Removed handle(0x%04x), wwid(0x%016llx)\n", __func__, tgtdev->dev_handle, (unsigned long long)tgtdev->wwid); @@ -749,11 +802,20 @@ static int mpi3mr_report_tgtdev_to_host(struct mpi3mr= _ioc *mrioc, } if (!tgtdev->host_exposed && !mrioc->reset_in_progress) { tgtdev->host_exposed =3D 1; + if (mrioc->current_event) + mrioc->current_event->pending_at_sml =3D 1; scsi_scan_target(&mrioc->shost->shost_gendev, 0, tgtdev->perst_id, SCAN_WILD_CARD, SCSI_SCAN_INITIAL); if (!tgtdev->starget) tgtdev->host_exposed =3D 0; + if (mrioc->current_event) { + mrioc->current_event->pending_at_sml =3D 0; + if (mrioc->current_event->discard) { + mpi3mr_print_device_event_notice(mrioc, true); + goto out; + } + } } out: if (tgtdev) @@ -1193,6 +1255,8 @@ static void mpi3mr_sastopochg_evt_bh(struct mpi3mr_io= c *mrioc, mpi3mr_sastopochg_evt_debug(mrioc, event_data); =20 for (i =3D 0; i < event_data->num_entries; i++) { + if (fwevt->discard) + return; handle =3D le16_to_cpu(event_data->phy_entry[i].attached_dev_handle); if (!handle) continue; @@ -1324,6 +1388,8 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_i= oc *mrioc, mpi3mr_pcietopochg_evt_debug(mrioc, event_data); =20 for (i =3D 0; i < event_data->num_entries; i++) { + if (fwevt->discard) + return; handle =3D le16_to_cpu(event_data->port_entry[i].attached_dev_handle); if (!handle) @@ -1362,8 +1428,8 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_i= oc *mrioc, static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, struct mpi3mr_fwevt *fwevt) { - mrioc->current_event =3D fwevt; mpi3mr_fwevt_del_from_list(mrioc, fwevt); + mrioc->current_event =3D fwevt; =20 if (mrioc->stop_drv_processing) goto out; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A2DA4C43219 for ; Tue, 12 Apr 2022 08:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383646AbiDLIhl (ORCPT ); Tue, 12 Apr 2022 04:37:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356921AbiDLHje (ORCPT ); Tue, 12 Apr 2022 03:39: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 749B74AE1D; Tue, 12 Apr 2022 00:10: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 2FCCAB81895; Tue, 12 Apr 2022 07:10:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9047BC385A1; Tue, 12 Apr 2022 07:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747427; bh=9RNdqvPcLPb8b+M8U33rEJl9Lj4sczmsTc4ZUKP6pR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIpTVDPHhJVuHr/U30sF+fbDCiYMKD8S2D7j9ljQxsDH0ZT63IK92EqWrIh+XwtHo fOiOfVfWYKR5YU7WNc/IHByxUqedAJ7csRHT/x2dEuHmwb09nlTzGNzpaJiLRBZ37e PZ8O8f6PI4cVNh4idUVBTX5C+6aQGDOsXRdFGNJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sreekanth Reddy , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 076/343] scsi: mpi3mr: Fix reporting of actual data transfer size Date: Tue, 12 Apr 2022 08:28:14 +0200 Message-Id: <20220412062953.293940522@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sreekanth Reddy [ Upstream commit 9992246127246a27cc7184f05cce6f62ac48f84e ] The driver is missing to set the residual size while completing an I/O. Ensure proper data transfer size is reported to the kernel on I/O completion based on the transfer length reported by the firmware. Link: https://lore.kernel.org/r/20220210095817.22828-7-sreekanth.reddy@broa= dcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/mpi3mr/mpi3mr_os.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_o= s.c index d205354be63a..f7893de35b26 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -2617,6 +2617,8 @@ void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *= mrioc, scmd->result =3D DID_OK << 16; goto out_success; } + + scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_count); if (ioc_status =3D=3D MPI3_IOCSTATUS_SCSI_DATA_UNDERRUN && xfer_count =3D=3D 0 && (scsi_status =3D=3D MPI3_SCSI_STATUS_BUSY || scsi_status =3D=3D MPI3_SCSI_STATUS_RESERVATION_CONFLICT || --=20 2.35.1 From nobody Thu May 14 08:08:21 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 34355C352A7 for ; Tue, 12 Apr 2022 08:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383676AbiDLIhw (ORCPT ); Tue, 12 Apr 2022 04:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356933AbiDLHjf (ORCPT ); Tue, 12 Apr 2022 03:39:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9924AE23; Tue, 12 Apr 2022 00:10: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 EA703B81B4F; Tue, 12 Apr 2022 07:10:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4305EC385A5; Tue, 12 Apr 2022 07:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747429; bh=ROcSE4hl0LuGq9CRnKIb3ozIiz0n9mh+Gy8XDHNAMQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWru7+pb70nOWJ7AGygYR2yby7Pj8oRCe5h0UVJpEJwmuQj36NZzaNue9oJg1n6aG HYOSlB8U797QGRdZ+ZsWXlwm2QXeB3LnGk+4T16412KYPhz0iYMDuegaF+W8RaNA1b iVdSFu+WAsw4GAoCr7W6MDywSkwjrfZn94OR7HTE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sreekanth Reddy , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 077/343] scsi: mpi3mr: Fix memory leaks Date: Tue, 12 Apr 2022 08:28:15 +0200 Message-Id: <20220412062953.322673660@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sreekanth Reddy [ Upstream commit d44b5fefb22e139408ae12b864da1ecb9ad9d1d2 ] Fix memory leaks related to operational reply queue's memory segments which are not getting freed while unloading the driver. Link: https://lore.kernel.org/r/20220210095817.22828-9-sreekanth.reddy@broa= dcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/mpi3mr/mpi3mr_fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_f= w.c index 7193b983ee3b..e44868230197 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -1520,7 +1520,7 @@ static void mpi3mr_free_op_req_q_segments(struct mpi3= mr_ioc *mrioc, u16 q_idx) MPI3MR_MAX_SEG_LIST_SIZE, mrioc->req_qinfo[q_idx].q_segment_list, mrioc->req_qinfo[q_idx].q_segment_list_dma); - mrioc->op_reply_qinfo[q_idx].q_segment_list =3D NULL; + mrioc->req_qinfo[q_idx].q_segment_list =3D NULL; } } else size =3D mrioc->req_qinfo[q_idx].segment_qd * --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C5A42C47082 for ; Tue, 12 Apr 2022 08:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383661AbiDLIhs (ORCPT ); Tue, 12 Apr 2022 04:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356941AbiDLHjf (ORCPT ); Tue, 12 Apr 2022 03:39:35 -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 8E1B82716D; Tue, 12 Apr 2022 00:10: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 06EA361531; Tue, 12 Apr 2022 07:10:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FCAEC385A5; Tue, 12 Apr 2022 07:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747432; bh=F6q0NgFn3EUSCj5ij3cTfIIF72wNVw0Hn/8yaYM1iPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TVU1Q0rJpDTgv5xkAP9Ujx75k3Hec0+qb6cw4mogXpIH3ulZwTxftaQtP+/R/cIc4 N1NTyJd20h/GCqyYOMjnyUAgymTTw6WPlySoMMnEKHgICPs4lzr0UbhNJW5dc1uXno TvPwM1ZylwwC/vzG6waS/T/xTxX3PBRonRqt2Vz0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Bizon , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 078/343] powerpc/set_memory: Avoid spinlock recursion in change_page_attr() Date: Tue, 12 Apr 2022 08:28:16 +0200 Message-Id: <20220412062953.351886212@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Christophe Leroy [ Upstream commit a4c182ecf33584b9b2d1aa9dad073014a504c01f ] Commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") included a spin_lock() to change_page_attr() in order to safely perform the three step operations. But then commit 9f7853d7609d ("powerpc/mm: Fix set_memory_*() against concurrent accesses") modify it to use pte_update() and do the operation safely against concurrent access. In the meantime, Maxime reported some spinlock recursion. [ 15.351649] BUG: spinlock recursion on CPU#0, kworker/0:2/217 [ 15.357540] lock: init_mm+0x3c/0x420, .magic: dead4ead, .owner: kworker= /0:2/217, .owner_cpu: 0 [ 15.366563] CPU: 0 PID: 217 Comm: kworker/0:2 Not tainted 5.15.0+ #523 [ 15.373350] Workqueue: events do_free_init [ 15.377615] Call Trace: [ 15.380232] [e4105ac0] [800946a4] do_raw_spin_lock+0xf8/0x120 (unreliabl= e) [ 15.387340] [e4105ae0] [8001f4ec] change_page_attr+0x40/0x1d4 [ 15.393413] [e4105b10] [801424e0] __apply_to_page_range+0x164/0x310 [ 15.400009] [e4105b60] [80169620] free_pcp_prepare+0x1e4/0x4a0 [ 15.406045] [e4105ba0] [8016c5a0] free_unref_page+0x40/0x2b8 [ 15.411979] [e4105be0] [8018724c] kasan_depopulate_vmalloc_pte+0x6c/0x94 [ 15.418989] [e4105c00] [801424e0] __apply_to_page_range+0x164/0x310 [ 15.425451] [e4105c50] [80187834] kasan_release_vmalloc+0xbc/0x134 [ 15.431898] [e4105c70] [8015f7a8] __purge_vmap_area_lazy+0x4e4/0xdd8 [ 15.438560] [e4105d30] [80160d10] _vm_unmap_aliases.part.0+0x17c/0x24c [ 15.445283] [e4105d60] [801642d0] __vunmap+0x2f0/0x5c8 [ 15.450684] [e4105db0] [800e32d0] do_free_init+0x68/0x94 [ 15.456181] [e4105dd0] [8005d094] process_one_work+0x4bc/0x7b8 [ 15.462283] [e4105e90] [8005d614] worker_thread+0x284/0x6e8 [ 15.468227] [e4105f00] [8006aaec] kthread+0x1f0/0x210 [ 15.473489] [e4105f40] [80017148] ret_from_kernel_thread+0x14/0x1c Remove the read / modify / write sequence to make the operation atomic and remove the spin_lock() in change_page_attr(). To do the operation atomically, we can't use pte modification helpers anymore. Because all platforms have different combination of bits, it is not easy to use those bits directly. But all have the _PAGE_KERNEL_{RO/ROX/RW/RWX} set of flags. All we need it to compare two sets to know which bits are set or cleared. For instance, by comparing _PAGE_KERNEL_ROX and _PAGE_KERNEL_RO you know which bit gets cleared and which bit get set when changing exec permission. Reported-by: Maxime Bizon Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/all/20211212112152.GA27070@sakura/ Link: https://lore.kernel.org/r/43c3c76a1175ae6dc1a3d3b5c3f7ecb48f683eea.16= 40344012.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/mm/pageattr.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/mm/pageattr.c b/arch/powerpc/mm/pageattr.c index 3bb9d168e3b3..85753e32a4de 100644 --- a/arch/powerpc/mm/pageattr.c +++ b/arch/powerpc/mm/pageattr.c @@ -15,12 +15,14 @@ #include =20 =20 +static pte_basic_t pte_update_delta(pte_t *ptep, unsigned long addr, + unsigned long old, unsigned long new) +{ + return pte_update(&init_mm, addr, ptep, old & ~new, new & ~old, 0); +} + /* - * Updates the attributes of a page in three steps: - * - * 1. take the page_table_lock - * 2. install the new entry with the updated attributes - * 3. flush the TLB + * Updates the attributes of a page atomically. * * This sequence is safe against concurrent updates, and also allows updat= ing the * attributes of a page currently being executed or accessed. @@ -28,25 +30,21 @@ static int change_page_attr(pte_t *ptep, unsigned long addr, void *data) { long action =3D (long)data; - pte_t pte; =20 - spin_lock(&init_mm.page_table_lock); - - pte =3D ptep_get(ptep); - - /* modify the PTE bits as desired, then apply */ + /* modify the PTE bits as desired */ switch (action) { case SET_MEMORY_RO: - pte =3D pte_wrprotect(pte); + /* Don't clear DIRTY bit */ + pte_update_delta(ptep, addr, _PAGE_KERNEL_RW & ~_PAGE_DIRTY, _PAGE_KERNE= L_RO); break; case SET_MEMORY_RW: - pte =3D pte_mkwrite(pte_mkdirty(pte)); + pte_update_delta(ptep, addr, _PAGE_KERNEL_RO, _PAGE_KERNEL_RW); break; case SET_MEMORY_NX: - pte =3D pte_exprotect(pte); + pte_update_delta(ptep, addr, _PAGE_KERNEL_ROX, _PAGE_KERNEL_RO); break; case SET_MEMORY_X: - pte =3D pte_mkexec(pte); + pte_update_delta(ptep, addr, _PAGE_KERNEL_RO, _PAGE_KERNEL_ROX); break; case SET_MEMORY_NP: pte_update(&init_mm, addr, ptep, _PAGE_PRESENT, 0, 0); @@ -59,16 +57,12 @@ static int change_page_attr(pte_t *ptep, unsigned long = addr, void *data) break; } =20 - pte_update(&init_mm, addr, ptep, ~0UL, pte_val(pte), 0); - /* See ptesync comment in radix__set_pte_at() */ if (radix_enabled()) asm volatile("ptesync": : :"memory"); =20 flush_tlb_kernel_range(addr, addr + PAGE_SIZE); =20 - spin_unlock(&init_mm.page_table_lock); - return 0; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 5B012C3527C for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359860AbiDLJUo (ORCPT ); Tue, 12 Apr 2022 05:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356949AbiDLHjg (ORCPT ); Tue, 12 Apr 2022 03:39: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 6D4A74B1C4; Tue, 12 Apr 2022 00:10: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 B222E616AB; Tue, 12 Apr 2022 07:10:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFCACC385A1; Tue, 12 Apr 2022 07:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747435; bh=CBy5DzSt/DDqfNIg2zikiyymZmnWiRhZbtSG9wmBV8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PW3gbfiS4SEcNbvqVmItBM3FPJYlrv/qyU3lCE8gAWxppcZh8fs/cu/eCQQMDwisq 6jTicJu+vYV4KI4LmDMAk3649Wlt5PdZYVuWOWz3xvg7B7gpIi9z3m84RVyFs0G11V EzaaRkNd765T+8zEFOVrrrW4aQY8dfR+HgAczAMw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.17 079/343] power: supply: axp288-charger: Set Vhold to 4.4V Date: Tue, 12 Apr 2022 08:28:17 +0200 Message-Id: <20220412062953.380604209@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hans de Goede [ Upstream commit 5ac121b81b4051e7fc83d5b3456a5e499d5bd147 ] The AXP288's recommended and factory default Vhold value (minimum input voltage below which the input current draw will be reduced) is 4.4V. This lines up with other charger IC's such as the TI bq2419x/bq2429x series which use 4.36V or 4.44V. For some reason some BIOS-es initialize Vhold to 4.6V or even 4.7V which combined with the typical voltage drop over typically low wire gauge micro-USB cables leads to the input-current getting capped below 1A (with a 2A capable dedicated charger) based on Vhold. This leads to slow charging, or even to the device slowly discharging if the device is in heavy use. As the Linux AXP288 drivers use the builtin BC1.2 charger detection and send the input-current-limit according to the detected charger there really is no reason not to use the recommended 4.4V Vhold. Set Vhold to 4.4V to fix the slow charging issue on various devices. There is one exception, the special-case of the HP X2 2-in-1s which combine this BC1.2 capable PMIC with a Type-C port and a 5V/3A factory provided charger with a Type-C plug which does not do BC1.2. These have their input-current-limit hardcoded to 3A (like under Windows) and use a higher Vhold on purpose to limit the current when used with other chargers. To avoid touching Vhold on these HP X2 laptops the code setting Vhold is added to an else branch of the if checking for these models. Note this also fixes the sofar unused VBUS_ISPOUT_VHOLD_SET_MASK define, which was wrong. Signed-off-by: Hans de Goede Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/power/supply/axp288_charger.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/a= xp288_charger.c index ec41f6cd3f93..c498e62ab4e2 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -42,11 +42,11 @@ #define VBUS_ISPOUT_CUR_LIM_1500MA 0x1 /* 1500mA */ #define VBUS_ISPOUT_CUR_LIM_2000MA 0x2 /* 2000mA */ #define VBUS_ISPOUT_CUR_NO_LIM 0x3 /* 2500mA */ -#define VBUS_ISPOUT_VHOLD_SET_MASK 0x31 +#define VBUS_ISPOUT_VHOLD_SET_MASK 0x38 #define VBUS_ISPOUT_VHOLD_SET_BIT_POS 0x3 #define VBUS_ISPOUT_VHOLD_SET_OFFSET 4000 /* 4000mV */ #define VBUS_ISPOUT_VHOLD_SET_LSB_RES 100 /* 100mV */ -#define VBUS_ISPOUT_VHOLD_SET_4300MV 0x3 /* 4300mV */ +#define VBUS_ISPOUT_VHOLD_SET_4400MV 0x4 /* 4400mV */ #define VBUS_ISPOUT_VBUS_PATH_DIS BIT(7) =20 #define CHRG_CCCV_CC_MASK 0xf /* 4 bits */ @@ -769,6 +769,16 @@ static int charger_init_hw_regs(struct axp288_chrg_inf= o *info) ret =3D axp288_charger_vbus_path_select(info, true); if (ret < 0) return ret; + } else { + /* Set Vhold to the factory default / recommended 4.4V */ + val =3D VBUS_ISPOUT_VHOLD_SET_4400MV << VBUS_ISPOUT_VHOLD_SET_BIT_POS; + ret =3D regmap_update_bits(info->regmap, AXP20X_VBUS_IPSOUT_MGMT, + VBUS_ISPOUT_VHOLD_SET_MASK, val); + if (ret < 0) { + dev_err(&info->pdev->dev, "register(%x) write error(%d)\n", + AXP20X_VBUS_IPSOUT_MGMT, ret); + return ret; + } } =20 /* Read current charge voltage and current limit */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 590CBC433F5 for ; Tue, 12 Apr 2022 08:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383691AbiDLIhy (ORCPT ); Tue, 12 Apr 2022 04:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356959AbiDLHjg (ORCPT ); Tue, 12 Apr 2022 03:39: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 3760728E33; Tue, 12 Apr 2022 00:10: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 75CCE6157E; Tue, 12 Apr 2022 07:10:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82C2CC385A5; Tue, 12 Apr 2022 07:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747437; bh=htaFqnftVObrnN1B1DrLIaFhG697hzt0hv0PLXg/hdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rzs9fC5u8kMA7Poha9SykkhkN1mnOp8jrnR2gYoAT5cWwZlUGGaBYtkKrgnaq6bA6 E2eGIrfSUNl9utKFBj86NeUxSgBYcgJAkHrrzUeKRjKADh49wVj+a09zvfFIlbL5EA CHskQgImjDzLaG2u2omYK9e6yZ1zj2BfbLNCTqAA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Kevin Tang , Javier Martinez Canillas , Thomas Zimmermann , Sasha Levin Subject: [PATCH 5.17 080/343] drm/sprd: fix potential NULL dereference Date: Tue, 12 Apr 2022 08:28:18 +0200 Message-Id: <20220412062953.409337667@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kevin Tang [ Upstream commit 8668658aebb0a19d877d5a81c004baf716c4aaa6 ] 'drm' could be null in sprd_drm_shutdown, and drm_warn maybe dereference it, remove this warning log. Reported-by: Dan Carpenter Signed-off-by: Kevin Tang Reviewed-by: Javier Martinez Canillas Acked-by: Thomas Zimmermann Link: https://lore.kernel.org/all/20220117084044.9210-1-kevin3.tang@gmail.c= om v1 -> v2: - Split checking platform_get_resource() return value to a separate patch - Use dev_warn() instead of removing the warning log Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/sprd/sprd_drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sprd/sprd_drm.c b/drivers/gpu/drm/sprd/sprd_dr= m.c index a077e2d4d721..af2be97d5ed0 100644 --- a/drivers/gpu/drm/sprd/sprd_drm.c +++ b/drivers/gpu/drm/sprd/sprd_drm.c @@ -155,7 +155,7 @@ static void sprd_drm_shutdown(struct platform_device *p= dev) struct drm_device *drm =3D platform_get_drvdata(pdev); =20 if (!drm) { - drm_warn(drm, "drm device is not available, no shutdown\n"); + dev_warn(&pdev->dev, "drm device is not available, no shutdown\n"); return; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4C999C4707A for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358909AbiDLJUT (ORCPT ); Tue, 12 Apr 2022 05:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357004AbiDLHjj (ORCPT ); Tue, 12 Apr 2022 03:39: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 5309915708; Tue, 12 Apr 2022 00:10: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 ams.source.kernel.org (Postfix) with ESMTPS id BECF1B81B55; Tue, 12 Apr 2022 07:10:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07FEAC385A1; Tue, 12 Apr 2022 07:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747443; bh=JQ4CIo/B9TfQlgpiYFcfzmhMll5JVvDMZabjKybC0oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVZsYFyTDA6BkmU6FwozgUvISvOvTlqlOIHb5panTBj1VmqrkI3HHdnfqNxOlt8tW H4tcvdmTr/5qnVG+fHYI2JGEkZK6/MLiMEfO2DcpB5tpYiCdO1jy+v24Q4F5+FLb2A cusdPmlZEx/EiwRjtCMIodQR7huv8JDfR82Wngys= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zou Wei , Kevin Tang , Javier Martinez Canillas , Thomas Zimmermann , Sasha Levin Subject: [PATCH 5.17 081/343] drm/sprd: check the platform_get_resource() return value Date: Tue, 12 Apr 2022 08:28:19 +0200 Message-Id: <20220412062953.438250061@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kevin Tang [ Upstream commit 73792e6e66be1225837cc1a40f1e39b1d077751c ] platform_get_resource() may fail and return NULL, so check it's value before using it. Reported-by: Zou Wei Signed-off-by: Kevin Tang Reviewed-by: Javier Martinez Canillas Acked-by: Thomas Zimmermann Link: https://lore.kernel.org/all/20220117084156.9338-1-kevin3.tang@gmail.c= om v1 -> v2: - new patch Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/sprd/sprd_dpu.c | 5 +++++ drivers/gpu/drm/sprd/sprd_dsi.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/sprd/sprd_dpu.c b/drivers/gpu/drm/sprd/sprd_dp= u.c index 06a3414ee43a..1637203ea103 100644 --- a/drivers/gpu/drm/sprd/sprd_dpu.c +++ b/drivers/gpu/drm/sprd/sprd_dpu.c @@ -790,6 +790,11 @@ static int sprd_dpu_context_init(struct sprd_dpu *dpu, int ret; =20 res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "failed to get I/O resource\n"); + return -EINVAL; + } + ctx->base =3D devm_ioremap(dev, res->start, resource_size(res)); if (!ctx->base) { dev_err(dev, "failed to map dpu registers\n"); diff --git a/drivers/gpu/drm/sprd/sprd_dsi.c b/drivers/gpu/drm/sprd/sprd_ds= i.c index 911b3cddc264..12b67a5d5923 100644 --- a/drivers/gpu/drm/sprd/sprd_dsi.c +++ b/drivers/gpu/drm/sprd/sprd_dsi.c @@ -907,6 +907,11 @@ static int sprd_dsi_context_init(struct sprd_dsi *dsi, struct resource *res; =20 res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "failed to get I/O resource\n"); + return -EINVAL; + } + ctx->base =3D devm_ioremap(dev, res->start, resource_size(res)); if (!ctx->base) { drm_err(dsi->drm, "failed to map dsi host registers\n"); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A139CC4332F for ; Tue, 12 Apr 2022 08:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383707AbiDLIh7 (ORCPT ); Tue, 12 Apr 2022 04:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357023AbiDLHjm (ORCPT ); Tue, 12 Apr 2022 03:39: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 1BDD329C90; Tue, 12 Apr 2022 00:10: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 8EC97B81A8F; Tue, 12 Apr 2022 07:10:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0F17C385A1; Tue, 12 Apr 2022 07:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747446; bh=DNsSy1b0PI3PmwLmgzdEV6RJCPflO8LhpqM5IpcKNIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=irLhlekZtN29YMhS1KqPT4m7C3BTv9fELq+gzr/rTqtDgLtsPsc/uoviAG+G31f7K TssRj/inGdNpLR4dVtLpxsX2LLjCMTcmKcMZzOiAlYqmmVEaEfXOmGDn5xJW446I8W UKx0HIPYL6PB0W+1n3md4Th2WyG1LJ3c8fD32xgI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Meenakshikumar Somasundaram , Jun Lei , Jasdeep Dhillon , Sung Joon Kim , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 082/343] drm/amd/display: reset lane settings after each PHY repeater LT Date: Tue, 12 Apr 2022 08:28:20 +0200 Message-Id: <20220412062953.467774112@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sung Joon Kim [ Upstream commit 3b853c316c9321e195414a6fb121d1c2d45b1e87 ] [why] In LTTPR non-transparent mode, we need to reset the cached lane settings before performing link training on the next PHY repeater. Otherwise, the cached lane settings will be used for the next clock recovery e.g. VS =3D MAX (3) which should not be the case according to the DP specs. We expect to use minimum lane settings on each clock recovery sequence. [how] Reset DPCD and HW lane settings on each repeater LT. Set training pattern to 0 for the repeater that failed LT at the proper place. Reviewed-by: Meenakshikumar Somasundaram Reviewed-by: Jun Lei Acked-by: Jasdeep Dhillon Signed-off-by: Sung Joon Kim Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu= /drm/amd/display/dc/core/dc_link_dp.c index 61b8f29a0c30..49d5271dcfdc 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c @@ -2378,22 +2378,27 @@ static enum link_training_result dp_perform_8b_10b_= link_training( repeater_id--) { status =3D perform_clock_recovery_sequence(link, link_res, lt_settings,= repeater_id); =20 - if (status !=3D LINK_TRAINING_SUCCESS) + if (status !=3D LINK_TRAINING_SUCCESS) { + repeater_training_done(link, repeater_id); break; + } =20 status =3D perform_channel_equalization_sequence(link, link_res, lt_settings, repeater_id); =20 + repeater_training_done(link, repeater_id); + if (status !=3D LINK_TRAINING_SUCCESS) break; =20 - repeater_training_done(link, repeater_id); + for (lane =3D 0; lane < LANE_COUNT_DP_MAX; lane++) { + lt_settings->dpcd_lane_settings[lane].raw =3D 0; + lt_settings->hw_lane_settings[lane].VOLTAGE_SWING =3D 0; + lt_settings->hw_lane_settings[lane].PRE_EMPHASIS =3D 0; + } } - - for (lane =3D 0; lane < (uint8_t)lt_settings->link_settings.lane_count; = lane++) - lt_settings->dpcd_lane_settings[lane].raw =3D 0; } =20 if (status =3D=3D LINK_TRAINING_SUCCESS) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2DBE1C35295 for ; Tue, 12 Apr 2022 09:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359248AbiDLJU2 (ORCPT ); Tue, 12 Apr 2022 05:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357025AbiDLHjm (ORCPT ); Tue, 12 Apr 2022 03:39: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 A136F52E62; Tue, 12 Apr 2022 00:10: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 ams.source.kernel.org (Postfix) with ESMTPS id 60AFFB81B55; Tue, 12 Apr 2022 07:10:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB389C385A8; Tue, 12 Apr 2022 07:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747449; bh=SNxsj0Sda60OXMqwWwNqNF+nUGirEVBwy2IM3bUSL9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kuFYlrz5F9dp1iwyyvqL2Tc2m16NDKjGIQKZFCo0hQde9I3WdQLMdK8GRLjwkauiy uxrvxvGiTchspbHxelbsrHM84sI9Ou9t4IOlQH9e1i6sdTFNgY5UJlqLIY3ABxFgFG uQR0YDtvmOYFMze//yCpsYyO9k7lxP1leRh7njRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Tariq Toukan , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.17 083/343] net/mlx5e: Disable TX queues before registering the netdev Date: Tue, 12 Apr 2022 08:28:21 +0200 Message-Id: <20220412062953.496711938@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maxim Mikityanskiy [ Upstream commit d08c6e2a4d0308a7922d7ef3b1b3af45d4096aad ] Normally, the queues are disabled when the channels are deactivated, and enabled when the channels are activated. However, on register, the channels are not active, but the queues are enabled by default. This change fixes it, preventing mlx5e_xmit from running when the channels are deactivated in the beginning. Signed-off-by: Maxim Mikityanskiy Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/ne= t/ethernet/mellanox/mlx5/core/en_main.c index 3667f5ef5990..169e3524bb1c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5345,6 +5345,7 @@ mlx5e_create_netdev(struct mlx5_core_dev *mdev, const= struct mlx5e_profile *prof } =20 netif_carrier_off(netdev); + netif_tx_disable(netdev); dev_net_set(netdev, mlx5_core_net(mdev)); =20 return netdev; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CD2A2C47080 for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359094AbiDLJUW (ORCPT ); Tue, 12 Apr 2022 05:20:22 -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 S1357024AbiDLHjm (ORCPT ); Tue, 12 Apr 2022 03:39:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C2B2532C2; Tue, 12 Apr 2022 00:10: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 26196B81A8F; Tue, 12 Apr 2022 07:10:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F876C385A5; Tue, 12 Apr 2022 07:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747451; bh=6x8yKFGa5U5mRxTV0zTicniMpUeHjVzDeMdNkP+EaOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVfwNrioM9CGtgBjd5b5SXATmKSh4pVd7W1VH+JUZGf9T5l+sKtUC13D9hzd25WcQ vHfnxgncKWjm/5Ymx4B4khcxAdLgG0j86Zzq7jpSWC7++VwxcZZ/VPrBxYi5O0aWgo nZRqgyenqddK7ISQvMkZ4sWeNlpS08nQk8hlFEmY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Jiri Kosina , Sasha Levin Subject: [PATCH 5.17 084/343] HID: apple: Report Magic Keyboard 2021 battery over USB Date: Tue, 12 Apr 2022 08:28:22 +0200 Message-Id: <20220412062953.524501912@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jos=C3=A9 Exp=C3=B3sito [ Upstream commit 8ae5c16c9d421d43f32f66d2308031f1bd3f9336 ] Like the Apple Magic Keyboard 2015, when connected over USB, the 2021 version registers 2 different interfaces. One of them is used to report the battery level. However, unlike when connected over Bluetooth, the battery level is not reported automatically and it is required to fetch it manually. Add the APPLE_RDESC_BATTERY quirk to fix the battery report descriptor and manually fetch the battery level. Tested with the ANSI, ISO and JIS variants of the keyboard. Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/hid/hid-apple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 7dc89dc6b0f0..18de4ccb0fb2 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -748,7 +748,7 @@ static const struct hid_device_id apple_devices[] =3D { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY= ), .driver_data =3D APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_= 2021), - .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATT= ERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYB= OARD_2021), .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_= FINGERPRINT_2021), --=20 2.35.1 From nobody Thu May 14 08:08:21 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 004F3C3527E for ; Tue, 12 Apr 2022 08:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386661AbiDLI6x (ORCPT ); Tue, 12 Apr 2022 04:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357042AbiDLHjn (ORCPT ); Tue, 12 Apr 2022 03:39: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 1D68F165A5; Tue, 12 Apr 2022 00:10: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 C8EC2B81895; Tue, 12 Apr 2022 07:10:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 291E9C385A1; Tue, 12 Apr 2022 07:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747454; bh=75XHWw54css5obuqON8cmpEPngRNcXM5PRhjE/n61S0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ehsqCT31AYccLV1qEKz3UcsrcmwFLWOqWvnQy+kd43AHZ9i1B5ZiWjcUFV2lBB6r2 2RXSudOH51y1HTKjDfRvwYa71QUdlwg3HwvBz1+w948C2/FQH/eiEASxI+Ik5kZdyq cma1pjZKY5ewLZTEfnzFGtAjnKqoNH/U4+S5saF0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Jiri Kosina , Sasha Levin Subject: [PATCH 5.17 085/343] HID: apple: Report Magic Keyboard 2021 with fingerprint reader battery over USB Date: Tue, 12 Apr 2022 08:28:23 +0200 Message-Id: <20220412062953.552831502@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jos=C3=A9 Exp=C3=B3sito [ Upstream commit cbfcfbfc384890a062a5d0cc4792df094a6cc7a8 ] Like the Apple Magic Keyboard 2015, when connected over USB, the 2021 version with fingerprint reader registers 2 different interfaces. One of them is used to report the battery level. However, unlike when connected over Bluetooth, the battery level is not reported automatically and it is required to fetch it manually. Add the APPLE_RDESC_BATTERY quirk to fix the battery report descriptor and manually fetch the battery level. Tested with the ANSI variant of the keyboard with and without numpad. Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/hid/hid-apple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 18de4ccb0fb2..590376d776a1 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -752,11 +752,11 @@ static const struct hid_device_id apple_devices[] =3D= { { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYB= OARD_2021), .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_= FINGERPRINT_2021), - .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATT= ERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYB= OARD_FINGERPRINT_2021), .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_= NUMPAD_2021), - .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, + .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATT= ERY }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYB= OARD_NUMPAD_2021), .driver_data =3D APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK }, =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C4311C433EF for ; Tue, 12 Apr 2022 09:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358779AbiDLJUM (ORCPT ); Tue, 12 Apr 2022 05:20:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357040AbiDLHjn (ORCPT ); Tue, 12 Apr 2022 03:39:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F00417045; Tue, 12 Apr 2022 00:10: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 AC8EF6103A; Tue, 12 Apr 2022 07:10:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD78FC385A5; Tue, 12 Apr 2022 07:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747457; bh=1eZQ2mG1B5Ze4BFKltM7j3jjf6Smhu+NEKul0MLnFVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sQOxHtpUbRwbKrf7QwI1bs+38NvWrgs0OzMKJqxvaAie2VMfgw9FRvzprVCZ5G466 fDnWVinTEFKy/EEXY7osfD0cU7ZHjUjeXzXNXJOFpylOiasVd2EuOWLStLCDu0tyLv n20PGga6cb7V5k7JHsy69HG9NJsu3eOuqNGsoJn8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Sasha Levin Subject: [PATCH 5.17 086/343] usb: dwc3: pci: Set the swnode from inside dwc3_pci_quirks() Date: Tue, 12 Apr 2022 08:28:24 +0200 Message-Id: <20220412062953.589206078@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hans de Goede [ Upstream commit e285cb403994419e997749c9a52b9370884ae0c8 ] The quirk handling may need to set some different properties which means using a different swnode, move the setting of the swnode to inside dwc3_pci_quirks() so that the quirk handling can choose a different swnode. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20220213130524.18748-4-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/dwc3/dwc3-pci.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 06d0e88ec8af..4d9608cc55f7 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -185,7 +185,8 @@ static const struct software_node dwc3_pci_amd_mr_swnod= e =3D { .properties =3D dwc3_pci_mr_properties, }; =20 -static int dwc3_pci_quirks(struct dwc3_pci *dwc) +static int dwc3_pci_quirks(struct dwc3_pci *dwc, + const struct software_node *swnode) { struct pci_dev *pdev =3D dwc->pci; =20 @@ -242,7 +243,7 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) } } =20 - return 0; + return device_add_software_node(&dwc->dwc3->dev, swnode); } =20 #ifdef CONFIG_PM @@ -307,11 +308,7 @@ static int dwc3_pci_probe(struct pci_dev *pci, const s= truct pci_device_id *id) dwc->dwc3->dev.parent =3D dev; ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev)); =20 - ret =3D device_add_software_node(&dwc->dwc3->dev, (void *)id->driver_data= ); - if (ret < 0) - goto err; - - ret =3D dwc3_pci_quirks(dwc); + ret =3D dwc3_pci_quirks(dwc, (void *)id->driver_data); if (ret) goto err; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 28F5DC433EF for ; Tue, 12 Apr 2022 08:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383752AbiDLIiM (ORCPT ); Tue, 12 Apr 2022 04:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357053AbiDLHjp (ORCPT ); Tue, 12 Apr 2022 03:39: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 6B2A0532D6; Tue, 12 Apr 2022 00:11: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 241C9B81A8F; Tue, 12 Apr 2022 07:11:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A73AC385A5; Tue, 12 Apr 2022 07:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747460; bh=bcdUogpj52SUG8nQQS8SqrwbgPj2XDWbLfXBv7xXEhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SRMwFzJlSpdkjqHx0WWcMBFDjv9mTY5Or4LepehLSRvLrGTHv7ZSce8swMKeOlRkt 76GWHQjA0HiVcTszOECk1OSqD1Wq95dp4GO4MCFCKAbwe2rxcHjFA9l5v2In+Z7tdJ G8Frs6BZKBsX4Q4S8mELhDz3albQGaPnlwXtouB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilan Peer , Luca Coelho , Sasha Levin Subject: [PATCH 5.17 087/343] iwlwifi: mvm: Correctly set fragmented EBS Date: Tue, 12 Apr 2022 08:28:25 +0200 Message-Id: <20220412062953.617437038@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ilan Peer [ Upstream commit d8d4dd26b9e0469baf5017f0544d852fd4e3fb6d ] Currently, fragmented EBS was set for a channel only if the 'hb_type' was set to fragmented or balanced scan. However, 'hb_type' is set only in case of CDB, and thus fragmented EBS is never set for a channel for non-CDB devices. Fix it. Signed-off-by: Ilan Peer Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20220204122220.a6165ac9b9d5.I654eaf= a62fd647030ae6d4f07f32c96c3171decb@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wi= reless/intel/iwlwifi/mvm/scan.c index 5f92a09db374..4cd507cb412d 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c @@ -1893,7 +1893,10 @@ static u8 iwl_mvm_scan_umac_chan_flags_v2(struct iwl= _mvm *mvm, IWL_SCAN_CHANNEL_FLAG_CACHE_ADD; =20 /* set fragmented ebs for fragmented scan on HB channels */ - if (iwl_mvm_is_scan_fragmented(params->hb_type)) + if ((!iwl_mvm_is_cdb_supported(mvm) && + iwl_mvm_is_scan_fragmented(params->type)) || + (iwl_mvm_is_cdb_supported(mvm) && + iwl_mvm_is_scan_fragmented(params->hb_type))) flags |=3D IWL_SCAN_CHANNEL_FLAG_EBS_FRAG; =20 return flags; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 72693C433FE for ; Tue, 12 Apr 2022 08:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383812AbiDLIiV (ORCPT ); Tue, 12 Apr 2022 04:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357056AbiDLHjo (ORCPT ); Tue, 12 Apr 2022 03:39:44 -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 4A4FCEAF; Tue, 12 Apr 2022 00:11: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 F20D6B81895; Tue, 12 Apr 2022 07:11:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D528C385A1; Tue, 12 Apr 2022 07:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747463; bh=CaOPJcfL/tfWoek1acG/0Z4Scs1IcTmTfZliCCSDYak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y84vntcpJsi6NFwZWy4cbzNLfA/5RQ1d+jj+bjcfTb/Qlr/aF57ze9slWdWTB5Xnq QhTQ00GzAhHLq1QYJbk0DPPWBePwYZvXyg3h7og0HVetvqYmuCmsgXq0MPTBIdaMUH TqShqABlywI1o6WPG++bI2mIJbrC8MbICwXBloxY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luca Coelho , Sasha Levin Subject: [PATCH 5.17 088/343] iwlwifi: fix small doc mistake for iwl_fw_ini_addr_val Date: Tue, 12 Apr 2022 08:28:26 +0200 Message-Id: <20220412062953.646591622@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Luca Coelho [ Upstream commit 3009c797c4b3840495e8f48d8d07f48d2ddfed80 ] There was a small copy and paste mistake in the doc declaration of iwl_fw_ini_addr_val. Fix it. Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20220205112029.aeec71c397b3.I0ba323= 4419eb8c8c7512a2ca531a6dbb55046cf7@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h b/drivers/= net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h index 456b7eaac570..061fe6cc6cf5 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation */ #ifndef __iwl_fw_dbg_tlv_h__ #define __iwl_fw_dbg_tlv_h__ @@ -249,11 +249,10 @@ struct iwl_fw_ini_hcmd_tlv { } __packed; /* FW_TLV_DEBUG_HCMD_API_S_VER_1 */ =20 /** -* struct iwl_fw_ini_conf_tlv - preset configuration TLV +* struct iwl_fw_ini_addr_val - Address and value to set it to * * @address: the base address * @value: value to set at address - */ struct iwl_fw_ini_addr_val { __le32 address; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 5E09BC4332F for ; Tue, 12 Apr 2022 08:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383782AbiDLIiS (ORCPT ); Tue, 12 Apr 2022 04:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357058AbiDLHjo (ORCPT ); Tue, 12 Apr 2022 03:39:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A42A5E9F; Tue, 12 Apr 2022 00:11: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 dfw.source.kernel.org (Postfix) with ESMTPS id 36338616B2; Tue, 12 Apr 2022 07:11:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 395C9C385A5; Tue, 12 Apr 2022 07:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747466; bh=sGHw+Qc1sKYhrFjSu0qr7jBNBmG3wNZQljjWBWyhD2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVu1/VZCcfnVH1/Ww3PKcWDT3M7jvlXXeUMSQ4OGcmU81UN8K9c974yaj2ZdDUi6O LeoboqMETbBPH/SdcF86IymB0Je5ShFjyik1uKfXeXz/f47wpj2OKvsqtrdVlmyiZ6 xIe7jNe0F9IUF4NnVf5ls4DfognvkGsM7NlRlyt4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miri Korenblit , Luca Coelho , Sasha Levin Subject: [PATCH 5.17 089/343] iwlwifi: mvm: move only to an enabled channel Date: Tue, 12 Apr 2022 08:28:27 +0200 Message-Id: <20220412062953.675935614@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Miri Korenblit [ Upstream commit e04135c07755d001b5cde61048c69a7cc84bb94b ] During disassociation we're decreasing the phy's ref count. If the ref count becomes 0, we're configuring the phy ctxt to the default channel (the lowest channel which the device can operate on). Currently we're not checking whether the the default channel is enabled or not. Fix it by configuring the phy ctxt to the lowest channel which is enabled. Signed-off-by: Miri Korenblit Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20220210181930.03f281b6a6bc.I5b63d4= 3ec41996d599e6f37ec3f32e878b3e405e@changeid Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- .../net/wireless/intel/iwlwifi/mvm/phy-ctxt.c | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c b/drivers/ne= t/wireless/intel/iwlwifi/mvm/phy-ctxt.c index 9af40b0fa37a..a6e6673bf4ee 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* - * Copyright (C) 2012-2014, 2018-2021 Intel Corporation + * Copyright (C) 2012-2014, 2018-2022 Intel Corporation * Copyright (C) 2013-2014 Intel Mobile Communications GmbH * Copyright (C) 2017 Intel Deutschland GmbH */ @@ -349,18 +349,31 @@ void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, stru= ct iwl_mvm_phy_ctxt *ctxt) * otherwise we might not be able to reuse this phy. */ if (ctxt->ref =3D=3D 0) { - struct ieee80211_channel *chan; + struct ieee80211_channel *chan =3D NULL; struct cfg80211_chan_def chandef; - struct ieee80211_supported_band *sband =3D NULL; - enum nl80211_band band =3D NL80211_BAND_2GHZ; + struct ieee80211_supported_band *sband; + enum nl80211_band band; + int channel; =20 - while (!sband && band < NUM_NL80211_BANDS) - sband =3D mvm->hw->wiphy->bands[band++]; + for (band =3D NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) { + sband =3D mvm->hw->wiphy->bands[band]; =20 - if (WARN_ON(!sband)) - return; + if (!sband) + continue; + + for (channel =3D 0; channel < sband->n_channels; channel++) + if (!(sband->channels[channel].flags & + IEEE80211_CHAN_DISABLED)) { + chan =3D &sband->channels[channel]; + break; + } =20 - chan =3D &sband->channels[0]; + if (chan) + break; + } + + if (WARN_ON(!chan)) + return; =20 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); iwl_mvm_phy_ctxt_changed(mvm, ctxt, &chandef, 1, 1); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BC1CCC352A8 for ; Tue, 12 Apr 2022 08:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383721AbiDLIiD (ORCPT ); Tue, 12 Apr 2022 04:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357055AbiDLHjo (ORCPT ); Tue, 12 Apr 2022 03:39: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 6923EEBE; Tue, 12 Apr 2022 00:11:10 -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 06D7A616B2; Tue, 12 Apr 2022 07:11:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12171C385A5; Tue, 12 Apr 2022 07:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747469; bh=zgITDaPiAeLIf6/TWaZY2wCzKCFRSQVmMhsZTlPKrso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zb05itzi60PoJFD3tjcR3EZil7eh3FY960Gw0/PsWTEywOMAvQHRUJIuFAYzTEHY5 0kVUar8JkalVWFNpENPJ0ZH4k04FdCG3C+5q05N0gQbgIyPDqAvHhjZ2TGxTANX4hL qRC7TdGP+gBgxpka6lQsctIMeD9GYGfDqZbJOUC0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 090/343] ipv6: annotate some data-races around sk->sk_prot Date: Tue, 12 Apr 2022 08:28:28 +0200 Message-Id: <20220412062953.705135357@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 086d49058cd8471046ae9927524708820f5fd1c7 ] IPv6 has this hack changing sk->sk_prot when an IPv6 socket is 'converted' to an IPv4 one with IPV6_ADDRFORM option. This operation is only performed for TCP and UDP, knowing their 'struct proto' for the two network families are populated in the same way, and can not disappear while a reader might use and dereference sk->sk_prot. If we think about it all reads of sk->sk_prot while either socket lock or RTNL is not acquired should be using READ_ONCE(). Also note that other layers like MPTCP, XFRM, CHELSIO_TLS also write over sk->sk_prot. BUG: KCSAN: data-race in inet6_recvmsg / ipv6_setsockopt write to 0xffff8881386f7aa8 of 8 bytes by task 26932 on cpu 0: do_ipv6_setsockopt net/ipv6/ipv6_sockglue.c:492 [inline] ipv6_setsockopt+0x3758/0x3910 net/ipv6/ipv6_sockglue.c:1019 udpv6_setsockopt+0x85/0x90 net/ipv6/udp.c:1649 sock_common_setsockopt+0x5d/0x70 net/core/sock.c:3489 __sys_setsockopt+0x209/0x2a0 net/socket.c:2180 __do_sys_setsockopt net/socket.c:2191 [inline] __se_sys_setsockopt net/socket.c:2188 [inline] __x64_sys_setsockopt+0x62/0x70 net/socket.c:2188 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae read to 0xffff8881386f7aa8 of 8 bytes by task 26911 on cpu 1: inet6_recvmsg+0x7a/0x210 net/ipv6/af_inet6.c:659 ____sys_recvmsg+0x16c/0x320 ___sys_recvmsg net/socket.c:2674 [inline] do_recvmmsg+0x3f5/0xae0 net/socket.c:2768 __sys_recvmmsg net/socket.c:2847 [inline] __do_sys_recvmmsg net/socket.c:2870 [inline] __se_sys_recvmmsg net/socket.c:2863 [inline] __x64_sys_recvmmsg+0xde/0x160 net/socket.c:2863 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae value changed: 0xffffffff85e0e980 -> 0xffffffff85e01580 Reported by Kernel Concurrency Sanitizer on: CPU: 1 PID: 26911 Comm: syz-executor.3 Not tainted 5.17.0-rc2-syzkaller-003= 16-g0457e5153e0e-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 01/01/2011 Reported-by: syzbot Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/ipv6/af_inet6.c | 24 ++++++++++++++++++------ net/ipv6/ipv6_sockglue.c | 6 ++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 8fe7900f1949..7d7b7523d126 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -441,11 +441,14 @@ int inet6_bind(struct socket *sock, struct sockaddr *= uaddr, int addr_len) { struct sock *sk =3D sock->sk; u32 flags =3D BIND_WITH_LOCK; + const struct proto *prot; int err =3D 0; =20 + /* IPV6_ADDRFORM can change sk->sk_prot under us. */ + prot =3D READ_ONCE(sk->sk_prot); /* If the socket has its own bind function then use it. */ - if (sk->sk_prot->bind) - return sk->sk_prot->bind(sk, uaddr, addr_len); + if (prot->bind) + return prot->bind(sk, uaddr, addr_len); =20 if (addr_len < SIN6_LEN_RFC2133) return -EINVAL; @@ -555,6 +558,7 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, = unsigned long arg) void __user *argp =3D (void __user *)arg; struct sock *sk =3D sock->sk; struct net *net =3D sock_net(sk); + const struct proto *prot; =20 switch (cmd) { case SIOCADDRT: @@ -572,9 +576,11 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd,= unsigned long arg) case SIOCSIFDSTADDR: return addrconf_set_dstaddr(net, argp); default: - if (!sk->sk_prot->ioctl) + /* IPV6_ADDRFORM can change sk->sk_prot under us. */ + prot =3D READ_ONCE(sk->sk_prot); + if (!prot->ioctl) return -ENOIOCTLCMD; - return sk->sk_prot->ioctl(sk, cmd, arg); + return prot->ioctl(sk, cmd, arg); } /*NOTREACHED*/ return 0; @@ -636,11 +642,14 @@ INDIRECT_CALLABLE_DECLARE(int udpv6_sendmsg(struct so= ck *, struct msghdr *, int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) { struct sock *sk =3D sock->sk; + const struct proto *prot; =20 if (unlikely(inet_send_prepare(sk))) return -EAGAIN; =20 - return INDIRECT_CALL_2(sk->sk_prot->sendmsg, tcp_sendmsg, udpv6_sendmsg, + /* IPV6_ADDRFORM can change sk->sk_prot under us. */ + prot =3D READ_ONCE(sk->sk_prot); + return INDIRECT_CALL_2(prot->sendmsg, tcp_sendmsg, udpv6_sendmsg, sk, msg, size); } =20 @@ -650,13 +659,16 @@ int inet6_recvmsg(struct socket *sock, struct msghdr = *msg, size_t size, int flags) { struct sock *sk =3D sock->sk; + const struct proto *prot; int addr_len =3D 0; int err; =20 if (likely(!(flags & MSG_ERRQUEUE))) sock_rps_record_flow(sk); =20 - err =3D INDIRECT_CALL_2(sk->sk_prot->recvmsg, tcp_recvmsg, udpv6_recvmsg, + /* IPV6_ADDRFORM can change sk->sk_prot under us. */ + prot =3D READ_ONCE(sk->sk_prot); + err =3D INDIRECT_CALL_2(prot->recvmsg, tcp_recvmsg, udpv6_recvmsg, sk, msg, size, flags & MSG_DONTWAIT, flags & ~MSG_DONTWAIT, &addr_len); if (err >=3D 0) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index a733803a710c..222f6bf220ba 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -475,7 +475,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int leve= l, int optname, sock_prot_inuse_add(net, sk->sk_prot, -1); sock_prot_inuse_add(net, &tcp_prot, 1); =20 - sk->sk_prot =3D &tcp_prot; + /* Paired with READ_ONCE(sk->sk_prot) in net/ipv6/af_inet6.c */ + WRITE_ONCE(sk->sk_prot, &tcp_prot); icsk->icsk_af_ops =3D &ipv4_specific; sk->sk_socket->ops =3D &inet_stream_ops; sk->sk_family =3D PF_INET; @@ -489,7 +490,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int leve= l, int optname, sock_prot_inuse_add(net, sk->sk_prot, -1); sock_prot_inuse_add(net, prot, 1); =20 - sk->sk_prot =3D prot; + /* Paired with READ_ONCE(sk->sk_prot) in net/ipv6/af_inet6.c */ + WRITE_ONCE(sk->sk_prot, prot); sk->sk_socket->ops =3D &inet_dgram_ops; sk->sk_family =3D PF_INET; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 AC072C43219 for ; Tue, 12 Apr 2022 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358418AbiDLJUG (ORCPT ); Tue, 12 Apr 2022 05:20:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357065AbiDLHjp (ORCPT ); Tue, 12 Apr 2022 03:39: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 5588E114C; Tue, 12 Apr 2022 00:11: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 0510CB81A8F; Tue, 12 Apr 2022 07:11:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72C5FC385A1; Tue, 12 Apr 2022 07:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747474; bh=N2m2EF/idhBuMoo91o/pQx+Ffciel0SdknXzASO33Sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKp3kA81zGXeWnYBI03RPhQkKvou5o58oLteWPgrLhSNUBDl5mLMX/LBxaQvPx4Rh +dlBRoKvmu6PnjpB/D0At5OR8BjYaiXUkSy54tmmnIoCCQCPSjhWd9UP/9Mu0Nc6/M Y/IrgtwCnOPu1Ivym4ixqV9ap5mENMuX1Pn/otuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Thompson , Dmitry Baryshkov , Sasha Levin Subject: [PATCH 5.17 091/343] drm/msm/dsi: Remove spurious IRQF_ONESHOT flag Date: Tue, 12 Apr 2022 08:28:29 +0200 Message-Id: <20220412062953.733834814@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Daniel Thompson [ Upstream commit 24b176d8827d167ac3b379317f60c0985f6e95aa ] Quoting the header comments, IRQF_ONESHOT is "Used by threaded interrupts which need to keep the irq line disabled until the threaded handler has been run.". When applied to an interrupt that doesn't request a threaded irq then IRQF_ONESHOT has a lesser known (undocumented?) side effect, which it to disable the forced threading of irqs (and for "normal" kernels it is a nop). In this case I can find no evidence that suppressing forced threading is intentional. Had it been intentional then a driver must adopt the raw_spinlock API in order to avoid deadlocks on PREEMPT_RT kernels (and avoid calling any kernel API that uses regular spinlocks). Fix this by removing the spurious additional flag. This change is required for my Snapdragon 7cx Gen2 tablet to boot-to-GUI with PREEMPT_RT enabled. Signed-off-by: Daniel Thompson Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20220201174734.196718-2-daniel.thompson@lin= aro.org Signed-off-by: Dmitry Baryshkov Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/d= si_host.c index 6b3ced4aaaf5..3a3f53f0c8ae 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1877,7 +1877,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) =20 /* do not autoenable, will be enabled later */ ret =3D devm_request_irq(&pdev->dev, msm_host->irq, dsi_host_irq, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT | IRQF_NO_AUTOEN, + IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN, "dsi_isr", msm_host); if (ret < 0) { dev_err(&pdev->dev, "failed to request IRQ%u: %d\n", --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4C66AC43217 for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383862AbiDLIiZ (ORCPT ); Tue, 12 Apr 2022 04:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357079AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 3C5A663D5; Tue, 12 Apr 2022 00:11: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 DFF7AB81895; Tue, 12 Apr 2022 07:11:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35E73C385A5; Tue, 12 Apr 2022 07:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747477; bh=nzvXPEI7J0IIuAHx5XEdwuw0XuZ8AG2uXAtfb8oiZ+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lbz9PkKrTUO5mzvarvtahJTea7v/s16YtJQzcKLFstwTku6XMHPHt7A8IeIAFiXre SUAwjZ15R6lps8+WA2Fyih5ot7g1J724DpRToRnoovDVfeveQCQx5ASmsekCNxf0Mc cPSYDmB4Edk2LgsJ2tezxPKmQKxbNaDKgCSMhEks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jue Wang , Borislav Petkov , Tony Luck , Sasha Levin Subject: [PATCH 5.17 092/343] x86/mce: Work around an erratum on fast string copy instructions Date: Tue, 12 Apr 2022 08:28:30 +0200 Message-Id: <20220412062953.761874027@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jue Wang [ Upstream commit 8ca97812c3c830573f965a07bbd84223e8c5f5bd ] A rare kernel panic scenario can happen when the following conditions are met due to an erratum on fast string copy instructions: 1) An uncorrected error. 2) That error must be in first cache line of a page. 3) Kernel must execute page_copy from the page immediately before that page. The fast string copy instructions ("REP; MOVS*") could consume an uncorrectable memory error in the cache line _right after_ the desired region to copy and raise an MCE. Bit 0 of MSR_IA32_MISC_ENABLE can be cleared to disable fast string copy and will avoid such spurious machine checks. However, that is less preferable due to the permanent performance impact. Considering memory poison is rare, it's desirable to keep fast string copy enabled until an MCE is seen. Intel has confirmed the following: 1. The CPU erratum of fast string copy only applies to Skylake, Cascade Lake and Cooper Lake generations. Directly return from the MCE handler: 2. Will result in complete execution of the "REP; MOVS*" with no data loss or corruption. 3. Will not result in another MCE firing on the next poisoned cache line due to "REP; MOVS*". 4. Will resume execution from a correct point in code. 5. Will result in the same instruction that triggered the MCE firing a second MCE immediately for any other software recoverable data fetch errors. 6. Is not safe without disabling the fast string copy, as the next fast string copy of the same buffer on the same CPU would result in a PANIC MCE. This should mitigate the erratum completely with the only caveat that the fast string copy is disabled on the affected hyper thread thus performance degradation. This is still better than the OS crashing on MCEs raised on an irrelevant process due to "REP; MOVS*' accesses in a kernel context, e.g., copy_page. Tested: Injected errors on 1st cache line of 8 anonymous pages of process 'proc1' and observed MCE consumption from 'proc2' with no panic (directly returned). Without the fix, the host panicked within a few minutes on a random 'proc2' process due to kernel access from copy_page. [ bp: Fix comment style + touch ups, zap an unlikely(), improve the quirk function's readability. ] Signed-off-by: Jue Wang Signed-off-by: Borislav Petkov Reviewed-by: Tony Luck Link: https://lore.kernel.org/r/20220218013209.2436006-1-juew@google.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/kernel/cpu/mce/core.c | 64 ++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/mce/internal.h | 5 ++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 5818b837fd4d..2d719e0d2e40 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -834,6 +834,59 @@ static void quirk_sandybridge_ifu(int bank, struct mce= *m, struct pt_regs *regs) m->cs =3D regs->cs; } =20 +/* + * Disable fast string copy and return from the MCE handler upon the first= SRAR + * MCE on bank 1 due to a CPU erratum on Intel Skylake/Cascade Lake/Cooper= Lake + * CPUs. + * The fast string copy instructions ("REP; MOVS*") could consume an + * uncorrectable memory error in the cache line _right after_ the desired = region + * to copy and raise an MCE with RIP pointing to the instruction _after_ t= he + * "REP; MOVS*". + * This mitigation addresses the issue completely with the caveat of perfo= rmance + * degradation on the CPU affected. This is still better than the OS crash= ing on + * MCEs raised on an irrelevant process due to "REP; MOVS*" accesses from a + * kernel context (e.g., copy_page). + * + * Returns true when fast string copy on CPU has been disabled. + */ +static noinstr bool quirk_skylake_repmov(void) +{ + u64 mcgstatus =3D mce_rdmsrl(MSR_IA32_MCG_STATUS); + u64 misc_enable =3D mce_rdmsrl(MSR_IA32_MISC_ENABLE); + u64 mc1_status; + + /* + * Apply the quirk only to local machine checks, i.e., no broadcast + * sync is needed. + */ + if (!(mcgstatus & MCG_STATUS_LMCES) || + !(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) + return false; + + mc1_status =3D mce_rdmsrl(MSR_IA32_MCx_STATUS(1)); + + /* Check for a software-recoverable data fetch error. */ + if ((mc1_status & + (MCI_STATUS_VAL | MCI_STATUS_OVER | MCI_STATUS_UC | MCI_STATUS_EN | + MCI_STATUS_ADDRV | MCI_STATUS_MISCV | MCI_STATUS_PCC | + MCI_STATUS_AR | MCI_STATUS_S)) =3D=3D + (MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN | + MCI_STATUS_ADDRV | MCI_STATUS_MISCV | + MCI_STATUS_AR | MCI_STATUS_S)) { + misc_enable &=3D ~MSR_IA32_MISC_ENABLE_FAST_STRING; + mce_wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable); + mce_wrmsrl(MSR_IA32_MCx_STATUS(1), 0); + + instrumentation_begin(); + pr_err_once("Erratum detected, disable fast string copy instructions.\n"= ); + instrumentation_end(); + + return true; + } + + return false; +} + /* * Do a quick check if any of the events requires a panic. * This decides if we keep the events around or clear them. @@ -1403,6 +1456,9 @@ noinstr void do_machine_check(struct pt_regs *regs) else if (unlikely(!mca_cfg.initialized)) return unexpected_machine_check(regs); =20 + if (mce_flags.skx_repmov_quirk && quirk_skylake_repmov()) + goto clear; + /* * Establish sequential order between the CPUs entering the machine * check handler. @@ -1545,6 +1601,7 @@ noinstr void do_machine_check(struct pt_regs *regs) out: instrumentation_end(); =20 +clear: mce_wrmsrl(MSR_IA32_MCG_STATUS, 0); } EXPORT_SYMBOL_GPL(do_machine_check); @@ -1858,6 +1915,13 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_= x86 *c) =20 if (c->x86 =3D=3D 6 && c->x86_model =3D=3D 45) mce_flags.snb_ifu_quirk =3D 1; + + /* + * Skylake, Cascacde Lake and Cooper Lake require a quirk on + * rep movs. + */ + if (c->x86 =3D=3D 6 && c->x86_model =3D=3D INTEL_FAM6_SKYLAKE_X) + mce_flags.skx_repmov_quirk =3D 1; } =20 if (c->x86_vendor =3D=3D X86_VENDOR_ZHAOXIN) { diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/i= nternal.h index 52c633950b38..24d099e2d2a2 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -170,7 +170,10 @@ struct mce_vendor_flags { /* SandyBridge IFU quirk */ snb_ifu_quirk : 1, =20 - __reserved_0 : 57; + /* Skylake, Cascade Lake, Cooper Lake REP;MOVS* quirk */ + skx_repmov_quirk : 1, + + __reserved_0 : 56; }; =20 extern struct mce_vendor_flags mce_flags; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 76FDBC4167B for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383935AbiDLIik (ORCPT ); Tue, 12 Apr 2022 04:38:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357077AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 3F4ED6154; Tue, 12 Apr 2022 00:11: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 D3A2261708; Tue, 12 Apr 2022 07:11:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0309C385A1; Tue, 12 Apr 2022 07:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747480; bh=JuQoUq9MbXyRlrK7iZuC7xbWXkRy/SoCZJLz/mDlEeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WzcfYZ83+tnWXxhI1S/oyVH9KVUiTLmWNrAXlBIUgYyTUBdVUbNywZMGfCqofFvrD qrUGlCXErO1hCQx9fNMxymATQ2jcsZc9PaYHUdTlarSX+uxDLEJTu1j51O9ikeh8QW S1oG/l2a/J1t9CeloivPfL5kHoYFN9dBrcaPno/w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Kosina , Ping-Ke Shih , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 093/343] rtw89: fix RCU usage in rtw89_core_txq_push() Date: Tue, 12 Apr 2022 08:28:31 +0200 Message-Id: <20220412062953.789664782@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jiri Kosina [ Upstream commit f3d825a35920714fb7f73e4d4f36ea2328860660 ] ieee80211_tx_h_select_key() is performing a series of RCU dereferences, but rtw89_core_txq_push() is calling it (via ieee80211_tx_dequeue_ni()) without RCU read-side lock held; fix that. This addresses the splat below. =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 WARNING: suspicious RCU usage 5.17.0-rc4-00003-gccad664b7f14 #3 Tainted: G E ----------------------------- net/mac80211/tx.c:593 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active =3D 2, debug_locks =3D 1 2 locks held by kworker/u33:0/184: #0: ffff9c0b14811d38 ((wq_completion)rtw89_tx_wq){+.+.}-{0:0}, at: proces= s_one_work+0x258/0x660 #1: ffffb97380cf3e78 ((work_completion)(&rtwdev->txq_work)){+.+.}-{0:0}, = at: process_one_work+0x258/0x660 stack backtrace: CPU: 8 PID: 184 Comm: kworker/u33:0 Tainted: G E 5.17.0-rc4= -00003-gccad664b7f14 #3 473b49ab0e7c2d6af2900c756bfd04efd7a9de13 Hardware name: LENOVO 20UJS2B905/20UJS2B905, BIOS R1CET63W(1.32 ) 04/09/20= 21 Workqueue: rtw89_tx_wq rtw89_core_txq_work [rtw89_core] Call Trace: dump_stack_lvl+0x58/0x71 ieee80211_tx_h_select_key+0x2c0/0x530 [mac80211 911c23e2351c0ae60b597a67b= 1204a5ea955e365] ieee80211_tx_dequeue+0x1a7/0x1260 [mac80211 911c23e2351c0ae60b597a67b1204= a5ea955e365] rtw89_core_txq_work+0x1a6/0x420 [rtw89_core b39ba493f2e517ad75e0f8187ecc2= 4edf58bbbea] process_one_work+0x2d8/0x660 worker_thread+0x39/0x3e0 ? process_one_work+0x660/0x660 kthread+0xe5/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 =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 WARNING: suspicious RCU usage 5.17.0-rc4-00003-gccad664b7f14 #3 Tainted: G E ----------------------------- net/mac80211/tx.c:607 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active =3D 2, debug_locks =3D 1 2 locks held by kworker/u33:0/184: #0: ffff9c0b14811d38 ((wq_completion)rtw89_tx_wq){+.+.}-{0:0}, at: proces= s_one_work+0x258/0x660 #1: ffffb97380cf3e78 ((work_completion)(&rtwdev->txq_work)){+.+.}-{0:0}, = at: process_one_work+0x258/0x660 stack backtrace: CPU: 8 PID: 184 Comm: kworker/u33:0 Tainted: G E 5.17.0-rc4= -00003-gccad664b7f14 #3 473b49ab0e7c2d6af2900c756bfd04efd7a9de13 Hardware name: LENOVO 20UJS2B905/20UJS2B905, BIOS R1CET63W(1.32 ) 04/09/20= 21 Workqueue: rtw89_tx_wq rtw89_core_txq_work [rtw89_core] Call Trace: dump_stack_lvl+0x58/0x71 ieee80211_tx_h_select_key+0x464/0x530 [mac80211 911c23e2351c0ae60b597a67b= 1204a5ea955e365] ieee80211_tx_dequeue+0x1a7/0x1260 [mac80211 911c23e2351c0ae60b597a67b1204= a5ea955e365] rtw89_core_txq_work+0x1a6/0x420 [rtw89_core b39ba493f2e517ad75e0f8187ecc2= 4edf58bbbea] process_one_work+0x2d8/0x660 worker_thread+0x39/0x3e0 ? process_one_work+0x660/0x660 kthread+0xe5/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 Signed-off-by: Jiri Kosina Acked-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/nycvar.YFH.7.76.2202152037000.11721@cbobk.f= hfr.pm Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/realtek/rtw89/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wirele= ss/realtek/rtw89/core.c index a0737eea9f81..9632e7f218dd 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -1509,11 +1509,12 @@ static void rtw89_core_txq_push(struct rtw89_dev *r= twdev, unsigned long i; int ret; =20 + rcu_read_lock(); for (i =3D 0; i < frame_cnt; i++) { skb =3D ieee80211_tx_dequeue_ni(rtwdev->hw, txq); if (!skb) { rtw89_debug(rtwdev, RTW89_DBG_TXRX, "dequeue a NULL skb\n"); - return; + goto out; } rtw89_core_txq_check_agg(rtwdev, rtwtxq, skb); ret =3D rtw89_core_tx_write(rtwdev, vif, sta, skb, NULL); @@ -1523,6 +1524,8 @@ static void rtw89_core_txq_push(struct rtw89_dev *rtw= dev, break; } } +out: + rcu_read_unlock(); } =20 static u32 rtw89_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev, u= 8 tid) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 F3EB0C433F5 for ; Tue, 12 Apr 2022 08:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386694AbiDLI7I (ORCPT ); Tue, 12 Apr 2022 04:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357082AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 445CF63D6; Tue, 12 Apr 2022 00:11: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 ams.source.kernel.org (Postfix) with ESMTPS id 0773BB81895; Tue, 12 Apr 2022 07:11:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75E15C385A5; Tue, 12 Apr 2022 07:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747482; bh=2+ftSL5NcUXy6CE0F8SeFe0sjVAuEieqam5hcatJqBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqyNPDpnBUjmrint43xwBoBom0sRWANlfPIceKK8p5OneW5tHIajDNp0YUdFHhtyW 9pUFLEByYwUd4pPcaJh20M6K/6i3h/bGpBMdjRyAAIA16/GBmi/V/gKMzcCeNlkOZW HcJqtRTmOhqiqhoaHyrbqLesYYwaROKf0dZ6/MtA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baochen Qiang , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 094/343] ath11k: Fix frames flush failure caused by deadlock Date: Tue, 12 Apr 2022 08:28:32 +0200 Message-Id: <20220412062953.817595885@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Baochen Qiang [ Upstream commit 261b07519518bd14cb168b287b17e1d195f8d0c8 ] We are seeing below warnings: kernel: [25393.301506] ath11k_pci 0000:01:00.0: failed to flush mgmt transm= it queue 0 kernel: [25398.421509] ath11k_pci 0000:01:00.0: failed to flush mgmt transm= it queue 0 kernel: [25398.421831] ath11k_pci 0000:01:00.0: dropping mgmt frame for vde= v 0, is_started 0 this means ath11k fails to flush mgmt. frames because wmi_mgmt_tx_work has no chance to run in 5 seconds. By setting /proc/sys/kernel/hung_task_timeout_secs to 20 and increasing ATH11K_FLUSH_TIMEOUT to 50 we get below warnings: kernel: [ 120.763160] INFO: task wpa_supplicant:924 blocked for more than = 20 seconds. kernel: [ 120.763169] Not tainted 5.10.90 #12 kernel: [ 120.763177] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" d= isables this message. kernel: [ 120.763186] task:wpa_supplicant state:D stack: 0 pid: 924 p= pid: 1 flags:0x000043a0 kernel: [ 120.763201] Call Trace: kernel: [ 120.763214] __schedule+0x785/0x12fa kernel: [ 120.763224] ? lockdep_hardirqs_on_prepare+0xe2/0x1bb kernel: [ 120.763242] schedule+0x7e/0xa1 kernel: [ 120.763253] schedule_timeout+0x98/0xfe kernel: [ 120.763266] ? run_local_timers+0x4a/0x4a kernel: [ 120.763291] ath11k_mac_flush_tx_complete+0x197/0x2b1 [ath11k 13= c3a9bf37790f4ac8103b3decf7ab4008ac314a] kernel: [ 120.763306] ? init_wait_entry+0x2e/0x2e kernel: [ 120.763343] __ieee80211_flush_queues+0x167/0x21f [mac80211 335d= a900954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763378] __ieee80211_recalc_idle+0x105/0x125 [mac80211 335da= 900954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763411] ieee80211_recalc_idle+0x14/0x27 [mac80211 335da9009= 54f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763441] ieee80211_free_chanctx+0x77/0xa2 [mac80211 335da900= 954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763473] __ieee80211_vif_release_channel+0x100/0x131 [mac802= 11 335da900954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763540] ieee80211_vif_release_channel+0x66/0x81 [mac80211 3= 35da900954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763572] ieee80211_destroy_auth_data+0xa3/0xe6 [mac80211 335= da900954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763612] ieee80211_mgd_deauth+0x178/0x29b [mac80211 335da900= 954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.763654] cfg80211_mlme_deauth+0x1a8/0x22c [cfg80211 8945aa5b= c2af5f6972336665d8ad6f9c191ad5be] kernel: [ 120.763697] nl80211_deauthenticate+0xfa/0x123 [cfg80211 8945aa5= bc2af5f6972336665d8ad6f9c191ad5be] kernel: [ 120.763715] genl_rcv_msg+0x392/0x3c2 kernel: [ 120.763750] ? nl80211_associate+0x432/0x432 [cfg80211 8945aa5bc= 2af5f6972336665d8ad6f9c191ad5be] kernel: [ 120.763782] ? nl80211_associate+0x432/0x432 [cfg80211 8945aa5bc= 2af5f6972336665d8ad6f9c191ad5be] kernel: [ 120.763802] ? genl_rcv+0x36/0x36 kernel: [ 120.763814] netlink_rcv_skb+0x89/0xf7 kernel: [ 120.763829] genl_rcv+0x28/0x36 kernel: [ 120.763840] netlink_unicast+0x179/0x24b kernel: [ 120.763854] netlink_sendmsg+0x393/0x401 kernel: [ 120.763872] sock_sendmsg+0x72/0x76 kernel: [ 120.763886] ____sys_sendmsg+0x170/0x1e6 kernel: [ 120.763897] ? copy_msghdr_from_user+0x7a/0xa2 kernel: [ 120.763914] ___sys_sendmsg+0x95/0xd1 kernel: [ 120.763940] __sys_sendmsg+0x85/0xbf kernel: [ 120.763956] do_syscall_64+0x43/0x55 kernel: [ 120.763966] entry_SYSCALL_64_after_hwframe+0x44/0xa9 kernel: [ 120.763977] RIP: 0033:0x79089f3fcc83 kernel: [ 120.763986] RSP: 002b:00007ffe604f0508 EFLAGS: 00000246 ORIG_RAX= : 000000000000002e kernel: [ 120.763997] RAX: ffffffffffffffda RBX: 000059b40e987690 RCX: 000= 079089f3fcc83 kernel: [ 120.764006] RDX: 0000000000000000 RSI: 00007ffe604f0558 RDI: 000= 0000000000009 kernel: [ 120.764014] RBP: 00007ffe604f0540 R08: 0000000000000004 R09: 000= 0000000400000 kernel: [ 120.764023] R10: 00007ffe604f0638 R11: 0000000000000246 R12: 000= 059b40ea04980 kernel: [ 120.764032] R13: 00007ffe604f0638 R14: 000059b40e98c360 R15: 000= 07ffe604f0558 ... kernel: [ 120.765230] INFO: task kworker/u32:26:4239 blocked for more than= 20 seconds. kernel: [ 120.765238] Not tainted 5.10.90 #12 kernel: [ 120.765245] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" d= isables this message. kernel: [ 120.765253] task:kworker/u32:26 state:D stack: 0 pid: 4239 p= pid: 2 flags:0x00004080 kernel: [ 120.765284] Workqueue: phy0 ieee80211_iface_work [mac80211] kernel: [ 120.765295] Call Trace: kernel: [ 120.765306] __schedule+0x785/0x12fa kernel: [ 120.765316] ? find_held_lock+0x3d/0xb2 kernel: [ 120.765331] schedule+0x7e/0xa1 kernel: [ 120.765340] schedule_preempt_disabled+0x15/0x1e kernel: [ 120.765349] __mutex_lock_common+0x561/0xc0d kernel: [ 120.765375] ? ieee80211_sta_work+0x3e/0x1232 [mac80211 335da900= 954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.765390] mutex_lock_nested+0x20/0x26 kernel: [ 120.765416] ieee80211_sta_work+0x3e/0x1232 [mac80211 335da90095= 4f1c5ea7f1613d92088ce83342042c] kernel: [ 120.765430] ? skb_dequeue+0x54/0x5e kernel: [ 120.765456] ? ieee80211_iface_work+0x7b/0x339 [mac80211 335da90= 0954f1c5ea7f1613d92088ce83342042c] kernel: [ 120.765485] process_one_work+0x270/0x504 kernel: [ 120.765501] worker_thread+0x215/0x376 kernel: [ 120.765514] kthread+0x159/0x168 kernel: [ 120.765526] ? pr_cont_work+0x5b/0x5b kernel: [ 120.765536] ? kthread_blkcg+0x31/0x31 kernel: [ 120.765550] ret_from_fork+0x22/0x30 ... kernel: [ 120.765867] Showing all locks held in the system: ... kernel: [ 120.766164] 5 locks held by wpa_supplicant/924: kernel: [ 120.766172] #0: ffffffffb1e63eb0 (cb_lock){++++}-{3:3}, at: gen= l_rcv+0x19/0x36 kernel: [ 120.766197] #1: ffffffffb1e5b1c8 (rtnl_mutex){+.+.}-{3:3}, at: = nl80211_pre_doit+0x2a/0x15c [cfg80211] kernel: [ 120.766238] #2: ffff99f08347cd08 (&wdev->mtx){+.+.}-{3:3}, at: = nl80211_deauthenticate+0xde/0x123 [cfg80211] kernel: [ 120.766279] #3: ffff99f09df12a48 (&local->mtx){+.+.}-{3:3}, at:= ieee80211_destroy_auth_data+0x9b/0xe6 [mac80211] kernel: [ 120.766321] #4: ffff99f09df12ce0 (&local->chanctx_mtx){+.+.}-{3= :3}, at: ieee80211_vif_release_channel+0x5e/0x81 [mac80211] ... kernel: [ 120.766585] 3 locks held by kworker/u32:26/4239: kernel: [ 120.766593] #0: ffff99f04458f948 ((wq_completion)phy0){+.+.}-{0= :0}, at: process_one_work+0x19a/0x504 kernel: [ 120.766621] #1: ffffbad54b3cfe50 ((work_completion)(&sdata->wor= k)){+.+.}-{0:0}, at: process_one_work+0x1c0/0x504 kernel: [ 120.766649] #2: ffff99f08347cd08 (&wdev->mtx){+.+.}-{3:3}, at: = ieee80211_sta_work+0x3e/0x1232 [mac80211] With above info the issue is clear: First wmi_mgmt_tx_work is inserted to local->workqueue after sdata->work inserted, then wpa_supplicant acquires wdev->mtx in nl80211_deauthenticate and finally calls ath11k_mac_op_flush where it waits all mgmt. frames to be sent out by wmi_mgmt_tx_work. Meanwhile, sdata->work is blocked by wdev->mtx in ieee80211_sta_work, as a result wmi_mgmt_tx_work has no chance to run. Change to use ab->workqueue instead of local->workqueue to fix this issue. Signed-off-by: Baochen Qiang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220217084545.18844-1-quic_bqiang@quicinc.= com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/ath/ath11k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/a= th/ath11k/mac.c index 08e33778f63b..28de877ad6c4 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -5574,7 +5574,7 @@ static int ath11k_mac_mgmt_tx(struct ath11k *ar, stru= ct sk_buff *skb, =20 skb_queue_tail(q, skb); atomic_inc(&ar->num_pending_mgmt_tx); - ieee80211_queue_work(ar->hw, &ar->wmi_mgmt_tx_work); + queue_work(ar->ab->workqueue, &ar->wmi_mgmt_tx_work); =20 return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 607B6C43219 for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383922AbiDLIif (ORCPT ); Tue, 12 Apr 2022 04:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357084AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 86D5C63E4; Tue, 12 Apr 2022 00:11: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 223B36153F; Tue, 12 Apr 2022 07:11:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30075C385A1; Tue, 12 Apr 2022 07:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747485; bh=3A+lts5Jmkxi1Vl6g+GgubSBNduEpMzl+j8xy2f2L9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oB7gMREMeuhzsvuY+qNtEyGk6z/5jcF0BDI21Cf0THm7mpvDnI7A0Z8vRP3k/42ov xgmkslvUqIcdvDQ6wtzzKetOz00aEzyMl+DrP03mfTNTKcxgBa+mt8OAcLrUYJGOKd D2r+80XyhSuqGJgxLyE/cPYS9wJTyiCzc70KxX9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Hai , Ido Schimmel , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 095/343] ipv4: Invalidate neighbour for broadcast address upon address addition Date: Tue, 12 Apr 2022 08:28:33 +0200 Message-Id: <20220412062953.845365010@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 [ Upstream commit 0c51e12e218f20b7d976158fdc18019627326f7a ] In case user space sends a packet destined to a broadcast address when a matching broadcast route is not configured, the kernel will create a unicast neighbour entry that will never be resolved [1]. When the broadcast route is configured, the unicast neighbour entry will not be invalidated and continue to linger, resulting in packets being dropped. Solve this by invalidating unresolved neighbour entries for broadcast addresses after routes for these addresses are internally configured by the kernel. This allows the kernel to create a broadcast neighbour entry following the next route lookup. Another possible solution that is more generic but also more complex is to have the ARP code register a listener to the FIB notification chain and invalidate matching neighbour entries upon the addition of broadcast routes. It is also possible to wave off the issue as a user space problem, but it seems a bit excessive to expect user space to be that intimately familiar with the inner workings of the FIB/neighbour kernel code. [1] https://lore.kernel.org/netdev/55a04a8f-56f3-f73c-2aea-2195923f09d1@hua= wei.com/ Reported-by: Wang Hai Signed-off-by: Ido Schimmel Tested-by: Wang Hai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/net/arp.h | 1 + net/ipv4/arp.c | 9 +++++++-- net/ipv4/fib_frontend.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/net/arp.h b/include/net/arp.h index 031374ac2f22..d7ef4ec71dfe 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -65,6 +65,7 @@ void arp_send(int type, int ptype, __be32 dest_ip, const unsigned char *src_hw, const unsigned char *th); int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); void arp_ifdown(struct net_device *dev); +int arp_invalidate(struct net_device *dev, __be32 ip, bool force); =20 struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, struct net_device *dev, __be32 src_ip, diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 4db0325f6e1a..dc28f0588e54 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1116,13 +1116,18 @@ static int arp_req_get(struct arpreq *r, struct net= _device *dev) return err; } =20 -static int arp_invalidate(struct net_device *dev, __be32 ip) +int arp_invalidate(struct net_device *dev, __be32 ip, bool force) { struct neighbour *neigh =3D neigh_lookup(&arp_tbl, &ip, dev); int err =3D -ENXIO; struct neigh_table *tbl =3D &arp_tbl; =20 if (neigh) { + if ((neigh->nud_state & NUD_VALID) && !force) { + neigh_release(neigh); + return 0; + } + if (neigh->nud_state & ~NUD_NOARP) err =3D neigh_update(neigh, NULL, NUD_FAILED, NEIGH_UPDATE_F_OVERRIDE| @@ -1169,7 +1174,7 @@ static int arp_req_delete(struct net *net, struct arp= req *r, if (!dev) return -EINVAL; } - return arp_invalidate(dev, ip); + return arp_invalidate(dev, ip, true); } =20 /* diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 85117b45216d..89a5a4875595 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -1115,9 +1115,11 @@ void fib_add_ifaddr(struct in_ifaddr *ifa) return; =20 /* Add broadcast address, if it is explicitly assigned. */ - if (ifa->ifa_broadcast && ifa->ifa_broadcast !=3D htonl(0xFFFFFFFF)) + if (ifa->ifa_broadcast && ifa->ifa_broadcast !=3D htonl(0xFFFFFFFF)) { fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim, 0); + arp_invalidate(dev, ifa->ifa_broadcast, false); + } =20 if (!ipv4_is_zeronet(prefix) && !(ifa->ifa_flags & IFA_F_SECONDARY) && (prefix !=3D addr || ifa->ifa_prefixlen < 32)) { @@ -1131,6 +1133,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa) if (ifa->ifa_prefixlen < 31) { fib_magic(RTM_NEWROUTE, RTN_BROADCAST, prefix | ~mask, 32, prim, 0); + arp_invalidate(dev, prefix | ~mask, false); } } } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C4166C433F5 for ; Tue, 12 Apr 2022 09:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389497AbiDLJXs (ORCPT ); Tue, 12 Apr 2022 05:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357087AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEDE565DA; Tue, 12 Apr 2022 00:11:30 -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 6EAB1B81895; Tue, 12 Apr 2022 07:11:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA477C385A5; Tue, 12 Apr 2022 07:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747488; bh=c0eHMg/vupodfFtJJT7UW8Yeq3VVqZoxDRGVYvTreuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0d5g2fKQUIO70v4tpxl7NwKlQHtAHavlolyO9b3aMkhD7s1+YIp1Ihdt/LNHeaRkY E2wRzjZZ6if2sCvJFtc2a7o9u+xHSJw3cCKum0ycw4QfKFKEi9XIyW8BffusmJaxEm vXIJ97cSitkWU74ikRiXxBbyqDbL4NGHYMw6FPBo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Larry Finger , Ping-Ke Shih , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 096/343] rtw88: change rtw_info() to proper message level Date: Tue, 12 Apr 2022 08:28:34 +0200 Message-Id: <20220412062953.872878897@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ping-Ke Shih [ Upstream commit a0061be4e54b52e5e4ff179c3f817107ddbb2830 ] Larry reported funny log entries [1] when he used rtl8821ce. These messages are not harmless, but not useful for users, so change them to rtw_dbg() level. By the way, I review all rtw_info() and change others to rtw_warn(). [1] https://lore.kernel.org/linux-wireless/c356d5ae-a7b3-3065-1121-64c446e7= 0333@lwfinger.net/ Reported-by: Larry Finger Signed-off-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220218035527.9835-1-pkshih@realtek.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/realtek/rtw88/debug.c | 2 +- drivers/net/wireless/realtek/rtw88/debug.h | 1 + drivers/net/wireless/realtek/rtw88/fw.c | 2 +- drivers/net/wireless/realtek/rtw88/mac80211.c | 8 ++++---- drivers/net/wireless/realtek/rtw88/main.c | 8 ++++---- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8822b.c | 4 ++-- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 4 ++-- drivers/net/wireless/realtek/rtw88/sar.c | 8 ++++---- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wirel= ess/realtek/rtw88/debug.c index e429428232c1..e7e9f17df96a 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -390,7 +390,7 @@ static ssize_t rtw_debugfs_set_h2c(struct file *filp, ¶m[0], ¶m[1], ¶m[2], ¶m[3], ¶m[4], ¶m[5], ¶m[6], ¶m[7]); if (num !=3D 8) { - rtw_info(rtwdev, "invalid H2C command format for debug\n"); + rtw_warn(rtwdev, "invalid H2C command format for debug\n"); return -EINVAL; } =20 diff --git a/drivers/net/wireless/realtek/rtw88/debug.h b/drivers/net/wirel= ess/realtek/rtw88/debug.h index 61f8369fe2d6..066792dd96af 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.h +++ b/drivers/net/wireless/realtek/rtw88/debug.h @@ -23,6 +23,7 @@ enum rtw_debug_mask { RTW_DBG_PATH_DIV =3D 0x00004000, RTW_DBG_ADAPTIVITY =3D 0x00008000, RTW_DBG_HW_SCAN =3D 0x00010000, + RTW_DBG_STATE =3D 0x00020000, =20 RTW_DBG_ALL =3D 0xffffffff }; diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless= /realtek/rtw88/fw.c index 4c8e5ea5d069..db90d75a8633 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -2131,7 +2131,7 @@ void rtw_hw_scan_status_report(struct rtw_dev *rtwdev= , struct sk_buff *skb) rtw_hw_scan_complete(rtwdev, vif, aborted); =20 if (aborted) - rtw_info(rtwdev, "HW scan aborted with code: %d\n", rc); + rtw_dbg(rtwdev, RTW_DBG_HW_SCAN, "HW scan aborted with code: %d\n", rc); } =20 void rtw_store_op_chan(struct rtw_dev *rtwdev) diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wi= reless/realtek/rtw88/mac80211.c index 647d2662955b..5cdc54c9a9aa 100644 --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c @@ -208,7 +208,7 @@ static int rtw_ops_add_interface(struct ieee80211_hw *h= w, =20 mutex_unlock(&rtwdev->mutex); =20 - rtw_info(rtwdev, "start vif %pM on port %d\n", vif->addr, rtwvif->port); + rtw_dbg(rtwdev, RTW_DBG_STATE, "start vif %pM on port %d\n", vif->addr, r= twvif->port); return 0; } =20 @@ -219,7 +219,7 @@ static void rtw_ops_remove_interface(struct ieee80211_h= w *hw, struct rtw_vif *rtwvif =3D (struct rtw_vif *)vif->drv_priv; u32 config =3D 0; =20 - rtw_info(rtwdev, "stop vif %pM on port %d\n", vif->addr, rtwvif->port); + rtw_dbg(rtwdev, RTW_DBG_STATE, "stop vif %pM on port %d\n", vif->addr, rt= wvif->port); =20 mutex_lock(&rtwdev->mutex); =20 @@ -245,8 +245,8 @@ static int rtw_ops_change_interface(struct ieee80211_hw= *hw, { struct rtw_dev *rtwdev =3D hw->priv; =20 - rtw_info(rtwdev, "change vif %pM (%d)->(%d), p2p (%d)->(%d)\n", - vif->addr, vif->type, type, vif->p2p, p2p); + rtw_dbg(rtwdev, RTW_DBG_STATE, "change vif %pM (%d)->(%d), p2p (%d)->(%d)= \n", + vif->addr, vif->type, type, vif->p2p, p2p); =20 rtw_ops_remove_interface(hw, vif); =20 diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wirele= ss/realtek/rtw88/main.c index 39c223a2e3e2..b00200f81db7 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -314,8 +314,8 @@ int rtw_sta_add(struct rtw_dev *rtwdev, struct ieee8021= 1_sta *sta, =20 rtwdev->sta_cnt++; rtwdev->beacon_loss =3D false; - rtw_info(rtwdev, "sta %pM joined with macid %d\n", - sta->addr, si->mac_id); + rtw_dbg(rtwdev, RTW_DBG_STATE, "sta %pM joined with macid %d\n", + sta->addr, si->mac_id); =20 return 0; } @@ -336,8 +336,8 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee= 80211_sta *sta, kfree(si->mask); =20 rtwdev->sta_cnt--; - rtw_info(rtwdev, "sta %pM with macid %d left\n", - sta->addr, si->mac_id); + rtw_dbg(rtwdev, RTW_DBG_STATE, "sta %pM with macid %d left\n", + sta->addr, si->mac_id); } =20 struct rtw_fwcd_hdr { diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wi= reless/realtek/rtw88/rtw8821c.c index db078df63f85..80d4761796b1 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -499,7 +499,7 @@ static s8 get_cck_rx_pwr(struct rtw_dev *rtwdev, u8 lna= _idx, u8 vga_idx) } =20 if (lna_idx >=3D lna_gain_table_size) { - rtw_info(rtwdev, "incorrect lna index (%d)\n", lna_idx); + rtw_warn(rtwdev, "incorrect lna index (%d)\n", lna_idx); return -120; } =20 diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wi= reless/realtek/rtw88/rtw8822b.c index dd4fbb82750d..a23806b69b0f 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -1012,12 +1012,12 @@ static int rtw8822b_set_antenna(struct rtw_dev *rtw= dev, antenna_tx, antenna_rx); =20 if (!rtw8822b_check_rf_path(antenna_tx)) { - rtw_info(rtwdev, "unsupported tx path 0x%x\n", antenna_tx); + rtw_warn(rtwdev, "unsupported tx path 0x%x\n", antenna_tx); return -EINVAL; } =20 if (!rtw8822b_check_rf_path(antenna_rx)) { - rtw_info(rtwdev, "unsupported rx path 0x%x\n", antenna_rx); + rtw_warn(rtwdev, "unsupported rx path 0x%x\n", antenna_rx); return -EINVAL; } =20 diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wi= reless/realtek/rtw88/rtw8822c.c index 35c46e5209de..ddf4d1a23e60 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -2798,7 +2798,7 @@ static int rtw8822c_set_antenna(struct rtw_dev *rtwde= v, case BB_PATH_AB: break; default: - rtw_info(rtwdev, "unsupported tx path 0x%x\n", antenna_tx); + rtw_warn(rtwdev, "unsupported tx path 0x%x\n", antenna_tx); return -EINVAL; } =20 @@ -2808,7 +2808,7 @@ static int rtw8822c_set_antenna(struct rtw_dev *rtwde= v, case BB_PATH_AB: break; default: - rtw_info(rtwdev, "unsupported rx path 0x%x\n", antenna_rx); + rtw_warn(rtwdev, "unsupported rx path 0x%x\n", antenna_rx); return -EINVAL; } =20 diff --git a/drivers/net/wireless/realtek/rtw88/sar.c b/drivers/net/wireles= s/realtek/rtw88/sar.c index 3383726c4d90..c472f1502b82 100644 --- a/drivers/net/wireless/realtek/rtw88/sar.c +++ b/drivers/net/wireless/realtek/rtw88/sar.c @@ -91,10 +91,10 @@ int rtw_set_sar_specs(struct rtw_dev *rtwdev, return -EINVAL; =20 power =3D sar->sub_specs[i].power; - rtw_info(rtwdev, "On freq %u to %u, set SAR %d in 1/%lu dBm\n", - rtw_common_sar_freq_ranges[idx].start_freq, - rtw_common_sar_freq_ranges[idx].end_freq, - power, BIT(RTW_COMMON_SAR_FCT)); + rtw_dbg(rtwdev, RTW_DBG_REGD, "On freq %u to %u, set SAR %d in 1/%lu dBm= \n", + rtw_common_sar_freq_ranges[idx].start_freq, + rtw_common_sar_freq_ranges[idx].end_freq, + power, BIT(RTW_COMMON_SAR_FCT)); =20 for (j =3D 0; j < RTW_RF_PATH_MAX; j++) { for (k =3D 0; k < RTW_RATE_SECTION_MAX; k++) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 0D2D2C4707A for ; Tue, 12 Apr 2022 09:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389385AbiDLJXo (ORCPT ); Tue, 12 Apr 2022 05:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357089AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A7F67641; Tue, 12 Apr 2022 00:11: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 15388B81B5D; Tue, 12 Apr 2022 07:11:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82F67C385A5; Tue, 12 Apr 2022 07:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747490; bh=tghxGsbaqHcpP6pV6vKAw/1Th5K64SKUYwOYUvBJVKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekrHwtemNyq0AAtSrJsQqqqtwWIwAahhr1YKZwvMKFuQwGCIjOp4QhHyrJWcTiTiy 66zUZtBjHXnJ/i1l2SVJeT9oGshRAErIMYcWhWNiKMmt6WHPOeIiE7usDt3V9JO636 HVoQZafDewAV1ZnAntxH6SUoic7t6qMciUuaaOLQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jordy Zomer , Mike Snitzer , Sasha Levin Subject: [PATCH 5.17 097/343] dm ioctl: prevent potential spectre v1 gadget Date: Tue, 12 Apr 2022 08:28:35 +0200 Message-Id: <20220412062953.901053788@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jordy Zomer [ Upstream commit cd9c88da171a62c4b0f1c70e50c75845969fbc18 ] It appears like cmd could be a Spectre v1 gadget as it's supplied by a user and used as an array index. Prevent the contents of kernel memory from being leaked to userspace via speculative execution by using array_index_nospec. Signed-off-by: Jordy Zomer Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/md/dm-ioctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 21fe8652b095..901abd6dea41 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 #include #include @@ -1788,6 +1789,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *i= octl_flags) if (unlikely(cmd >=3D ARRAY_SIZE(_ioctls))) return NULL; =20 + cmd =3D array_index_nospec(cmd, ARRAY_SIZE(_ioctls)); *ioctl_flags =3D _ioctls[cmd].flags; return _ioctls[cmd].fn; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 8EE51C433FE for ; Tue, 12 Apr 2022 09:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233498AbiDLI75 (ORCPT ); Tue, 12 Apr 2022 04:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357086AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 4EE7B766A; Tue, 12 Apr 2022 00:11: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 00F55B81B55; Tue, 12 Apr 2022 07:11:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CD82C385A5; Tue, 12 Apr 2022 07:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747493; bh=cOJMjEz2leFlw3+iOtU0SQJpbPFauZMyUI2oO2RpbFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6vs034tVjJRLMRcNkjMIZT+Hi9XUk/aCgCU85yDKlG+uTNmORxgyzpvzanZzW/eq lnxS89ivCVJM7t6fXho8b5HOR7+Q8Yh4Yr/QsJM5yqsWFeS/aD21j4TFXwHPHglIkM HLAVXfutqx0G2UY/tqCQ3wGBL8FD9tWWoggf58jQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Yi , Mike Snitzer , Sasha Levin Subject: [PATCH 5.17 098/343] dm: requeue IO if mapping table not yet available Date: Tue, 12 Apr 2022 08:28:36 +0200 Message-Id: <20220412062953.930612409@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Mike Snitzer [ Upstream commit fa247089de9936a46e290d4724cb5f0b845600f5 ] Update both bio-based and request-based DM to requeue IO if the mapping table not available. This race of IO being submitted before the DM device ready is so narrow, yet possible for initial table load given that the DM device's request_queue is created prior, that it best to requeue IO to handle this unlikely case. Reported-by: Zhang Yi Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/md/dm-rq.c | 7 ++++++- drivers/md/dm.c | 11 +++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 579ab6183d4d..dffeb47a9efb 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -499,8 +499,13 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ct= x *hctx, =20 if (unlikely(!ti)) { int srcu_idx; - struct dm_table *map =3D dm_get_live_table(md, &srcu_idx); + struct dm_table *map; =20 + map =3D dm_get_live_table(md, &srcu_idx); + if (unlikely(!map)) { + dm_put_live_table(md, srcu_idx); + return BLK_STS_RESOURCE; + } ti =3D dm_table_find_target(map, 0); dm_put_live_table(md, srcu_idx); } diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 394778d8bf54..dcb8d8fc7877 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1519,15 +1519,10 @@ static void dm_submit_bio(struct bio *bio) struct dm_table *map; =20 map =3D dm_get_live_table(md, &srcu_idx); - if (unlikely(!map)) { - DMERR_LIMIT("%s: mapping table unavailable, erroring io", - dm_device_name(md)); - bio_io_error(bio); - goto out; - } =20 - /* If suspended, queue this IO for later */ - if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))) { + /* If suspended, or map not yet available, queue this IO for later */ + if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) || + unlikely(!map)) { if (bio->bi_opf & REQ_NOWAIT) bio_wouldblock_error(bio); else if (bio->bi_opf & REQ_RAHEAD) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2B7C7C3527C for ; Tue, 12 Apr 2022 09:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389457AbiDLJXq (ORCPT ); Tue, 12 Apr 2022 05:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357088AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 EBC12767D; Tue, 12 Apr 2022 00:11: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 A7BFFB81A8F; Tue, 12 Apr 2022 07:11:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0542FC385A5; Tue, 12 Apr 2022 07:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747496; bh=PIRfs3JA6VwCrYK9rs78+T4RhVQHLme5xSV84VBX9NY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vcsAqVK2gf3KCnMYzc9qy9eIN2ej0+ygQ7OLrvCk3KVRq8MNnaPijVnoJ/sKnT+ay kAG1WaF6dw0KkXAGQtMnB5QQtBZbsBFVyUG3nU91l9Uw4Q35U1kXg2ciZGjNJWEWSg HuzcH5ebElA/x39DqbH23zlfYxB2KaZUG7Zn1Z/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 099/343] drm/amdkfd: make CRAT table missing message informational only Date: Tue, 12 Apr 2022 08:28:37 +0200 Message-Id: <20220412062953.958432293@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Alex Deucher [ Upstream commit 9dff13f9edf755a15f6507874185a3290c1ae8bb ] The driver has a fallback so make the message informational rather than a warning. The driver has a fallback if the Component Resource Association Table (CRAT) is missing, so make this informational now. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1906 Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/am= dkfd/kfd_crat.c index 9624bbe8b501..281def1c6c08 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -1567,7 +1567,7 @@ int kfd_create_crat_image_acpi(void **crat_image, siz= e_t *size) /* Fetch the CRAT table from ACPI */ status =3D acpi_get_table(CRAT_SIGNATURE, 0, &crat_table); if (status =3D=3D AE_NOT_FOUND) { - pr_warn("CRAT table not found\n"); + pr_info("CRAT table not found\n"); return -ENODATA; } else if (ACPI_FAILURE(status)) { const char *err =3D acpi_format_exception(status); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 17E73C4707A for ; Tue, 12 Apr 2022 08:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386677AbiDLI65 (ORCPT ); Tue, 12 Apr 2022 04:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357085AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E609FC6; Tue, 12 Apr 2022 00:11: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 9713661701; Tue, 12 Apr 2022 07:11:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A07EDC385A1; Tue, 12 Apr 2022 07:11:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747499; bh=nCTmKaY5tqg5mpxtTmdTE1Ti9amTVIWQFxjrQKhEUwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j4utKWVgxiYg1YbpfDs8CFjrw3Wb2XYsC574rSNb6oO0GoiF7gJLrkxY15nvU0VOj CALwaGmOAbi+dPasWlZoT4ZU41J4JGq03bQPQ3Z6xhpHA1HwDLnNrWOY0c43mf6toi jvEWQTkUX5Uv5KuFADrv3SRaqOLMLzV3fMNLaD+Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Alex Williamson , Sasha Levin Subject: [PATCH 5.17 100/343] vfio/pci: Stub vfio_pci_vga_rw when !CONFIG_VFIO_PCI_VGA Date: Tue, 12 Apr 2022 08:28:38 +0200 Message-Id: <20220412062953.986525765@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Alex Williamson [ Upstream commit 6e031ec0e5a2dda53e12e0d2a7e9b15b47a3c502 ] Resolve build errors reported against UML build for undefined ioport_map() and ioport_unmap() functions. Without this config option a device cannot have vfio_pci_core_device.has_vga set, so the existing function would always return -EINVAL anyway. Reported-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20220123125737.2658758-1-geert@linux-m68k.o= rg Link: https://lore.kernel.org/r/164306582968.3758255.15192949639574660648.s= tgit@omen Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/vfio/pci/vfio_pci_rdwr.c | 2 ++ include/linux/vfio_pci_core.h | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_r= dwr.c index 57d3b2cbbd8e..82ac1569deb0 100644 --- a/drivers/vfio/pci/vfio_pci_rdwr.c +++ b/drivers/vfio/pci/vfio_pci_rdwr.c @@ -288,6 +288,7 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vd= ev, char __user *buf, return done; } =20 +#ifdef CONFIG_VFIO_PCI_VGA ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *bu= f, size_t count, loff_t *ppos, bool iswrite) { @@ -355,6 +356,7 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vd= ev, char __user *buf, =20 return done; } +#endif =20 static void vfio_pci_ioeventfd_do_write(struct vfio_pci_ioeventfd *ioevent= fd, bool test_mem) diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index ef9a44b6cf5d..ae6f4838ab75 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -159,8 +159,17 @@ extern ssize_t vfio_pci_config_rw(struct vfio_pci_core= _device *vdev, extern ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __u= ser *buf, size_t count, loff_t *ppos, bool iswrite); =20 +#ifdef CONFIG_VFIO_PCI_VGA extern ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __u= ser *buf, size_t count, loff_t *ppos, bool iswrite); +#else +static inline ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, + char __user *buf, size_t count, + loff_t *ppos, bool iswrite) +{ + return -EINVAL; +} +#endif =20 extern long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t o= ffset, uint64_t data, int count, int fd); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 74B25C433EF for ; Tue, 12 Apr 2022 09:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242407AbiDLI7Y (ORCPT ); Tue, 12 Apr 2022 04:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357091AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8708A9FCB; Tue, 12 Apr 2022 00:11: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 2105361708; Tue, 12 Apr 2022 07:11:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D66C385A5; Tue, 12 Apr 2022 07:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747504; bh=c07T1VKAgPFpXfFZqznD8JY4cifFxI9tOTKw0rt5/t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HH+NpbekPY+JO82vVv+odCKfOwHuPGXZrBoY/kid8/r691Us9rTKoGoF/VAWHqPws Tn8ALgGODsaxld+ipPRGyWRxfXlZ83H1v7De0Rz2An3OdhMuy6/PcwO94cLnZrE6G1 IiQS5e/sc5fLQb6nQu/YiI88T8FxeDryJAoTRKeA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 101/343] scsi: pm8001: Fix pm80xx_pci_mem_copy() interface Date: Tue, 12 Apr 2022 08:28:39 +0200 Message-Id: <20220412062954.014428709@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal [ Upstream commit 3762d8f6edcdb03994c919f9487fd6d336c06561 ] The declaration of the local variable destination1 in pm80xx_pci_mem_copy() as a pointer to a u32 results in the sparse warning: warning: incorrect type in assignment (different base types) expected unsigned int [usertype] got restricted __le32 [usertype] Furthermore, the destination" argument of pm80xx_pci_mem_copy() is wrongly declared with the const attribute. Fix both problems by changing the type of the "destination" argument to "__le32 *" and use this argument directly inside the pm80xx_pci_mem_copy() function, thus removing the need for the destination1 local variable. Link: https://lore.kernel.org/r/20220220031810.738362-6-damien.lemoal@opens= ource.wdc.com Reviewed-by: Jack Wang Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/pm8001/pm80xx_hwi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_= hwi.c index 908dbac20b48..9a0d65ac0174 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -67,18 +67,16 @@ int pm80xx_bar4_shift(struct pm8001_hba_info *pm8001_ha= , u32 shift_value) } =20 static void pm80xx_pci_mem_copy(struct pm8001_hba_info *pm8001_ha, u32 so= ffset, - const void *destination, + __le32 *destination, u32 dw_count, u32 bus_base_number) { u32 index, value, offset; - u32 *destination1; - destination1 =3D (u32 *)destination; =20 - for (index =3D 0; index < dw_count; index +=3D 4, destination1++) { + for (index =3D 0; index < dw_count; index +=3D 4, destination++) { offset =3D (soffset + index); if (offset < (64 * 1024)) { value =3D pm8001_cr32(pm8001_ha, bus_base_number, offset); - *destination1 =3D cpu_to_le32(value); + *destination =3D cpu_to_le32(value); } } return; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 F1DC5C3525B for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384030AbiDLIi7 (ORCPT ); Tue, 12 Apr 2022 04:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357092AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 28DB99FD4; Tue, 12 Apr 2022 00:11: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 dfw.source.kernel.org (Postfix) with ESMTPS id B8921616E7; Tue, 12 Apr 2022 07:11:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB604C385A5; Tue, 12 Apr 2022 07:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747507; bh=qBiFHKXgg2zD6b/5j7HVuOH2dTTTHrfHFZb8RUAUM90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9k9PdVxonjhQ9cFQOGdEV36tdOvSHzxYVmBclcCQ5oUy5S8AcqmcKBFuPzzdYnPo BGDJwvOb67LqamlIouSjb0/vf8zqQnN9scMABCSbUtMUo2OxrIP+QgjnSphLmBVSHx SDhdHmkQkm4zpp5uR2UZRksxbbq8QiIWsxbdL0v0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 102/343] scsi: pm8001: Fix pm8001_mpi_task_abort_resp() Date: Tue, 12 Apr 2022 08:28:40 +0200 Message-Id: <20220412062954.042654150@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal [ Upstream commit 7e6b7e740addcea450041b5be8e42f0a4ceece0f ] The call to pm8001_ccb_task_free() at the end of pm8001_mpi_task_abort_resp() already frees the ccb tag. So when the device NCQ_ABORT_ALL_FLAG is set, the tag should not be freed again. Also change the hardcoded 0xBFFFFFFF value to ~NCQ_ABORT_ALL_FLAG as it ought to be. Link: https://lore.kernel.org/r/20220220031810.738362-19-damien.lemoal@open= source.wdc.com Reviewed-by: Jack Wang Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/pm8001/pm8001_hwi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_= hwi.c index d853e8d0195a..4f4a9dcb6a1e 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -3706,12 +3706,11 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_in= fo *pm8001_ha, void *piomb) mb(); =20 if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) { - pm8001_tag_free(pm8001_ha, tag); sas_free_task(t); - /* clear the flag */ - pm8001_dev->id &=3D 0xBFFFFFFF; - } else + pm8001_dev->id &=3D ~NCQ_ABORT_ALL_FLAG; + } else { t->task_done(t); + } =20 return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7E21EC38A2B for ; Tue, 12 Apr 2022 09:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389343AbiDLJXm (ORCPT ); Tue, 12 Apr 2022 05:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357090AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 E5EFBA190; Tue, 12 Apr 2022 00:11: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 81D6C6153F; Tue, 12 Apr 2022 07:11:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91609C385A1; Tue, 12 Apr 2022 07:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747510; bh=H0DjKy6Nwqc8oMmhiQthRhWVO2XkEzQnxtL4GLgLCiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZWVT7s3MBziK/7P8LwkwjUGpLGeO32r9HClsTpz0dc5oUjdCs8FuQnG7Wg4L0Lvh jvm6xSOFir6CCC0SG2L4jZy6GX0WLB6eWWpEE7XWXWAE9xRYTjoEeG9i844dP2cidE 82ng9kTTCLrYZxKANSQx731WDaV59ajcFOOjGeds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 103/343] scsi: pm8001: Fix tag values handling Date: Tue, 12 Apr 2022 08:28:41 +0200 Message-Id: <20220412062954.071874684@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal [ Upstream commit 7fb23a785ba38dea907323a039123f231195b297 ] The function pm8001_tag_alloc() determines free tags using the function find_first_zero_bit() which can return 0 when the first bit of the bitmap being inspected is 0. As such, tag 0 is a valid tag value that should not be dismissed as invalid. Fix the functions pm8001_work_fn(), mpi_sata_completion(), pm8001_mpi_task_abort_resp() and pm8001_open_reject_retry() to not dismiss 0 tags as invalid. The value 0xffffffff is used for invalid tags for unused ccb information structures. Add the macro definition PM8001_INVALID_TAG to define this value. Link: https://lore.kernel.org/r/20220220031810.738362-20-damien.lemoal@open= source.wdc.com Reviewed-by: Jack Wang Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/pm8001/pm8001_hwi.c | 52 +++++++++++-------------------- drivers/scsi/pm8001/pm8001_init.c | 3 +- drivers/scsi/pm8001/pm8001_sas.c | 13 ++++---- drivers/scsi/pm8001/pm8001_sas.h | 2 ++ drivers/scsi/pm8001/pm80xx_hwi.c | 5 --- 5 files changed, 28 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_= hwi.c index 4f4a9dcb6a1e..d244231e62f9 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1522,7 +1522,6 @@ void pm8001_work_fn(struct work_struct *work) case IO_XFER_ERROR_BREAK: { /* This one stashes the sas_task instead */ struct sas_task *t =3D (struct sas_task *)pm8001_dev; - u32 tag; struct pm8001_ccb_info *ccb; struct pm8001_hba_info *pm8001_ha =3D pw->pm8001_ha; unsigned long flags, flags1; @@ -1544,8 +1543,8 @@ void pm8001_work_fn(struct work_struct *work) /* Search for a possible ccb that matches the task */ for (i =3D 0; ccb =3D NULL, i < PM8001_MAX_CCB; i++) { ccb =3D &pm8001_ha->ccb_info[i]; - tag =3D ccb->ccb_tag; - if ((tag !=3D 0xFFFFFFFF) && (ccb->task =3D=3D t)) + if ((ccb->ccb_tag !=3D PM8001_INVALID_TAG) && + (ccb->task =3D=3D t)) break; } if (!ccb) { @@ -1567,11 +1566,11 @@ void pm8001_work_fn(struct work_struct *work) spin_unlock_irqrestore(&t->task_state_lock, flags1); pm8001_dbg(pm8001_ha, FAIL, "task 0x%p done with event 0x%x resp 0x%x s= tat 0x%x but aborted by upper layer!\n", t, pw->handler, ts->resp, ts->stat); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); spin_unlock_irqrestore(&pm8001_ha->lock, flags); } else { spin_unlock_irqrestore(&t->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, t, ccb, ccb->ccb_tag); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); t->task_done(t); @@ -1580,7 +1579,6 @@ void pm8001_work_fn(struct work_struct *work) case IO_XFER_OPEN_RETRY_TIMEOUT: { /* This one stashes the sas_task instead */ struct sas_task *t =3D (struct sas_task *)pm8001_dev; - u32 tag; struct pm8001_ccb_info *ccb; struct pm8001_hba_info *pm8001_ha =3D pw->pm8001_ha; unsigned long flags, flags1; @@ -1614,8 +1612,8 @@ void pm8001_work_fn(struct work_struct *work) /* Search for a possible ccb that matches the task */ for (i =3D 0; ccb =3D NULL, i < PM8001_MAX_CCB; i++) { ccb =3D &pm8001_ha->ccb_info[i]; - tag =3D ccb->ccb_tag; - if ((tag !=3D 0xFFFFFFFF) && (ccb->task =3D=3D t)) + if ((ccb->ccb_tag !=3D PM8001_INVALID_TAG) && + (ccb->task =3D=3D t)) break; } if (!ccb) { @@ -1686,19 +1684,13 @@ void pm8001_work_fn(struct work_struct *work) struct task_status_struct *ts; struct sas_task *task; int i; - u32 tag, device_id; + u32 device_id; =20 for (i =3D 0; ccb =3D NULL, i < PM8001_MAX_CCB; i++) { ccb =3D &pm8001_ha->ccb_info[i]; task =3D ccb->task; ts =3D &task->task_status; - tag =3D ccb->ccb_tag; - /* check if tag is NULL */ - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, - "tag Null\n"); - continue; - } + if (task !=3D NULL) { dev =3D task->dev; if (!dev) { @@ -1707,10 +1699,11 @@ void pm8001_work_fn(struct work_struct *work) continue; } /*complete sas task and update to top layer */ - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, + ccb->ccb_tag); ts->resp =3D SAS_TASK_COMPLETE; task->task_done(task); - } else if (tag !=3D 0xFFFFFFFF) { + } else if (ccb->ccb_tag !=3D PM8001_INVALID_TAG) { /* complete the internal commands/non-sas task */ pm8001_dev =3D ccb->device; if (pm8001_dev->dcompletion) { @@ -1718,7 +1711,7 @@ void pm8001_work_fn(struct work_struct *work) pm8001_dev->dcompletion =3D NULL; } complete(pm8001_ha->nvmd_completion); - pm8001_tag_free(pm8001_ha, tag); + pm8001_tag_free(pm8001_ha, ccb->ccb_tag); } } /* Deregister all the device ids */ @@ -2316,11 +2309,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_h= a, void *piomb) param =3D le32_to_cpu(psataPayload->param); tag =3D le32_to_cpu(psataPayload->tag); =20 - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); - return; - } - ccb =3D &pm8001_ha->ccb_info[tag]; t =3D ccb->task; pm8001_dev =3D ccb->device; @@ -3056,7 +3044,7 @@ void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_= info *pm8001_ha, device_id, pds, nds, status); complete(pm8001_dev->setds_completion); ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } =20 @@ -3074,7 +3062,7 @@ void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info = *pm8001_ha, void *piomb) dlen_status); } ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } =20 @@ -3101,7 +3089,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm80= 01_ha, void *piomb) * freed by requesting path anywhere. */ ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); return; } @@ -3147,7 +3135,7 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info *pm80= 01_ha, void *piomb) complete(pm8001_ha->nvmd_completion); pm8001_dbg(pm8001_ha, MSG, "Get nvmd data complete!\n"); ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); } =20 @@ -3560,7 +3548,7 @@ int pm8001_mpi_reg_resp(struct pm8001_hba_info *pm800= 1_ha, void *piomb) } complete(pm8001_dev->dcompletion); ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, htag); return 0; } @@ -3632,7 +3620,7 @@ int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba= _info *pm8001_ha, } kfree(ccb->fw_control_context); ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; pm8001_tag_free(pm8001_ha, tag); complete(pm8001_ha->nvmd_completion); return 0; @@ -3668,10 +3656,6 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_inf= o *pm8001_ha, void *piomb) =20 status =3D le32_to_cpu(pPayload->status); tag =3D le32_to_cpu(pPayload->tag); - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, " TAG NULL. RETURNING !!!\n"); - return -1; - } =20 scp =3D le32_to_cpu(pPayload->scp); ccb =3D &pm8001_ha->ccb_info[tag]; diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001= _init.c index d8a2121cb8d9..d2a2593f669d 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -1216,10 +1216,11 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_= ha, struct Scsi_Host *shost, goto err_out; } pm8001_ha->ccb_info[i].task =3D NULL; - pm8001_ha->ccb_info[i].ccb_tag =3D 0xffffffff; + pm8001_ha->ccb_info[i].ccb_tag =3D PM8001_INVALID_TAG; pm8001_ha->ccb_info[i].device =3D NULL; ++pm8001_ha->tags_num; } + return 0; =20 err_out_noccb: diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_= sas.c index 32edda3e55c6..c1f871561b32 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -567,7 +567,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm800= 1_ha, =20 task->lldd_task =3D NULL; ccb->task =3D NULL; - ccb->ccb_tag =3D 0xFFFFFFFF; + ccb->ccb_tag =3D PM8001_INVALID_TAG; ccb->open_retry =3D 0; pm8001_tag_free(pm8001_ha, ccb_idx); } @@ -952,9 +952,11 @@ void pm8001_open_reject_retry( struct task_status_struct *ts; struct pm8001_device *pm8001_dev; unsigned long flags1; - u32 tag; struct pm8001_ccb_info *ccb =3D &pm8001_ha->ccb_info[i]; =20 + if (ccb->ccb_tag =3D=3D PM8001_INVALID_TAG) + continue; + pm8001_dev =3D ccb->device; if (!pm8001_dev || (pm8001_dev->dev_type =3D=3D SAS_PHY_UNUSED)) continue; @@ -966,9 +968,6 @@ void pm8001_open_reject_retry( continue; } else if (pm8001_dev !=3D device_to_close) continue; - tag =3D ccb->ccb_tag; - if (!tag || (tag =3D=3D 0xFFFFFFFF)) - continue; task =3D ccb->task; if (!task || !task->task_done) continue; @@ -989,11 +988,11 @@ void pm8001_open_reject_retry( & SAS_TASK_STATE_ABORTED))) { spin_unlock_irqrestore(&task->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb->ccb_tag); } else { spin_unlock_irqrestore(&task->task_state_lock, flags1); - pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); + pm8001_ccb_task_free(pm8001_ha, task, ccb, ccb->ccb_tag); mb();/* in order to force CPU ordering */ spin_unlock_irqrestore(&pm8001_ha->lock, flags); task->task_done(task); diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_= sas.h index a17da1cebce1..1791cdf30276 100644 --- a/drivers/scsi/pm8001/pm8001_sas.h +++ b/drivers/scsi/pm8001/pm8001_sas.h @@ -738,6 +738,8 @@ void pm8001_free_dev(struct pm8001_device *pm8001_dev); /* ctl shared API */ extern const struct attribute_group *pm8001_host_groups[]; =20 +#define PM8001_INVALID_TAG ((u32)-1) + static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha, struct sas_task *task, struct pm8001_ccb_info *ccb, diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_= hwi.c index 9a0d65ac0174..728190b26924 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -2404,11 +2404,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_h= a, param =3D le32_to_cpu(psataPayload->param); tag =3D le32_to_cpu(psataPayload->tag); =20 - if (!tag) { - pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); - return; - } - ccb =3D &pm8001_ha->ccb_info[tag]; t =3D ccb->task; pm8001_dev =3D ccb->device; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 5D193C433EF for ; Tue, 12 Apr 2022 08:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238569AbiDLI7M (ORCPT ); Tue, 12 Apr 2022 04:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357094AbiDLHjq (ORCPT ); Tue, 12 Apr 2022 03:39:46 -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 BD35EAE42; Tue, 12 Apr 2022 00:11: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 5680C61701; Tue, 12 Apr 2022 07:11:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B8CCC385A1; Tue, 12 Apr 2022 07:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747512; bh=zA0v4Qy4WXC0LcGcBZlWZQSSdhxr+jTwE52o+vhjBOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wwPEUSnV3xAiUFwZuPIIfkj76wk8PLLhWRZCHvBZbgkSaMjlKLu78NDTwPj3uOF0n +bPPHPPVpqTno366WtyPXce9cM6ltRn6B+u467Ji9i+DzgZJXjG6lwvhwTuAu91sRM vRyIeRt+FXWk/MuRrloB0C8p2LAX4S/ubMJzconc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 104/343] scsi: pm8001: Fix task leak in pm8001_send_abort_all() Date: Tue, 12 Apr 2022 08:28:42 +0200 Message-Id: <20220412062954.099450979@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal [ Upstream commit f90a74892f3acf0cdec5844e90fc8686ca13e7d7 ] In pm8001_send_abort_all(), make sure to free the allocated sas task if pm8001_tag_alloc() or pm8001_mpi_build_cmd() fail. Link: https://lore.kernel.org/r/20220220031810.738362-21-damien.lemoal@open= source.wdc.com Reviewed-by: John Garry Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/pm8001/pm8001_hwi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_= hwi.c index d244231e62f9..5ec429cf1e20 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1765,7 +1765,6 @@ static void pm8001_send_abort_all(struct pm8001_hba_i= nfo *pm8001_ha, } =20 task =3D sas_alloc_slow_task(GFP_ATOMIC); - if (!task) { pm8001_dbg(pm8001_ha, FAIL, "cannot allocate task\n"); return; @@ -1774,8 +1773,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_= info *pm8001_ha, task->task_done =3D pm8001_task_done; =20 res =3D pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) + if (res) { + sas_free_task(task); return; + } =20 ccb =3D &pm8001_ha->ccb_info[ccb_tag]; ccb->device =3D pm8001_ha_dev; @@ -1792,8 +1793,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_= info *pm8001_ha, =20 ret =3D pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); - if (ret) + if (ret) { + sas_free_task(task); pm8001_tag_free(pm8001_ha, ccb_tag); + } =20 } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 102CBC47084 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384381AbiDLIlf (ORCPT ); Tue, 12 Apr 2022 04:41:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357230AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23413B78; Tue, 12 Apr 2022 00:14: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 B38FE6171D; Tue, 12 Apr 2022 07:14:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C69F9C385A1; Tue, 12 Apr 2022 07:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747647; bh=Sx8uKUQ+GqGVj+GrmxGPRwn4kz+73o+QY6P6TKiQsuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r9VqVWpOyk8FR1kPcnJyNOA1QR4QrKE/aymzRv/bTNmRvtLgVTXbbBRJMe4wid5ob lYtLS/b5+jmrB9rayjl2ox7ZqIAfNYv829yFtUhrJ3g+J3XrL/rBC7gX7gisr8o45q dHwzGPTOikNVebeNXsTdAsENFfIorF7GY0CdY4/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 105/343] scsi: pm8001: Fix tag leaks on error Date: Tue, 12 Apr 2022 08:28:43 +0200 Message-Id: <20220412062954.127666081@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal [ Upstream commit 4c8f04b1905cd4b776d0b720463c091545478ef7 ] In pm8001_chip_set_dev_state_req(), pm8001_chip_fw_flash_update_req(), pm80xx_chip_phy_ctl_req() and pm8001_chip_reg_dev_req() add missing calls to pm8001_tag_free() to free the allocated tag when pm8001_mpi_build_cmd() fails. Similarly, in pm8001_exec_internal_task_abort(), if the chip ->task_abort method fails, the tag allocated for the abort request task must be freed. Add the missing call to pm8001_tag_free(). Link: https://lore.kernel.org/r/20220220031810.738362-22-damien.lemoal@open= source.wdc.com Reviewed-by: John Garry Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/pm8001/pm8001_hwi.c | 9 +++++++++ drivers/scsi/pm8001/pm8001_sas.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 9 +++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_= hwi.c index 5ec429cf1e20..ccc7f53ddbd6 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4465,6 +4465,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_= info *pm8001_ha, SAS_ADDR_SIZE); rc =3D pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } =20 @@ -4877,6 +4880,9 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_inf= o *pm8001_ha, ccb->ccb_tag =3D tag; rc =3D pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } =20 @@ -4981,6 +4987,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info = *pm8001_ha, payload.nds =3D cpu_to_le32(state); rc =3D pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; =20 } diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_= sas.c index c1f871561b32..b68c8400ca15 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -847,10 +847,10 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_inf= o *pm8001_ha, =20 res =3D PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, task_tag, ccb_tag); - if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); + pm8001_tag_free(pm8001_ha, ccb_tag); goto ex_err; } wait_for_completion(&task->slow_task->completion); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_= hwi.c index 728190b26924..55163469030d 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4920,8 +4920,13 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba= _info *pm8001_ha, payload.tag =3D cpu_to_le32(tag); payload.phyop_phyid =3D cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); - return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + rc =3D pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + + return rc; } =20 static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9C536C4167E for ; Tue, 12 Apr 2022 08:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383965AbiDLIiq (ORCPT ); Tue, 12 Apr 2022 04:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357105AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE065DEB4; Tue, 12 Apr 2022 00:12: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 93ADBB81A8F; Tue, 12 Apr 2022 07:12:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1FC3C385A1; Tue, 12 Apr 2022 07:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747532; bh=RVCl0QueOUEdBG+WdafdDuCg8pAcvRppNDasLe0JeiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I0aSQznAjyslXpfuDE0ybt9nm6oYgXMZa/ZAQCJd4aQv3k7rqn0lM6Ulx+su7C/wy XPrOPuDswcL3AX0kUg5w7BTdfGhTppcfJ+2D/bnRkP6utik/pHg8YtePWw9YFhoOoI pT8Is2NSr9vwegP/AVXDNP069FGt1mj040LjXf2w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Wang , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 106/343] scsi: pm8001: Fix memory leak in pm8001_chip_fw_flash_update_req() Date: Tue, 12 Apr 2022 08:28:44 +0200 Message-Id: <20220412062954.155454566@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal [ Upstream commit f792a3629f4c4aa4c3703d66b43ce1edcc3ec09a ] In pm8001_chip_fw_flash_update_build(), if pm8001_chip_fw_flash_update_build() fails, the struct fw_control_ex allocated must be freed. Link: https://lore.kernel.org/r/20220220031810.738362-23-damien.lemoal@open= source.wdc.com Reviewed-by: Jack Wang Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/pm8001/pm8001_hwi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_= hwi.c index ccc7f53ddbd6..27ead825c2bb 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4880,8 +4880,10 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_in= fo *pm8001_ha, ccb->ccb_tag =3D tag; rc =3D pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); - if (rc) + if (rc) { + kfree(fw_control_context); pm8001_tag_free(pm8001_ha, tag); + } =20 return rc; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 58CB5C433F5 for ; Tue, 12 Apr 2022 08:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385037AbiDLImo (ORCPT ); Tue, 12 Apr 2022 04:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357136AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D76A11C09; Tue, 12 Apr 2022 00:12: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 CC22461708; Tue, 12 Apr 2022 07:12:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD9B4C385A1; Tue, 12 Apr 2022 07:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747562; bh=5Ngrx2Q19iM3tFer9YqiG47OUVg8drZR6c8HQGUFLDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=woHvrvt0nfWVH2yd0xLGzR0ZvUPNuPqBkSsJhoxBiTEL+IVzCQcoASjJgq+bZPDVf nX4GvVOuoK/uCDFx4EOAa4EHfyti8sVS7zlM4aZ7WNtwnWXALEuqo6b7dec7cWgamD 2tIq6PvB4LJlfiS7ubuwZL+oW+vcu250xTnm6BqU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Almbladh , Felix Fietkau , Sasha Levin Subject: [PATCH 5.17 107/343] mt76: mt7915: fix injected MPDU transmission to not use HW A-MSDU Date: Tue, 12 Apr 2022 08:28:45 +0200 Message-Id: <20220412062954.183179970@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Johan Almbladh [ Upstream commit 28225a6ef80ebf46c46e5fbd5b1ee231a0b2b5b7 ] Before, the hardware would be allowed to transmit injected 802.11 MPDUs as A-MSDU. This resulted in corrupted frames being transmitted. Now, injected MPDUs are transmitted as-is, without A-MSDU. The fix was verified with frame injection on MT7915 hardware, both with and without the injected frame being encrypted. If the hardware cannot do A-MSDU aggregation on MPDUs, this problem would also be present in the TX path where mac80211 does the 802.11 encapsulation. However, I have not observed any such problem when disabling IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD to force that mode. Therefore this fix is isolated to injected frames only. The same A-MSDU logic is also present in the mt7921 driver, so it is likely that this fix should be applied there too. I do not have access to mt7921 hardware so I have not been able to test that. Signed-off-by: Johan Almbladh Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/= wireless/mediatek/mt76/mt7915/mac.c index db267642924d..e4c300aa1526 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1085,6 +1085,7 @@ mt7915_mac_write_txwi_80211(struct mt7915_dev *dev, _= _le32 *txwi, val =3D MT_TXD3_SN_VALID | FIELD_PREP(MT_TXD3_SEQ, IEEE80211_SEQ_TO_SN(seqno)); txwi[3] |=3D cpu_to_le32(val); + txwi[7] &=3D ~cpu_to_le32(MT_TXD7_HW_AMSDU); } =20 val =3D FIELD_PREP(MT_TXD7_TYPE, fc_type) | --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C0E21C4707A for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384211AbiDLIji (ORCPT ); Tue, 12 Apr 2022 04:39:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357164AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39: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 24BF713E01; Tue, 12 Apr 2022 00:13: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 CE7E3B81A8F; Tue, 12 Apr 2022 07:13:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EC49C385A6; Tue, 12 Apr 2022 07:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747592; bh=bnNakFxqskyH9Z6SrX9IiVWIDVGGSYF51Zlbl2yDyU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7QhNBnL4DbKr+LSkZNAp5JNKLkeQ7vztwVgQb881Vtw7fi5tcW5V7rXB7Ebwl4Y/ NERoZ1Z480tgSHW84r2tnfXd0PinHa6KGVxRbGp2HU5hwdlbFT5kEtFvohg7Vijd+l sgST0Uuk7WFeZLSJudkoJ+V0x3GWPRslD7u7S7nY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Matt Johnston , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 108/343] mctp: make __mctp_dev_get() take a refcount hold Date: Tue, 12 Apr 2022 08:28:46 +0200 Message-Id: <20220412062954.511957104@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Matt Johnston [ Upstream commit dc121c0084910db985cf1c8ba6fce5d8c307cc02 ] Previously there was a race that could allow the mctp_dev refcount to hit zero: rcu_read_lock(); mdev =3D __mctp_dev_get(dev); // mctp_unregister() happens here, mdev->refs hits zero mctp_dev_hold(dev); rcu_read_unlock(); Now we make __mctp_dev_get() take the hold itself. It is safe to test against the zero refcount because __mctp_dev_get() is called holding rcu_read_lock and mctp_dev uses kfree_rcu(). Reported-by: Jakub Kicinski Signed-off-by: Matt Johnston Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/mctp/device.c | 21 ++++++++++++++++++--- net/mctp/route.c | 5 ++++- net/mctp/test/utils.c | 1 - 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/net/mctp/device.c b/net/mctp/device.c index ef2755f82f87..f86ef6d751bd 100644 --- a/net/mctp/device.c +++ b/net/mctp/device.c @@ -24,12 +24,25 @@ struct mctp_dump_cb { size_t a_idx; }; =20 -/* unlocked: caller must hold rcu_read_lock */ +/* unlocked: caller must hold rcu_read_lock. + * Returned mctp_dev has its refcount incremented, or NULL if unset. + */ struct mctp_dev *__mctp_dev_get(const struct net_device *dev) { - return rcu_dereference(dev->mctp_ptr); + struct mctp_dev *mdev =3D rcu_dereference(dev->mctp_ptr); + + /* RCU guarantees that any mdev is still live. + * Zero refcount implies a pending free, return NULL. + */ + if (mdev) + if (!refcount_inc_not_zero(&mdev->refs)) + return NULL; + return mdev; } =20 +/* Returned mctp_dev does not have refcount incremented. The returned poin= ter + * remains live while rtnl_lock is held, as that prevents mctp_unregister() + */ struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev) { return rtnl_dereference(dev->mctp_ptr); @@ -123,6 +136,7 @@ static int mctp_dump_addrinfo(struct sk_buff *skb, stru= ct netlink_callback *cb) if (mdev) { rc =3D mctp_dump_dev_addrinfo(mdev, skb, cb); + mctp_dev_put(mdev); // Error indicates full buffer, this // callback will get retried. if (rc < 0) @@ -297,7 +311,7 @@ void mctp_dev_hold(struct mctp_dev *mdev) =20 void mctp_dev_put(struct mctp_dev *mdev) { - if (refcount_dec_and_test(&mdev->refs)) { + if (mdev && refcount_dec_and_test(&mdev->refs)) { dev_put(mdev->dev); kfree_rcu(mdev, rcu); } @@ -369,6 +383,7 @@ static size_t mctp_get_link_af_size(const struct net_de= vice *dev, if (!mdev) return 0; ret =3D nla_total_size(4); /* IFLA_MCTP_NET */ + mctp_dev_put(mdev); return ret; } =20 diff --git a/net/mctp/route.c b/net/mctp/route.c index e52cef750500..05fbd318eb98 100644 --- a/net/mctp/route.c +++ b/net/mctp/route.c @@ -786,7 +786,7 @@ int mctp_local_output(struct sock *sk, struct mctp_rout= e *rt, { struct mctp_sock *msk =3D container_of(sk, struct mctp_sock, sk); struct mctp_skb_cb *cb =3D mctp_cb(skb); - struct mctp_route tmp_rt; + struct mctp_route tmp_rt =3D {0}; struct mctp_sk_key *key; struct net_device *dev; struct mctp_hdr *hdr; @@ -892,6 +892,7 @@ int mctp_local_output(struct sock *sk, struct mctp_rout= e *rt, mctp_route_release(rt); =20 dev_put(dev); + mctp_dev_put(tmp_rt.dev); =20 return rc; =20 @@ -1057,11 +1058,13 @@ static int mctp_pkttype_receive(struct sk_buff *skb= , struct net_device *dev, =20 rt->output(rt, skb); mctp_route_release(rt); + mctp_dev_put(mdev); =20 return NET_RX_SUCCESS; =20 err_drop: kfree_skb(skb); + mctp_dev_put(mdev); return NET_RX_DROP; } =20 diff --git a/net/mctp/test/utils.c b/net/mctp/test/utils.c index 7b7918702592..e03ba66bbe18 100644 --- a/net/mctp/test/utils.c +++ b/net/mctp/test/utils.c @@ -54,7 +54,6 @@ struct mctp_test_dev *mctp_test_create_dev(void) =20 rcu_read_lock(); dev->mdev =3D __mctp_dev_get(ndev); - mctp_dev_hold(dev->mdev); rcu_read_unlock(); =20 return dev; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 89B49C43217 for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356455AbiDLIkk (ORCPT ); Tue, 12 Apr 2022 04:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357213AbiDLHjw (ORCPT ); Tue, 12 Apr 2022 03:39:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED6715707; Tue, 12 Apr 2022 00:13: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 F083C61701; Tue, 12 Apr 2022 07:13:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A32FC385A1; Tue, 12 Apr 2022 07:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747622; bh=ctW1ThIgpxwzuN8BeP9EVDXP931hObzA6ZOjA61uv6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0JYth9AHX1MD8jHMXQmWvSVd61zmDRjNiwr9eg6lRSzLMJGD8OkoZpSAv21194u6k JuDlU2FSyffVKllW3kDvxvj77LEH2DopFGprTHpUokFKbN7Tj1AiMg7JYzTkdVtKL6 p7shhLqRlToLl2VVM1cnf0FRNUKRrxalR3GxDMbY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Dufour , Nicholas Piggin , "Aneesh Kumar K.V" , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 109/343] powerpc/64s/hash: Make hash faults work in NMI context Date: Tue, 12 Apr 2022 08:28:47 +0200 Message-Id: <20220412062954.541005939@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Nicholas Piggin [ Upstream commit 8b91cee5eadd2021f55e6775f2d50bd56d00c217 ] Hash faults are not resoved in NMI context, instead causing the access to fail. This is done because perf interrupts can get backtraces including walking the user stack, and taking a hash fault on those could deadlock on the HPTE lock if the perf interrupt hits while the same HPTE lock is being held by the hash fault code. The user-access for the stack walking will notice the access failed and deal with that in the perf code. The reason to allow perf interrupts in is to better profile hash faults. The problem with this is any hash fault on a kernel access that happens in NMI context will crash, because kernel accesses must not fail. Hard lockups, system reset, machine checks that access vmalloc space including modules and including stack backtracing and symbol lookup in modules, per-cpu data, etc could all run into this problem. Fix this by disallowing perf interrupts in the hash fault code (the direct hash fault is covered by MSR[EE]=3D0 so the PMI disable just needs to extend to the preload case). This simplifies the tricky logic in hash faults and perf, at the cost of reduced profiling of hash faults. perf can still latch addresses when interrupts are disabled, it just won't get the stack trace at that point, so it would still find hot spots, just sometimes with confusing stack chains. An alternative could be to allow perf interrupts here but always do the slowpath stack walk if we are in nmi context, but that slows down all perf interrupt stack walking on hash though and it does not remove as much tricky code. Reported-by: Laurent Dufour Signed-off-by: Nicholas Piggin Tested-by: Laurent Dufour Reviewed-by: Aneesh Kumar K.V Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220204035348.545435-1-npiggin@gmail.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/include/asm/interrupt.h | 2 +- arch/powerpc/mm/book3s64/hash_utils.c | 54 ++++----------------------- arch/powerpc/perf/callchain.h | 9 +---- arch/powerpc/perf/callchain_64.c | 27 -------------- 4 files changed, 10 insertions(+), 82 deletions(-) diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/as= m/interrupt.h index fc28f46d2f9d..5404f7abbcf8 100644 --- a/arch/powerpc/include/asm/interrupt.h +++ b/arch/powerpc/include/asm/interrupt.h @@ -612,7 +612,7 @@ DECLARE_INTERRUPT_HANDLER_RAW(do_slb_fault); DECLARE_INTERRUPT_HANDLER(do_bad_segment_interrupt); =20 /* hash_utils.c */ -DECLARE_INTERRUPT_HANDLER_RAW(do_hash_fault); +DECLARE_INTERRUPT_HANDLER(do_hash_fault); =20 /* fault.c */ DECLARE_INTERRUPT_HANDLER(do_page_fault); diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s= 64/hash_utils.c index 7abf82a698d3..985cabdd7f67 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -1621,8 +1621,7 @@ int hash_page(unsigned long ea, unsigned long access,= unsigned long trap, } EXPORT_SYMBOL_GPL(hash_page); =20 -DECLARE_INTERRUPT_HANDLER(__do_hash_fault); -DEFINE_INTERRUPT_HANDLER(__do_hash_fault) +DEFINE_INTERRUPT_HANDLER(do_hash_fault) { unsigned long ea =3D regs->dar; unsigned long dsisr =3D regs->dsisr; @@ -1681,35 +1680,6 @@ DEFINE_INTERRUPT_HANDLER(__do_hash_fault) } } =20 -/* - * The _RAW interrupt entry checks for the in_nmi() case before - * running the full handler. - */ -DEFINE_INTERRUPT_HANDLER_RAW(do_hash_fault) -{ - /* - * If we are in an "NMI" (e.g., an interrupt when soft-disabled), then - * don't call hash_page, just fail the fault. This is required to - * prevent re-entrancy problems in the hash code, namely perf - * interrupts hitting while something holds H_PAGE_BUSY, and taking a - * hash fault. See the comment in hash_preload(). - * - * We come here as a result of a DSI at a point where we don't want - * to call hash_page, such as when we are accessing memory (possibly - * user memory) inside a PMU interrupt that occurred while interrupts - * were soft-disabled. We want to invoke the exception handler for - * the access, or panic if there isn't a handler. - */ - if (unlikely(in_nmi())) { - do_bad_page_fault_segv(regs); - return 0; - } - - __do_hash_fault(regs); - - return 0; -} - #ifdef CONFIG_PPC_MM_SLICES static bool should_hash_preload(struct mm_struct *mm, unsigned long ea) { @@ -1776,26 +1746,18 @@ static void hash_preload(struct mm_struct *mm, pte_= t *ptep, unsigned long ea, #endif /* CONFIG_PPC_64K_PAGES */ =20 /* - * __hash_page_* must run with interrupts off, as it sets the - * H_PAGE_BUSY bit. It's possible for perf interrupts to hit at any - * time and may take a hash fault reading the user stack, see - * read_user_stack_slow() in the powerpc/perf code. - * - * If that takes a hash fault on the same page as we lock here, it - * will bail out when seeing H_PAGE_BUSY set, and retry the access - * leading to an infinite loop. + * __hash_page_* must run with interrupts off, including PMI interrupts + * off, as it sets the H_PAGE_BUSY bit. * - * Disabling interrupts here does not prevent perf interrupts, but it - * will prevent them taking hash faults (see the NMI test in - * do_hash_page), then read_user_stack's copy_from_user_nofault will - * fail and perf will fall back to read_user_stack_slow(), which - * walks the Linux page tables. + * It's otherwise possible for perf interrupts to hit at any time and + * may take a hash fault reading the user stack, which could take a + * hash miss and deadlock on the same H_PAGE_BUSY bit. * * Interrupts must also be off for the duration of the * mm_is_thread_local test and update, to prevent preempt running the * mm on another CPU (XXX: this may be racy vs kthread_use_mm). */ - local_irq_save(flags); + powerpc_local_irq_pmu_save(flags); =20 /* Is that local to this CPU ? */ if (mm_is_thread_local(mm)) @@ -1820,7 +1782,7 @@ static void hash_preload(struct mm_struct *mm, pte_t = *ptep, unsigned long ea, mm_ctx_user_psize(&mm->context), pte_val(*ptep)); =20 - local_irq_restore(flags); + powerpc_local_irq_pmu_restore(flags); } =20 /* diff --git a/arch/powerpc/perf/callchain.h b/arch/powerpc/perf/callchain.h index d6fa6e25234f..19a8d051ddf1 100644 --- a/arch/powerpc/perf/callchain.h +++ b/arch/powerpc/perf/callchain.h @@ -2,7 +2,6 @@ #ifndef _POWERPC_PERF_CALLCHAIN_H #define _POWERPC_PERF_CALLCHAIN_H =20 -int read_user_stack_slow(const void __user *ptr, void *buf, int nb); void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs); void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry, @@ -26,17 +25,11 @@ static inline int __read_user_stack(const void __user *= ptr, void *ret, size_t size) { unsigned long addr =3D (unsigned long)ptr; - int rc; =20 if (addr > TASK_SIZE - size || (addr & (size - 1))) return -EFAULT; =20 - rc =3D copy_from_user_nofault(ret, ptr, size); - - if (IS_ENABLED(CONFIG_PPC64) && !radix_enabled() && rc) - return read_user_stack_slow(ptr, ret, size); - - return rc; + return copy_from_user_nofault(ret, ptr, size); } =20 #endif /* _POWERPC_PERF_CALLCHAIN_H */ diff --git a/arch/powerpc/perf/callchain_64.c b/arch/powerpc/perf/callchain= _64.c index 8d0df4226328..488e8a21a11e 100644 --- a/arch/powerpc/perf/callchain_64.c +++ b/arch/powerpc/perf/callchain_64.c @@ -18,33 +18,6 @@ =20 #include "callchain.h" =20 -/* - * On 64-bit we don't want to invoke hash_page on user addresses from - * interrupt context, so if the access faults, we read the page tables - * to find which page (if any) is mapped and access it directly. Radix - * has no need for this so it doesn't use read_user_stack_slow. - */ -int read_user_stack_slow(const void __user *ptr, void *buf, int nb) -{ - - unsigned long addr =3D (unsigned long) ptr; - unsigned long offset; - struct page *page; - void *kaddr; - - if (get_user_page_fast_only(addr, FOLL_WRITE, &page)) { - kaddr =3D page_address(page); - - /* align address to page boundary */ - offset =3D addr & ~PAGE_MASK; - - memcpy(buf, kaddr + offset, nb); - put_page(page); - return 0; - } - return -EFAULT; -} - static int read_user_stack_64(const unsigned long __user *ptr, unsigned lo= ng *ret) { return __read_user_stack(ptr, ret, sizeof(*ret)); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 667BBC47080 for ; Tue, 12 Apr 2022 08:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384320AbiDLIkL (ORCPT ); Tue, 12 Apr 2022 04:40:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357223AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -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 6CB121582B; Tue, 12 Apr 2022 00:13: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 dfw.source.kernel.org (Postfix) with ESMTPS id 07BF561701; Tue, 12 Apr 2022 07:13:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1363DC385A5; Tue, 12 Apr 2022 07:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747633; bh=/uOxVJWrytHOQa/dr3wg/Qm9js3id4tXNTPbdtNpAHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmLdsOgiBp9gAh4LiiQEeeZ3MDjbd0kZ5hCdxKneFRDl53naiwM2Q9zbz63UJkmmL iZkH9DBTJtYboIzlj1KvrVUpThjvl8PVbL2vqovCzYeOOXLJCEfGmPwxfEdEW1vtPt C5UmBSPkgJWNI+hVfoXVIYJeFhuU9BC+uYKXIirw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abaci Robot , Yang Li , Felix Fietkau , Sasha Levin Subject: [PATCH 5.17 110/343] mt76: mt7615: Fix assigning negative values to unsigned variable Date: Tue, 12 Apr 2022 08:28:48 +0200 Message-Id: <20220412062954.569850456@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yang Li [ Upstream commit 9273ffcc9a11942bd586bb42584337ef3962b692 ] Smatch reports the following: drivers/net/wireless/mediatek/mt76/mt7615/mac.c:1865 mt7615_mac_adjust_sensitivity() warn: assigning (-110) to unsigned variable 'def_th' drivers/net/wireless/mediatek/mt76/mt7615/mac.c:1865 mt7615_mac_adjust_sensitivity() warn: assigning (-98) to unsigned variable 'def_th' Reported-by: Abaci Robot Signed-off-by: Yang Li Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/= wireless/mediatek/mt76/mt7615/mac.c index ba31bb7caaf9..5d69e77814c9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -1841,7 +1841,7 @@ mt7615_mac_adjust_sensitivity(struct mt7615_phy *phy, struct mt7615_dev *dev =3D phy->dev; int false_cca =3D ofdm ? phy->false_cca_ofdm : phy->false_cca_cck; bool ext_phy =3D phy !=3D &dev->phy; - u16 def_th =3D ofdm ? -98 : -110; + s16 def_th =3D ofdm ? -98 : -110; bool update =3D false; s8 *sensitivity; int signal; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C416DC47082 for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357162AbiDLIlB (ORCPT ); Tue, 12 Apr 2022 04:41:01 -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 S1357221AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -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 4901D1582D; Tue, 12 Apr 2022 00:13: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 D766461045; Tue, 12 Apr 2022 07:13:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E335CC385A1; Tue, 12 Apr 2022 07:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747636; bh=Hh8TQDDukf6SBZKFe+GfLCSWmvkOIWW41tky6bIOHxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w5f4NSYM0fJ/iefeF4bI70uYnrHRpzSAwVZt4bIPShIxrDPkgQtiWbRryoI7hFmna XDTDgEKjyXWnBYrarGnRpmPAGKaKCtgqzD9z2Y52xHbvQUTMioQfL3X56JqXvINexl pdbXKBIwCd31m3eQMtRMUAtyH/1j3z3PFrtqfQak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.17 111/343] power: supply: axp288_charger: Use acpi_quirk_skip_acpi_ac_and_battery() Date: Tue, 12 Apr 2022 08:28:49 +0200 Message-Id: <20220412062954.597367971@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hans de Goede [ Upstream commit 00d0566614b7bb7b226cb5a6895b0180ffe6915a ] Normally the native AXP288 fg/charger drivers are preferred but one some devices the ACPI drivers should be used instead. The ACPI battery/ac drivers use the acpi_quirk_skip_acpi_ac_and_battery() helper to determine if they should skip loading because native fuel-gauge/ charger drivers like the AXP288 drivers will be used. The new acpi_quirk_skip_acpi_ac_and_battery() helper includes a list of exceptions for boards where the ACPI drivers should be used instead. Use this new helper to avoid loading on such boards. Note this requires adding a Kconfig dependency on ACPI, this is not a problem because ACPI should be enabled on all boards with an AXP288 PMIC anyways. Signed-off-by: Hans de Goede Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/power/supply/Kconfig | 2 +- drivers/power/supply/axp288_charger.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index b366e2fd8e97..d7534f12e9ef 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -351,7 +351,7 @@ config AXP20X_POWER =20 config AXP288_CHARGER tristate "X-Powers AXP288 Charger" - depends on MFD_AXP20X && EXTCON_AXP288 && IOSF_MBI + depends on MFD_AXP20X && EXTCON_AXP288 && IOSF_MBI && ACPI help Say yes here to have support X-Power AXP288 power management IC (PMIC) integrated charger. diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/a= xp288_charger.c index c498e62ab4e2..19746e658a6a 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -838,6 +838,13 @@ static int axp288_charger_probe(struct platform_device= *pdev) struct power_supply_config charger_cfg =3D {}; unsigned int val; =20 + /* + * Normally the native AXP288 fg/charger drivers are preferred but + * on some devices the ACPI drivers should be used instead. + */ + if (!acpi_quirk_skip_acpi_ac_and_battery()) + return -ENODEV; + /* * On some devices the fuelgauge and charger parts of the axp288 are * not used, check that the fuelgauge is enabled (CC_CTRL !=3D 0). --=20 2.35.1 From nobody Thu May 14 08:08:21 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 96206C35296 for ; Tue, 12 Apr 2022 08:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352385AbiDLIkP (ORCPT ); Tue, 12 Apr 2022 04:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357220AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -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 EA8B315A02; Tue, 12 Apr 2022 00:13: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 dfw.source.kernel.org (Postfix) with ESMTPS id 851D36153F; Tue, 12 Apr 2022 07:13:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C568C385A1; Tue, 12 Apr 2022 07:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747639; bh=VdfdafuRcjTS5UUKaCXYsrTgX5OBbE6LcxYACf3ZdkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PgzXWVfJBn62Y7bU96wH1/AAq4IZDR3x+Z4Zk5I8d5wgs99HRiKXiaz+Oce0981E9 TfsJFnURnLx3U9tfVQ7mbq1QE0VDryKeDgwGcQF5y1Dl0dl5Wx/U2yJdfZjL9JcWen mp+QFZ/7UOHuGEfzlYi3XTw7PZyz4ktx/0jZ+R1A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.17 112/343] power: supply: axp288_fuel_gauge: Use acpi_quirk_skip_acpi_ac_and_battery() Date: Tue, 12 Apr 2022 08:28:50 +0200 Message-Id: <20220412062954.625100457@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hans de Goede [ Upstream commit da365db704d290fb4dc4cdbd41f60b0ecec1cc03 ] Normally the native AXP288 fg/charger drivers are preferred but one some devices the ACPI drivers should be used instead. The ACPI battery/ac drivers use the acpi_quirk_skip_acpi_ac_and_battery() helper to determine if they should skip loading because native fuel-gauge/ charger drivers like the AXP288 drivers will be used. The new acpi_quirk_skip_acpi_ac_and_battery() helper includes a list of exceptions for boards where the ACPI drivers should be used instead. Use this new helper to avoid loading on such boards. Note this requires adding a Kconfig dependency on ACPI, this is not a problem because ACPI should be enabled on all boards with an AXP288 PMIC anyways. Signed-off-by: Hans de Goede Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/power/supply/Kconfig | 2 +- drivers/power/supply/axp288_fuel_gauge.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index d7534f12e9ef..5e4a69352811 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -358,7 +358,7 @@ config AXP288_CHARGER =20 config AXP288_FUEL_GAUGE tristate "X-Powers AXP288 Fuel Gauge" - depends on MFD_AXP20X && IIO && IOSF_MBI + depends on MFD_AXP20X && IIO && IOSF_MBI && ACPI help Say yes here to have support for X-Power power management IC (PMIC) Fuel Gauge. The device provides battery statistics and status diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/suppl= y/axp288_fuel_gauge.c index c1da217fdb0e..ce8ffd0a41b5 100644 --- a/drivers/power/supply/axp288_fuel_gauge.c +++ b/drivers/power/supply/axp288_fuel_gauge.c @@ -9,6 +9,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ */ =20 +#include #include #include #include @@ -560,12 +561,6 @@ static const struct dmi_system_id axp288_no_battery_li= st[] =3D { DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"), }, }, - { - /* ECS EF20EA */ - .matches =3D { - DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"), - }, - }, { /* Intel Cherry Trail Compute Stick, Windows version */ .matches =3D { @@ -624,6 +619,13 @@ static int axp288_fuel_gauge_probe(struct platform_dev= ice *pdev) }; unsigned int val; =20 + /* + * Normally the native AXP288 fg/charger drivers are preferred but + * on some devices the ACPI drivers should be used instead. + */ + if (!acpi_quirk_skip_acpi_ac_and_battery()) + return -ENODEV; + if (dmi_check_system(axp288_no_battery_list)) return -ENODEV; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6BFE1C352AA for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353839AbiDLIkd (ORCPT ); Tue, 12 Apr 2022 04:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357222AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF58BF6; Tue, 12 Apr 2022 00:14: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4A8F36171C; Tue, 12 Apr 2022 07:14:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58414C385A5; Tue, 12 Apr 2022 07:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747641; bh=fEaYpuKnP4mDHD7HHYhCWcISb75U1FDjOghhvQZ4igY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQm7l7ASfn8iEAxaUHkF2abXkFrAaqv2vVeUKnKqRRmhjuW+7fxQDVj5VLU54qLoN dHvUZWnCQOXCVqmSYS5efbwb63Z95RGOYV/zoGnCd1DFVqu/K4CysUevh5UsNaaa5f +bxlVM5yPyf41ivAzEWDBXbUZs453rfn/7PyQv+A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Juergen E. Fischer" , "James E.J. Bottomley" , "Martin K. Petersen" , Igor Zhbanov , Randy Dunlap , Sasha Levin Subject: [PATCH 5.17 113/343] scsi: aha152x: Fix aha152x_setup() __setup handler return value Date: Tue, 12 Apr 2022 08:28:51 +0200 Message-Id: <20220412062954.652829312@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Randy Dunlap [ Upstream commit cc8294ec4738d25e2bb2d71f7d82a9bf7f4a157b ] __setup() handlers should return 1 if the command line option is handled and 0 if not (or maybe never return 0; doing so just pollutes init's environment with strings that are not init arguments/parameters). Return 1 from aha152x_setup() to indicate that the boot option has been handled. Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru Link: https://lore.kernel.org/r/20220223000623.5920-1-rdunlap@infradead.org Cc: "Juergen E. Fischer" Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Reported-by: Igor Zhbanov Signed-off-by: Randy Dunlap Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/aha152x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index d17880b57d17..2449b4215b32 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -3375,13 +3375,11 @@ static int __init aha152x_setup(char *str) setup[setup_count].synchronous =3D ints[0] >=3D 6 ? ints[6] : 1; setup[setup_count].delay =3D ints[0] >=3D 7 ? ints[7] : DELAY_DEFAU= LT; setup[setup_count].ext_trans =3D ints[0] >=3D 8 ? ints[8] : 0; - if (ints[0] > 8) { /*}*/ + if (ints[0] > 8) printk(KERN_NOTICE "aha152x: usage: aha152x=3D[,[," "[,[,[,[,[,]]]]= ]]]\n"); - } else { + else setup_count++; - return 0; - } =20 return 1; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 F4177C43219 for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384364AbiDLIl2 (ORCPT ); Tue, 12 Apr 2022 04:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357231AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5E5B01; Tue, 12 Apr 2022 00:14: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 dfw.source.kernel.org (Postfix) with ESMTPS id 142A061708; Tue, 12 Apr 2022 07:14:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23150C385A5; Tue, 12 Apr 2022 07:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747644; bh=AC/lpISE/nCmGE6hGsO4RLyENvs+xPM1kkPjSbokyfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VsfM2dqMOO4SRo64Uc8Ew7UblAr8/qdRhCDDF7Buw8qtGv3MgUDP7+hDUYg79yGA9 ke0LSz1ua4al1hR40LJyyj/R0eunh8BneleQd8jKKoDH92AdDcX8Cxb+eLcxCY47be 4/ieCHlYZL0RjxX60QtSk4YSZEEQrJFzT286w4Rg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qi Liu , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 114/343] scsi: hisi_sas: Free irq vectors in order for v3 HW Date: Tue, 12 Apr 2022 08:28:52 +0200 Message-Id: <20220412062954.681531539@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Qi Liu [ Upstream commit 554fb72ee34f4732c7f694f56c3c6e67790352a0 ] If the driver probe fails to request the channel IRQ or fatal IRQ, the driver will free the IRQ vectors before freeing the IRQs in free_irq(), and this will cause a kernel BUG like this: Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz ------------[ cut here ]------------ kernel BUG at drivers/pci/msi.c:369! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Call trace: free_msi_irqs+0x118/0x13c pci_disable_msi+0xfc/0x120 pci_free_irq_vectors+0x24/0x3c hisi_sas_v3_probe+0x360/0x9d0 [hisi_sas_v3_hw] local_pci_probe+0x44/0xb0 work_for_cpu_fn+0x20/0x34 process_one_work+0x1d0/0x340 worker_thread+0x2e0/0x460 kthread+0x180/0x190 ret_from_fork+0x10/0x20 ---[ end trace b88990335b610c11 ]--- So we use devm_add_action() to control the order in which we free the vectors. Link: https://lore.kernel.org/r/1645703489-87194-4-git-send-email-john.garr= y@huawei.com Signed-off-by: Qi Liu Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v3_hw.c index 70173389f6eb..104ef772b512 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2398,17 +2398,25 @@ static irqreturn_t cq_interrupt_v3_hw(int irq_no, v= oid *p) return IRQ_WAKE_THREAD; } =20 +static void hisi_sas_v3_free_vectors(void *data) +{ + struct pci_dev *pdev =3D data; + + pci_free_irq_vectors(pdev); +} + static int interrupt_preinit_v3_hw(struct hisi_hba *hisi_hba) { int vectors; int max_msi =3D HISI_SAS_MSI_COUNT_V3_HW, min_msi; struct Scsi_Host *shost =3D hisi_hba->shost; + struct pci_dev *pdev =3D hisi_hba->pci_dev; struct irq_affinity desc =3D { .pre_vectors =3D BASE_VECTORS_V3_HW, }; =20 min_msi =3D MIN_AFFINE_VECTORS_V3_HW; - vectors =3D pci_alloc_irq_vectors_affinity(hisi_hba->pci_dev, + vectors =3D pci_alloc_irq_vectors_affinity(pdev, min_msi, max_msi, PCI_IRQ_MSI | PCI_IRQ_AFFINITY, @@ -2420,6 +2428,7 @@ static int interrupt_preinit_v3_hw(struct hisi_hba *h= isi_hba) hisi_hba->cq_nvecs =3D vectors - BASE_VECTORS_V3_HW; shost->nr_hw_queues =3D hisi_hba->cq_nvecs; =20 + devm_add_action(&pdev->dev, hisi_sas_v3_free_vectors, pdev); return 0; } =20 @@ -4769,7 +4778,7 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct = pci_device_id *id) =20 rc =3D scsi_add_host(shost, dev); if (rc) - goto err_out_free_irq_vectors; + goto err_out_debugfs; =20 rc =3D sas_register_ha(sha); if (rc) @@ -4800,8 +4809,6 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct = pci_device_id *id) sas_unregister_ha(sha); err_out_register_ha: scsi_remove_host(shost); -err_out_free_irq_vectors: - pci_free_irq_vectors(pdev); err_out_debugfs: debugfs_exit_v3_hw(hisi_hba); err_out_ha: @@ -4825,7 +4832,6 @@ hisi_sas_v3_destroy_irqs(struct pci_dev *pdev, struct= hisi_hba *hisi_hba) =20 devm_free_irq(&pdev->dev, pci_irq_vector(pdev, nr), cq); } - pci_free_irq_vectors(pdev); } =20 static void hisi_sas_v3_remove(struct pci_dev *pdev) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 D42D3C4167E for ; Tue, 12 Apr 2022 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357680AbiDLJTu (ORCPT ); Tue, 12 Apr 2022 05:19:50 -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 S1357119AbiDLHjr (ORCPT ); Tue, 12 Apr 2022 03:39: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 84E75E03E; Tue, 12 Apr 2022 00:12: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 4741BB81A8F; Tue, 12 Apr 2022 07:12:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6AE6C385A1; Tue, 12 Apr 2022 07:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747535; bh=hazLm5am94HK3azxAnqRUzpau4Gl8Ss7OCk2MIw4hFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQxbFfIX3VKxEFVkh3+q2PVXqzdsC9/HFyQwQsRvOt0fVU+p5Ny3hkZ3oNcNQGIR8 JyrLaNCts3IP9qXltIEpyhe+29JpkuyL7yxLS/PkN/3nDa+QCReFHqy72m+Jh+B4wL u9OsUo9C39z64OtcLZwWwTXNLhwrtKOxxte9leFc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , Qi Liu , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 115/343] scsi: hisi_sas: Limit users changing debugfs BIST count value Date: Tue, 12 Apr 2022 08:28:53 +0200 Message-Id: <20220412062954.709854729@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiang Chen [ Upstream commit 286ce4c65fbdf5eb9d4d5f4e4997c4e32bf1b073 ] Add a file operation for "cnt" file under bist directory, so users can only read "cnt" or clear "cnt" to zero, but cannot randomly modify. Link: https://lore.kernel.org/r/1645703489-87194-6-git-send-email-john.garr= y@huawei.com Signed-off-by: Xiang Chen Signed-off-by: Qi Liu Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 52 +++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v3_hw.c index 104ef772b512..52089538e9de 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3976,6 +3976,54 @@ static const struct file_operations debugfs_bist_phy= _v3_hw_fops =3D { .owner =3D THIS_MODULE, }; =20 +static ssize_t debugfs_bist_cnt_v3_hw_write(struct file *filp, + const char __user *buf, + size_t count, loff_t *ppos) +{ + struct seq_file *m =3D filp->private_data; + struct hisi_hba *hisi_hba =3D m->private; + unsigned int cnt; + int val; + + if (hisi_hba->debugfs_bist_enable) + return -EPERM; + + val =3D kstrtouint_from_user(buf, count, 0, &cnt); + if (val) + return val; + + if (cnt) + return -EINVAL; + + hisi_hba->debugfs_bist_cnt =3D 0; + return count; +} + +static int debugfs_bist_cnt_v3_hw_show(struct seq_file *s, void *p) +{ + struct hisi_hba *hisi_hba =3D s->private; + + seq_printf(s, "%u\n", hisi_hba->debugfs_bist_cnt); + + return 0; +} + +static int debugfs_bist_cnt_v3_hw_open(struct inode *inode, + struct file *filp) +{ + return single_open(filp, debugfs_bist_cnt_v3_hw_show, + inode->i_private); +} + +static const struct file_operations debugfs_bist_cnt_v3_hw_ops =3D { + .open =3D debugfs_bist_cnt_v3_hw_open, + .read =3D seq_read, + .write =3D debugfs_bist_cnt_v3_hw_write, + .llseek =3D seq_lseek, + .release =3D single_release, + .owner =3D THIS_MODULE, +}; + static const struct { int value; char *name; @@ -4613,8 +4661,8 @@ static void debugfs_bist_init_v3_hw(struct hisi_hba *= hisi_hba) debugfs_create_file("phy_id", 0600, hisi_hba->debugfs_bist_dentry, hisi_hba, &debugfs_bist_phy_v3_hw_fops); =20 - debugfs_create_u32("cnt", 0600, hisi_hba->debugfs_bist_dentry, - &hisi_hba->debugfs_bist_cnt); + debugfs_create_file("cnt", 0600, hisi_hba->debugfs_bist_dentry, + hisi_hba, &debugfs_bist_cnt_v3_hw_ops); =20 debugfs_create_file("loopback_mode", 0600, hisi_hba->debugfs_bist_dentry, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C4CBEC43217 for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356375AbiDLJD3 (ORCPT ); Tue, 12 Apr 2022 05:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357123AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39: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 486D9E080; Tue, 12 Apr 2022 00:12: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 03318B81B55; Tue, 12 Apr 2022 07:12:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ABF9C385A1; Tue, 12 Apr 2022 07:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747537; bh=uJjfmRLmfVzd8ksjcEl8BYhQjcPtbCrQav23XF1v1rA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N7kY6gwzctbXDTMOE5Qhog3vxvYg8lwX/3WNaNaWnVvHrMMFImfyDC11Zi4Rvrxd0 TNMgQdjLF2yi/cfoLbQ1k1FF01cJ045XI+99+T/x9C8sepQy0ZmPYWbNGa7LLJ0+A4 4HOhEbA6SFQqMO5xeY5YYyzAD6AiY4oK9CrL9u1c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dust Li , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 116/343] net/smc: correct settings of RMB window update limit Date: Tue, 12 Apr 2022 08:28:54 +0200 Message-Id: <20220412062954.738738746@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Dust Li [ Upstream commit 6bf536eb5c8ca011d1ff57b5c5f7c57ceac06a37 ] rmbe_update_limit is used to limit announcing receive window updating too frequently. RFC7609 request a minimal increase in the window size of 10% of the receive buffer space. But current implementation used: min_t(int, rmbe_size / 10, SOCK_MIN_SNDBUF / 2) and SOCK_MIN_SNDBUF / 2 =3D=3D 2304 Bytes, which is almost always less then 10% of the receive buffer space. This causes the receiver always sending CDC message to update its consumer cursor when it consumes more then 2K of data. And as a result, we may encounter something like "TCP silly window syndrome" when sending 2.5~8K message. This patch fixes this using max(rmbe_size / 10, SOCK_MIN_SNDBUF / 2). With this patch and SMC autocorking enabled, qperf 2K/4K/8K tcp_bw test shows 45%/75%/40% increase in throughput respectively. Signed-off-by: Dust Li Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/smc/smc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index be7d704976ff..f40f6ed0fbdb 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1989,7 +1989,7 @@ static struct smc_buf_desc *smc_buf_get_slot(int comp= ressed_bufsize, */ static inline int smc_rmb_wnd_update_limit(int rmbe_size) { - return min_t(int, rmbe_size / 10, SOCK_MIN_SNDBUF / 2); + return max_t(int, rmbe_size / 10, SOCK_MIN_SNDBUF / 2); } =20 /* map an rmb buf to a link */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BF995C433EF for ; Tue, 12 Apr 2022 09:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357956AbiDLJBO (ORCPT ); Tue, 12 Apr 2022 05:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357127AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB31E096; Tue, 12 Apr 2022 00:12: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 AA84CB81B55; Tue, 12 Apr 2022 07:12:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04A25C385A5; Tue, 12 Apr 2022 07:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747540; bh=f4cy6lBY19D7k4IFU8QzAsLt3NLEQwMDsH8Qum2ngQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYoqn68ottBs/BoTQTkk3BPKV+CUNFyxRFxQqkM1ie9q+uziqDDqlcC06N1GZOGyA MDdz2vXO+8p3x31gT4KsYLJX6YzJmehRT8K2B+faZk+vAguctUBpMcesrMyzvVSNKs 4TWh7UXqXqMfnRjkTSyfOyxqful6HNZKrtR5VmJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.17 117/343] mips: ralink: fix a refcount leak in ill_acc_of_setup() Date: Tue, 12 Apr 2022 08:28:55 +0200 Message-Id: <20220412062954.767196595@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 4a0a1436053b17e50b7c88858fb0824326641793 ] of_node_put(np) needs to be called when pdev =3D=3D NULL. Signed-off-by: Hangyu Hua Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/mips/ralink/ill_acc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/ralink/ill_acc.c b/arch/mips/ralink/ill_acc.c index 115a69fc20ca..f395ae218470 100644 --- a/arch/mips/ralink/ill_acc.c +++ b/arch/mips/ralink/ill_acc.c @@ -61,6 +61,7 @@ static int __init ill_acc_of_setup(void) pdev =3D of_find_device_by_node(np); if (!pdev) { pr_err("%pOFn: failed to lookup pdev\n", np); + of_node_put(np); return -EINVAL; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6A438C4167B for ; Tue, 12 Apr 2022 08:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242430AbiDLInY (ORCPT ); Tue, 12 Apr 2022 04:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357126AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39: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 CF8E6E098; Tue, 12 Apr 2022 00:12: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 ams.source.kernel.org (Postfix) with ESMTPS id 5D8D3B81B55; Tue, 12 Apr 2022 07:12:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACDBCC385A1; Tue, 12 Apr 2022 07:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747543; bh=uzDXKDops8c82OpS66moXmIUpMJ74Q9whaBRRngaBCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhBZ7aYLc0P9tHYLLhMg2Z1LoJ4XCni8sXyD+oH5Ds9HZT4w63dV6W2eGHuIN0n5x 3bL1wjbn3HSNuBprpxFZ8vXra6ASuXKO/2Td0IDtaSqr3HLc/ylq7iO5jgsNOTxbGR q9AismmBNeeSmbqUgRTGEuIJjriOSH9/Xk89Zv9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Keller , Mateusz Palczewski , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.17 118/343] iavf: stop leaking iavf_status as "errno" values Date: Tue, 12 Apr 2022 08:28:56 +0200 Message-Id: <20220412062954.795563604@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Mateusz Palczewski [ Upstream commit bae569d01a1f4929ce28093be80bbbbacbf1b127 ] Several functions in the iAVF core files take status values of the enum iavf_status and convert them into integer values. This leads to confusion as functions return both Linux errno values and status codes intermixed. Reporting status codes as if they were "errno" values can lead to confusion when reviewing error logs. Additionally, it can lead to unexpected behavior if a return value is not interpreted properly. Fix this by introducing iavf_status_to_errno, a switch that explicitly converts from the status codes into an appropriate error value. Also introduce a virtchnl_status_to_errno function for the one case where we were returning both virtchnl status codes and iavf_status codes in the same function. Signed-off-by: Jacob Keller Signed-off-by: Mateusz Palczewski Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/iavf/iavf.h | 5 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 173 +++++++++++++++--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 18 +- 3 files changed, 157 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/= intel/iavf/iavf.h index 4babe4705a55..358a9b3031d5 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -44,6 +44,9 @@ #define DEFAULT_DEBUG_LEVEL_SHIFT 3 #define PFX "iavf: " =20 +int iavf_status_to_errno(enum iavf_status status); +int virtchnl_status_to_errno(enum virtchnl_status_code v_status); + /* VSI state flags shared with common code */ enum iavf_vsi_state_t { __IAVF_VSI_DOWN, @@ -515,7 +518,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter); void iavf_del_vlans(struct iavf_adapter *adapter); void iavf_set_promiscuous(struct iavf_adapter *adapter, int flags); void iavf_request_stats(struct iavf_adapter *adapter); -void iavf_request_reset(struct iavf_adapter *adapter); +int iavf_request_reset(struct iavf_adapter *adapter); void iavf_get_hena(struct iavf_adapter *adapter); void iavf_set_hena(struct iavf_adapter *adapter); void iavf_set_rss_key(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 0e178a0a59c5..d10e9a8e8011 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -51,6 +51,113 @@ MODULE_LICENSE("GPL v2"); static const struct net_device_ops iavf_netdev_ops; struct workqueue_struct *iavf_wq; =20 +int iavf_status_to_errno(enum iavf_status status) +{ + switch (status) { + case IAVF_SUCCESS: + return 0; + case IAVF_ERR_PARAM: + case IAVF_ERR_MAC_TYPE: + case IAVF_ERR_INVALID_MAC_ADDR: + case IAVF_ERR_INVALID_LINK_SETTINGS: + case IAVF_ERR_INVALID_PD_ID: + case IAVF_ERR_INVALID_QP_ID: + case IAVF_ERR_INVALID_CQ_ID: + case IAVF_ERR_INVALID_CEQ_ID: + case IAVF_ERR_INVALID_AEQ_ID: + case IAVF_ERR_INVALID_SIZE: + case IAVF_ERR_INVALID_ARP_INDEX: + case IAVF_ERR_INVALID_FPM_FUNC_ID: + case IAVF_ERR_QP_INVALID_MSG_SIZE: + case IAVF_ERR_INVALID_FRAG_COUNT: + case IAVF_ERR_INVALID_ALIGNMENT: + case IAVF_ERR_INVALID_PUSH_PAGE_INDEX: + case IAVF_ERR_INVALID_IMM_DATA_SIZE: + case IAVF_ERR_INVALID_VF_ID: + case IAVF_ERR_INVALID_HMCFN_ID: + case IAVF_ERR_INVALID_PBLE_INDEX: + case IAVF_ERR_INVALID_SD_INDEX: + case IAVF_ERR_INVALID_PAGE_DESC_INDEX: + case IAVF_ERR_INVALID_SD_TYPE: + case IAVF_ERR_INVALID_HMC_OBJ_INDEX: + case IAVF_ERR_INVALID_HMC_OBJ_COUNT: + case IAVF_ERR_INVALID_SRQ_ARM_LIMIT: + return -EINVAL; + case IAVF_ERR_NVM: + case IAVF_ERR_NVM_CHECKSUM: + case IAVF_ERR_PHY: + case IAVF_ERR_CONFIG: + case IAVF_ERR_UNKNOWN_PHY: + case IAVF_ERR_LINK_SETUP: + case IAVF_ERR_ADAPTER_STOPPED: + case IAVF_ERR_MASTER_REQUESTS_PENDING: + case IAVF_ERR_AUTONEG_NOT_COMPLETE: + case IAVF_ERR_RESET_FAILED: + case IAVF_ERR_BAD_PTR: + case IAVF_ERR_SWFW_SYNC: + case IAVF_ERR_QP_TOOMANY_WRS_POSTED: + case IAVF_ERR_QUEUE_EMPTY: + case IAVF_ERR_FLUSHED_QUEUE: + case IAVF_ERR_OPCODE_MISMATCH: + case IAVF_ERR_CQP_COMPL_ERROR: + case IAVF_ERR_BACKING_PAGE_ERROR: + case IAVF_ERR_NO_PBLCHUNKS_AVAILABLE: + case IAVF_ERR_MEMCPY_FAILED: + case IAVF_ERR_SRQ_ENABLED: + case IAVF_ERR_ADMIN_QUEUE_ERROR: + case IAVF_ERR_ADMIN_QUEUE_FULL: + case IAVF_ERR_BAD_IWARP_CQE: + case IAVF_ERR_NVM_BLANK_MODE: + case IAVF_ERR_PE_DOORBELL_NOT_ENABLED: + case IAVF_ERR_DIAG_TEST_FAILED: + case IAVF_ERR_FIRMWARE_API_VERSION: + case IAVF_ERR_ADMIN_QUEUE_CRITICAL_ERROR: + return -EIO; + case IAVF_ERR_DEVICE_NOT_SUPPORTED: + return -ENODEV; + case IAVF_ERR_NO_AVAILABLE_VSI: + case IAVF_ERR_RING_FULL: + return -ENOSPC; + case IAVF_ERR_NO_MEMORY: + return -ENOMEM; + case IAVF_ERR_TIMEOUT: + case IAVF_ERR_ADMIN_QUEUE_TIMEOUT: + return -ETIMEDOUT; + case IAVF_ERR_NOT_IMPLEMENTED: + case IAVF_NOT_SUPPORTED: + return -EOPNOTSUPP; + case IAVF_ERR_ADMIN_QUEUE_NO_WORK: + return -EALREADY; + case IAVF_ERR_NOT_READY: + return -EBUSY; + case IAVF_ERR_BUF_TOO_SHORT: + return -EMSGSIZE; + } + + return -EIO; +} + +int virtchnl_status_to_errno(enum virtchnl_status_code v_status) +{ + switch (v_status) { + case VIRTCHNL_STATUS_SUCCESS: + return 0; + case VIRTCHNL_STATUS_ERR_PARAM: + case VIRTCHNL_STATUS_ERR_INVALID_VF_ID: + return -EINVAL; + case VIRTCHNL_STATUS_ERR_NO_MEMORY: + return -ENOMEM; + case VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH: + case VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR: + case VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR: + return -EIO; + case VIRTCHNL_STATUS_ERR_NOT_SUPPORTED: + return -EOPNOTSUPP; + } + + return -EIO; +} + /** * iavf_pdev_to_adapter - go from pci_dev to adapter * @pdev: pci_dev pointer @@ -1421,7 +1528,7 @@ static int iavf_config_rss_aq(struct iavf_adapter *ad= apter) struct iavf_aqc_get_set_rss_key_data *rss_key =3D (struct iavf_aqc_get_set_rss_key_data *)adapter->rss_key; struct iavf_hw *hw =3D &adapter->hw; - int ret =3D 0; + enum iavf_status status; =20 if (adapter->current_op !=3D VIRTCHNL_OP_UNKNOWN) { /* bail because we already have a command pending */ @@ -1430,24 +1537,25 @@ static int iavf_config_rss_aq(struct iavf_adapter *= adapter) return -EBUSY; } =20 - ret =3D iavf_aq_set_rss_key(hw, adapter->vsi.id, rss_key); - if (ret) { + status =3D iavf_aq_set_rss_key(hw, adapter->vsi.id, rss_key); + if (status) { dev_err(&adapter->pdev->dev, "Cannot set RSS key, err %s aq_err %s\n", - iavf_stat_str(hw, ret), + iavf_stat_str(hw, status), iavf_aq_str(hw, hw->aq.asq_last_status)); - return ret; + return iavf_status_to_errno(status); =20 } =20 - ret =3D iavf_aq_set_rss_lut(hw, adapter->vsi.id, false, - adapter->rss_lut, adapter->rss_lut_size); - if (ret) { + status =3D iavf_aq_set_rss_lut(hw, adapter->vsi.id, false, + adapter->rss_lut, adapter->rss_lut_size); + if (status) { dev_err(&adapter->pdev->dev, "Cannot set RSS lut, err %s aq_err %s\n", - iavf_stat_str(hw, ret), + iavf_stat_str(hw, status), iavf_aq_str(hw, hw->aq.asq_last_status)); + return iavf_status_to_errno(status); } =20 - return ret; + return 0; =20 } =20 @@ -2003,23 +2111,24 @@ static void iavf_startup(struct iavf_adapter *adapt= er) { struct pci_dev *pdev =3D adapter->pdev; struct iavf_hw *hw =3D &adapter->hw; - int err; + enum iavf_status status; + int ret; =20 WARN_ON(adapter->state !=3D __IAVF_STARTUP); =20 /* driver loaded, probe complete */ adapter->flags &=3D ~IAVF_FLAG_PF_COMMS_FAILED; adapter->flags &=3D ~IAVF_FLAG_RESET_PENDING; - err =3D iavf_set_mac_type(hw); - if (err) { - dev_err(&pdev->dev, "Failed to set MAC type (%d)\n", err); + status =3D iavf_set_mac_type(hw); + if (status) { + dev_err(&pdev->dev, "Failed to set MAC type (%d)\n", status); goto err; } =20 - err =3D iavf_check_reset_complete(hw); - if (err) { + ret =3D iavf_check_reset_complete(hw); + if (ret) { dev_info(&pdev->dev, "Device is still in reset (%d), retrying\n", - err); + ret); goto err; } hw->aq.num_arq_entries =3D IAVF_AQ_LEN; @@ -2027,14 +2136,15 @@ static void iavf_startup(struct iavf_adapter *adapt= er) hw->aq.arq_buf_size =3D IAVF_MAX_AQ_BUF_SIZE; hw->aq.asq_buf_size =3D IAVF_MAX_AQ_BUF_SIZE; =20 - err =3D iavf_init_adminq(hw); - if (err) { - dev_err(&pdev->dev, "Failed to init Admin Queue (%d)\n", err); + status =3D iavf_init_adminq(hw); + if (status) { + dev_err(&pdev->dev, "Failed to init Admin Queue (%d)\n", + status); goto err; } - err =3D iavf_send_api_ver(adapter); - if (err) { - dev_err(&pdev->dev, "Unable to send to PF (%d)\n", err); + ret =3D iavf_send_api_ver(adapter); + if (ret) { + dev_err(&pdev->dev, "Unable to send to PF (%d)\n", ret); iavf_shutdown_adminq(hw); goto err; } @@ -2070,7 +2180,7 @@ static void iavf_init_version_check(struct iavf_adapt= er *adapter) /* aq msg sent, awaiting reply */ err =3D iavf_verify_api_ver(adapter); if (err) { - if (err =3D=3D IAVF_ERR_ADMIN_QUEUE_NO_WORK) + if (err =3D=3D -EALREADY) err =3D iavf_send_api_ver(adapter); else dev_err(&pdev->dev, "Unsupported PF API version %d.%d, expected %d.%d\n= ", @@ -2171,11 +2281,11 @@ static void iavf_init_get_resources(struct iavf_ada= pter *adapter) } } err =3D iavf_get_vf_config(adapter); - if (err =3D=3D IAVF_ERR_ADMIN_QUEUE_NO_WORK) { + if (err =3D=3D -EALREADY) { err =3D iavf_send_vf_config_msg(adapter); goto err_alloc; - } else if (err =3D=3D IAVF_ERR_PARAM) { - /* We only get ERR_PARAM if the device is in a very bad + } else if (err =3D=3D -EINVAL) { + /* We only get -EINVAL if the device is in a very bad * state or if we've been disabled for previous bad * behavior. Either way, we're done now. */ @@ -2626,6 +2736,7 @@ static void iavf_reset_task(struct work_struct *work) struct iavf_hw *hw =3D &adapter->hw; struct iavf_mac_filter *f, *ftmp; struct iavf_cloud_filter *cf; + enum iavf_status status; u32 reg_val; int i =3D 0, err; bool running; @@ -2727,10 +2838,12 @@ static void iavf_reset_task(struct work_struct *wor= k) /* kill and reinit the admin queue */ iavf_shutdown_adminq(hw); adapter->current_op =3D VIRTCHNL_OP_UNKNOWN; - err =3D iavf_init_adminq(hw); - if (err) + status =3D iavf_init_adminq(hw); + if (status) { dev_info(&adapter->pdev->dev, "Failed to init adminq: %d\n", - err); + status); + goto reset_err; + } adapter->aq_required =3D 0; =20 if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) || diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/= ethernet/intel/iavf/iavf_virtchnl.c index 5263cefe46f5..b8c5837f8b50 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -22,17 +22,17 @@ static int iavf_send_pf_msg(struct iavf_adapter *adapte= r, enum virtchnl_ops op, u8 *msg, u16 len) { struct iavf_hw *hw =3D &adapter->hw; - enum iavf_status err; + enum iavf_status status; =20 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) return 0; /* nothing to see here, move along */ =20 - err =3D iavf_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL); - if (err) - dev_dbg(&adapter->pdev->dev, "Unable to send opcode %d to PF, err %s, aq= _err %s\n", - op, iavf_stat_str(hw, err), + status =3D iavf_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL); + if (status) + dev_dbg(&adapter->pdev->dev, "Unable to send opcode %d to PF, status %s,= aq_err %s\n", + op, iavf_stat_str(hw, status), iavf_aq_str(hw, hw->aq.asq_last_status)); - return err; + return iavf_status_to_errno(status); } =20 /** @@ -1827,11 +1827,13 @@ void iavf_del_adv_rss_cfg(struct iavf_adapter *adap= ter) * * Request that the PF reset this VF. No response is expected. **/ -void iavf_request_reset(struct iavf_adapter *adapter) +int iavf_request_reset(struct iavf_adapter *adapter) { + int err; /* Don't check CURRENT_OP - this is always higher priority */ - iavf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0); + err =3D iavf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0); adapter->current_op =3D VIRTCHNL_OP_UNKNOWN; + return err; } =20 /** --=20 2.35.1 From nobody Thu May 14 08:08:21 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 80686C433F5 for ; Tue, 12 Apr 2022 08:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345183AbiDLIng (ORCPT ); Tue, 12 Apr 2022 04:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357124AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7DEBE0C9; Tue, 12 Apr 2022 00:12: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 531AD61701; Tue, 12 Apr 2022 07:12:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66537C385A5; Tue, 12 Apr 2022 07:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747545; bh=pVMto6fjjwueK9ViwPV90DDETbSPUIeOI1EqV4D79rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yPFvxgi3efw8Fm2ugpkp+DTVO9y8kxWe03UqOREfVtFJlnBZZMPIxcPKFSBkiO/0z PCgaQdKsZnKV6hp1/ebPcw9I9MDm5zuW7g2jAC0UHgcaDXKq4bPgsrIv5akH/u5Kh+ qCLTMxNrYxCPLXeMWy37DWa+vvf3g0FeaKqCz/vk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Leonardo=20M=C3=B6rlein?= , Sven Eckelmann , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 119/343] macvtap: advertise link netns via netlink Date: Tue, 12 Apr 2022 08:28:57 +0200 Message-Id: <20220412062954.823238910@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sven Eckelmann [ Upstream commit a02192151b7dbf855084c38dca380d77c7658353 ] Assign rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is added to rtnetlink messages. This fixes iproute2 which otherwise resolved the link interface to an interface in the wrong namespace. Test commands: ip netns add nst ip link add dummy0 type dummy ip link add link macvtap0 link dummy0 type macvtap ip link set macvtap0 netns nst ip -netns nst link show macvtap0 Before: 10: macvtap0@gre0: mtu 1500 qdisc noop state DOWN m= ode DEFAULT group default qlen 500 link/ether 5e:8f:ae:1d:60:50 brd ff:ff:ff:ff:ff:ff After: 10: macvtap0@if2: mtu 1500 qdisc noop state DOWN mo= de DEFAULT group default qlen 500 link/ether 5e:8f:ae:1d:60:50 brd ff:ff:ff:ff:ff:ff link-netnsid 0 Reported-by: Leonardo M=C3=B6rlein Signed-off-by: Sven Eckelmann Link: https://lore.kernel.org/r/20220228003240.1337426-1-sven@narfation.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/macvtap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 6b12902a803f..cecf8c63096c 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -133,11 +133,17 @@ static void macvtap_setup(struct net_device *dev) dev->tx_queue_len =3D TUN_READQ_SIZE; } =20 +static struct net *macvtap_link_net(const struct net_device *dev) +{ + return dev_net(macvlan_dev_real_dev(dev)); +} + static struct rtnl_link_ops macvtap_link_ops __read_mostly =3D { .kind =3D "macvtap", .setup =3D macvtap_setup, .newlink =3D macvtap_newlink, .dellink =3D macvtap_dellink, + .get_link_net =3D macvtap_link_net, .priv_size =3D sizeof(struct macvtap_dev), }; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 82A74C4332F for ; Tue, 12 Apr 2022 08:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345015AbiDLIm4 (ORCPT ); Tue, 12 Apr 2022 04:42:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357125AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -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 58BD8E00A; Tue, 12 Apr 2022 00:12: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 E933A61708; Tue, 12 Apr 2022 07:12:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08E9DC385A1; Tue, 12 Apr 2022 07:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747548; bh=58NZpBGE/MdScoZVVTaWzcGrj8gsOfoLzLtXdcoy4iM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+1jCzdlrrQwiNCVCZeWXslZC5cuCoqpkoQSzOmcojymYDeoCZdDnE+Vj/OifdD1W X5yYbeU6p3Vbf6dC9fB7sb6XxVn4PZf9RFPptE8fb9W0IMr2wmjQy+oieJABUOl2Me eVZSeJwq7kHT3NpVUtfCtIAnFEU4xEPxdbmVTvcQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Pearson , Hans de Goede , Sasha Levin Subject: [PATCH 5.17 120/343] platform/x86: thinkpad_acpi: Add dual fan probe Date: Tue, 12 Apr 2022 08:28:58 +0200 Message-Id: <20220412062954.851180854@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Mark Pearson [ Upstream commit bf779aaf56ea23864e39e9862b3b3a8436236e07 ] Instead of having quirks for systems that have a second fan it would be nice to detect this setup. Unfortunately, confirmed by the Lenovo FW team, there is no way to retrieve this information from the EC or BIOS. Recommendation was to attempt to read the fan and if successful then assume a 2nd fan is present. The fans are also supposed to spin up on boot for some time, so in theory we could check for a speed > 0. In testing this seems to hold true but as I couldn't test on all platforms I've avoided implementing this. It also breaks for the corner case where you load the module once the fans are idle. Tested on P1G4, P1G3, X1C9 and T14 (no fans) and it works correctly. For the platforms with dual fans where it was confirmed to work I have removed the quirks. Potentially this could be done for all platforms but I've left untested platforms in for now. On these platforms the fans will be enabled and then detected - so no impact. Signed-off-by: Mark Pearson Link: https://lore.kernel.org/r/20220222185137.4325-1-markpearson@lenovo.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/platform/x86/thinkpad_acpi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index 3424b080db77..3fb8cda31eb9 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -8699,10 +8699,7 @@ static const struct tpacpi_quirk fan_quirk_table[] _= _initconst =3D { TPACPI_Q_LNV3('N', '2', 'N', TPACPI_FAN_2CTL), /* P53 / P73 */ TPACPI_Q_LNV3('N', '2', 'E', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (1st ge= n) */ TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (2nd ge= n) */ - TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (3nd ge= n) */ - TPACPI_Q_LNV3('N', '4', '0', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (4nd ge= n) */ TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL), /* P15 (1st gen) / P15v (1= st gen) */ - TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL), /* X1 Carbon (9th gen) */ TPACPI_Q_LNV3('N', '3', '7', TPACPI_FAN_2CTL), /* T15g (2nd gen) */ TPACPI_Q_LNV3('N', '1', 'O', TPACPI_FAN_NOFAN), /* X1 Tablet (2nd gen) */ }; @@ -8746,6 +8743,9 @@ static int __init fan_init(struct ibm_init_struct *ii= bm) * ThinkPad ECs supports the fan control register */ if (likely(acpi_ec_read(fan_status_offset, &fan_control_initial_status))) { + int res; + unsigned int speed; + fan_status_access_mode =3D TPACPI_FAN_RD_TPEC; if (quirks & TPACPI_FAN_Q1) fan_quirk1_setup(); @@ -8758,6 +8758,15 @@ static int __init fan_init(struct ibm_init_struct *i= ibm) tp_features.second_fan_ctl =3D 1; pr_info("secondary fan control enabled\n"); } + /* Try and probe the 2nd fan */ + res =3D fan2_get_speed(&speed); + if (res >=3D 0) { + /* It responded - so let's assume it's there */ + tp_features.second_fan =3D 1; + tp_features.second_fan_ctl =3D 1; + pr_info("secondary fan control detected & enabled\n"); + } + } else { pr_err("ThinkPad ACPI EC access misbehaving, fan status and control una= vailable\n"); return -ENODEV; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2CF9DC433FE for ; Tue, 12 Apr 2022 08:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbiDLInM (ORCPT ); Tue, 12 Apr 2022 04:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357129AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5E8FE0EB; Tue, 12 Apr 2022 00:12: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 8DC5DB81B4F; Tue, 12 Apr 2022 07:12:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4465C385A1; Tue, 12 Apr 2022 07:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747551; bh=eM3zSXnaKtt3m9HyT5kgK2aDOmYWDuK0rx7nb8xNlD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMCc+9ahUQKpMS05STeAz763vj2PWQ1YlrSEb4dBgf1//tFI/x1umKtNFyHHy06pQ 4KBX6C7F7aZe9/PfcW/Z7QY99LRMrKHPr2DNzA53pQf/S/d22XpSiZ/SFBL7IFuqEE ZgSJOwzT29Lp7rIRUHsYbY+rQWGSxnlhq2fVwb+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Jason Wang , Harold Huang , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 121/343] tuntap: add sanity checks about msg_controllen in sendmsg Date: Tue, 12 Apr 2022 08:28:59 +0200 Message-Id: <20220412062954.878973078@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Harold Huang [ Upstream commit 74a335a07a17d131b9263bfdbdcb5e40673ca9ca ] In patch [1], tun_msg_ctl was added to allow pass batched xdp buffers to tun_sendmsg. Although we donot use msg_controllen in this path, we should check msg_controllen to make sure the caller pass a valid msg_ctl. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/com= mit/?id=3Dfe8dd45bb7556246c6b76277b1ba4296c91c2505 Reported-by: Eric Dumazet Suggested-by: Jason Wang Signed-off-by: Harold Huang Acked-by: Jason Wang Link: https://lore.kernel.org/r/20220303022441.383865-1-baymaxhuang@gmail.c= om Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/tap.c | 3 ++- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 8e3a28ba6b28..ba2ef5437e16 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -1198,7 +1198,8 @@ static int tap_sendmsg(struct socket *sock, struct ms= ghdr *m, struct xdp_buff *xdp; int i; =20 - if (ctl && (ctl->type =3D=3D TUN_MSG_PTR)) { + if (m->msg_controllen =3D=3D sizeof(struct tun_msg_ctl) && + ctl && ctl->type =3D=3D TUN_MSG_PTR) { for (i =3D 0; i < ctl->num; i++) { xdp =3D &((struct xdp_buff *)ctl->ptr)[i]; tap_get_user_xdp(q, xdp); diff --git a/drivers/net/tun.c b/drivers/net/tun.c index fed85447701a..de999e0fedbc 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2489,7 +2489,8 @@ static int tun_sendmsg(struct socket *sock, struct ms= ghdr *m, size_t total_len) if (!tun) return -EBADFD; =20 - if (ctl && (ctl->type =3D=3D TUN_MSG_PTR)) { + if (m->msg_controllen =3D=3D sizeof(struct tun_msg_ctl) && + ctl && ctl->type =3D=3D TUN_MSG_PTR) { struct tun_page tpage; int n =3D ctl->num; int flush =3D 0; diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 28ef323882fb..792ab5f23647 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -473,6 +473,7 @@ static void vhost_tx_batch(struct vhost_net *net, goto signal_used; =20 msghdr->msg_control =3D &ctl; + msghdr->msg_controllen =3D sizeof(ctl); err =3D sock->ops->sendmsg(sock, msghdr, 0); if (unlikely(err < 0)) { vq_err(&nvq->vq, "Fail to batch sending packets\n"); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 0A946C433F5 for ; Tue, 12 Apr 2022 09:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355920AbiDLJAw (ORCPT ); Tue, 12 Apr 2022 05:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357133AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E606E0ED; Tue, 12 Apr 2022 00:12: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 BF3FC61701; Tue, 12 Apr 2022 07:12:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD63FC385A8; Tue, 12 Apr 2022 07:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747554; bh=uI2XgojJVRs/M3pnMPo98r1Z61W5OShYvXRzR0APpwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cp7rxEM4xb3iEOJNMu7B7r0Y0p4BWvVGRcNvmPDcxTzoGR6T1LrL93b4gbGYbIxyK 1pc445j9KrbCPOafqAVsGoWa1AogEjIeOzF3RtgsaciaiKE+sZ2vBLz0DF/XIq6uzD EbcjW0NIO21aZ083fxjVrpvTV6BkwqzpNbBlhd6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Wang , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.17 122/343] Bluetooth: mediatek: fix the conflict between mtk and msft vendor event Date: Tue, 12 Apr 2022 08:29:00 +0200 Message-Id: <20220412062954.907253389@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sean Wang [ Upstream commit e4412654e260842e1a94ffe0d4026e8a6fd34246 ] There is a conflict between MediaTek wmt event and msft vendor extension logic in the core layer since 145373cb1b1f ("Bluetooth: Add framework for Microsoft vendor extension") was introduced because we changed the type of mediatek wmt event to the type of msft vendor event in the driver. But the purpose we reported mediatek event to the core layer is for the diagnostic purpose with that we are able to see the full packet trace via monitoring socket with btmon. Thus, it is harmless we keep the original type of mediatek vendor event here to avoid breaking the msft extension function especially they can be supported by Mediatek chipset like MT7921 , MT7922 devices and future devices. Signed-off-by: Sean Wang Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/bluetooth/btmtk.h | 1 + drivers/bluetooth/btmtksdio.c | 9 +-------- drivers/bluetooth/btusb.c | 8 -------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h index 6e7b0c7567c0..0defa68bc2ce 100644 --- a/drivers/bluetooth/btmtk.h +++ b/drivers/bluetooth/btmtk.h @@ -5,6 +5,7 @@ #define FIRMWARE_MT7668 "mediatek/mt7668pr2h.bin" #define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin" =20 +#define HCI_EV_WMT 0xe4 #define HCI_WMT_MAX_EVENT_SIZE 64 =20 #define BTMTK_WMT_REG_READ 0x2 diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index 9b868f187316..ecf29cfa7d79 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -370,13 +370,6 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, = struct sk_buff *skb) struct hci_event_hdr *hdr =3D (void *)skb->data; int err; =20 - /* Fix up the vendor event id with 0xff for vendor specific instead - * of 0xe4 so that event send via monitoring socket can be parsed - * properly. - */ - if (hdr->evt =3D=3D 0xe4) - hdr->evt =3D HCI_EV_VENDOR; - /* When someone waits for the WMT event, the skb is being cloned * and being processed the events from there then. */ @@ -392,7 +385,7 @@ static int btmtksdio_recv_event(struct hci_dev *hdev, s= truct sk_buff *skb) if (err < 0) goto err_free_skb; =20 - if (hdr->evt =3D=3D HCI_EV_VENDOR) { + if (hdr->evt =3D=3D HCI_EV_WMT) { if (test_and_clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state)) { /* Barrier to sync with other CPUs */ diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 2afbd87d77c9..42234d5f602d 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2254,7 +2254,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb) { struct hci_dev *hdev =3D urb->context; struct btusb_data *data =3D hci_get_drvdata(hdev); - struct hci_event_hdr *hdr; struct sk_buff *skb; int err; =20 @@ -2274,13 +2273,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb) hci_skb_pkt_type(skb) =3D HCI_EVENT_PKT; skb_put_data(skb, urb->transfer_buffer, urb->actual_length); =20 - hdr =3D (void *)skb->data; - /* Fix up the vendor event id with 0xff for vendor specific - * instead of 0xe4 so that event send via monitoring socket can - * be parsed properly. - */ - hdr->evt =3D 0xff; - /* When someone waits for the WMT event, the skb is being cloned * and being processed the events from there then. */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A8754C433F5 for ; Tue, 12 Apr 2022 09:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357573AbiDLJBC (ORCPT ); Tue, 12 Apr 2022 05:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357132AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F12FD31; Tue, 12 Apr 2022 00:12: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 3A147B81B55; Tue, 12 Apr 2022 07:12:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 869B0C385A1; Tue, 12 Apr 2022 07:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747556; bh=5NTmI6cF9YlOd3EfQBumtiJWmNT4gp1nOCiCo3LgUOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2qK2JZk0NufA0hFxJ5KW+mkcBCFlYqedLfIN30xSEbewJiqvVoYrsOB0yD2zACrB4 1IFU2rogHRkqpO0MyAQNCfmIc3ThxsF7cERGMEgIy4hnj8ZEAsvVUwJeRVjYsJasu2 rKdybTYx6XY2Hn3+gYfiWX/TwzptEMnz8zN1nxd8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.17 123/343] Bluetooth: Fix not checking for valid hdev on bt_dev_{info,warn,err,dbg} Date: Tue, 12 Apr 2022 08:29:01 +0200 Message-Id: <20220412062954.935795098@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Luiz Augusto von Dentz [ Upstream commit 9b392e0e0b6d026da5a62bb79a08f32e27af858e ] This fixes attemting to print hdev->name directly which causes them to print an error: kernel: read_version:367: (efault): sock 000000006a3008f2 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/net/bluetooth/bluetooth.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/blue= tooth.h index a647e5fabdbd..2aa5e95808a5 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -204,19 +204,21 @@ void bt_err_ratelimited(const char *fmt, ...); #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) #endif =20 +#define bt_dev_name(hdev) ((hdev) ? (hdev)->name : "null") + #define bt_dev_info(hdev, fmt, ...) \ - BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) #define bt_dev_warn(hdev, fmt, ...) \ - BT_WARN("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) #define bt_dev_err(hdev, fmt, ...) \ - BT_ERR("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_ERR("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) #define bt_dev_dbg(hdev, fmt, ...) \ - BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) =20 #define bt_dev_warn_ratelimited(hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) #define bt_dev_err_ratelimited(hdev, fmt, ...) \ - bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__) + bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) =20 /* Connection and socket states */ enum { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A5F63C4332F for ; Tue, 12 Apr 2022 09:00:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345940AbiDLJA0 (ORCPT ); Tue, 12 Apr 2022 05:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357134AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -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 901E611A0B; Tue, 12 Apr 2022 00:12: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 2CCE46171D; Tue, 12 Apr 2022 07:12:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CADFC385A5; Tue, 12 Apr 2022 07:12:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747559; bh=+kEf3DBHo2kVE4kTgh3KWbV87GbTuKgz+6MwloITBMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZ9rVYxpILP8w5YVdMYifGs8w4iJHRvE2vpuTgvJYCx1u2ckORkGjHS/Y9yjMf2/N hVqCSHYnSW1167ZiKlOa1LU2iVPFNIySZwmRTBgK3S8NtyOpOyAXb3SNb+HmSnwigk dOBFCtV6ymxwnSIxrttbzu2Yw22npRMOSoalImkw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeal Robot , "Minghao Chi (CGEL ZTE)" , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.17 124/343] Bluetooth: use memset avoid memory leaks Date: Tue, 12 Apr 2022 08:29:02 +0200 Message-Id: <20220412062954.964230937@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Minghao Chi (CGEL ZTE) [ Upstream commit d3715b2333e9a21692ba16ef8645eda584a9515d ] Use memset to initialize structs to prevent memory leaks in l2cap_ecred_connect Reported-by: Zeal Robot Signed-off-by: Minghao Chi (CGEL ZTE) Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/bluetooth/l2cap_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index e817ff0607a0..8df99c07f272 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1436,6 +1436,7 @@ static void l2cap_ecred_connect(struct l2cap_chan *ch= an) =20 l2cap_ecred_init(chan, 0); =20 + memset(&data, 0, sizeof(data)); data.pdu.req.psm =3D chan->psm; data.pdu.req.mtu =3D cpu_to_le16(chan->imtu); data.pdu.req.mps =3D cpu_to_le16(chan->mps); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6858BC433FE for ; Tue, 12 Apr 2022 08:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385076AbiDLImt (ORCPT ); Tue, 12 Apr 2022 04:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357137AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39: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 B9A0412639; Tue, 12 Apr 2022 00:12: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 6F4EEB81895; Tue, 12 Apr 2022 07:12:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2C8BC385A1; Tue, 12 Apr 2022 07:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747565; bh=D395o5bGU/NH15icxNw1+v+DkBD0CVO/J/ItItHyemY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tu0bTUqRLEPyJV+LrtGesJnv1c7S1IWPJ8/1MN5IlSrBn/oHRx4k/KlOgVQ8iIJyz mMVkoDQqCWwEoritY1arPmrh+anfMuzsshOp5o3j7bfIH9qZWAkM2sBe3vUKGRSBKo Zx+EQVXqEmiqaLhyUjZRQAifkP5XTfIrQmyPCPng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Winegarden , Pavan Chebbi , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 125/343] bnxt_en: Eliminate unintended link toggle during FW reset Date: Tue, 12 Apr 2022 08:29:03 +0200 Message-Id: <20220412062954.992335228@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael Chan [ Upstream commit 7c492a2530c1f05441da541307c2534230dfd59b ] If the flow control settings have been changed, a subsequent FW reset may cause the ethernet link to toggle unnecessarily. This link toggle will increase the down time by a few seconds. The problem is caused by bnxt_update_phy_setting() detecting a false mismatch in the flow control settings between the stored software settings and the current FW settings after the FW reset. This mismatch is caused by the AUTONEG bit added to link_info->req_flow_ctrl in an inconsistent way in bnxt_set_pauseparam() in autoneg mode. The AUTONEG bit should not be added to link_info->req_flow_ctrl. Reviewed-by: Colin Winegarden Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/ne= t/ethernet/broadcom/bnxt/bnxt_ethtool.c index 8aaa2335f848..f09b04556c32 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -2101,9 +2101,7 @@ static int bnxt_set_pauseparam(struct net_device *dev, } =20 link_info->autoneg |=3D BNXT_AUTONEG_FLOW_CTRL; - if (bp->hwrm_spec_code >=3D 0x10201) - link_info->req_flow_ctrl =3D - PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE; + link_info->req_flow_ctrl =3D 0; } else { /* when transition from auto pause to force pause, * force a link change --=20 2.35.1 From nobody Thu May 14 08:08:21 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 703D9C433F5 for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384161AbiDLIjZ (ORCPT ); Tue, 12 Apr 2022 04:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357138AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A469F12631; Tue, 12 Apr 2022 00:12: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 4A109B81B61; Tue, 12 Apr 2022 07:12:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88D0CC385A1; Tue, 12 Apr 2022 07:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747567; bh=rQ1sIUJmPcKMjONAfGVjnlPTe+lzGwpPriP4zODIReU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=svCyxHtKa16aMIe2y72po6VKZCHV0vTaa+g9NDI+sCOzurt3xPza8d2BEFUs0XZnS Elk7xDsSFIE91+02TS2vqQjxHE1sjGeqM5vxsgORDsonY+rGwWAsMkUz4nE5uyyWcU uf7BWwF94jVGIou3QiYaH1mgzfP/0SmLNsIiVoPc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Chen , Lorenzo Pieralisi , Kishon Vijay Abraham I , Sasha Levin Subject: [PATCH 5.17 126/343] PCI: endpoint: Fix misused goto label Date: Tue, 12 Apr 2022 08:29:04 +0200 Message-Id: <20220412062955.021555822@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Li Chen [ Upstream commit bf8d87c076f55b8b4dfdb6bc6c6b6dc0c2ccb487 ] Fix a misused goto label jump since that can result in a memory leak. Link: https://lore.kernel.org/r/17e7b9b9ee6.c6d9c6a02564.454538841740274232= 6@zohomail.com Signed-off-by: Li Chen Signed-off-by: Lorenzo Pieralisi Acked-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/en= dpoint/functions/pci-epf-test.c index c7e45633beaf..5b833f00e980 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -451,7 +451,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_= test) if (!epf_test->dma_supported) { dev_err(dev, "Cannot transfer data using DMA\n"); ret =3D -EINVAL; - goto err_map_addr; + goto err_dma_map; } =20 src_phys_addr =3D dma_map_single(dma_dev, buf, reg->size, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7DDC1C433EF for ; Tue, 12 Apr 2022 08:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385029AbiDLImw (ORCPT ); Tue, 12 Apr 2022 04:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357140AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4658F12745; Tue, 12 Apr 2022 00:12: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 EFC16B81B40; Tue, 12 Apr 2022 07:12:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45CEAC385A5; Tue, 12 Apr 2022 07:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747570; bh=3mqLrVOoC/oN+O05pbj3f0xUloAMzNFYHVq/bqvXAmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lao3SB9MGl2DBw1Pa7tfhnIGxeWrZK4t9FGE53+mV1p9KDX8W2c2sk5m0FB1mwQYv EIyjsqBKfQpEiAJsDVFi4n5bjW/cF09WIvDZex0Ko8hMD0ZJLU2EP0tjemzFRzo/ao 2YUSSazjeayY9Lcdab1t4Lh6icSP/MDYvHdwCDQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Lobakin , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.17 127/343] MIPS: fix fortify panic when copying asm exception handlers Date: Tue, 12 Apr 2022 08:29:05 +0200 Message-Id: <20220412062955.050353309@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Lobakin [ Upstream commit d17b66417308996e7e64b270a3c7f3c1fbd4cfc8 ] With KCFLAGS=3D"-O3", I was able to trigger a fortify-source memcpy() overflow panic on set_vi_srs_handler(). Although O3 level is not supported in the mainline, under some conditions that may've happened with any optimization settings, it's just a matter of inlining luck. The panic itself is correct, more precisely, 50/50 false-positive and not at the same time. >From the one side, no real overflow happens. Exception handler defined in asm just gets copied to some reserved places in the memory. But the reason behind is that C code refers to that exception handler declares it as `char`, i.e. something of 1 byte length. It's obvious that the asm function itself is way more than 1 byte, so fortify logics thought we are going to past the symbol declared. The standard way to refer to asm symbols from C code which is not supposed to be called from C is to declare them as `extern const u8[]`. This is fully correct from any point of view, as any code itself is just a bunch of bytes (including 0 as it is for syms like _stext/_etext/etc.), and the exact size is not known at the moment of compilation. Adjust the type of the except_vec_vi_*() and related variables. Make set_handler() take `const` as a second argument to avoid cast-away warnings and give a little more room for optimization. Signed-off-by: Alexander Lobakin Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/mips/include/asm/setup.h | 2 +- arch/mips/kernel/traps.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h index bb36a400203d..8c56b862fd9c 100644 --- a/arch/mips/include/asm/setup.h +++ b/arch/mips/include/asm/setup.h @@ -16,7 +16,7 @@ static inline void setup_8250_early_printk_port(unsigned = long base, unsigned int reg_shift, unsigned int timeout) {} #endif =20 -extern void set_handler(unsigned long offset, void *addr, unsigned long le= n); +void set_handler(unsigned long offset, const void *addr, unsigned long len= ); extern void set_uncached_handler(unsigned long offset, void *addr, unsigne= d long len); =20 typedef void (*vi_handler_t)(void); diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index a486486b2355..246c6a6b0261 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2091,19 +2091,19 @@ static void *set_vi_srs_handler(int n, vi_handler_t= addr, int srs) * If no shadow set is selected then use the default handler * that does normal register saving and standard interrupt exit */ - extern char except_vec_vi, except_vec_vi_lui; - extern char except_vec_vi_ori, except_vec_vi_end; - extern char rollback_except_vec_vi; - char *vec_start =3D using_rollback_handler() ? - &rollback_except_vec_vi : &except_vec_vi; + extern const u8 except_vec_vi[], except_vec_vi_lui[]; + extern const u8 except_vec_vi_ori[], except_vec_vi_end[]; + extern const u8 rollback_except_vec_vi[]; + const u8 *vec_start =3D using_rollback_handler() ? + rollback_except_vec_vi : except_vec_vi; #if defined(CONFIG_CPU_MICROMIPS) || defined(CONFIG_CPU_BIG_ENDIAN) - const int lui_offset =3D &except_vec_vi_lui - vec_start + 2; - const int ori_offset =3D &except_vec_vi_ori - vec_start + 2; + const int lui_offset =3D except_vec_vi_lui - vec_start + 2; + const int ori_offset =3D except_vec_vi_ori - vec_start + 2; #else - const int lui_offset =3D &except_vec_vi_lui - vec_start; - const int ori_offset =3D &except_vec_vi_ori - vec_start; + const int lui_offset =3D except_vec_vi_lui - vec_start; + const int ori_offset =3D except_vec_vi_ori - vec_start; #endif - const int handler_len =3D &except_vec_vi_end - vec_start; + const int handler_len =3D except_vec_vi_end - vec_start; =20 if (handler_len > VECTORSPACING) { /* @@ -2311,7 +2311,7 @@ void per_cpu_trap_init(bool is_boot_cpu) } =20 /* Install CPU exception handler */ -void set_handler(unsigned long offset, void *addr, unsigned long size) +void set_handler(unsigned long offset, const void *addr, unsigned long siz= e) { #ifdef CONFIG_CPU_MICROMIPS memcpy((void *)(ebase + offset), ((unsigned char *)addr - 1), size); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 AF491C4332F for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343655AbiDLJDG (ORCPT ); Tue, 12 Apr 2022 05:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357141AbiDLHjs (ORCPT ); Tue, 12 Apr 2022 03:39:48 -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 63042FD38; Tue, 12 Apr 2022 00:12: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 dfw.source.kernel.org (Postfix) with ESMTPS id DBAC06153F; Tue, 12 Apr 2022 07:12:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F01E6C385A1; Tue, 12 Apr 2022 07:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747573; bh=P9339kzxSF3vWnhasGJ8BLgcj+pm607be6iydjNTHqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRInyC0O9oR19/y3S8GAnXLyBD5nRifESNtX9IsfO1ut0kylyZjdzICHBKQHftaNC /7iDmciHBnaRje5eF28Y7MYAmd06FnP/pnRseFWPZPIe5vxCeP2Nu3wBSC0WqzOn0b VW/BmlJy8p/Vn8rWu5ApN03i93jRMZuxiQO3oRoM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , Christophe Leroy , Michael Ellerman , Sasha Levin , Peter Zijlstra Subject: [PATCH 5.17 128/343] powerpc/code-patching: Pre-map patch area Date: Tue, 12 Apr 2022 08:29:06 +0200 Message-Id: <20220412062955.078609639@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael Ellerman [ Upstream commit 591b4b268435f00d2f0b81f786c2c7bd5ef66416 ] Paul reported a warning with DEBUG_ATOMIC_SLEEP=3Dy: BUG: sleeping function called from invalid context at include/linux/sched= /mm.h:256 in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper/0 preempt_count: 0, expected: 0 ... Call Trace: dump_stack_lvl+0xa0/0xec (unreliable) __might_resched+0x2f4/0x310 kmem_cache_alloc+0x220/0x4b0 __pud_alloc+0x74/0x1d0 hash__map_kernel_page+0x2cc/0x390 do_patch_instruction+0x134/0x4a0 arch_jump_label_transform+0x64/0x78 __jump_label_update+0x148/0x180 static_key_enable_cpuslocked+0xd0/0x120 static_key_enable+0x30/0x50 check_kvm_guest+0x60/0x88 pSeries_smp_probe+0x54/0xb0 smp_prepare_cpus+0x3e0/0x430 kernel_init_freeable+0x20c/0x43c kernel_init+0x30/0x1a0 ret_from_kernel_thread+0x5c/0x64 Peter pointed out that this is because do_patch_instruction() has disabled interrupts, but then map_patch_area() calls map_kernel_page() then hash__map_kernel_page() which does a sleeping memory allocation. We only see the warning in KVM guests with SMT enabled, which is not particularly common, or on other platforms if CONFIG_KPROBES is disabled, also not common. The reason we don't see it in most configurations is that another path that happens to have interrupts enabled has allocated the required page tables for us, eg. there's a path in kprobes init that does that. That's just pure luck though. As Christophe suggested, the simplest solution is to do a dummy map/unmap when we initialise the patching, so that any required page table levels are pre-allocated before the first call to do_patch_instruction(). This works because the unmap doesn't free any page tables that were allocated by the map, it just clears the PTE, leaving the page table levels there for the next map. Reported-by: Paul Menzel Debugged-by: Peter Zijlstra Suggested-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220223015821.473097-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/lib/code-patching.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patch= ing.c index 906d43463366..00c68e7fb11e 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -43,9 +43,14 @@ int raw_patch_instruction(u32 *addr, ppc_inst_t instr) #ifdef CONFIG_STRICT_KERNEL_RWX static DEFINE_PER_CPU(struct vm_struct *, text_poke_area); =20 +static int map_patch_area(void *addr, unsigned long text_poke_addr); +static void unmap_patch_area(unsigned long addr); + static int text_area_cpu_up(unsigned int cpu) { struct vm_struct *area; + unsigned long addr; + int err; =20 area =3D get_vm_area(PAGE_SIZE, VM_ALLOC); if (!area) { @@ -53,6 +58,15 @@ static int text_area_cpu_up(unsigned int cpu) cpu); return -1; } + + // Map/unmap the area to ensure all page tables are pre-allocated + addr =3D (unsigned long)area->addr; + err =3D map_patch_area(empty_zero_page, addr); + if (err) + return err; + + unmap_patch_area(addr); + this_cpu_write(text_poke_area, area); =20 return 0; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9DC8DC433EF for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345559AbiDLJCl (ORCPT ); Tue, 12 Apr 2022 05:02:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357143AbiDLHjt (ORCPT ); Tue, 12 Apr 2022 03:39:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04EAA12740; Tue, 12 Apr 2022 00:12: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 9495F6171D; Tue, 12 Apr 2022 07:12:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F773C385A1; Tue, 12 Apr 2022 07:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747576; bh=G5f8bIMC7fhIMlaJ0SsC5j0qVYj4RFyRi1Q0CSpTW28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2SpYJwrtNB0l1f+YgqWAUlStyRr+i6AuAqI6Y0P8nI5g3rlQTgauyq27REbytzpcY G/OXYzHkLwYwj+ywWncUG+d4gLLBK7cuYFKA3lNDM/bQhu18uOUqURk7g74wRUby8s SGmjODm1lQTc8PJ7Ak+r5ZDhQv49I0WynCEefKPM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , "Naveen N. Rao" , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 129/343] powerpc/64e: Tie PPC_BOOK3E_64 to PPC_FSL_BOOK3E Date: Tue, 12 Apr 2022 08:29:07 +0200 Message-Id: <20220412062955.107810032@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael Ellerman [ Upstream commit 1a76e520ee1831a81dabf8a9a58c6453f700026e ] Since the IBM A2 CPU support was removed, see commit fb5a515704d7 ("powerpc: Remove platforms/wsp and associated pieces"), the only 64-bit Book3E CPUs we support are Freescale (NXP) ones. However our Kconfig still allows configurating a kernel that has 64-bit Book3E support, but no Freescale CPU support enabled. Such a kernel would never boot, it doesn't know about any CPUs. It also causes build errors, as reported by lkp, because PPC_BARRIER_NOSPEC is not enabled in such a configuration: powerpc64-linux-ld: arch/powerpc/net/bpf_jit_comp64.o:(.toc+0x0): undefined reference to `powerpc_security_features' To fix this, force PPC_FSL_BOOK3E to be selected whenever we are building a 64-bit Book3E kernel. Reported-by: kernel test robot Reported-by: Naveen N. Rao Suggested-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220304061222.2478720-1-mpe@ellerman.id.au Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/platforms/Kconfig.cputype | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platform= s/Kconfig.cputype index 87bc1929ee5a..e2e1fec91c6e 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -107,6 +107,7 @@ config PPC_BOOK3S_64 =20 config PPC_BOOK3E_64 bool "Embedded processors" + select PPC_FSL_BOOK3E select PPC_FPU # Make it a choice ? select PPC_SMP_MUXED_IPI select PPC_DOORBELL @@ -295,7 +296,7 @@ config FSL_BOOKE config PPC_FSL_BOOK3E bool select ARCH_SUPPORTS_HUGETLBFS if PHYS_64BIT || PPC64 - select FSL_EMB_PERFMON + imply FSL_EMB_PERFMON select PPC_SMP_MUXED_IPI select PPC_DOORBELL select PPC_KUEP --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4E1DBC433EF for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384135AbiDLIjT (ORCPT ); Tue, 12 Apr 2022 04:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357144AbiDLHjt (ORCPT ); Tue, 12 Apr 2022 03:39:49 -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 A0EBC12747; Tue, 12 Apr 2022 00:12: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3E30A6176E; Tue, 12 Apr 2022 07:12:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AEC0C385A1; Tue, 12 Apr 2022 07:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747578; bh=L4AE/btcFbCZktUVXKI6UoJsesrXhv9p0ciRMSDqhhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJZpVU8IpKrl4DqJEVDvyP9zpUcgGr8YxHtRVpIlxeqKHMO1rNai3IhiERU4Sc1nM ftkVg8b/8KXN9EyjZ2hjMGHE3M0TYLSmGCAvM786wm8rQ4RXFwj4vCRdk1gvjc5qG/ k25FvGdehVRuNcfexxZp8yYFubHYQ9QoZ9FNt4kY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Michael Ellerman , Sasha Levin Subject: [PATCH 5.17 130/343] powerpc/secvar: fix refcount leak in format_show() Date: Tue, 12 Apr 2022 08:29:08 +0200 Message-Id: <20220412062955.136639329@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 d601fd24e6964967f115f036a840f4f28488f63f ] Refcount leak will happen when format_show returns failure in multiple cases. Unified management of of_node_put can fix this problem. Signed-off-by: Hangyu Hua Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220302021959.10959-1-hbh25y@gmail.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/kernel/secvar-sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secva= r-sysfs.c index a0a78aba2083..1ee4640a2641 100644 --- a/arch/powerpc/kernel/secvar-sysfs.c +++ b/arch/powerpc/kernel/secvar-sysfs.c @@ -26,15 +26,18 @@ static ssize_t format_show(struct kobject *kobj, struct= kobj_attribute *attr, const char *format; =20 node =3D of_find_compatible_node(NULL, NULL, "ibm,secvar-backend"); - if (!of_device_is_available(node)) - return -ENODEV; + if (!of_device_is_available(node)) { + rc =3D -ENODEV; + goto out; + } =20 rc =3D of_property_read_string(node, "format", &format); if (rc) - return rc; + goto out; =20 rc =3D sprintf(buf, "%s\n", format); =20 +out: of_node_put(node); =20 return rc; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 DAA0BC433F5 for ; Tue, 12 Apr 2022 09:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359765AbiDLJBl (ORCPT ); Tue, 12 Apr 2022 05:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357158AbiDLHjt (ORCPT ); Tue, 12 Apr 2022 03:39:49 -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 91A6713D7C; Tue, 12 Apr 2022 00:13: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 dfw.source.kernel.org (Postfix) with ESMTPS id 0EE2761701; Tue, 12 Apr 2022 07:13:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 159B8C385A8; Tue, 12 Apr 2022 07:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747581; bh=RYJBN0sO+bxatsg4SRUBwH/bmw/chcpuG9tRlvPBoEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P38ypWuhZtBmWoG2El1136yqbLU7dvwkODBfp7KKfgydYm/67ZYgLqOZfh+WJAeso 1JSLfsHlK97jYFVUYpRtls4wSGYVKH5LeVb3rVS6PapI2W0Q6Nr4ETHTJuhvFBBVhH lkRCXtgdi/jNhVGjyLn/1ARuThn0EBot8UXzKuns= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Jianglei Nie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 131/343] scsi: libfc: Fix use after free in fc_exch_abts_resp() Date: Tue, 12 Apr 2022 08:29:09 +0200 Message-Id: <20220412062955.165334337@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jianglei Nie [ Upstream commit 271add11994ba1a334859069367e04d2be2ebdd4 ] fc_exch_release(ep) will decrease the ep's reference count. When the reference count reaches zero, it is freed. But ep is still used in the following code, which will lead to a use after free. Return after the fc_exch_release() call to avoid use after free. Link: https://lore.kernel.org/r/20220303015115.459778-1-niejianglei2021@163= .com Reviewed-by: Hannes Reinecke Signed-off-by: Jianglei Nie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/libfc/fc_exch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 841000445b9a..aa223db4cf53 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -1701,6 +1701,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, str= uct fc_frame *fp) if (cancel_delayed_work_sync(&ep->timeout_work)) { FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n"); fc_exch_release(ep); /* release from pending timer hold */ + return; } =20 spin_lock_bh(&ep->ex_lock); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 5BDF0C4332F for ; Tue, 12 Apr 2022 09:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379500AbiDLJB4 (ORCPT ); Tue, 12 Apr 2022 05:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357157AbiDLHjt (ORCPT ); Tue, 12 Apr 2022 03:39:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9834213DD3; Tue, 12 Apr 2022 00:13: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 51A80B81B62; Tue, 12 Apr 2022 07:13:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1A3AC385A8; Tue, 12 Apr 2022 07:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747584; bh=P982WA0OnbBbtgqrPXIZFhga1DDONaAzPMFsDGWMByU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=faNa/+ek7w+2VRuRhtJDv+1t0+vZsR0CXrdmCNQzUPVtwtITTP/I6YBWH494gWf7y JFOldUOngfFnq0b9P92/s8NHVnRV7AaEwC/8cLeNR36l/A6RFZBws4mlIsLgSSm/eV UamVJr/OwDG0oKOZMzab969uOyqBAAIOkDYBQ46k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Hans de Goede , Sasha Levin Subject: [PATCH 5.17 132/343] platform/x86: x86-android-tablets: Depend on EFI and SPI Date: Tue, 12 Apr 2022 08:29:10 +0200 Message-Id: <20220412062955.193655986@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Hans de Goede [ Upstream commit 1e8aa2aa1274953e8e595f0630436744597d0d64 ] The recently added support for Lenovo Yoga Tablet 2 tablets uses symbols from EFI and SPI add "depends on EFI && SPI" to the X86_ANDROID_TABLETS Kconfig entry. Reported-by: Randy Dunlap Signed-off-by: Hans de Goede Acked-by: Randy Dunlap Tested-by: Randy Dunlap Link: https://lore.kernel.org/r/20220308152942.262130-1-hdegoede@redhat.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/platform/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 24deeeb29af2..53abd553b842 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1027,7 +1027,7 @@ config TOUCHSCREEN_DMI =20 config X86_ANDROID_TABLETS tristate "X86 Android tablet support" - depends on I2C && SERIAL_DEV_BUS && ACPI && GPIOLIB + depends on I2C && SPI && SERIAL_DEV_BUS && ACPI && EFI && GPIOLIB help X86 tablets which ship with Android as (part of) the factory image typically have various problems with their DSDTs. The factory kernels --=20 2.35.1 From nobody Thu May 14 08:08:21 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 451EEC433EF for ; Tue, 12 Apr 2022 09:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359246AbiDLJB1 (ORCPT ); Tue, 12 Apr 2022 05:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357161AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39: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 61ECB13DDF; Tue, 12 Apr 2022 00:13: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 23819B81B60; Tue, 12 Apr 2022 07:13:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F303C385A1; Tue, 12 Apr 2022 07:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747586; bh=ZnTZ42DPMBoQ75SCZiE8sntMwYXskuJKw8g3vyalkdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zTn4176t6qBPLlPsSzYW9GScMn6ghGJ8nrbggg8YFHAB16cKg/h3nFJOPYQvX975G 6WFvaoJf5uitqANNVYYhcez23n5utjGR+RPKvVV6dlpEtYHN7j4AFcQqBjYObxcihf oO/uyLg+qCOu1P9cJPNWQFrEBW1miL45Q4Zor6CE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Hartkopp , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.17 133/343] can: isotp: set default value for N_As to 50 micro seconds Date: Tue, 12 Apr 2022 08:29:11 +0200 Message-Id: <20220412062955.222619662@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Oliver Hartkopp [ Upstream commit 530e0d46c61314c59ecfdb8d3bcb87edbc0f85d3 ] The N_As value describes the time a CAN frame needs on the wire when transmitted by the CAN controller. Even very short CAN FD frames need arround 100 usecs (bitrate 1Mbit/s, data bitrate 8Mbit/s). Having N_As to be zero (the former default) leads to 'no CAN frame separation' when STmin is set to zero by the receiving node. This 'burst mode' should not be enabled by default as it could potentially dump a high number of CAN frames into the netdev queue from the soft hrtimer context. This does not affect the system stability but is just not nice and cooperative. With this N_As/frame_txtime value the 'burst mode' is disabled by default. As user space applications usually do not set the frame_txtime element of struct can_isotp_options the new in-kernel default is very likely overwritten with zero when the sockopt() CAN_ISOTP_OPTS is invoked. To make sure that a N_As value of zero is only set intentional the value '0' is now interpreted as 'do not change the current value'. When a frame_txtime of zero is required for testing purposes this CAN_ISOTP_FRAME_TXTIME_ZERO u32 value has to be set in frame_txtime. Link: https://lore.kernel.org/all/20220309120416.83514-2-socketcan@hartkopp= .net Signed-off-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/uapi/linux/can/isotp.h | 28 ++++++++++++++++++++++------ net/can/isotp.c | 12 +++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/can/isotp.h b/include/uapi/linux/can/isotp.h index c55935b64ccc..590f8aea2b6d 100644 --- a/include/uapi/linux/can/isotp.h +++ b/include/uapi/linux/can/isotp.h @@ -137,20 +137,16 @@ struct can_isotp_ll_options { #define CAN_ISOTP_WAIT_TX_DONE 0x400 /* wait for tx completion */ #define CAN_ISOTP_SF_BROADCAST 0x800 /* 1-to-N functional addressing */ =20 -/* default values */ +/* protocol machine default values */ =20 #define CAN_ISOTP_DEFAULT_FLAGS 0 #define CAN_ISOTP_DEFAULT_EXT_ADDRESS 0x00 #define CAN_ISOTP_DEFAULT_PAD_CONTENT 0xCC /* prevent bit-stuffing */ -#define CAN_ISOTP_DEFAULT_FRAME_TXTIME 0 +#define CAN_ISOTP_DEFAULT_FRAME_TXTIME 50000 /* 50 micro seconds */ #define CAN_ISOTP_DEFAULT_RECV_BS 0 #define CAN_ISOTP_DEFAULT_RECV_STMIN 0x00 #define CAN_ISOTP_DEFAULT_RECV_WFTMAX 0 =20 -#define CAN_ISOTP_DEFAULT_LL_MTU CAN_MTU -#define CAN_ISOTP_DEFAULT_LL_TX_DL CAN_MAX_DLEN -#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS 0 - /* * Remark on CAN_ISOTP_DEFAULT_RECV_* values: * @@ -162,4 +158,24 @@ struct can_isotp_ll_options { * consistency and copied directly into the flow control (FC) frame. */ =20 +/* link layer default values =3D> make use of Classical CAN frames */ + +#define CAN_ISOTP_DEFAULT_LL_MTU CAN_MTU +#define CAN_ISOTP_DEFAULT_LL_TX_DL CAN_MAX_DLEN +#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS 0 + +/* + * The CAN_ISOTP_DEFAULT_FRAME_TXTIME has become a non-zero value as + * it only makes sense for isotp implementation tests to run without + * a N_As value. As user space applications usually do not set the + * frame_txtime element of struct can_isotp_options the new in-kernel + * default is very likely overwritten with zero when the sockopt() + * CAN_ISOTP_OPTS is invoked. + * To make sure that a N_As value of zero is only set intentional the + * value '0' is now interpreted as 'do not change the current value'. + * When a frame_txtime of zero is required for testing purposes this + * CAN_ISOTP_FRAME_TXTIME_ZERO u32 value has to be set in frame_txtime. + */ +#define CAN_ISOTP_FRAME_TXTIME_ZERO 0xFFFFFFFF + #endif /* !_UAPI_CAN_ISOTP_H */ diff --git a/net/can/isotp.c b/net/can/isotp.c index a95d171b3a64..5bce7c66c121 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -141,6 +141,7 @@ struct isotp_sock { struct can_isotp_options opt; struct can_isotp_fc_options rxfc, txfc; struct can_isotp_ll_options ll; + u32 frame_txtime; u32 force_tx_stmin; u32 force_rx_stmin; struct tpcon rx, tx; @@ -360,7 +361,7 @@ static int isotp_rcv_fc(struct isotp_sock *so, struct c= anfd_frame *cf, int ae) =20 so->tx_gap =3D ktime_set(0, 0); /* add transmission time for CAN frame N_As */ - so->tx_gap =3D ktime_add_ns(so->tx_gap, so->opt.frame_txtime); + so->tx_gap =3D ktime_add_ns(so->tx_gap, so->frame_txtime); /* add waiting time for consecutive frames N_Cs */ if (so->opt.flags & CAN_ISOTP_FORCE_TXSTMIN) so->tx_gap =3D ktime_add_ns(so->tx_gap, @@ -1247,6 +1248,14 @@ static int isotp_setsockopt_locked(struct socket *so= ck, int level, int optname, /* no separate rx_ext_address is given =3D> use ext_address */ if (!(so->opt.flags & CAN_ISOTP_RX_EXT_ADDR)) so->opt.rx_ext_address =3D so->opt.ext_address; + + /* check for frame_txtime changes (0 =3D> no changes) */ + if (so->opt.frame_txtime) { + if (so->opt.frame_txtime =3D=3D CAN_ISOTP_FRAME_TXTIME_ZERO) + so->frame_txtime =3D 0; + else + so->frame_txtime =3D so->opt.frame_txtime; + } break; =20 case CAN_ISOTP_RECV_FC: @@ -1448,6 +1457,7 @@ static int isotp_init(struct sock *sk) so->opt.rxpad_content =3D CAN_ISOTP_DEFAULT_PAD_CONTENT; so->opt.txpad_content =3D CAN_ISOTP_DEFAULT_PAD_CONTENT; so->opt.frame_txtime =3D CAN_ISOTP_DEFAULT_FRAME_TXTIME; + so->frame_txtime =3D CAN_ISOTP_DEFAULT_FRAME_TXTIME; so->rxfc.bs =3D CAN_ISOTP_DEFAULT_RECV_BS; so->rxfc.stmin =3D CAN_ISOTP_DEFAULT_RECV_STMIN; so->rxfc.wftmax =3D CAN_ISOTP_DEFAULT_RECV_WFTMAX; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E06DEC3527E for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384225AbiDLIjo (ORCPT ); Tue, 12 Apr 2022 04:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357162AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39: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 2E2B413DFE; Tue, 12 Apr 2022 00:13: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 DDB15B81B40; Tue, 12 Apr 2022 07:13:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 572AEC385A5; Tue, 12 Apr 2022 07:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747589; bh=vakCdvee7SIQCIJsOXH5YHwEpOpJbOq2zIJG+tti2LY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+CQ2RIpDusNfXgy96Se7ZaJE6LPDYglO+4hstB4DqYuR/+Xc2fSQdBi38Tlnh2Zk caaeRdQ3/LJOV+NRxkQ+VQIPI50I2sWo6p+sC/muxtZGYqPQHKU1DY6sbJtU2JnRhI wZThjnV0SpLY/FJuEFbiZ/8QO+Ehm08K3CZwBdx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Mailhol , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.17 134/343] can: etas_es58x: es58x_fd_rx_event_msg(): initialize rx_event_msg before calling es58x_check_msg_len() Date: Tue, 12 Apr 2022 08:29:12 +0200 Message-Id: <20220412062955.251503928@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Vincent Mailhol [ Upstream commit 7a8cd7c0ee823a1cc893ab3feaa23e4b602bfb9a ] Function es58x_fd_rx_event() invokes the es58x_check_msg_len() macro: | ret =3D es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len); While doing so, it dereferences an uninitialized variable: *rx_event_msg. This is actually harmless because es58x_check_msg_len() only uses preprocessor macros (sizeof() and __stringify()) on *rx_event_msg. c.f. [1]. Nonetheless, this pattern is confusing so the lines are reordered to make sure that rx_event_msg is correctly initialized. This patch also fixes a false positive warning reported by cppcheck: | cppcheck possible warnings: (new ones prefixed by >>, may not be real pro= blems) | | In file included from drivers/net/can/usb/etas_es58x/es58x_fd.c: | >> drivers/net/can/usb/etas_es58x/es58x_fd.c:174:8: warning: Uninitialize= d variable: rx_event_msg [uninitvar] | ret =3D es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len); | ^ [1] https://elixir.bootlin.com/linux/v5.16/source/drivers/net/can/usb/etas_= es58x/es58x_core.h#L467 Link: https://lore.kernel.org/all/20220306101302.708783-1-mailhol.vincent@w= anadoo.fr Signed-off-by: Vincent Mailhol Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/can/usb/etas_es58x/es58x_fd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/can/usb/etas_es58x/es58x_fd.c b/drivers/net/can/us= b/etas_es58x/es58x_fd.c index ec87126e1a7d..8ccda748fd08 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_fd.c +++ b/drivers/net/can/usb/etas_es58x/es58x_fd.c @@ -172,12 +172,11 @@ static int es58x_fd_rx_event_msg(struct net_device *n= etdev, const struct es58x_fd_rx_event_msg *rx_event_msg; int ret; =20 + rx_event_msg =3D &es58x_fd_urb_cmd->rx_event_msg; ret =3D es58x_check_msg_len(es58x_dev->dev, *rx_event_msg, msg_len); if (ret) return ret; =20 - rx_event_msg =3D &es58x_fd_urb_cmd->rx_event_msg; - return es58x_rx_err_msg(netdev, rx_event_msg->error_code, rx_event_msg->event_code, get_unaligned_le64(&rx_event_msg->timestamp)); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B1379C3527C for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384196AbiDLIje (ORCPT ); Tue, 12 Apr 2022 04:39:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357165AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10BEF13E17; Tue, 12 Apr 2022 00:13: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 ams.source.kernel.org (Postfix) with ESMTPS id 953B5B81B40; Tue, 12 Apr 2022 07:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD1C8C385A5; Tue, 12 Apr 2022 07:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747595; bh=RVaYlPGXRy05pVmg1yjhV4/vNvos4ZHe2Jm0XS9O1A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sV7IiFK0/hjtka2jlJmuMMbPMrgWzUlRfMzyJVGbYCC2m8IR0XxriJShTj2FMXNL+ qKVdiNBIUVP6wcKI+Oyg1q54lPLqauwpDGDGhrQbsEwmXY/GZf0lPByq+HBF4IF1Gt k94MvXD7XgI0BNhxpueRCYLJQh5W7QDGfDqcC7tI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael T. Kloos" , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.17 135/343] riscv: Fixed misaligned memory access. Fixed pointer comparison. Date: Tue, 12 Apr 2022 08:29:13 +0200 Message-Id: <20220412062955.285001325@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael T. Kloos [ Upstream commit 9d1f0ec9f71780e69ceb9d91697600c747d6e02e ] Rewrote the RISC-V memmove() assembly implementation. The previous implementation did not check memory alignment and it compared 2 pointers with a signed comparison. The misaligned memory access would cause the kernel to crash on systems that did not emulate it in firmware and did not support it in hardware. Firmware emulation is slow and may not exist. The RISC-V spec does not guarantee that support for misaligned memory accesses will exist. It should not be depended on. This patch now checks for XLEN granularity of co-alignment between the pointers. Failing that, copying is done by loading from the 2 contiguous and naturally aligned XLEN memory locations containing the overlapping XLEN sized data to be copied. The data is shifted into the correct place and binary or'ed together on each iteration. The result is then stored into the corresponding naturally aligned XLEN sized location in the destination. For unaligned data at the terminations of the regions to be copied or for copies less than (2 * XLEN) in size, byte copy is used. This patch also now uses unsigned comparison for the pointers and migrates to the newer assembler annotations from the now deprecated ones. Signed-off-by: Michael T. Kloos Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/riscv/lib/memmove.S | 368 +++++++++++++++++++++++++++++++++------ 1 file changed, 310 insertions(+), 58 deletions(-) diff --git a/arch/riscv/lib/memmove.S b/arch/riscv/lib/memmove.S index 07d1d2152ba5..e0609e1f0864 100644 --- a/arch/riscv/lib/memmove.S +++ b/arch/riscv/lib/memmove.S @@ -1,64 +1,316 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2022 Michael T. Kloos + */ =20 #include #include =20 -ENTRY(__memmove) -WEAK(memmove) - move t0, a0 - move t1, a1 - - beq a0, a1, exit_memcpy - beqz a2, exit_memcpy - srli t2, a2, 0x2 - - slt t3, a0, a1 - beqz t3, do_reverse - - andi a2, a2, 0x3 - li t4, 1 - beqz t2, byte_copy - -word_copy: - lw t3, 0(a1) - addi t2, t2, -1 - addi a1, a1, 4 - sw t3, 0(a0) - addi a0, a0, 4 - bnez t2, word_copy - beqz a2, exit_memcpy - j byte_copy - -do_reverse: - add a0, a0, a2 - add a1, a1, a2 - andi a2, a2, 0x3 - li t4, -1 - beqz t2, reverse_byte_copy - -reverse_word_copy: - addi a1, a1, -4 - addi t2, t2, -1 - lw t3, 0(a1) - addi a0, a0, -4 - sw t3, 0(a0) - bnez t2, reverse_word_copy - beqz a2, exit_memcpy - -reverse_byte_copy: - addi a0, a0, -1 - addi a1, a1, -1 +SYM_FUNC_START(__memmove) +SYM_FUNC_START_WEAK(memmove) + /* + * Returns + * a0 - dest + * + * Parameters + * a0 - Inclusive first byte of dest + * a1 - Inclusive first byte of src + * a2 - Length of copy n + * + * Because the return matches the parameter register a0, + * we will not clobber or modify that register. + * + * Note: This currently only works on little-endian. + * To port to big-endian, reverse the direction of shifts + * in the 2 misaligned fixup copy loops. + */ =20 + /* Return if nothing to do */ + beq a0, a1, return_from_memmove + beqz a2, return_from_memmove + + /* + * Register Uses + * Forward Copy: a1 - Index counter of src + * Reverse Copy: a4 - Index counter of src + * Forward Copy: t3 - Index counter of dest + * Reverse Copy: t4 - Index counter of dest + * Both Copy Modes: t5 - Inclusive first multibyte/aligned of dest + * Both Copy Modes: t6 - Non-Inclusive last multibyte/aligned of dest + * Both Copy Modes: t0 - Link / Temporary for load-store + * Both Copy Modes: t1 - Temporary for load-store + * Both Copy Modes: t2 - Temporary for load-store + * Both Copy Modes: a5 - dest to src alignment offset + * Both Copy Modes: a6 - Shift ammount + * Both Copy Modes: a7 - Inverse Shift ammount + * Both Copy Modes: a2 - Alternate breakpoint for unrolled loops + */ + + /* + * Solve for some register values now. + * Byte copy does not need t5 or t6. + */ + mv t3, a0 + add t4, a0, a2 + add a4, a1, a2 + + /* + * Byte copy if copying less than (2 * SZREG) bytes. This can + * cause problems with the bulk copy implementation and is + * small enough not to bother. + */ + andi t0, a2, -(2 * SZREG) + beqz t0, byte_copy + + /* + * Now solve for t5 and t6. + */ + andi t5, t3, -SZREG + andi t6, t4, -SZREG + /* + * If dest(Register t3) rounded down to the nearest naturally + * aligned SZREG address, does not equal dest, then add SZREG + * to find the low-bound of SZREG alignment in the dest memory + * region. Note that this could overshoot the dest memory + * region if n is less than SZREG. This is one reason why + * we always byte copy if n is less than SZREG. + * Otherwise, dest is already naturally aligned to SZREG. + */ + beq t5, t3, 1f + addi t5, t5, SZREG + 1: + + /* + * If the dest and src are co-aligned to SZREG, then there is + * no need for the full rigmarole of a full misaligned fixup copy. + * Instead, do a simpler co-aligned copy. + */ + xor t0, a0, a1 + andi t1, t0, (SZREG - 1) + beqz t1, coaligned_copy + /* Fall through to misaligned fixup copy */ + +misaligned_fixup_copy: + bltu a1, a0, misaligned_fixup_copy_reverse + +misaligned_fixup_copy_forward: + jal t0, byte_copy_until_aligned_forward + + andi a5, a1, (SZREG - 1) /* Find the alignment offset of src (a1) */ + slli a6, a5, 3 /* Multiply by 8 to convert that to bits to shift */ + sub a5, a1, t3 /* Find the difference between src and dest */ + andi a1, a1, -SZREG /* Align the src pointer */ + addi a2, t6, SZREG /* The other breakpoint for the unrolled loop*/ + + /* + * Compute The Inverse Shift + * a7 =3D XLEN - a6 =3D XLEN + -a6 + * 2s complement negation to find the negative: -a6 =3D ~a6 + 1 + * Add that to XLEN. XLEN =3D SZREG * 8. + */ + not a7, a6 + addi a7, a7, (SZREG * 8 + 1) + + /* + * Fix Misalignment Copy Loop - Forward + * load_val0 =3D load_ptr[0]; + * do { + * load_val1 =3D load_ptr[1]; + * store_ptr +=3D 2; + * store_ptr[0 - 2] =3D (load_val0 >> {a6}) | (load_val1 << {a7}); + * + * if (store_ptr =3D=3D {a2}) + * break; + * + * load_val0 =3D load_ptr[2]; + * load_ptr +=3D 2; + * store_ptr[1 - 2] =3D (load_val1 >> {a6}) | (load_val0 << {a7}); + * + * } while (store_ptr !=3D store_ptr_end); + * store_ptr =3D store_ptr_end; + */ + + REG_L t0, (0 * SZREG)(a1) + 1: + REG_L t1, (1 * SZREG)(a1) + addi t3, t3, (2 * SZREG) + srl t0, t0, a6 + sll t2, t1, a7 + or t2, t0, t2 + REG_S t2, ((0 * SZREG) - (2 * SZREG))(t3) + + beq t3, a2, 2f + + REG_L t0, (2 * SZREG)(a1) + addi a1, a1, (2 * SZREG) + srl t1, t1, a6 + sll t2, t0, a7 + or t2, t1, t2 + REG_S t2, ((1 * SZREG) - (2 * SZREG))(t3) + + bne t3, t6, 1b + 2: + mv t3, t6 /* Fix the dest pointer in case the loop was broken */ + + add a1, t3, a5 /* Restore the src pointer */ + j byte_copy_forward /* Copy any remaining bytes */ + +misaligned_fixup_copy_reverse: + jal t0, byte_copy_until_aligned_reverse + + andi a5, a4, (SZREG - 1) /* Find the alignment offset of src (a4) */ + slli a6, a5, 3 /* Multiply by 8 to convert that to bits to shift */ + sub a5, a4, t4 /* Find the difference between src and dest */ + andi a4, a4, -SZREG /* Align the src pointer */ + addi a2, t5, -SZREG /* The other breakpoint for the unrolled loop*/ + + /* + * Compute The Inverse Shift + * a7 =3D XLEN - a6 =3D XLEN + -a6 + * 2s complement negation to find the negative: -a6 =3D ~a6 + 1 + * Add that to XLEN. XLEN =3D SZREG * 8. + */ + not a7, a6 + addi a7, a7, (SZREG * 8 + 1) + + /* + * Fix Misalignment Copy Loop - Reverse + * load_val1 =3D load_ptr[0]; + * do { + * load_val0 =3D load_ptr[-1]; + * store_ptr -=3D 2; + * store_ptr[1] =3D (load_val0 >> {a6}) | (load_val1 << {a7}); + * + * if (store_ptr =3D=3D {a2}) + * break; + * + * load_val1 =3D load_ptr[-2]; + * load_ptr -=3D 2; + * store_ptr[0] =3D (load_val1 >> {a6}) | (load_val0 << {a7}); + * + * } while (store_ptr !=3D store_ptr_end); + * store_ptr =3D store_ptr_end; + */ + + REG_L t1, ( 0 * SZREG)(a4) + 1: + REG_L t0, (-1 * SZREG)(a4) + addi t4, t4, (-2 * SZREG) + sll t1, t1, a7 + srl t2, t0, a6 + or t2, t1, t2 + REG_S t2, ( 1 * SZREG)(t4) + + beq t4, a2, 2f + + REG_L t1, (-2 * SZREG)(a4) + addi a4, a4, (-2 * SZREG) + sll t0, t0, a7 + srl t2, t1, a6 + or t2, t0, t2 + REG_S t2, ( 0 * SZREG)(t4) + + bne t4, t5, 1b + 2: + mv t4, t5 /* Fix the dest pointer in case the loop was broken */ + + add a4, t4, a5 /* Restore the src pointer */ + j byte_copy_reverse /* Copy any remaining bytes */ + +/* + * Simple copy loops for SZREG co-aligned memory locations. + * These also make calls to do byte copies for any unaligned + * data at their terminations. + */ +coaligned_copy: + bltu a1, a0, coaligned_copy_reverse + +coaligned_copy_forward: + jal t0, byte_copy_until_aligned_forward + + 1: + REG_L t1, ( 0 * SZREG)(a1) + addi a1, a1, SZREG + addi t3, t3, SZREG + REG_S t1, (-1 * SZREG)(t3) + bne t3, t6, 1b + + j byte_copy_forward /* Copy any remaining bytes */ + +coaligned_copy_reverse: + jal t0, byte_copy_until_aligned_reverse + + 1: + REG_L t1, (-1 * SZREG)(a4) + addi a4, a4, -SZREG + addi t4, t4, -SZREG + REG_S t1, ( 0 * SZREG)(t4) + bne t4, t5, 1b + + j byte_copy_reverse /* Copy any remaining bytes */ + +/* + * These are basically sub-functions within the function. They + * are used to byte copy until the dest pointer is in alignment. + * At which point, a bulk copy method can be used by the + * calling code. These work on the same registers as the bulk + * copy loops. Therefore, the register values can be picked + * up from where they were left and we avoid code duplication + * without any overhead except the call in and return jumps. + */ +byte_copy_until_aligned_forward: + beq t3, t5, 2f + 1: + lb t1, 0(a1) + addi a1, a1, 1 + addi t3, t3, 1 + sb t1, -1(t3) + bne t3, t5, 1b + 2: + jalr zero, 0x0(t0) /* Return to multibyte copy loop */ + +byte_copy_until_aligned_reverse: + beq t4, t6, 2f + 1: + lb t1, -1(a4) + addi a4, a4, -1 + addi t4, t4, -1 + sb t1, 0(t4) + bne t4, t6, 1b + 2: + jalr zero, 0x0(t0) /* Return to multibyte copy loop */ + +/* + * Simple byte copy loops. + * These will byte copy until they reach the end of data to copy. + * At that point, they will call to return from memmove. + */ byte_copy: - lb t3, 0(a1) - addi a2, a2, -1 - sb t3, 0(a0) - add a1, a1, t4 - add a0, a0, t4 - bnez a2, byte_copy - -exit_memcpy: - move a0, t0 - move a1, t1 - ret -END(__memmove) + bltu a1, a0, byte_copy_reverse + +byte_copy_forward: + beq t3, t4, 2f + 1: + lb t1, 0(a1) + addi a1, a1, 1 + addi t3, t3, 1 + sb t1, -1(t3) + bne t3, t4, 1b + 2: + ret + +byte_copy_reverse: + beq t4, t3, 2f + 1: + lb t1, -1(a4) + addi a4, a4, -1 + addi t4, t4, -1 + sb t1, 0(t4) + bne t4, t3, 1b + 2: + +return_from_memmove: + ret + +SYM_FUNC_END(memmove) +SYM_FUNC_END(__memmove) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 91A04C3527D for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384177AbiDLIja (ORCPT ); Tue, 12 Apr 2022 04:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357163AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39: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 EBC8D13E36; Tue, 12 Apr 2022 00:13: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 8858261708; Tue, 12 Apr 2022 07:13:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94933C385A5; Tue, 12 Apr 2022 07:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747597; bh=1rVLR/bONBr0cUtCgca2ph/k+Es2uGQyvcanGGCrC9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AdD842gg1o/pyEOqLSky0xn/tsvfZuGoDj+k6FkQiq3Sb1ptdMWhcAPVNYjRMoO1P lsQMbXL/FD2aww/H5afu11h2hE//vqNcB3V0+L5hVqllbJ7YRtUbRuIdWRY87437C4 nZSkDj0LQIoNHozMdRi/3vRkHK70TgrxKRaiR2Yo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, George Shuklin , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 136/343] net: account alternate interface name memory Date: Tue, 12 Apr 2022 08:29:14 +0200 Message-Id: <20220412062955.313243456@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Kicinski [ Upstream commit 5d26cff5bdbebdf98ba48217c078ff102536f134 ] George reports that altnames can eat up kernel memory. We should charge that memory appropriately. Reported-by: George Shuklin Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 2fb8eb6791e8..9c9ad3d4b766 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3658,7 +3658,7 @@ static int rtnl_alt_ifname(int cmd, struct net_device= *dev, struct nlattr *attr, if (err) return err; =20 - alt_ifname =3D nla_strdup(attr, GFP_KERNEL); + alt_ifname =3D nla_strdup(attr, GFP_KERNEL_ACCOUNT); if (!alt_ifname) return -ENOMEM; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 36F83C38162 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384436AbiDLIlq (ORCPT ); Tue, 12 Apr 2022 04:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357168AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979A113E83; Tue, 12 Apr 2022 00:13: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 325D46171C; Tue, 12 Apr 2022 07:13:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4033DC385A5; Tue, 12 Apr 2022 07:13:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747600; bh=rDwGZVgTVPjbN7qUraf4diMbB4q1VpnmC8hkj5oXOms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vnm9V0A5u8BWSOqEr8ChUyhxpVajaOkw7Uqk2/r6f5VLQoh6dOiLx9R5GFEmAHXxo 72qcz9feCHWyOM5rEIBWSMmlOP6cxlauvEMtJX2nE/Kpx8+lWweOsFYPmISl485cyW y1sO8aikkrHkHtDFE/OxhUqczhx0rGj9gs7ea008= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, George Shuklin , David Ahern , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 137/343] net: limit altnames to 64k total Date: Tue, 12 Apr 2022 08:29:15 +0200 Message-Id: <20220412062955.341689476@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Kicinski [ Upstream commit 155fb43b70b5fce341347a77d1af2765d1e8fbb8 ] Property list (altname is a link "property") is wrapped in a nlattr. nlattrs length is 16bit so practically speaking the list of properties can't be longer than that, otherwise user space would have to interpret broken netlink messages. Prevent the problem from occurring by checking the length of the property list before adding new entries. Reported-by: George Shuklin Reviewed-by: David Ahern Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/core/rtnetlink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 9c9ad3d4b766..43b995e935cd 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3652,12 +3652,23 @@ static int rtnl_alt_ifname(int cmd, struct net_devi= ce *dev, struct nlattr *attr, bool *changed, struct netlink_ext_ack *extack) { char *alt_ifname; + size_t size; int err; =20 err =3D nla_validate(attr, attr->nla_len, IFLA_MAX, ifla_policy, extack); if (err) return err; =20 + if (cmd =3D=3D RTM_NEWLINKPROP) { + size =3D rtnl_prop_list_size(dev); + size +=3D nla_total_size(ALTIFNAMSIZ); + if (size >=3D U16_MAX) { + NL_SET_ERR_MSG(extack, + "effective property list too long"); + return -EINVAL; + } + } + alt_ifname =3D nla_strdup(attr, GFP_KERNEL_ACCOUNT); if (!alt_ifname) return -ENOMEM; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4CFF2C47085 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384449AbiDLIlu (ORCPT ); Tue, 12 Apr 2022 04:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357169AbiDLHju (ORCPT ); Tue, 12 Apr 2022 03:39: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 51AE613F70; Tue, 12 Apr 2022 00:13: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 dfw.source.kernel.org (Postfix) with ESMTPS id DC8B56153F; Tue, 12 Apr 2022 07:13:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9B44C385A1; Tue, 12 Apr 2022 07:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747603; bh=YgBs7SCqNKxfkEo9PqweIDQmp3ZWSfZhb89F6s7+12c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sxsGcLuYm28rCDJxFsUD5y1Fl756+A7c1xBH6gju3YtzwnF75m46NVzjNx2sgqVq1 7XQuxW4851Z+MlOY/7ZQesS10muEuMGvj69wSi6NoVboCNM+CVBHZpzdYNqVyQdcj9 eOAfVoa2AUkN8KEamicmGujyGweS3xhHBv6p3y7I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gal Pressman , Ido Schimmel , Maxim Mikityanskiy , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.17 138/343] net/mlx5e: Remove overzealous validations in netlink EEPROM query Date: Tue, 12 Apr 2022 08:29:16 +0200 Message-Id: <20220412062955.369912798@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Gal Pressman [ Upstream commit 970adfb76095fa719778d70a6b86030d2feb88dd ] Unlike the legacy EEPROM callbacks, when using the netlink EEPROM query (get_module_eeprom_by_page) the driver should not try to validate the query parameters, but just perform the read requested by the userspace. Recent discussion in the mailing list: https://lore.kernel.org/netdev/20220120093051.70845141@kicinski-fedora-PC1C= 0HJN.hsd1.ca.comcast.net/ Signed-off-by: Gal Pressman Reviewed-by: Ido Schimmel Reviewed-by: Maxim Mikityanskiy Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- .../net/ethernet/mellanox/mlx5/core/port.c | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/e= thernet/mellanox/mlx5/core/port.c index 7b16a1188aab..fd79860de723 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/port.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c @@ -433,35 +433,12 @@ int mlx5_query_module_eeprom_by_page(struct mlx5_core= _dev *dev, struct mlx5_module_eeprom_query_params *params, u8 *data) { - u8 module_id; int err; =20 err =3D mlx5_query_module_num(dev, ¶ms->module_number); if (err) return err; =20 - err =3D mlx5_query_module_id(dev, params->module_number, &module_id); - if (err) - return err; - - switch (module_id) { - case MLX5_MODULE_ID_SFP: - if (params->page > 0) - return -EINVAL; - break; - case MLX5_MODULE_ID_QSFP: - case MLX5_MODULE_ID_QSFP28: - case MLX5_MODULE_ID_QSFP_PLUS: - if (params->page > 3) - return -EINVAL; - break; - case MLX5_MODULE_ID_DSFP: - break; - default: - mlx5_core_err(dev, "Module ID not recognized: 0x%x\n", module_id); - return -EINVAL; - } - if (params->i2c_address !=3D MLX5_I2C_ADDR_HIGH && params->i2c_address !=3D MLX5_I2C_ADDR_LOW) { mlx5_core_err(dev, "I2C address not recognized: 0x%x\n", params->i2c_add= ress); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 EFA1CC35280 for ; Tue, 12 Apr 2022 08:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384241AbiDLIjq (ORCPT ); Tue, 12 Apr 2022 04:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357177AbiDLHjv (ORCPT ); Tue, 12 Apr 2022 03:39:51 -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 8DC9113EAD; Tue, 12 Apr 2022 00:13:28 -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 50ADAB81A8F; Tue, 12 Apr 2022 07:13:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B25A8C385A5; Tue, 12 Apr 2022 07:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747606; bh=oaKURCUL+ymgN1tWdKGVd0Jf/51rzZ/0MT5vgz0oFlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m87WWX7Z/hgrT2CBQlvOoPXOu77ycf16qEDIsHrt2uaU/5XS3tCY8Vo09y1BsXeO9 3LXJIJyQ96kGpOiK1xnxHW1Mkn7qyP5vppi2Crbqqm8JrpFrMRUL9A+0hAAlJt5zDn R578ZonVOVwBg63XT4HFyFHW6e6L16BqwjJqCK0c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jorge Lopez , Hans de Goede , Sasha Levin Subject: [PATCH 5.17 139/343] platform/x86: hp-wmi: Fix SW_TABLET_MODE detection method Date: Tue, 12 Apr 2022 08:29:17 +0200 Message-Id: <20220412062955.398785893@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jorge Lopez [ Upstream commit 520ee4ea1cc60251a6e3c911cf0336278aa52634 ] The purpose of this patch is to introduce a fix and removal of the current hack when determining tablet mode status. Determining the tablet mode status requires reading Byte 0 bit 2 as reported by HPWMI_HARDWARE_QUERY. The investigation identified the failure was rooted in two areas: HPWMI_HARDWARE_QUERY failure (0x05) and reading Byte 0, bit 2 only to determine the table mode status. HPWMI_HARDWARE_QUERY WMI failure also rendered the dock state value invalid. The latest changes use SMBIOS Type 3 (chassis type) and WMI Command 0x40 (device_mode_status) information to determine if the device is in tablet mode or not. hp_wmi_hw_state function was split into two functions; hp_wmi_get_dock_state and hp_wmi_get_tablet_mode. The new functions separate how dock_state and tablet_mode is handled in a cleaner manner. All changes were validated on a HP ZBook Workstation notebook, HP EliteBook x360, and HP EliteBook 850 G8. Signed-off-by: Jorge Lopez Link: https://lore.kernel.org/r/20220310210853.28367-3-jorge.lopez2@hp.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/platform/x86/hp-wmi.c | 71 +++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 48a46466f086..f822ef6eb93c 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -35,10 +35,6 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C"); MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); =20 -static int enable_tablet_mode_sw =3D -1; -module_param(enable_tablet_mode_sw, int, 0444); -MODULE_PARM_DESC(enable_tablet_mode_sw, "Enable SW_TABLET_MODE reporting (= -1=3Dauto, 0=3Dno, 1=3Dyes)"); - #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4" #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95 @@ -107,6 +103,7 @@ enum hp_wmi_commandtype { HPWMI_FEATURE2_QUERY =3D 0x0d, HPWMI_WIRELESS2_QUERY =3D 0x1b, HPWMI_POSTCODEERROR_QUERY =3D 0x2a, + HPWMI_SYSTEM_DEVICE_MODE =3D 0x40, HPWMI_THERMAL_PROFILE_QUERY =3D 0x4c, }; =20 @@ -217,6 +214,19 @@ struct rfkill2_device { static int rfkill2_count; static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES]; =20 +/* + * Chassis Types values were obtained from SMBIOS reference + * specification version 3.00. A complete list of system enclosures + * and chassis types is available on Table 17. + */ +static const char * const tablet_chassis_types[] =3D { + "30", /* Tablet*/ + "31", /* Convertible */ + "32" /* Detachable */ +}; + +#define DEVICE_MODE_TABLET 0x06 + /* map output size to the corresponding WMI method id */ static inline int encode_outsize_for_pvsz(int outsize) { @@ -345,14 +355,39 @@ static int hp_wmi_read_int(int query) return val; } =20 -static int hp_wmi_hw_state(int mask) +static int hp_wmi_get_dock_state(void) { int state =3D hp_wmi_read_int(HPWMI_HARDWARE_QUERY); =20 if (state < 0) return state; =20 - return !!(state & mask); + return !!(state & HPWMI_DOCK_MASK); +} + +static int hp_wmi_get_tablet_mode(void) +{ + char system_device_mode[4] =3D { 0 }; + const char *chassis_type; + bool tablet_found; + int ret; + + chassis_type =3D dmi_get_system_info(DMI_CHASSIS_TYPE); + if (!chassis_type) + return -ENODEV; + + tablet_found =3D match_string(tablet_chassis_types, + ARRAY_SIZE(tablet_chassis_types), + chassis_type) >=3D 0; + if (!tablet_found) + return -ENODEV; + + ret =3D hp_wmi_perform_query(HPWMI_SYSTEM_DEVICE_MODE, HPWMI_READ, + system_device_mode, 0, sizeof(system_device_mode)); + if (ret < 0) + return ret; + + return system_device_mode[0] =3D=3D DEVICE_MODE_TABLET; } =20 static int omen_thermal_profile_set(int mode) @@ -568,7 +603,7 @@ static ssize_t als_show(struct device *dev, struct devi= ce_attribute *attr, static ssize_t dock_show(struct device *dev, struct device_attribute *attr, char *buf) { - int value =3D hp_wmi_hw_state(HPWMI_DOCK_MASK); + int value =3D hp_wmi_get_dock_state(); if (value < 0) return value; return sprintf(buf, "%d\n", value); @@ -577,7 +612,7 @@ static ssize_t dock_show(struct device *dev, struct dev= ice_attribute *attr, static ssize_t tablet_show(struct device *dev, struct device_attribute *at= tr, char *buf) { - int value =3D hp_wmi_hw_state(HPWMI_TABLET_MASK); + int value =3D hp_wmi_get_tablet_mode(); if (value < 0) return value; return sprintf(buf, "%d\n", value); @@ -699,10 +734,10 @@ static void hp_wmi_notify(u32 value, void *context) case HPWMI_DOCK_EVENT: if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit)) input_report_switch(hp_wmi_input_dev, SW_DOCK, - hp_wmi_hw_state(HPWMI_DOCK_MASK)); + hp_wmi_get_dock_state()); if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit)) input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, - hp_wmi_hw_state(HPWMI_TABLET_MASK)); + hp_wmi_get_tablet_mode()); input_sync(hp_wmi_input_dev); break; case HPWMI_PARK_HDD: @@ -780,19 +815,17 @@ static int __init hp_wmi_input_setup(void) __set_bit(EV_SW, hp_wmi_input_dev->evbit); =20 /* Dock */ - val =3D hp_wmi_hw_state(HPWMI_DOCK_MASK); + val =3D hp_wmi_get_dock_state(); if (!(val < 0)) { __set_bit(SW_DOCK, hp_wmi_input_dev->swbit); input_report_switch(hp_wmi_input_dev, SW_DOCK, val); } =20 /* Tablet mode */ - if (enable_tablet_mode_sw > 0) { - val =3D hp_wmi_hw_state(HPWMI_TABLET_MASK); - if (val >=3D 0) { - __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); - input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); - } + val =3D hp_wmi_get_tablet_mode(); + if (!(val < 0)) { + __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); + input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); } =20 err =3D sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL); @@ -1227,10 +1260,10 @@ static int hp_wmi_resume_handler(struct device *dev= ice) if (hp_wmi_input_dev) { if (test_bit(SW_DOCK, hp_wmi_input_dev->swbit)) input_report_switch(hp_wmi_input_dev, SW_DOCK, - hp_wmi_hw_state(HPWMI_DOCK_MASK)); + hp_wmi_get_dock_state()); if (test_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit)) input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, - hp_wmi_hw_state(HPWMI_TABLET_MASK)); + hp_wmi_get_tablet_mode()); input_sync(hp_wmi_input_dev); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1B780C4707E for ; Tue, 12 Apr 2022 08:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384254AbiDLIj4 (ORCPT ); Tue, 12 Apr 2022 04:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357176AbiDLHjv (ORCPT ); Tue, 12 Apr 2022 03:39:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D948913F77; Tue, 12 Apr 2022 00:13: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 7455861708; Tue, 12 Apr 2022 07:13:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FDFBC385A5; Tue, 12 Apr 2022 07:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747608; bh=9xQ3uX4h9l1REPAIIrIh96bR7xnygsUSU5H1Cu9F32g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKCsTg5k+KAleHqAC7ViVP+z9u1P1tyXhi9KVoKQGq+XFtN/1aJe/ho5XN22uD8hx UOw4zzsNY2LQYhYQdZrcYSMZOMPfooXYcqLBUb5RSZNAtvypy1tr1pSdRLfaRWup6O NvZohir7O8Y+3f2v00DtoouwoAqde7W7ycn82qrQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jorge Lopez , Hans de Goede , Sasha Levin Subject: [PATCH 5.17 140/343] platform/x86: hp-wmi: Fix 0x05 error code reported by several WMI calls Date: Tue, 12 Apr 2022 08:29:18 +0200 Message-Id: <20220412062955.426856975@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jorge Lopez [ Upstream commit be9d73e64957bbd31ee9a0d11adc0f720974c558 ] Several WMI queries leverage hp_wmi_read_int function to read their data. hp_wmi_read_int function was corrected in a previous patch. Now, this function invokes hp_wmi_perform_query with input parameter of size zero and the output buffer of size 4. WMI commands calling hp_wmi_perform_query with input buffer size value of zero are listed below. HPWMI_DISPLAY_QUERY HPWMI_HDDTEMP_QUERY HPWMI_ALS_QUERY HPWMI_HARDWARE_QUERY HPWMI_WIRELESS_QUERY HPWMI_BIOS_QUERY HPWMI_FEATURE_QUERY HPWMI_HOTKEY_QUERY HPWMI_FEATURE2_QUERY HPWMI_WIRELESS2_QUERY HPWMI_POSTCODEERROR_QUERY HPWMI_THERMAL_PROFILE_QUERY HPWMI_FAN_SPEED_MAX_GET_QUERY Invoking those WMI commands with an input buffer size greater than zero will cause error 0x05 to be returned. All WMI commands executed by the driver were reviewed and changes were made to ensure the expected input and output buffer size match the WMI specification. Changes were validated on a HP ZBook Workstation notebook, HP EliteBook x360, and HP EliteBook 850 G8. Additional validation was included in the test process to ensure no other commands were incorrectly handled. Signed-off-by: Jorge Lopez Link: https://lore.kernel.org/r/20220310210853.28367-4-jorge.lopez2@hp.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/platform/x86/hp-wmi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index f822ef6eb93c..88f0bfd6ecf1 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -330,7 +330,7 @@ static int hp_wmi_get_fan_speed(int fan) char fan_data[4] =3D { fan, 0, 0, 0 }; =20 int ret =3D hp_wmi_perform_query(HPWMI_FAN_SPEED_GET_QUERY, HPWMI_GM, - &fan_data, sizeof(fan_data), + &fan_data, sizeof(char), sizeof(fan_data)); =20 if (ret !=3D 0) @@ -399,7 +399,7 @@ static int omen_thermal_profile_set(int mode) return -EINVAL; =20 ret =3D hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM, - &buffer, sizeof(buffer), sizeof(buffer)); + &buffer, sizeof(buffer), 0); =20 if (ret) return ret < 0 ? ret : -EINVAL; @@ -436,7 +436,7 @@ static int hp_wmi_fan_speed_max_set(int enabled) int ret; =20 ret =3D hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_SET_QUERY, HPWMI_GM, - &enabled, sizeof(enabled), sizeof(enabled)); + &enabled, sizeof(enabled), 0); =20 if (ret) return ret < 0 ? ret : -EINVAL; @@ -449,7 +449,7 @@ static int hp_wmi_fan_speed_max_get(void) int val =3D 0, ret; =20 ret =3D hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_GET_QUERY, HPWMI_GM, - &val, sizeof(val), sizeof(val)); + &val, 0, sizeof(val)); =20 if (ret) return ret < 0 ? ret : -EINVAL; @@ -461,7 +461,7 @@ static int __init hp_wmi_bios_2008_later(void) { int state =3D 0; int ret =3D hp_wmi_perform_query(HPWMI_FEATURE_QUERY, HPWMI_READ, &state, - sizeof(state), sizeof(state)); + 0, sizeof(state)); if (!ret) return 1; =20 @@ -472,7 +472,7 @@ static int __init hp_wmi_bios_2009_later(void) { u8 state[128]; int ret =3D hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state, - sizeof(state), sizeof(state)); + 0, sizeof(state)); if (!ret) return 1; =20 @@ -550,7 +550,7 @@ static int hp_wmi_rfkill2_refresh(void) int err, i; =20 err =3D hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state, - sizeof(state), sizeof(state)); + 0, sizeof(state)); if (err) return err; =20 @@ -639,7 +639,7 @@ static ssize_t als_store(struct device *dev, struct dev= ice_attribute *attr, return ret; =20 ret =3D hp_wmi_perform_query(HPWMI_ALS_QUERY, HPWMI_WRITE, &tmp, - sizeof(tmp), sizeof(tmp)); + sizeof(tmp), 0); if (ret) return ret < 0 ? ret : -EINVAL; =20 @@ -660,9 +660,9 @@ static ssize_t postcode_store(struct device *dev, struc= t device_attribute *attr, if (clear =3D=3D false) return -EINVAL; =20 - /* Clear the POST error code. It is kept until until cleared. */ + /* Clear the POST error code. It is kept until cleared. */ ret =3D hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, HPWMI_WRITE, &tmp, - sizeof(tmp), sizeof(tmp)); + sizeof(tmp), 0); if (ret) return ret < 0 ? ret : -EINVAL; =20 @@ -952,7 +952,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_= device *device) int err, i; =20 err =3D hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state, - sizeof(state), sizeof(state)); + 0, sizeof(state)); if (err) return err < 0 ? err : -EINVAL; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6EACBC433F5 for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386743AbiDLJCK (ORCPT ); Tue, 12 Apr 2022 05:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357184AbiDLHjv (ORCPT ); Tue, 12 Apr 2022 03:39:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FE613F9A; Tue, 12 Apr 2022 00:13: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 235606153F; Tue, 12 Apr 2022 07:13:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 302A2C385A5; Tue, 12 Apr 2022 07:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747611; bh=Ueb/n5/degKcP/u90rkPTK409N1+OCvbJpRbir3mBN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nd6hfCDYiPKQ2D/MEtcn1oXcKUlU0+xa0e4s0yQQTsYXxwBshk2awAwX68gTEX8A+ UxgoyZklI4ohAYf5SuqqslTERo7XnGNmD5/jETmAurZ/FlVm56gi3mHYXt6TrHF81r /jwx3DMxK7UgrgEy4stji0aMZKGqki52PH1NOr24= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Paolo Abeni , Sasha Levin Subject: [PATCH 5.17 141/343] net: sfp: add 2500base-X quirk for Lantech SFP module Date: Tue, 12 Apr 2022 08:29:19 +0200 Message-Id: <20220412062955.455501564@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael Walle [ Upstream commit 00eec9fe4f3b9588b4bfa8ef9dd0aae96407d5d7 ] The Lantech 8330-262D-E module is 2500base-X capable, but it reports the nominal bitrate as 2500MBd instead of 3125MBd. Add a quirk for the module. The following in an EEPROM dump of such a SFP with the serial number redacted: 00: 03 04 07 00 00 00 01 20 40 0c 05 01 19 00 00 00 ???...? @????... 10: 1e 0f 00 00 4c 61 6e 74 65 63 68 20 20 20 20 20 ??..Lantech 20: 20 20 20 20 00 00 00 00 38 33 33 30 2d 32 36 32 ....8330-262 30: 44 2d 45 20 20 20 20 20 56 31 2e 30 03 52 00 cb D-E V1.0?R.? 40: 00 1a 00 00 46 43 XX XX XX XX XX XX XX XX XX XX .?..FCXXXXXXXXXX 50: 20 20 20 20 32 32 30 32 31 34 20 20 68 b0 01 98 220214 h??? 60: 45 58 54 52 45 4d 45 4c 59 20 43 4f 4d 50 41 54 EXTREMELY COMPAT 70: 49 42 4c 45 20 20 20 20 20 20 20 20 20 20 20 20 IBLE Signed-off-by: Michael Walle Link: https://lore.kernel.org/r/20220312205014.4154907-1-michael@walle.cc Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/phy/sfp-bus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index c1512c9925a6..15aa5ac1ff49 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -74,6 +74,12 @@ static const struct sfp_quirk sfp_quirks[] =3D { .vendor =3D "HUAWEI", .part =3D "MA5671A", .modes =3D sfp_quirk_2500basex, + }, { + // Lantech 8330-262D-E can operate at 2500base-X, but + // incorrectly report 2500MBd NRZ in their EEPROM + .vendor =3D "Lantech", + .part =3D "8330-262D-E", + .modes =3D sfp_quirk_2500basex, }, { .vendor =3D "UBNT", .part =3D "UF-INSTANT", --=20 2.35.1 From nobody Thu May 14 08:08:21 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 30B36C35294 for ; Tue, 12 Apr 2022 08:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384269AbiDLIkA (ORCPT ); Tue, 12 Apr 2022 04:40:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357196AbiDLHjv (ORCPT ); Tue, 12 Apr 2022 03:39:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03D01140C1; Tue, 12 Apr 2022 00:13: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 914EBB81A8F; Tue, 12 Apr 2022 07:13:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF3A9C385A5; Tue, 12 Apr 2022 07:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747614; bh=k6MVIFARZQ6g50RBnCIzx3cvvXS7ccTygWy55DHgzXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlyhgoKC2m6V1bzVbwSM1Y+FjUHvdpfT/yRjzyivFo3ayO9sk9E7ueFvZseAXQKiM zyLLVwm/5lARd89m/Hfc+nR7zS437HwUA6xwt62jllLy7PkTQFTvHIByxvsJRJ1M1n ODtdNhyQXneg6O1zIRbZjnw6Rflc3YsutAaGSzN4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "H. Nikolaus Schaller" , Sasha Levin Subject: [PATCH 5.17 142/343] usb: dwc3: omap: fix "unbalanced disables for smps10_out1" on omap5evm Date: Tue, 12 Apr 2022 08:29:20 +0200 Message-Id: <20220412062955.483417266@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: H. Nikolaus Schaller [ Upstream commit ac01df343e5a6c6bcead2ed421af1fde30f73e7e ] Usually, the vbus_regulator (smps10 on omap5evm) boots up disabled. Hence calling regulator_disable() indirectly through dwc3_omap_set_mailbox() during probe leads to: [ 10.332764] WARNING: CPU: 0 PID: 1628 at drivers/regulator/core.c:2853 _= regulator_disable+0x40/0x164 [ 10.351919] unbalanced disables for smps10_out1 [ 10.361298] Modules linked in: dwc3_omap(+) clk_twl6040 at24 gpio_twl604= 0 palmas_gpadc palmas_pwrbutton industrialio snd_soc_omap_mcbsp(+) snd_soc_ti_sdma display_connector ti_tpd= 12s015 drm leds_gpio drm_panel_orientation_quirks ip_tables x_tables ipv6 autofs4 [ 10.387818] CPU: 0 PID: 1628 Comm: systemd-udevd Not tainted 5.17.0-rc1-= letux-lpae+ #8139 [ 10.405129] Hardware name: Generic OMAP5 (Flattened Device Tree) [ 10.411455] unwind_backtrace from show_stack+0x10/0x14 [ 10.416970] show_stack from dump_stack_lvl+0x40/0x4c [ 10.422313] dump_stack_lvl from __warn+0xb8/0x170 [ 10.427377] __warn from warn_slowpath_fmt+0x70/0x9c [ 10.432595] warn_slowpath_fmt from _regulator_disable+0x40/0x164 [ 10.439037] _regulator_disable from regulator_disable+0x30/0x64 [ 10.445382] regulator_disable from dwc3_omap_set_mailbox+0x8c/0xf0 [dwc= 3_omap] [ 10.453116] dwc3_omap_set_mailbox [dwc3_omap] from dwc3_omap_probe+0x2b= 8/0x394 [dwc3_omap] [ 10.467021] dwc3_omap_probe [dwc3_omap] from platform_probe+0x58/0xa8 [ 10.481762] platform_probe from really_probe+0x168/0x2fc [ 10.481782] really_probe from __driver_probe_device+0xc4/0xd8 [ 10.481782] __driver_probe_device from driver_probe_device+0x24/0xa4 [ 10.503762] driver_probe_device from __driver_attach+0xc4/0xd8 [ 10.510018] __driver_attach from bus_for_each_dev+0x64/0xa0 [ 10.516001] bus_for_each_dev from bus_add_driver+0x148/0x1a4 [ 10.524880] bus_add_driver from driver_register+0xb4/0xf8 [ 10.530678] driver_register from do_one_initcall+0x90/0x1c4 [ 10.536661] do_one_initcall from do_init_module+0x4c/0x200 [ 10.536683] do_init_module from load_module+0x13dc/0x1910 [ 10.551159] load_module from sys_finit_module+0xc8/0xd8 [ 10.561319] sys_finit_module from __sys_trace_return+0x0/0x18 [ 10.561336] Exception stack(0xc344bfa8 to 0xc344bff0) [ 10.561341] bfa0: b6fb5778 b6fab8d8 00000007 b6ecfbb8 = 00000000 b6ed0398 [ 10.561341] bfc0: b6fb5778 b6fab8d8 855c0500 0000017b 00020000 b6f9a3cc = 00000000 b6fb5778 [ 10.595500] bfe0: bede18f8 bede18e8 b6ec9aeb b6dda1c2 [ 10.601345] ---[ end trace 0000000000000000 ]--- Fix this unnecessary warning by checking if the regulator is enabled. Signed-off-by: H. Nikolaus Schaller Link: https://lore.kernel.org/r/af3b750dc2265d875deaabcf5f80098c9645da45.16= 46744616.git.hns@goldelico.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/dwc3/dwc3-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index e196673f5c64..efaf0db595f4 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -242,7 +242,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *oma= p, break; =20 case OMAP_DWC3_ID_FLOAT: - if (omap->vbus_reg) + if (omap->vbus_reg && regulator_is_enabled(omap->vbus_reg)) regulator_disable(omap->vbus_reg); val =3D dwc3_omap_read_utmi_ctrl(omap); val |=3D USBOTGSS_UTMI_OTG_CTRL_IDDIG; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 561B8C35295 for ; Tue, 12 Apr 2022 08:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384306AbiDLIkG (ORCPT ); Tue, 12 Apr 2022 04:40:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357198AbiDLHjw (ORCPT ); Tue, 12 Apr 2022 03:39:52 -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 93D88140D1; Tue, 12 Apr 2022 00:13: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 4F964B81895; Tue, 12 Apr 2022 07:13:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92D71C385A6; Tue, 12 Apr 2022 07:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747617; bh=CeNnsAwWRiktZfe8Ev3NbZKEPZE7owzZjYfHqz/jVog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PIs9AvLxhtdL2nWK2QenQiHoD/28H9SuWa7LerD2G/pcsrs51b+R2rfFeTZU59FlC sX8ZXu6bfcERv56LGNi9/5hKQY4A8M8hNODKvajlhQRgun3Gn49W+eZ9GI1hTZ4rN+ 4JHMRI/C9R0e/6ZDos45o65vGSuVqQ8Idr3BhS9I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Sasha Levin Subject: [PATCH 5.17 143/343] xen/usb: harden xen_hcd against malicious backends Date: Tue, 12 Apr 2022 08:29:21 +0200 Message-Id: <20220412062955.511302940@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Juergen Gross [ Upstream commit aff477cb8f94613f501d386d10f20019e294bc35 ] Make sure a malicious backend can't cause any harm other than wrong I/O data. Missing are verification of the request id in a response, sanitizing the reported actual I/O length, and protection against interrupt storms from the backend. Signed-off-by: Juergen Gross Link: https://lore.kernel.org/r/20220311103509.12908-1-jgross@suse.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/usb/host/xen-hcd.c | 57 ++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c index 19b8c7ed74cb..4ed3ee328a4a 100644 --- a/drivers/usb/host/xen-hcd.c +++ b/drivers/usb/host/xen-hcd.c @@ -51,6 +51,7 @@ struct vdevice_status { struct usb_shadow { struct xenusb_urb_request req; struct urb *urb; + bool in_flight; }; =20 struct xenhcd_info { @@ -722,6 +723,12 @@ static void xenhcd_gnttab_done(struct xenhcd_info *inf= o, unsigned int id) int nr_segs =3D 0; int i; =20 + if (!shadow->in_flight) { + xenhcd_set_error(info, "Illegal request id"); + return; + } + shadow->in_flight =3D false; + nr_segs =3D shadow->req.nr_buffer_segs; =20 if (xenusb_pipeisoc(shadow->req.pipe)) @@ -805,6 +812,7 @@ static int xenhcd_do_request(struct xenhcd_info *info, = struct urb_priv *urbp) =20 info->urb_ring.req_prod_pvt++; info->shadow[id].urb =3D urb; + info->shadow[id].in_flight =3D true; =20 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&info->urb_ring, notify); if (notify) @@ -933,10 +941,27 @@ static int xenhcd_unlink_urb(struct xenhcd_info *info= , struct urb_priv *urbp) return ret; } =20 -static int xenhcd_urb_request_done(struct xenhcd_info *info) +static void xenhcd_res_to_urb(struct xenhcd_info *info, + struct xenusb_urb_response *res, struct urb *urb) +{ + if (unlikely(!urb)) + return; + + if (res->actual_length > urb->transfer_buffer_length) + urb->actual_length =3D urb->transfer_buffer_length; + else if (res->actual_length < 0) + urb->actual_length =3D 0; + else + urb->actual_length =3D res->actual_length; + urb->error_count =3D res->error_count; + urb->start_frame =3D res->start_frame; + xenhcd_giveback_urb(info, urb, res->status); +} + +static int xenhcd_urb_request_done(struct xenhcd_info *info, + unsigned int *eoiflag) { struct xenusb_urb_response res; - struct urb *urb; RING_IDX i, rp; __u16 id; int more_to_do =3D 0; @@ -963,16 +988,12 @@ static int xenhcd_urb_request_done(struct xenhcd_info= *info) xenhcd_gnttab_done(info, id); if (info->error) goto err; - urb =3D info->shadow[id].urb; - if (likely(urb)) { - urb->actual_length =3D res.actual_length; - urb->error_count =3D res.error_count; - urb->start_frame =3D res.start_frame; - xenhcd_giveback_urb(info, urb, res.status); - } + xenhcd_res_to_urb(info, &res, info->shadow[id].urb); } =20 xenhcd_add_id_to_freelist(info, id); + + *eoiflag =3D 0; } info->urb_ring.rsp_cons =3D i; =20 @@ -990,7 +1011,7 @@ static int xenhcd_urb_request_done(struct xenhcd_info = *info) return 0; } =20 -static int xenhcd_conn_notify(struct xenhcd_info *info) +static int xenhcd_conn_notify(struct xenhcd_info *info, unsigned int *eoif= lag) { struct xenusb_conn_response res; struct xenusb_conn_request *req; @@ -1035,6 +1056,8 @@ static int xenhcd_conn_notify(struct xenhcd_info *inf= o) info->conn_ring.req_prod_pvt); req->id =3D id; info->conn_ring.req_prod_pvt++; + + *eoiflag =3D 0; } =20 if (rc !=3D info->conn_ring.req_prod_pvt) @@ -1057,14 +1080,19 @@ static int xenhcd_conn_notify(struct xenhcd_info *i= nfo) static irqreturn_t xenhcd_int(int irq, void *dev_id) { struct xenhcd_info *info =3D (struct xenhcd_info *)dev_id; + unsigned int eoiflag =3D XEN_EOI_FLAG_SPURIOUS; =20 - if (unlikely(info->error)) + if (unlikely(info->error)) { + xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); return IRQ_HANDLED; + } =20 - while (xenhcd_urb_request_done(info) | xenhcd_conn_notify(info)) + while (xenhcd_urb_request_done(info, &eoiflag) | + xenhcd_conn_notify(info, &eoiflag)) /* Yield point for this unbounded loop. */ cond_resched(); =20 + xen_irq_lateeoi(irq, eoiflag); return IRQ_HANDLED; } =20 @@ -1141,9 +1169,9 @@ static int xenhcd_setup_rings(struct xenbus_device *d= ev, goto fail; } =20 - err =3D bind_evtchn_to_irq(info->evtchn); + err =3D bind_evtchn_to_irq_lateeoi(info->evtchn); if (err <=3D 0) { - xenbus_dev_fatal(dev, err, "bind_evtchn_to_irq"); + xenbus_dev_fatal(dev, err, "bind_evtchn_to_irq_lateeoi"); goto fail; } =20 @@ -1496,6 +1524,7 @@ static struct usb_hcd *xenhcd_create_hcd(struct xenbu= s_device *dev) for (i =3D 0; i < XENUSB_URB_RING_SIZE; i++) { info->shadow[i].req.id =3D i + 1; info->shadow[i].urb =3D NULL; + info->shadow[i].in_flight =3D false; } info->shadow[XENUSB_URB_RING_SIZE - 1].req.id =3D 0x0fff; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 402D8C4707F for ; Tue, 12 Apr 2022 08:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384291AbiDLIkE (ORCPT ); Tue, 12 Apr 2022 04:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357210AbiDLHjw (ORCPT ); Tue, 12 Apr 2022 03:39: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 BBECC140F0; Tue, 12 Apr 2022 00:13: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 29CF161701; Tue, 12 Apr 2022 07:13:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D680C385A1; Tue, 12 Apr 2022 07:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747619; bh=keaXA1ahsEIO9lUMtg0aK6GPS2FnsxjF9uZtFjHzBoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hDSBi0cLG0R/OFbB25Cgkcbkw9KB04SnizM9ZsOJr5uhBlWmSUykJ8sUyDrdwiN18 L9jVmaoBNeVeP+3PeQSvZsugeNp4BezTvo9Vi9rKswpplQO2pYHBzqfdLtPsQbjLLK 5Tph1PWkNIPxmri9i0SJL35KnVrexrCYPipXE1rM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Sean Wang , Deren Wu , Felix Fietkau , Sasha Levin Subject: [PATCH 5.17 144/343] mt76: fix monitor mode crash with sdio driver Date: Tue, 12 Apr 2022 08:29:22 +0200 Message-Id: <20220412062955.539382313@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Deren Wu [ Upstream commit 123bc712b1de0805f9d683687e17b1ec2aba0b68 ] mt7921s driver may receive frames with fragment buffers. If there is a CTS packet received in monitor mode, the payload is 10 bytes only and need 6 bytes header padding after RXD buffer. However, only RXD in the first linear buffer, if we pull buffer size RXD-size+6 bytes with skb_pull(), that would trigger "BUG_ON(skb->len < skb->data_len)" in __skb_pull(). To avoid the nonlinear buffer issue, enlarge the RXD size from 128 to 256 to make sure all MCU operation in linear buffer. [ 52.007562] kernel BUG at include/linux/skbuff.h:2313! [ 52.007578] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 52.007987] pc : skb_pull+0x48/0x4c [ 52.008015] lr : mt7921_queue_rx_skb+0x494/0x890 [mt7921_common] [ 52.008361] Call trace: [ 52.008377] skb_pull+0x48/0x4c [ 52.008400] mt76s_net_worker+0x134/0x1b0 [mt76_sdio 35339a92c6eb7d4bbcc= 806a1d22f56365565135c] [ 52.008431] __mt76_worker_fn+0xe8/0x170 [mt76 ef716597d11a77150bc07e3fd= d68eeb0f9b56917] [ 52.008449] kthread+0x148/0x3ac [ 52.008466] ret_from_fork+0x10/0x30 Signed-off-by: Lorenzo Bianconi Signed-off-by: Sean Wang Signed-off-by: Deren Wu Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/mediatek/mt76/mt76.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wirele= ss/mediatek/mt76/mt76.h index 1f6f7a44d3f0..5197fcb06649 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -19,7 +19,7 @@ =20 #define MT_MCU_RING_SIZE 32 #define MT_RX_BUF_SIZE 2048 -#define MT_SKB_HEAD_LEN 128 +#define MT_SKB_HEAD_LEN 256 =20 #define MT_MAX_NON_AQL_PKT 16 #define MT_TXQ_FREE_THR 32 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 AA3BDC352B6 for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357055AbiDLIkw (ORCPT ); Tue, 12 Apr 2022 04:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357215AbiDLHjw (ORCPT ); Tue, 12 Apr 2022 03:39:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F5C215718; Tue, 12 Apr 2022 00:13: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 57E7FB81B60; Tue, 12 Apr 2022 07:13:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB9F3C385A1; Tue, 12 Apr 2022 07:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747625; bh=X/XV6dqIM01stGb6muJgsi2Mox5PAsrFHhzqwvCyAKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHBJ9SnRSnI36Y7gONWlnSu2F17O+s1aEbFcA23cicJE9PGEdsWjaeuUr/Ty4HKdo a2LHGyyMsutRSLtax9zV4xByZVBeH9pdkqefI0uJnjLt579bXTZ2Mtn15GKxBVjpEH yYfN5JxMDZdU8S4gxtKPiLZL46UsaQaEI/pdTisc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov , Sasha Levin Subject: [PATCH 5.17 145/343] xtensa: fix DTC warning unit_address_format Date: Tue, 12 Apr 2022 08:29:23 +0200 Message-Id: <20220412062955.567293837@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Max Filippov [ Upstream commit e85d29ba4b24f68e7a78cb85c55e754362eeb2de ] DTC issues the following warnings when building xtfpga device trees: /soc/flash@00000000/partition@0x0: unit name should not have leading "0x" /soc/flash@00000000/partition@0x6000000: unit name should not have leading= "0x" /soc/flash@00000000/partition@0x6800000: unit name should not have leading= "0x" /soc/flash@00000000/partition@0x7fe0000: unit name should not have leading= "0x" Drop leading 0x from flash partition unit names. Signed-off-by: Max Filippov Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi | 8 ++++---- arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi b/arch/xtensa/boot= /dts/xtfpga-flash-128m.dtsi index 9bf8bad1dd18..c33932568aa7 100644 --- a/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi +++ b/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi @@ -8,19 +8,19 @@ reg =3D <0x00000000 0x08000000>; bank-width =3D <2>; device-width =3D <2>; - partition@0x0 { + partition@0 { label =3D "data"; reg =3D <0x00000000 0x06000000>; }; - partition@0x6000000 { + partition@6000000 { label =3D "boot loader area"; reg =3D <0x06000000 0x00800000>; }; - partition@0x6800000 { + partition@6800000 { label =3D "kernel image"; reg =3D <0x06800000 0x017e0000>; }; - partition@0x7fe0000 { + partition@7fe0000 { label =3D "boot environment"; reg =3D <0x07fe0000 0x00020000>; }; diff --git a/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi b/arch/xtensa/boot/= dts/xtfpga-flash-16m.dtsi index 40c2f81f7cb6..7bde2ab2d6fb 100644 --- a/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi +++ b/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi @@ -8,19 +8,19 @@ reg =3D <0x08000000 0x01000000>; bank-width =3D <2>; device-width =3D <2>; - partition@0x0 { + partition@0 { label =3D "boot loader area"; reg =3D <0x00000000 0x00400000>; }; - partition@0x400000 { + partition@400000 { label =3D "kernel image"; reg =3D <0x00400000 0x00600000>; }; - partition@0xa00000 { + partition@a00000 { label =3D "data"; reg =3D <0x00a00000 0x005e0000>; }; - partition@0xfe0000 { + partition@fe0000 { label =3D "boot environment"; reg =3D <0x00fe0000 0x00020000>; }; diff --git a/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi b/arch/xtensa/boot/d= ts/xtfpga-flash-4m.dtsi index fb8d3a9f33c2..0655b868749a 100644 --- a/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi +++ b/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi @@ -8,11 +8,11 @@ reg =3D <0x08000000 0x00400000>; bank-width =3D <2>; device-width =3D <2>; - partition@0x0 { + partition@0 { label =3D "boot loader area"; reg =3D <0x00000000 0x003f0000>; }; - partition@0x3f0000 { + partition@3f0000 { label =3D "boot environment"; reg =3D <0x003f0000 0x00010000>; }; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1FBBBC38161 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384421AbiDLIlk (ORCPT ); Tue, 12 Apr 2022 04:41:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357214AbiDLHjw (ORCPT ); Tue, 12 Apr 2022 03:39:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721581571B; Tue, 12 Apr 2022 00:13: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 194ACB81B46; Tue, 12 Apr 2022 07:13:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B102C385A5; Tue, 12 Apr 2022 07:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747627; bh=ljsjBHnVqmoW3KTJKR7AJNY4q6I3EsUNpYuZ6eKN6FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcPpoDGYzukfKFH3eWz6BsOVxGqVe6TUAOxIHYY0GIQ+AxMkdqqTUBKVCG3J2uax4 DpIpyXPuVQ5MEwRqgqQl5l+L50u9jCcVYxG3vA17IC0N4VC+vkebjxH2Cx4yVY+v1g FmlTfay+zbFgvXKe/iqrYmEjTfTAGnUDPheqI5YQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Emmanuel Grumbach , Luca Coelho , Kalle Valo , Sasha Levin Subject: [PATCH 5.17 146/343] iwlwifi: mei: fix building iwlmei Date: Tue, 12 Apr 2022 08:29:24 +0200 Message-Id: <20220412062955.595930684@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Arnd Bergmann [ Upstream commit 066291bec0c55315e568ead501bebdefcb8453d2 ] Building iwlmei without CONFIG_CFG80211 causes a link-time warning: ld.lld: error: undefined symbol: ieee80211_hdrlen >>> referenced by net.c >>> net/wireless/intel/iwlwifi/mei/net.o:(iwl_mei_tx_copy_to_= csme) in archive drivers/built-in.a Add an explicit dependency to avoid this. In theory it should not be needed here, but it also seems pointless to allow IWLMEI for configurations without CFG80211. Signed-off-by: Arnd Bergmann Acked-by: Emmanuel Grumbach Acked-by: Luca Coelho Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220316183617.1470631-1-arnd@kernel.org Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/wireless/intel/iwlwifi/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/intel/iwlwifi/Kconfig b/drivers/net/wirel= ess/intel/iwlwifi/Kconfig index 85e704283755..a647a406b87b 100644 --- a/drivers/net/wireless/intel/iwlwifi/Kconfig +++ b/drivers/net/wireless/intel/iwlwifi/Kconfig @@ -139,6 +139,7 @@ config IWLMEI tristate "Intel Management Engine communication over WLAN" depends on INTEL_MEI depends on PM + depends on CFG80211 help Enables the iwlmei kernel module. =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 DDD33C4167B for ; Tue, 12 Apr 2022 08:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384330AbiDLIlP (ORCPT ); Tue, 12 Apr 2022 04:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357218AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03:39:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E33015724; Tue, 12 Apr 2022 00:13: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 2868D61701; Tue, 12 Apr 2022 07:13:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36A2CC385A5; Tue, 12 Apr 2022 07:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747630; bh=dZarbFzJ2SmFz2NpPCeU+jku5aUbzpxIrwl8F+N21Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDbNBKLqPqgNe2TKsG0Q1p5wi83fAvfFfr5QKlmmOVRgevvYnfr5/9KoFjx3971Hu vpnUPcuAIa91MLvQP5scDVyBH1EFoewz2Z0VkWsKxr2yX1G41eq22ut+H2ELofYL/D z5ymB0UP4F/cp0fvXDI2e1jPrgbwg7uAa3YQ4YeM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Paul Cercueil , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.17 147/343] MIPS: ingenic: correct unit node address Date: Tue, 12 Apr 2022 08:29:25 +0200 Message-Id: <20220412062955.624518273@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Krzysztof Kozlowski [ Upstream commit 8931ddd8d6a55fcefb20f44a38ba42bb746f0b62 ] Unit node addresses should not have leading 0x: Warning (unit_address_format): /nemc@13410000/efuse@d0/eth-mac-addr@0x22:= unit name should not have leading "0x" Signed-off-by: Krzysztof Kozlowski Reviewed-by: Paul Cercueil Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/mips/boot/dts/ingenic/jz4780.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/boot/dts/ingenic/jz4780.dtsi b/arch/mips/boot/dts/in= genic/jz4780.dtsi index 3f9ea47a10cd..b998301f179c 100644 --- a/arch/mips/boot/dts/ingenic/jz4780.dtsi +++ b/arch/mips/boot/dts/ingenic/jz4780.dtsi @@ -510,7 +510,7 @@ #address-cells =3D <1>; #size-cells =3D <1>; =20 - eth0_addr: eth-mac-addr@0x22 { + eth0_addr: eth-mac-addr@22 { reg =3D <0x22 0x6>; }; }; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 533E4C4167B for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359674AbiDLItG (ORCPT ); Tue, 12 Apr 2022 04:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357598AbiDLHkb (ORCPT ); Tue, 12 Apr 2022 03:40:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEBFF3135D; Tue, 12 Apr 2022 00:16:10 -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 6C7F161045; Tue, 12 Apr 2022 07:16:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7508CC385A5; Tue, 12 Apr 2022 07:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747769; bh=F+WfjaRIYyl7shRSoxYdmAXqg25fnMoFXFUXEBvboDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mMvhLI1GcnMOOBKKnFEymDYfqo+zWaGE/PghvlBpbx4/RNOU1XcsK443XLAPZO1zE spHbS/9ZpF0xFBHEnDdu1ZtqjnAWvrfB+7ZDhqFbpPAewMU3aTQUbXuQgLCqGuDgei s8tHxBi6n++Tji9pMKXBMk8EAPpjnQDL/ywoBUZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?S=C3=B6nke=20Huster?= , Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.17 148/343] Bluetooth: Fix use after free in hci_send_acl Date: Tue, 12 Apr 2022 08:29:26 +0200 Message-Id: <20220412062955.652398797@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Luiz Augusto von Dentz [ Upstream commit f63d24baff787e13b723d86fe036f84bdbc35045 ] This fixes the following trace caused by receiving HCI_EV_DISCONN_PHY_LINK_COMPLETE which does call hci_conn_del without first checking if conn->type is in fact AMP_LINK and in case it is do properly cleanup upper layers with hci_disconn_cfm: =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 BUG: KASAN: use-after-free in hci_send_acl+0xaba/0xc50 Read of size 8 at addr ffff88800e404818 by task bluetoothd/142 CPU: 0 PID: 142 Comm: bluetoothd Not tainted 5.17.0-rc5-00006-gda4022eeac1a #7 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0x45/0x59 print_address_description.constprop.0+0x1f/0x150 kasan_report.cold+0x7f/0x11b hci_send_acl+0xaba/0xc50 l2cap_do_send+0x23f/0x3d0 l2cap_chan_send+0xc06/0x2cc0 l2cap_sock_sendmsg+0x201/0x2b0 sock_sendmsg+0xdc/0x110 sock_write_iter+0x20f/0x370 do_iter_readv_writev+0x343/0x690 do_iter_write+0x132/0x640 vfs_writev+0x198/0x570 do_writev+0x202/0x280 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RSP: 002b:00007ffce8a099b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014 Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 14 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10 RDX: 0000000000000001 RSI: 00007ffce8a099e0 RDI: 0000000000000015 RAX: ffffffffffffffda RBX: 00007ffce8a099e0 RCX: 00007f788fc3cf77 R10: 00007ffce8af7080 R11: 0000000000000246 R12: 000055e4ccf75580 RBP: 0000000000000015 R08: 0000000000000002 R09: 0000000000000001 R13: 000055e4ccf754a0 R14: 000055e4ccf75cd0 R15: 000055e4ccf4a6b0 Allocated by task 45: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0x81/0xa0 hci_chan_create+0x9a/0x2f0 l2cap_conn_add.part.0+0x1a/0xdc0 l2cap_connect_cfm+0x236/0x1000 le_conn_complete_evt+0x15a7/0x1db0 hci_le_conn_complete_evt+0x226/0x2c0 hci_le_meta_evt+0x247/0x450 hci_event_packet+0x61b/0xe90 hci_rx_work+0x4d5/0xc50 process_one_work+0x8fb/0x15a0 worker_thread+0x576/0x1240 kthread+0x29d/0x340 ret_from_fork+0x1f/0x30 Freed by task 45: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0xfb/0x130 kfree+0xac/0x350 hci_conn_cleanup+0x101/0x6a0 hci_conn_del+0x27e/0x6c0 hci_disconn_phylink_complete_evt+0xe0/0x120 hci_event_packet+0x812/0xe90 hci_rx_work+0x4d5/0xc50 process_one_work+0x8fb/0x15a0 worker_thread+0x576/0x1240 kthread+0x29d/0x340 ret_from_fork+0x1f/0x30 The buggy address belongs to the object at ffff88800c0f0500 The buggy address is located 24 bytes inside of which belongs to the cache kmalloc-128 of size 128 The buggy address belongs to the page: 128-byte region [ffff88800c0f0500, ffff88800c0f0580) flags: 0x100000000000200(slab|node=3D0|zone=3D1) page:00000000fe45cd86 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xc0f0 raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000 raw: 0100000000000200 ffffea00003a2c80 dead000000000004 ffff8880078418c0 page dumped because: kasan: bad access detected ffff88800c0f0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc Memory state around the buggy address: >ffff88800c0f0500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88800c0f0480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88800c0f0580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ =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 ffff88800c0f0600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb Reported-by: S=C3=B6nke Huster Tested-by: S=C3=B6nke Huster Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 63b925921c87..d984777c9b58 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5453,8 +5453,9 @@ static void hci_disconn_phylink_complete_evt(struct h= ci_dev *hdev, void *data, hci_dev_lock(hdev); =20 hcon =3D hci_conn_hash_lookup_handle(hdev, ev->phy_handle); - if (hcon) { + if (hcon && hcon->type =3D=3D AMP_LINK) { hcon->state =3D BT_CLOSED; + hci_disconn_cfm(hcon, ev->reason); hci_conn_del(hcon); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 732CCC38A04 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384608AbiDLImJ (ORCPT ); Tue, 12 Apr 2022 04:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357241AbiDLHjx (ORCPT ); Tue, 12 Apr 2022 03: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 74978DB1; Tue, 12 Apr 2022 00:14: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 2D937B81B4F; Tue, 12 Apr 2022 07:14:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C64C385A1; Tue, 12 Apr 2022 07:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747650; bh=qTmYQrOjWDd3Zahu3bZmLVJ06wcEPA21y1qIWN7atiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKvfQ/Fs/BiNRpDgJPMA5u8a77nTTB/e9EViRGtdZERjVaU9K6C+CX2tCfSir/WwO PO7yW9Sp2bc5yapK7BN8j7JtXYC4+rsSzK9TDc01cl9GAS2HfdMUIwxmB1FS7oGwec BKeP88ltEe5fADP04UzGbPs6TzOjkORDNU02Hzs4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karel Rericha , Shmulik Ladkani , Eyal Birger , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.17 149/343] netfilter: conntrack: revisit gc autotuning Date: Tue, 12 Apr 2022 08:29:27 +0200 Message-Id: <20220412062955.680707128@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Florian Westphal [ Upstream commit 2cfadb761d3d0219412fd8150faea60c7e863833 ] as of commit 4608fdfc07e1 ("netfilter: conntrack: collect all entries in one cycle") conntrack gc was changed to run every 2 minutes. On systems where conntrack hash table is set to large value, most evictions happen from gc worker rather than the packet path due to hash table distribution. This causes netlink event overflows when events are collected. This change collects average expiry of scanned entries and reschedules to the average remaining value, within 1 to 60 second interval. To avoid event overflows, reschedule after each bucket and add a limit for both run time and number of evictions per run. If more entries have to be evicted, reschedule and restart 1 jiffy into the future. Reported-by: Karel Rericha Cc: Shmulik Ladkani Cc: Eyal Birger Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/netfilter/nf_conntrack_core.c | 85 ++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 17 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack= _core.c index bf1e17c678f1..7552e1e9fd62 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -67,6 +67,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_hash); struct conntrack_gc_work { struct delayed_work dwork; u32 next_bucket; + u32 avg_timeout; + u32 start_time; bool exiting; bool early_drop; }; @@ -78,8 +80,19 @@ static __read_mostly bool nf_conntrack_locks_all; /* serialize hash resizes and nf_ct_iterate_cleanup */ static DEFINE_MUTEX(nf_conntrack_mutex); =20 -#define GC_SCAN_INTERVAL (120u * HZ) +#define GC_SCAN_INTERVAL_MAX (60ul * HZ) +#define GC_SCAN_INTERVAL_MIN (1ul * HZ) + +/* clamp timeouts to this value (TCP unacked) */ +#define GC_SCAN_INTERVAL_CLAMP (300ul * HZ) + +/* large initial bias so that we don't scan often just because we have + * three entries with a 1s timeout. + */ +#define GC_SCAN_INTERVAL_INIT INT_MAX + #define GC_SCAN_MAX_DURATION msecs_to_jiffies(10) +#define GC_SCAN_EXPIRED_MAX (64000u / HZ) =20 #define MIN_CHAINLEN 8u #define MAX_CHAINLEN (32u - MIN_CHAINLEN) @@ -1421,16 +1434,28 @@ static bool gc_worker_can_early_drop(const struct n= f_conn *ct) =20 static void gc_worker(struct work_struct *work) { - unsigned long end_time =3D jiffies + GC_SCAN_MAX_DURATION; unsigned int i, hashsz, nf_conntrack_max95 =3D 0; - unsigned long next_run =3D GC_SCAN_INTERVAL; + u32 end_time, start_time =3D nfct_time_stamp; struct conntrack_gc_work *gc_work; + unsigned int expired_count =3D 0; + unsigned long next_run; + s32 delta_time; + gc_work =3D container_of(work, struct conntrack_gc_work, dwork.work); =20 i =3D gc_work->next_bucket; if (gc_work->early_drop) nf_conntrack_max95 =3D nf_conntrack_max / 100u * 95u; =20 + if (i =3D=3D 0) { + gc_work->avg_timeout =3D GC_SCAN_INTERVAL_INIT; + gc_work->start_time =3D start_time; + } + + next_run =3D gc_work->avg_timeout; + + end_time =3D start_time + GC_SCAN_MAX_DURATION; + do { struct nf_conntrack_tuple_hash *h; struct hlist_nulls_head *ct_hash; @@ -1447,6 +1472,7 @@ static void gc_worker(struct work_struct *work) =20 hlist_nulls_for_each_entry_rcu(h, n, &ct_hash[i], hnnode) { struct nf_conntrack_net *cnet; + unsigned long expires; struct net *net; =20 tmp =3D nf_ct_tuplehash_to_ctrack(h); @@ -1456,11 +1482,29 @@ static void gc_worker(struct work_struct *work) continue; } =20 + if (expired_count > GC_SCAN_EXPIRED_MAX) { + rcu_read_unlock(); + + gc_work->next_bucket =3D i; + gc_work->avg_timeout =3D next_run; + + delta_time =3D nfct_time_stamp - gc_work->start_time; + + /* re-sched immediately if total cycle time is exceeded */ + next_run =3D delta_time < (s32)GC_SCAN_INTERVAL_MAX; + goto early_exit; + } + if (nf_ct_is_expired(tmp)) { nf_ct_gc_expired(tmp); + expired_count++; continue; } =20 + expires =3D clamp(nf_ct_expires(tmp), GC_SCAN_INTERVAL_MIN, GC_SCAN_INT= ERVAL_CLAMP); + next_run +=3D expires; + next_run /=3D 2u; + if (nf_conntrack_max95 =3D=3D 0 || gc_worker_skip_ct(tmp)) continue; =20 @@ -1478,8 +1522,10 @@ static void gc_worker(struct work_struct *work) continue; } =20 - if (gc_worker_can_early_drop(tmp)) + if (gc_worker_can_early_drop(tmp)) { nf_ct_kill(tmp); + expired_count++; + } =20 nf_ct_put(tmp); } @@ -1492,33 +1538,38 @@ static void gc_worker(struct work_struct *work) cond_resched(); i++; =20 - if (time_after(jiffies, end_time) && i < hashsz) { + delta_time =3D nfct_time_stamp - end_time; + if (delta_time > 0 && i < hashsz) { + gc_work->avg_timeout =3D next_run; gc_work->next_bucket =3D i; next_run =3D 0; - break; + goto early_exit; } } while (i < hashsz); =20 + gc_work->next_bucket =3D 0; + + next_run =3D clamp(next_run, GC_SCAN_INTERVAL_MIN, GC_SCAN_INTERVAL_MAX); + + delta_time =3D max_t(s32, nfct_time_stamp - gc_work->start_time, 1); + if (next_run > (unsigned long)delta_time) + next_run -=3D delta_time; + else + next_run =3D 1; + +early_exit: if (gc_work->exiting) return; =20 - /* - * Eviction will normally happen from the packet path, and not - * from this gc worker. - * - * This worker is only here to reap expired entries when system went - * idle after a busy period. - */ - if (next_run) { + if (next_run) gc_work->early_drop =3D false; - gc_work->next_bucket =3D 0; - } + queue_delayed_work(system_power_efficient_wq, &gc_work->dwork, next_run); } =20 static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work) { - INIT_DEFERRABLE_WORK(&gc_work->dwork, gc_worker); + INIT_DELAYED_WORK(&gc_work->dwork, gc_worker); gc_work->exiting =3D false; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 81422C433EF for ; Tue, 12 Apr 2022 08:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357126AbiDLIoR (ORCPT ); Tue, 12 Apr 2022 04:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357293AbiDLHj4 (ORCPT ); Tue, 12 Apr 2022 03:39:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA9F1E3D4; Tue, 12 Apr 2022 00:14: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 9EDB3B81B62; Tue, 12 Apr 2022 07:14:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0577AC385A1; Tue, 12 Apr 2022 07:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747680; bh=ZqlXdUHFwKSPIS8dpBAWhiyXJFdqK6peU9QQ/0n3vBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iweCU7X67mX5vijQ1xv3ga5c6XANO0ldz1B6DCsal14ipc3uOWzYPOGRZ4M7jThxA d2xYV/zG6QPsLCzX2ytzM4IpHR4R6mwtlA83fiFskGeQdbV1IVLtpy4zafs22J8BzS WK7gWysLD6K400BUQppZFQDEdFiw+1wrPUJWBqlk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Yufen , Paul Moore , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 150/343] netlabel: fix out-of-bounds memory accesses Date: Tue, 12 Apr 2022 08:29:28 +0200 Message-Id: <20220412062955.708919528@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Yufen [ Upstream commit f22881de730ebd472e15bcc2c0d1d46e36a87b9c ] In calipso_map_cat_ntoh(), in the for loop, if the return value of netlbl_bitmap_walk() is equal to (net_clen_bits - 1), when netlbl_bitmap_walk() is called next time, out-of-bounds memory accesses of bitmap[byte_offset] occurs. The bug was found during fuzzing. The following is the fuzzing report BUG: KASAN: slab-out-of-bounds in netlbl_bitmap_walk+0x3c/0xd0 Read of size 1 at addr ffffff8107bf6f70 by task err_OH/252 CPU: 7 PID: 252 Comm: err_OH Not tainted 5.17.0-rc7+ #17 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x21c/0x230 show_stack+0x1c/0x60 dump_stack_lvl+0x64/0x7c print_address_description.constprop.0+0x70/0x2d0 __kasan_report+0x158/0x16c kasan_report+0x74/0x120 __asan_load1+0x80/0xa0 netlbl_bitmap_walk+0x3c/0xd0 calipso_opt_getattr+0x1a8/0x230 calipso_sock_getattr+0x218/0x340 calipso_sock_getattr+0x44/0x60 netlbl_sock_getattr+0x44/0x80 selinux_netlbl_socket_setsockopt+0x138/0x170 selinux_socket_setsockopt+0x4c/0x60 security_socket_setsockopt+0x4c/0x90 __sys_setsockopt+0xbc/0x2b0 __arm64_sys_setsockopt+0x6c/0x84 invoke_syscall+0x64/0x190 el0_svc_common.constprop.0+0x88/0x200 do_el0_svc+0x88/0xa0 el0_svc+0x128/0x1b0 el0t_64_sync_handler+0x9c/0x120 el0t_64_sync+0x16c/0x170 Reported-by: Hulk Robot Signed-off-by: Wang Yufen Acked-by: Paul Moore Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/netlabel/netlabel_kapi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index beb0e573266d..54c083003947 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -885,6 +885,8 @@ int netlbl_bitmap_walk(const unsigned char *bitmap, u32= bitmap_len, unsigned char bitmask; unsigned char byte; =20 + if (offset >=3D bitmap_len) + return -1; byte_offset =3D offset / 8; byte =3D bitmap[byte_offset]; bit_spot =3D offset; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 DD7FBC433F5 for ; Tue, 12 Apr 2022 08:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343933AbiDLIoz (ORCPT ); Tue, 12 Apr 2022 04:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357327AbiDLHkA (ORCPT ); Tue, 12 Apr 2022 03:40:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2922524974; Tue, 12 Apr 2022 00:15: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 BA15F6171C; Tue, 12 Apr 2022 07:15:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2BABC385A1; Tue, 12 Apr 2022 07:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747711; bh=keLc67H85t1z1LYE4Ij/7iXTCebH1rFsl3z5VNrPjMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZDaF1Y6jNXeu59sqtCDnuTQC1jJY8C2MadZNXY2JbOC/ia5eg+UX1gmuJNW6kNiBF 7hV3Rc9ycHWZtVcq4pSQrSCaLhlkkmZ1tkeffU/by/m4sBTXHk1huIsWXcJp6sOZyo 3bQzmDFf3KfQhx0LuZqiXVJs+xvj1Y97mRjr+fL8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiubo Li , Jeff Layton , Ilya Dryomov , Sasha Levin Subject: [PATCH 5.17 151/343] ceph: fix inode reference leakage in ceph_get_snapdir() Date: Tue, 12 Apr 2022 08:29:29 +0200 Message-Id: <20220412062955.737159359@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiubo Li [ Upstream commit 322794d3355c33adcc4feace0045d85a8e4ed813 ] The ceph_get_inode() will search for or insert a new inode into the hash for the given vino, and return a reference to it. If new is non-NULL, its reference is consumed. We should release the reference when in error handing cases. Signed-off-by: Xiubo Li Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/ceph/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index ef4a980a7bf3..c092dce0485c 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -87,13 +87,13 @@ struct inode *ceph_get_snapdir(struct inode *parent) if (!S_ISDIR(parent->i_mode)) { pr_warn_once("bad snapdir parent type (mode=3D0%o)\n", parent->i_mode); - return ERR_PTR(-ENOTDIR); + goto err; } =20 if (!(inode->i_state & I_NEW) && !S_ISDIR(inode->i_mode)) { pr_warn_once("bad snapdir inode type (mode=3D0%o)\n", inode->i_mode); - return ERR_PTR(-ENOTDIR); + goto err; } =20 inode->i_mode =3D parent->i_mode; @@ -113,6 +113,12 @@ struct inode *ceph_get_snapdir(struct inode *parent) } =20 return inode; +err: + if ((inode->i_state & I_NEW)) + discard_new_inode(inode); + else + iput(inode); + return ERR_PTR(-ENOTDIR); } =20 const struct inode_operations ceph_file_iops =3D { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2E25FC433FE for ; Tue, 12 Apr 2022 08:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355924AbiDLIsB (ORCPT ); Tue, 12 Apr 2022 04:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357370AbiDLHkJ (ORCPT ); Tue, 12 Apr 2022 03:40:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B987925582; Tue, 12 Apr 2022 00:15: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 56B7B6153F; Tue, 12 Apr 2022 07:15:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 655C8C385A1; Tue, 12 Apr 2022 07:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747741; bh=v3qD+lbxvAnDXHBSBZdV7PZeHWEbKNY3rvkqSI17XYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C3NQSBKQUD6JdWtgJGCVIu3DKcoD98Wtf9OVYZHUl63c+tPz0A94pclZp2NzorrwX N13C+on1CorkC76HvW4L7nohj/MiaIDx6+looWLRIcednaxiAd3zN1NSh2SgfoyY/r yQL10tx07S2goIk3GrXVYRiRHtilj+j012ljmk2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiubo Li , Jeff Layton , Ilya Dryomov , Sasha Levin Subject: [PATCH 5.17 152/343] ceph: fix memory leak in ceph_readdir when note_last_dentry returns error Date: Tue, 12 Apr 2022 08:29:30 +0200 Message-Id: <20220412062955.766286874@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiubo Li [ Upstream commit f639d9867eea647005dc824e0e24f39ffc50d4e4 ] Reset the last_readdir at the same time, and add a comment explaining why we don't free last_readdir when dir_emit returns false. Signed-off-by: Xiubo Li Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/ceph/dir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 133dbd9338e7..d91fa53e12b3 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -478,8 +478,11 @@ static int ceph_readdir(struct file *file, struct dir_= context *ctx) 2 : (fpos_off(rde->offset) + 1); err =3D note_last_dentry(dfi, rde->name, rde->name_len, next_offset); - if (err) + if (err) { + ceph_mdsc_put_request(dfi->last_readdir); + dfi->last_readdir =3D NULL; return err; + } } else if (req->r_reply_info.dir_end) { dfi->next_offset =3D 2; /* keep last name */ @@ -520,6 +523,12 @@ static int ceph_readdir(struct file *file, struct dir_= context *ctx) if (!dir_emit(ctx, rde->name, rde->name_len, ceph_present_ino(inode->i_sb, le64_to_cpu(rde->inode.in->ino)), le32_to_cpu(rde->inode.in->mode) >> 12)) { + /* + * NOTE: Here no need to put the 'dfi->last_readdir', + * because when dir_emit stops us it's most likely + * doesn't have enough memory, etc. So for next readdir + * it will continue. + */ dout("filldir stopping us...\n"); return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 307FBC43219 for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357834AbiDLIsm (ORCPT ); Tue, 12 Apr 2022 04:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357503AbiDLHkY (ORCPT ); Tue, 12 Apr 2022 03:40:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04C212E0BE; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id 5B63161708; Tue, 12 Apr 2022 07:15:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68225C385A6; Tue, 12 Apr 2022 07:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747755; bh=LbsWdC+mLgfWbAbtREdt53kY3KupLyZQyMuQajWJW3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sk+o+Rzha8yQ8mjbETEbYu5XHtc1UVIByWCmXHydK/Ag1mIX9n/mueOnXU+2Z4EOb eMd/usiiW0PkhTpuu8M98+di+nCPDiRnu51un1ipDvYydE8o4+wxWkqOOFULcg5COO 0JS3TQ4qjkwn0Sp0315LsJdG2CsQtY4qpkhS00wc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Feng Tang , Guo Ren , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.17 153/343] lib/Kconfig.debug: add ARCH dependency for FUNCTION_ALIGN option Date: Tue, 12 Apr 2022 08:29:31 +0200 Message-Id: <20220412062955.794651182@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Feng Tang [ Upstream commit 1bf18da62106225dbc47aab41efee2aeb99caccd ] 0Day robots reported there is compiling issue for 'csky' ARCH when CONFIG_DEBUG_FORCE_DATA_SECTION_ALIGNED is enabled [1]: All errors (new ones prefixed by >>): {standard input}: Assembler messages: >> {standard input}:2277: Error: pcrel offset for branch to .LS000B too far= (0x3c) Which was discussed in [2]. And as there is no solution for csky yet, add some dependency for this config to limit it to several ARCHs which have no compiling issue so far. [1]. https://lore.kernel.org/lkml/202202271612.W32UJAj2-lkp@intel.com/ [2]. https://www.spinics.net/lists/linux-kbuild/msg30298.html Link: https://lkml.kernel.org/r/20220304021100.GN4548@shbuild999.sh.intel.c= om Reported-by: kernel test robot Signed-off-by: Feng Tang Cc: Guo Ren Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- lib/Kconfig.debug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 14b89aa37c5c..440fd666c16d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -416,7 +416,8 @@ config SECTION_MISMATCH_WARN_ONLY If unsure, say Y. =20 config DEBUG_FORCE_FUNCTION_ALIGN_64B - bool "Force all function address 64B aligned" if EXPERT + bool "Force all function address 64B aligned" + depends on EXPERT && (X86_64 || ARM64 || PPC32 || PPC64 || ARC) help There are cases that a commit from one domain changes the function address alignment of other domains, and cause magic performance --=20 2.35.1 From nobody Thu May 14 08:08:21 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 3EEA1C43217 for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358587AbiDLItA (ORCPT ); Tue, 12 Apr 2022 04:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357529AbiDLHk2 (ORCPT ); Tue, 12 Apr 2022 03:40:28 -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 E1E452ED4B; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id 083286171C; Tue, 12 Apr 2022 07:15:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D303C385A1; Tue, 12 Apr 2022 07:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747758; bh=WXPNMbKHeZmu5I4cLSUJ3+i9FCuDQHO/zys4GIzz3F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iWxTdCDdliCiydxzSRpbpw803YXFZGimimn7OsPUQHv6v7MHvd4vYu0gVZl96CpRv V4OqhzEJMXK+LANBMMKgsNRugzS09bS/AvmXo6Fns4Bo7Qc6JMvxdA/E0NPplCD1SK hFdula2Zv7pqp8AggRqlbXz7X7Uqy2ZEA1k5+ZOE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Igor Zhbanov , Ingo Molnar , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.17 154/343] init/main.c: return 1 from handled __setup() functions Date: Tue, 12 Apr 2022 08:29:32 +0200 Message-Id: <20220412062955.822813285@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Randy Dunlap [ Upstream commit f9a40b0890658330c83c95511f9d6b396610defc ] initcall_blacklist() should return 1 to indicate that it handled its cmdline arguments. set_debug_rodata() should return 1 to indicate that it handled its cmdline arguments. Print a warning if the option string is invalid. This prevents these strings from being added to the 'init' program's environment as they are not init arguments/parameters. Link: https://lkml.kernel.org/r/20220221050901.23985-1-rdunlap@infradead.org Signed-off-by: Randy Dunlap Reported-by: Igor Zhbanov Cc: Ingo Molnar Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- init/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/init/main.c b/init/main.c index ada50f5a15e4..9a5097b2251a 100644 --- a/init/main.c +++ b/init/main.c @@ -1192,7 +1192,7 @@ static int __init initcall_blacklist(char *str) } } while (str_entry); =20 - return 0; + return 1; } =20 static bool __init_or_module initcall_blacklisted(initcall_t fn) @@ -1454,7 +1454,9 @@ static noinline void __init kernel_init_freeable(void= ); bool rodata_enabled __ro_after_init =3D true; static int __init set_debug_rodata(char *str) { - return strtobool(str, &rodata_enabled); + if (strtobool(str, &rodata_enabled)) + pr_warn("Invalid option string for rodata: '%s'\n", str); + return 1; } __setup("rodata=3D", set_debug_rodata); #endif --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C039CC4167B for ; Tue, 12 Apr 2022 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354463AbiDLJTP (ORCPT ); Tue, 12 Apr 2022 05:19:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357556AbiDLHk3 (ORCPT ); Tue, 12 Apr 2022 03:40:29 -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 797EA2B188; Tue, 12 Apr 2022 00:16: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 dfw.source.kernel.org (Postfix) with ESMTPS id A7AE76176E; Tue, 12 Apr 2022 07:16:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB33FC385A1; Tue, 12 Apr 2022 07:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747761; bh=FuKjtPKoVK7gpsVJPs78/XrHFLnI2blZAVO9LBmv2XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eTdVU9+vvtHQ8OH0gZ9w2ltlQrBZVyxwjQBTPFqkhIY2MY75aQsdnMWR+oKrysHwY 0Q/c1n6eZJ+IKXF8wcqLkaR1osnT8RnGFzr4eFyMfDRKH+r869K9ROYKCDbiTDCQ1u V1HQwboZARh9d+Z6Y6cfZ2YPKVsEXFYc6T9Ssgqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qinghua Jin , Colin Ian King , Jan Kara , Christian Brauner , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.17 155/343] minix: fix bug when opening a file with O_DIRECT Date: Tue, 12 Apr 2022 08:29:33 +0200 Message-Id: <20220412062955.850949267@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Qinghua Jin [ Upstream commit 9ce3c0d26c42d279b6c378a03cd6a61d828f19ca ] Testcase: 1. create a minix file system and mount it 2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT 3. open fails with -EINVAL but leaves an empty file behind. All other open() failures don't leave the failed open files behind. It is hard to check the direct_IO op before creating the inode. Just as ext4 and btrfs do, this patch will resolve the issue by allowing to create the file with O_DIRECT but returning error when writing the file. Link: https://lkml.kernel.org/r/20220107133626.413379-1-qhjin.dev@gmail.com Signed-off-by: Qinghua Jin Reported-by: Colin Ian King Reviewed-by: Jan Kara Acked-by: Christian Brauner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/minix/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/minix/inode.c b/fs/minix/inode.c index a71f1cf894b9..d4bd94234ef7 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops= =3D { .writepage =3D minix_writepage, .write_begin =3D minix_write_begin, .write_end =3D generic_write_end, - .bmap =3D minix_bmap + .bmap =3D minix_bmap, + .direct_IO =3D noop_direct_IO }; =20 static const struct inode_operations minix_symlink_inode_operations =3D { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9924EC433F5 for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355729AbiDLJTZ (ORCPT ); Tue, 12 Apr 2022 05:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357560AbiDLHk3 (ORCPT ); Tue, 12 Apr 2022 03:40:29 -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 E00AA30F56; Tue, 12 Apr 2022 00:16: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 8841E6171C; Tue, 12 Apr 2022 07:16:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FA03C385A5; Tue, 12 Apr 2022 07:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747764; bh=eyF2VnUNxOloLVIPfKJn9iNPrihstZvyrnDzYF9Nnbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kgTYtzIAxKPqIcFQl6DUfmlVKJXggtV5k/2LscdUpTunzMEyEoYW+F88x2SD0dGpv GJScbZq8hrcUzE2BM/7UqyQr2LLkLMPdAIhXFp/ngMgpkaMcu+x/OzdnCC6ZjJJgju 12ld9jyzwXSvFTvdNDkg+x0zCnFiGXFa9/28GeKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Wujek , Robert Hancock , Stephen Boyd , Sasha Levin Subject: [PATCH 5.17 156/343] clk: si5341: fix reported clk_rate when output divider is 2 Date: Tue, 12 Apr 2022 08:29:34 +0200 Message-Id: <20220412062955.878980290@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Adam Wujek [ Upstream commit 2a8b539433e111c4de364237627ef219d2f6350a ] SI5341_OUT_CFG_RDIV_FORCE2 shall be checked first to distinguish whether a divider for a given output is set to 2 (SI5341_OUT_CFG_RDIV_FORCE2 is set) or the output is disabled (SI5341_OUT_CFG_RDIV_FORCE2 not set, SI5341_OUT_R_REG is set 0). Before the change, divider set to 2 (SI5341_OUT_R_REG set to 0) was interpreted as output is disabled. Signed-off-by: Adam Wujek Link: https://lore.kernel.org/r/20211203141125.2447520-1-dev_public@wujek.eu Reviewed-by: Robert Hancock Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/clk/clk-si5341.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c index f7b41366666e..4de098b6b0d4 100644 --- a/drivers/clk/clk-si5341.c +++ b/drivers/clk/clk-si5341.c @@ -798,6 +798,15 @@ static unsigned long si5341_output_clk_recalc_rate(str= uct clk_hw *hw, u32 r_divider; u8 r[3]; =20 + err =3D regmap_read(output->data->regmap, + SI5341_OUT_CONFIG(output), &val); + if (err < 0) + return err; + + /* If SI5341_OUT_CFG_RDIV_FORCE2 is set, r_divider is 2 */ + if (val & SI5341_OUT_CFG_RDIV_FORCE2) + return parent_rate / 2; + err =3D regmap_bulk_read(output->data->regmap, SI5341_OUT_R_REG(output), r, 3); if (err < 0) @@ -814,13 +823,6 @@ static unsigned long si5341_output_clk_recalc_rate(str= uct clk_hw *hw, r_divider +=3D 1; r_divider <<=3D 1; =20 - err =3D regmap_read(output->data->regmap, - SI5341_OUT_CONFIG(output), &val); - if (err < 0) - return err; - - if (val & SI5341_OUT_CFG_RDIV_FORCE2) - r_divider =3D 2; =20 return parent_rate / r_divider; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 07EDFC41535 for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354398AbiDLJTC (ORCPT ); Tue, 12 Apr 2022 05:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357594AbiDLHkb (ORCPT ); Tue, 12 Apr 2022 03:40:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71EDF2F3B8; Tue, 12 Apr 2022 00:16: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 26EFBB81B62; Tue, 12 Apr 2022 07:16:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CBCAC385A5; Tue, 12 Apr 2022 07:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747767; bh=9knYtZs4cQxxwU+rTTGT8DPToBcIrwxkKouo22iwZ0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQd04LzbtbwJCxRrQcvWWa8wdaOdMMXakPh3GB1rFd23rPDVs096hvcGxxXpk/ne8 36quy3AkEhfg/FW67TLim9UEaEojoBjKW+aGGeh0NkPjSfNDQYwbLME39lIH6LS3uA ipsS2UkMFKKb7Cr0yQ0ro33slu4yGBdotSk3rywE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Chen-Yu Tsai , Stephen Boyd , Sasha Levin Subject: [PATCH 5.17 157/343] clk: mediatek: Fix memory leaks on probe Date: Tue, 12 Apr 2022 08:29:35 +0200 Message-Id: <20220412062955.906954562@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jos=C3=A9 Exp=C3=B3sito [ Upstream commit 7a688c91d3fd54c53e7a9edd6052cdae98dd99d8 ] Handle the error branches to free memory where required. Addresses-Coverity-ID: 1491825 ("Resource leak") Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Reviewed-by: Chen-Yu Tsai Link: https://lore.kernel.org/r/20220115183059.GA10809@elementary Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/clk/mediatek/clk-mt8192.c | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-m= t8192.c index cbc7c6dbe0f4..79ddb3cc0b98 100644 --- a/drivers/clk/mediatek/clk-mt8192.c +++ b/drivers/clk/mediatek/clk-mt8192.c @@ -1236,9 +1236,17 @@ static int clk_mt8192_infra_probe(struct platform_de= vice *pdev) =20 r =3D mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks), cl= k_data); if (r) - return r; + goto free_clk_data; + + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + if (r) + goto free_clk_data; + + return r; =20 - return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); +free_clk_data: + mtk_free_clk_data(clk_data); + return r; } =20 static int clk_mt8192_peri_probe(struct platform_device *pdev) @@ -1253,9 +1261,17 @@ static int clk_mt8192_peri_probe(struct platform_dev= ice *pdev) =20 r =3D mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks), clk_= data); if (r) - return r; + goto free_clk_data; + + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + if (r) + goto free_clk_data; =20 - return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + return r; + +free_clk_data: + mtk_free_clk_data(clk_data); + return r; } =20 static int clk_mt8192_apmixed_probe(struct platform_device *pdev) @@ -1271,9 +1287,17 @@ static int clk_mt8192_apmixed_probe(struct platform_= device *pdev) mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); r =3D mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks)= , clk_data); if (r) - return r; + goto free_clk_data; =20 - return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + r =3D of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); + if (r) + goto free_clk_data; + + return r; + +free_clk_data: + mtk_free_clk_data(clk_data); + return r; } =20 static const struct of_device_id of_match_clk_mt8192[] =3D { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 931BEC43219 for ; Tue, 12 Apr 2022 08:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384471AbiDLIlx (ORCPT ); Tue, 12 Apr 2022 04:41:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357248AbiDLHjy (ORCPT ); Tue, 12 Apr 2022 03:39: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 66D23E0B; Tue, 12 Apr 2022 00:14: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 23AACB81B46; Tue, 12 Apr 2022 07:14:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 721CEC385A1; Tue, 12 Apr 2022 07:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747652; bh=Zke0KUd98G+PJPnwjnLa6rkCfnBKinhb5f79hj3Av60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLqtc0y2wJHFm9u64sPqcThy0VjbqaBCkuYmyWwebr47ZUNk56HD2rdzpUYDfq3ga 9g51ev7hBUVKirecn32Tq6/sMJBGAbhW6bXAjtnlVH8swxVV+6MjkeEQhrishYAs9p H6MzSBGCQxTFm9eap7nCMltqRM27oyLoAzFzLHzE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Stefan Wahren , Sasha Levin Subject: [PATCH 5.17 158/343] staging: vchiq_arm: Avoid NULL ptr deref in vchiq_dump_platform_instances Date: Tue, 12 Apr 2022 08:29:36 +0200 Message-Id: <20220412062955.935949677@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Stefan Wahren [ Upstream commit aa899e686d442c63d50f4d369cc02dbbf0941cb0 ] vchiq_get_state() can return a NULL pointer. So handle this cases and avoid a NULL pointer derefence in vchiq_dump_platform_instances. Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/1642968143-19281-17-git-send-email-stefan.w= ahren@i2se.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c = b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3a2e4582db8e..a3e3c9f9aa18 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1209,6 +1209,9 @@ int vchiq_dump_platform_instances(void *dump_context) int len; int i; =20 + if (!state) + return -ENOTCONN; + /* * There is no list of instances, so instead scan all services, * marking those that have been dumped. --=20 2.35.1 From nobody Thu May 14 08:08:21 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 86393C433FE for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353122AbiDLJCY (ORCPT ); Tue, 12 Apr 2022 05:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357249AbiDLHjy (ORCPT ); Tue, 12 Apr 2022 03:39:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90CE6F15; Tue, 12 Apr 2022 00:14: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2C7A96171C; Tue, 12 Apr 2022 07:14:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37597C385A1; Tue, 12 Apr 2022 07:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747655; bh=2kkz2HUea5hGrLe3sIdjMljDa9VPFb9vQcDZSKUWuuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+Mz38X1iy2i7dwYYS5qHn3z51afrOex7ljTT8Pfo09J2QYD363wRBNntNb8yEtVo WDyCzHfunUoMWmRAoeS14QL2DPtnJHnrAy7eRuga8OpRsPOMlBqI0nHO/PH4qDvzJS 4WeE9QaCVJNqIbv4oTAHxGOhsZKBm53nmQoxg5lo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Stefan Wahren , Sasha Levin Subject: [PATCH 5.17 159/343] staging: vchiq_core: handle NULL result of find_service_by_handle Date: Tue, 12 Apr 2022 08:29:37 +0200 Message-Id: <20220412062955.964487496@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Stefan Wahren [ Upstream commit ca225857faf237234d2fffe5d1919467dfadd822 ] In case of an invalid handle the function find_servive_by_handle returns NULL. So take care of this and avoid a NULL pointer dereference. Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/1642968143-19281-18-git-send-email-stefan.w= ahren@i2se.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c= b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 7fe20d4b7ba2..b7295236671c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2306,6 +2306,9 @@ void vchiq_msg_queue_push(unsigned int handle, struct= vchiq_header *header) struct vchiq_service *service =3D find_service_by_handle(handle); int pos; =20 + if (!service) + return; + while (service->msg_queue_write =3D=3D service->msg_queue_read + VCHIQ_MAX_SLOTS) { if (wait_for_completion_interruptible(&service->msg_queue_pop)) @@ -2326,6 +2329,9 @@ struct vchiq_header *vchiq_msg_hold(unsigned int hand= le) struct vchiq_header *header; int pos; =20 + if (!service) + return NULL; + if (service->msg_queue_write =3D=3D service->msg_queue_read) return NULL; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 8BCDBC38A02 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384677AbiDLImO (ORCPT ); Tue, 12 Apr 2022 04:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357251AbiDLHjy (ORCPT ); Tue, 12 Apr 2022 03:39:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131D6264C; Tue, 12 Apr 2022 00:14: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 ams.source.kernel.org (Postfix) with ESMTPS id AF849B81B66; Tue, 12 Apr 2022 07:14:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04EEDC385A5; Tue, 12 Apr 2022 07:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747658; bh=XfMjc/mEojywwv+HmJCaUPY9r9cNx70P9ORURw+i7N0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UP2g7MUPB/nL/z9coLR+Vt+nLGZhthQnns6OWz9Wuvawj/NMqijv8s7LcJvPxUJqx wOc0mK4DFOgcOhH+eTGZE0cpj6akwxHLNp6PKqw8RllWvsmFxZiLuSmKocysGA8VvV APQ3a7hUXRqs4hHvZeTbMQeFKocN0Th0yzKARwU8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amjad Ouled-Ameur , Jerome Brunet , Martin Blumenstingl , Philipp Zabel , Neil Armstrong , Vinod Koul , Sasha Levin Subject: [PATCH 5.17 160/343] phy: amlogic: phy-meson-gxl-usb2: fix shared reset controller use Date: Tue, 12 Apr 2022 08:29:38 +0200 Message-Id: <20220412062955.992671708@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Amjad Ouled-Ameur [ Upstream commit 2f87727130ce17ffefecd0895eeebf22d5a36f6f ] Use reset_control_rearm() call if an error occurs in case phy_meson_gxl_usb2_init() fails after reset() has been called ; or in case phy_meson_gxl_usb2_exit() is called i.e the resource is no longer used and the reset line may be triggered again by other devices. reset_control_rearm() keeps use of triggered_count sane in the reset framework. Therefore, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm(). Signed-off-by: Amjad Ouled-Ameur Reported-by: Jerome Brunet Reviewed-by: Martin Blumenstingl Reviewed-by: Philipp Zabel Acked-by: Neil Armstrong Link: https://lore.kernel.org/r/20220111095255.176141-2-aouledameur@baylibr= e.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/phy/amlogic/phy-meson-gxl-usb2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/phy/amlogic/phy-meson-gxl-usb2.c b/drivers/phy/amlogic= /phy-meson-gxl-usb2.c index 2b3c0d730f20..db17c3448bfe 100644 --- a/drivers/phy/amlogic/phy-meson-gxl-usb2.c +++ b/drivers/phy/amlogic/phy-meson-gxl-usb2.c @@ -114,8 +114,10 @@ static int phy_meson_gxl_usb2_init(struct phy *phy) return ret; =20 ret =3D clk_prepare_enable(priv->clk); - if (ret) + if (ret) { + reset_control_rearm(priv->reset); return ret; + } =20 return 0; } @@ -125,6 +127,7 @@ static int phy_meson_gxl_usb2_exit(struct phy *phy) struct phy_meson_gxl_usb2_priv *priv =3D phy_get_drvdata(phy); =20 clk_disable_unprepare(priv->clk); + reset_control_rearm(priv->reset); =20 return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9FAA1C47086 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384716AbiDLImQ (ORCPT ); Tue, 12 Apr 2022 04:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357253AbiDLHjy (ORCPT ); Tue, 12 Apr 2022 03:39:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE335F67; Tue, 12 Apr 2022 00:14: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 dfw.source.kernel.org (Postfix) with ESMTPS id C082661708; Tue, 12 Apr 2022 07:14:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF4E7C385A1; Tue, 12 Apr 2022 07:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747661; bh=bAPP0KeYlE4Rw4hQig6h+AE3aP+2SVdMxEk/gwMuZbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cA2GC7/uj4coysw4y5OK7WK41CPcTzwIug32K2rqi5zeibHDCr7xBhSsdXNZ5aVVr WIQzWvaWZPI6ZOIiPt4Xbzz7gG398zOWK2bXsVDsqHdYGh7CZrK6b5J0bL5HtTuwUS Sdr/tIXDX4qD8zLEoW4C3HxRHIVi6tB7peUxw854= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amjad Ouled-Ameur , Martin Blumenstingl , Neil Armstrong , Vinod Koul , Sasha Levin Subject: [PATCH 5.17 161/343] phy: amlogic: meson8b-usb2: Use dev_err_probe() Date: Tue, 12 Apr 2022 08:29:39 +0200 Message-Id: <20220412062956.021318385@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Amjad Ouled-Ameur [ Upstream commit 6466ba1898d415b527e1013bd8551a6fdfece94c ] Use the existing dev_err_probe() helper instead of open-coding the same operation. Signed-off-by: Amjad Ouled-Ameur Reported-by: Martin Blumenstingl Reviewed-by: Martin Blumenstingl Acked-by: Neil Armstrong Link: https://lore.kernel.org/r/20220111095255.176141-3-aouledameur@baylibr= e.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/phy/amlogic/phy-meson8b-usb2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/p= hy-meson8b-usb2.c index cf10bed40528..77e7e9b1428c 100644 --- a/drivers/phy/amlogic/phy-meson8b-usb2.c +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c @@ -265,8 +265,9 @@ static int phy_meson8b_usb2_probe(struct platform_devic= e *pdev) return PTR_ERR(priv->clk_usb); =20 priv->reset =3D devm_reset_control_get_optional_shared(&pdev->dev, NULL); - if (PTR_ERR(priv->reset) =3D=3D -EPROBE_DEFER) - return PTR_ERR(priv->reset); + if (IS_ERR(priv->reset)) + return dev_err_probe(&pdev->dev, PTR_ERR(priv->reset), + "Failed to get the reset line"); =20 priv->dr_mode =3D of_usb_get_dr_mode_by_phy(pdev->dev.of_node, -1); if (priv->dr_mode =3D=3D USB_DR_MODE_UNKNOWN) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B39B1C4321E for ; Tue, 12 Apr 2022 08:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384778AbiDLImU (ORCPT ); Tue, 12 Apr 2022 04:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357257AbiDLHjy (ORCPT ); Tue, 12 Apr 2022 03:39:54 -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 2EC2D657C; Tue, 12 Apr 2022 00:14: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 BFDE96171D; Tue, 12 Apr 2022 07:14:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9E28C385A1; Tue, 12 Apr 2022 07:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747664; bh=+YTNds+8z0t2zHdYuIfAV4xXR8U6PjwOkzvV2rN7NGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2EOy1y7cIxiAeJnyBUU9ztV/jD5Dowz/7Ll5N6uS6DBKuv1IJ1pQmL1xMc/1gQ7c8 sK8v7YZ1BX8v7KlCV4HtyvQEMU2zw0kY3BwMSWOstcwyjmpjm35q/weq3YN7fBHbCX NXgS/Aen1Qs6925oGkFPVNhznld0eRKFfKhkq5Cg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amjad Ouled-Ameur , Jerome Brunet , Martin Blumenstingl , Neil Armstrong , Vinod Koul , Sasha Levin Subject: [PATCH 5.17 162/343] phy: amlogic: meson8b-usb2: fix shared reset control use Date: Tue, 12 Apr 2022 08:29:40 +0200 Message-Id: <20220412062956.050167011@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Amjad Ouled-Ameur [ Upstream commit 6f1dedf089ab1a4f03ea7aadc3c4a99885b4b4a0 ] Use reset_control_rearm() call if an error occurs in case phy_meson8b_usb2_power_on() fails after reset() has been called, or in case phy_meson8b_usb2_power_off() is called i.e the resource is no longer used and the reset line may be triggered again by other devices. reset_control_rearm() keeps use of triggered_count sane in the reset framework, use of reset_control_reset() on shared reset line should be balanced with reset_control_rearm(). Signed-off-by: Amjad Ouled-Ameur Reported-by: Jerome Brunet Reviewed-by: Martin Blumenstingl Acked-by: Neil Armstrong Link: https://lore.kernel.org/r/20220111095255.176141-4-aouledameur@baylibr= e.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/phy/amlogic/phy-meson8b-usb2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/p= hy-meson8b-usb2.c index 77e7e9b1428c..dd96763911b8 100644 --- a/drivers/phy/amlogic/phy-meson8b-usb2.c +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c @@ -154,6 +154,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) ret =3D clk_prepare_enable(priv->clk_usb_general); if (ret) { dev_err(&phy->dev, "Failed to enable USB general clock\n"); + reset_control_rearm(priv->reset); return ret; } =20 @@ -161,6 +162,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) if (ret) { dev_err(&phy->dev, "Failed to enable USB DDR clock\n"); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return ret; } =20 @@ -199,6 +201,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy) dev_warn(&phy->dev, "USB ID detect failed!\n"); clk_disable_unprepare(priv->clk_usb); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); return -EINVAL; } } @@ -218,6 +221,7 @@ static int phy_meson8b_usb2_power_off(struct phy *phy) =20 clk_disable_unprepare(priv->clk_usb); clk_disable_unprepare(priv->clk_usb_general); + reset_control_rearm(priv->reset); =20 /* power off the PHY by putting it into reset mode */ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CA191C43217 for ; Tue, 12 Apr 2022 08:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384973AbiDLImi (ORCPT ); Tue, 12 Apr 2022 04:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357267AbiDLHjz (ORCPT ); Tue, 12 Apr 2022 03:39:55 -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 21B4865C2; Tue, 12 Apr 2022 00:14: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 310EFB81A8F; Tue, 12 Apr 2022 07:14:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F006C385A1; Tue, 12 Apr 2022 07:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747667; bh=DxwY6l76XGwbPyQnxRwmwMjVIFRBEV1XjogZrmYIAC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5FLyzkOg2MDTowKJzmBLHd9D1RK9VQgrMYBD+5Fzf3P+vhDxw83Wn4I56b+JDesV tISbPNe9jhwYOwMgGA6gm95IaeVZaLgswivfbW3HjKsGBSSrgVV9ssnyQV1YCJIFUn Dpsvv1EePMoDPPP13LILl/IkYIpFz5EHuw87Tifs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sascha Hauer , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.17 163/343] clk: rockchip: drop CLK_SET_RATE_PARENT from dclk_vop* on rk3568 Date: Tue, 12 Apr 2022 08:29:41 +0200 Message-Id: <20220412062956.078049636@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sascha Hauer [ Upstream commit ff3187eabb5ce478d15b6ed62eb286756adefac3 ] The pixel clocks dclk_vop[012] can be clocked from hpll, vpll, gpll or cpll. gpll and cpll also drive many other clocks, so changing the dclk_vop[012] clocks could change these other clocks as well. Drop CLK_SET_RATE_PARENT to fix that. With this change the VOP2 driver can only adjust the pixel clocks with the divider between the PLL and the dclk_vop[012] which means the user may have to adjust the PLL clock to a suitable rate using the assigned-clock-rate device tree property. Signed-off-by: Sascha Hauer Link: https://lore.kernel.org/r/20220126145549.617165-25-s.hauer@pengutroni= x.de Signed-off-by: Heiko Stuebner Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/clk/rockchip/clk-rk3568.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/rockchip/clk-rk3568.c b/drivers/clk/rockchip/clk-r= k3568.c index 69a9e8069a48..604a367bc498 100644 --- a/drivers/clk/rockchip/clk-rk3568.c +++ b/drivers/clk/rockchip/clk-rk3568.c @@ -1038,13 +1038,13 @@ static struct rockchip_clk_branch rk3568_clk_branch= es[] __initdata =3D { RK3568_CLKGATE_CON(20), 8, GFLAGS), GATE(HCLK_VOP, "hclk_vop", "hclk_vo", 0, RK3568_CLKGATE_CON(20), 9, GFLAGS), - COMPOSITE(DCLK_VOP0, "dclk_vop0", hpll_vpll_gpll_cpll_p, CLK_SET_RATE_PAR= ENT | CLK_SET_RATE_NO_REPARENT, + COMPOSITE(DCLK_VOP0, "dclk_vop0", hpll_vpll_gpll_cpll_p, CLK_SET_RATE_NO_= REPARENT, RK3568_CLKSEL_CON(39), 10, 2, MFLAGS, 0, 8, DFLAGS, RK3568_CLKGATE_CON(20), 10, GFLAGS), - COMPOSITE(DCLK_VOP1, "dclk_vop1", hpll_vpll_gpll_cpll_p, CLK_SET_RATE_PAR= ENT | CLK_SET_RATE_NO_REPARENT, + COMPOSITE(DCLK_VOP1, "dclk_vop1", hpll_vpll_gpll_cpll_p, CLK_SET_RATE_NO_= REPARENT, RK3568_CLKSEL_CON(40), 10, 2, MFLAGS, 0, 8, DFLAGS, RK3568_CLKGATE_CON(20), 11, GFLAGS), - COMPOSITE(DCLK_VOP2, "dclk_vop2", hpll_vpll_gpll_cpll_p, 0, + COMPOSITE(DCLK_VOP2, "dclk_vop2", hpll_vpll_gpll_cpll_p, CLK_SET_RATE_NO_= REPARENT, RK3568_CLKSEL_CON(41), 10, 2, MFLAGS, 0, 8, DFLAGS, RK3568_CLKGATE_CON(20), 12, GFLAGS), GATE(CLK_VOP_PWM, "clk_vop_pwm", "xin24m", 0, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B5575C38A06 for ; Tue, 12 Apr 2022 08:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384831AbiDLImY (ORCPT ); Tue, 12 Apr 2022 04:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357269AbiDLHjz (ORCPT ); Tue, 12 Apr 2022 03:39:55 -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 41997BF4A; Tue, 12 Apr 2022 00:14: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 EC7C3B81B4F; Tue, 12 Apr 2022 07:14:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45A1BC385A5; Tue, 12 Apr 2022 07:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747669; bh=0+xvbaE1I0/8b+wbY9uFiN56VFJGLSH7zHl8KdntBK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j1pO9rxpUkCVSGocdvD8iNqENW8opFsh9sJZlegdoGzmVo0pWzlMccccKOcGXghLy fUJ2Et4fmFajUABKFRsTUqRcO55Nw1Zidh//3QmBoIgoikx505qAIGvfF2mdCZTC6B m3yen8C6bJpT3EafCVyGEQz36qkW1YkE5ZPaV2Jk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukasz Luba , Morten Rasmussen , Pierre Gondois , Viresh Kumar , Sasha Levin Subject: [PATCH 5.17 164/343] cpufreq: CPPC: Fix performance/frequency conversion Date: Tue, 12 Apr 2022 08:29:42 +0200 Message-Id: <20220412062956.106488224@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pierre Gondois [ Upstream commit ec1c7ad47664f964c1101fe555b6fde0cb124b38 ] CPUfreq governors request CPU frequencies using information on current CPU usage. The CPPC driver converts them to performance requests. Frequency targets are computed as: target_freq =3D (util / cpu_capacity) * max_freq target_freq is then clamped between [policy->min, policy->max]. The CPPC driver converts performance values to frequencies (and vice-versa) using cppc_cpufreq_perf_to_khz() and cppc_cpufreq_khz_to_perf(). These functions both use two different factors depending on the range of the input value. For cppc_cpufreq_khz_to_perf(): - (NOMINAL_PERF / NOMINAL_FREQ) or - (LOWEST_PERF / LOWEST_FREQ) and for cppc_cpufreq_perf_to_khz(): - (NOMINAL_FREQ / NOMINAL_PERF) or - ((NOMINAL_PERF - LOWEST_FREQ) / (NOMINAL_PERF - LOWEST_PERF)) This means: 1- the functions are not inverse for some values: (perf_to_khz(khz_to_perf(x)) !=3D x) 2- cppc_cpufreq_perf_to_khz(LOWEST_PERF) can sometimes give a different value from LOWEST_FREQ due to integer approximation 3- it is implied that performance and frequency are proportional (NOMINAL_FREQ / NOMINAL_PERF) =3D=3D (LOWEST_PERF / LOWEST_FREQ) This patch changes the conversion functions to an affine function. This fixes the 3 points above. Suggested-by: Lukasz Luba Suggested-by: Morten Rasmussen Signed-off-by: Pierre Gondois Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/cpufreq/cppc_cpufreq.c | 43 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index db17196266e4..82d370ae6a4a 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -303,52 +303,48 @@ static u64 cppc_get_dmi_max_khz(void) =20 /* * If CPPC lowest_freq and nominal_freq registers are exposed then we can - * use them to convert perf to freq and vice versa - * - * If the perf/freq point lies between Nominal and Lowest, we can treat - * (Low perf, Low freq) and (Nom Perf, Nom freq) as 2D co-ordinates of a l= ine - * and extrapolate the rest - * For perf/freq > Nominal, we use the ratio perf:freq at Nominal for conv= ersion + * use them to convert perf to freq and vice versa. The conversion is + * extrapolated as an affine function passing by the 2 points: + * - (Low perf, Low freq) + * - (Nominal perf, Nominal perf) */ static unsigned int cppc_cpufreq_perf_to_khz(struct cppc_cpudata *cpu_data, unsigned int perf) { struct cppc_perf_caps *caps =3D &cpu_data->perf_caps; + s64 retval, offset =3D 0; static u64 max_khz; u64 mul, div; =20 if (caps->lowest_freq && caps->nominal_freq) { - if (perf >=3D caps->nominal_perf) { - mul =3D caps->nominal_freq; - div =3D caps->nominal_perf; - } else { - mul =3D caps->nominal_freq - caps->lowest_freq; - div =3D caps->nominal_perf - caps->lowest_perf; - } + mul =3D caps->nominal_freq - caps->lowest_freq; + div =3D caps->nominal_perf - caps->lowest_perf; + offset =3D caps->nominal_freq - div64_u64(caps->nominal_perf * mul, div); } else { if (!max_khz) max_khz =3D cppc_get_dmi_max_khz(); mul =3D max_khz; div =3D caps->highest_perf; } - return (u64)perf * mul / div; + + retval =3D offset + div64_u64(perf * mul, div); + if (retval >=3D 0) + return retval; + return 0; } =20 static unsigned int cppc_cpufreq_khz_to_perf(struct cppc_cpudata *cpu_data, unsigned int freq) { struct cppc_perf_caps *caps =3D &cpu_data->perf_caps; + s64 retval, offset =3D 0; static u64 max_khz; u64 mul, div; =20 if (caps->lowest_freq && caps->nominal_freq) { - if (freq >=3D caps->nominal_freq) { - mul =3D caps->nominal_perf; - div =3D caps->nominal_freq; - } else { - mul =3D caps->lowest_perf; - div =3D caps->lowest_freq; - } + mul =3D caps->nominal_perf - caps->lowest_perf; + div =3D caps->nominal_freq - caps->lowest_freq; + offset =3D caps->nominal_perf - div64_u64(caps->nominal_freq * mul, div); } else { if (!max_khz) max_khz =3D cppc_get_dmi_max_khz(); @@ -356,7 +352,10 @@ static unsigned int cppc_cpufreq_khz_to_perf(struct cp= pc_cpudata *cpu_data, div =3D max_khz; } =20 - return (u64)freq * mul / div; + retval =3D offset + div64_u64(freq * mul, div); + if (retval >=3D 0) + return retval; + return 0; } =20 static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 41FB1C433EF for ; Tue, 12 Apr 2022 08:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384927AbiDLIme (ORCPT ); Tue, 12 Apr 2022 04:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357268AbiDLHjz (ORCPT ); Tue, 12 Apr 2022 03:39:55 -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 C288DDF35; Tue, 12 Apr 2022 00:14: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 81856B81A8F; Tue, 12 Apr 2022 07:14:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9731C385A1; Tue, 12 Apr 2022 07:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747672; bh=kUn2qAPqnhLi5OlFTb3kcm5yBG9tINbEWnBPKsnb0Rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1VYX004eLTAyU8kQJfG9T2fM6sjagt8zXQDB/kfLoTbNblSMzmP5oddrqSy9dxi7/ B+1m45fjIIkpN4ManvTBZw6Z0r7Z66lWTQqXPslqkUvul6cOEdV4z+tYWwxLrWujMS rswVrrVMJ8QVdJEZqhVEUEE62aL0egwVscaty7z8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Viresh Kumar , Sasha Levin Subject: [PATCH 5.17 165/343] opp: Expose of-nodes name in debugfs Date: Tue, 12 Apr 2022 08:29:43 +0200 Message-Id: <20220412062956.134808515@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Viresh Kumar [ Upstream commit 021dbecabc93b1610b5db989d52a94e0c6671136 ] It is difficult to find which OPPs are active at the moment, specially if there are multiple OPPs with same frequency available in the device tree (controlled by supported hardware feature). Expose name of the DT node to find out the exact OPP. While at it, also expose level field. Reported-by: Leo Yan Tested-by: Leo Yan Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/opp/debugfs.c | 5 +++++ drivers/opp/opp.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c index 596c185b5dda..b5f2f9f39392 100644 --- a/drivers/opp/debugfs.c +++ b/drivers/opp/debugfs.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -131,9 +132,13 @@ void opp_debug_create_one(struct dev_pm_opp *opp, stru= ct opp_table *opp_table) debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend); debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate); debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate); + debugfs_create_u32("level", S_IRUGO, d, &opp->level); debugfs_create_ulong("clock_latency_ns", S_IRUGO, d, &opp->clock_latency_ns); =20 + opp->of_name =3D of_node_full_name(opp->np); + debugfs_create_str("of_name", S_IRUGO, d, (char **)&opp->of_name); + opp_debug_create_supplies(opp, opp_table, d); opp_debug_create_bw(opp, opp_table, d); =20 diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 407c3bfe51d9..45e3a55239a1 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -96,6 +96,7 @@ struct dev_pm_opp { =20 #ifdef CONFIG_DEBUG_FS struct dentry *dentry; + const char *of_name; #endif }; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2C397C433F5 for ; Tue, 12 Apr 2022 08:41:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384886AbiDLImb (ORCPT ); Tue, 12 Apr 2022 04:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357271AbiDLHjz (ORCPT ); Tue, 12 Apr 2022 03:39:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F2CDFFB; Tue, 12 Apr 2022 00:14: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 8522561045; Tue, 12 Apr 2022 07:14:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AEDFC385A1; Tue, 12 Apr 2022 07:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747675; bh=vAiDl1GwVbQ82UKpOaMdXzGgdpkyRkO6Fv8harzJaY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJEPD98mgdrCaH7jXoTlUJrCY6SMP2Fxvpz2G+6X0891E5/JYE7ZiskqJ69qlpv3d p27R8hsz0iVvvdOKso+mgVtAJzlkEDdVCk3B8ITGjEGQKAoXuz5fEjCg70UgYxOz0d JqxB2kontUorx/9oihrImgD5P6OWuuirbHK9l8gg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Ulf Hansson , =?UTF-8?q?J=C3=A9r=C3=B4me=20Pouiller?= , Sasha Levin Subject: [PATCH 5.17 166/343] staging: wfx: apply the necessary SDIO quirks for the Silabs WF200 Date: Tue, 12 Apr 2022 08:29:44 +0200 Message-Id: <20220412062956.162857858@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: J=C3=A9r=C3=B4me Pouiller [ Upstream commit 96e0cbca1cb96e9d3deac3051aa816e13082f3fd ] Until now, the SDIO quirks are applied directly from the driver. However, it is better to apply the quirks before driver probing. So, this patch relocate the quirks in the MMC framework. Note that the WF200 has no valid SDIO VID/PID. Therefore, we match DT rather than on the SDIO VID/PID. Reviewed-by: Pali Roh=C3=A1r Reviewed-by: Ulf Hansson Signed-off-by: J=C3=A9r=C3=B4me Pouiller Link: https://lore.kernel.org/r/20220216093112.92469-3-Jerome.Pouiller@sila= bs.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/core/quirks.h | 5 +++++ drivers/staging/wfx/bus_sdio.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index 20f568727277..f879dc63d936 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -149,6 +149,11 @@ static const struct mmc_fixup __maybe_unused sdio_fixu= p_methods[] =3D { static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] =3D { SDIO_FIXUP_COMPATIBLE("ti,wl1251", wl1251_quirk, 0), =20 + SDIO_FIXUP_COMPATIBLE("silabs,wf200", add_quirk, + MMC_QUIRK_BROKEN_BYTE_MODE_512 | + MMC_QUIRK_LENIENT_FN0 | + MMC_QUIRK_BLKSZ_FOR_BYTE_MODE), + END_FIXUP }; =20 diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index a670176ba06f..0612f8a7c085 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -207,9 +207,6 @@ static int wfx_sdio_probe(struct sdio_func *func, =20 bus->func =3D func; sdio_set_drvdata(func, bus); - func->card->quirks |=3D MMC_QUIRK_LENIENT_FN0 | - MMC_QUIRK_BLKSZ_FOR_BYTE_MODE | - MMC_QUIRK_BROKEN_BYTE_MODE_512; =20 sdio_claim_host(func); ret =3D sdio_enable_func(func); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E519BC4332F for ; Tue, 12 Apr 2022 09:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357882AbiDLJUB (ORCPT ); Tue, 12 Apr 2022 05:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357294AbiDLHj4 (ORCPT ); Tue, 12 Apr 2022 03:39:56 -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 70619183B5; Tue, 12 Apr 2022 00:14: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 EB11CB81B46; Tue, 12 Apr 2022 07:14:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C3DDC385A1; Tue, 12 Apr 2022 07:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747677; bh=BJU3SoYaAQU5PGAAdKA5dXjOco3AbVhPcyDIW5TSjrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJ87HZP3qf6vCWKaLP/vFWZJjR8603lPkmhyGbSpMBYyAefuvntGziNPYcnI9wz5n 0mJJUYfpztjXUiwHR1/gAYMKChEjuDrJVomReYEWNOvvvFhNiUL16Uw8xNRtykNsR9 IxFa5Xr8LInXm/g2jwjfqwvzl+zJz/Dc/HHySE40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Pouiller?= , Dan Carpenter , Xiaoke Wang , Sasha Levin Subject: [PATCH 5.17 167/343] staging: wfx: fix an error handling in wfx_init_common() Date: Tue, 12 Apr 2022 08:29:45 +0200 Message-Id: <20220412062956.191258378@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiaoke Wang [ Upstream commit 60f1d3c92dc1ef1026e5b917a329a7fa947da036 ] One error handler of wfx_init_common() return without calling ieee80211_free_hw(hw), which may result in memory leak. And I add one err label to unify the error handler, which is useful for the subsequent changes. Suggested-by: J=C3=A9r=C3=B4me Pouiller Reviewed-by: Dan Carpenter Reviewed-by: J=C3=A9r=C3=B4me Pouiller Signed-off-by: Xiaoke Wang Link: https://lore.kernel.org/r/tencent_24A24A3EFF61206ECCC4B94B1C5C1454E10= 8@qq.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/staging/wfx/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 858d778cc589..e3999e95ce85 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -322,7 +322,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->pdata.gpio_wakeup =3D devm_gpiod_get_optional(dev, "wakeup", GPIOD_OUT_LOW); if (IS_ERR(wdev->pdata.gpio_wakeup)) - return NULL; + goto err; + if (wdev->pdata.gpio_wakeup) gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup"); =20 @@ -341,6 +342,10 @@ struct wfx_dev *wfx_init_common(struct device *dev, return NULL; =20 return wdev; + +err: + ieee80211_free_hw(hw); + return NULL; } =20 int wfx_probe(struct wfx_dev *wdev) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 17251C433FE for ; Tue, 12 Apr 2022 08:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243778AbiDLIo0 (ORCPT ); Tue, 12 Apr 2022 04:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357292AbiDLHj4 (ORCPT ); Tue, 12 Apr 2022 03:39:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF99B1D331; Tue, 12 Apr 2022 00:14: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 B111661708; Tue, 12 Apr 2022 07:14:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF59DC385A5; Tue, 12 Apr 2022 07:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747683; bh=S185JdGuYdxwHgdWpnMtDHTAglDdL1ACtJY7q/XQotg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BYFrxcs3Rtqa717BBctsNw1ZIqQHerdUt2mbT91x0eueToD6tRFfaZ/FhdBpv8kd0 xbGW/nADNhhQjnEs2il6APnMjpueKGEXGhljCSp6kTpciF8b5k2lNwb3cQMIShMjpd aGCDi/LJdq2Kw1KgsnSd1tqg3TPsUie0y45D6v5E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucas Denefle , Sasha Levin Subject: [PATCH 5.17 168/343] w1: w1_therm: fixes w1_seq for ds28ea00 sensors Date: Tue, 12 Apr 2022 08:29:46 +0200 Message-Id: <20220412062956.219559747@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Lucas Denefle [ Upstream commit 41a92a89eee819298f805c40187ad8b02bb53426 ] w1_seq was failing due to several devices responding to the CHAIN_DONE at the same time. Now properly selects the current device in the chain with MATCH_ROM. Also acknowledgment was read twice. Signed-off-by: Lucas Denefle Link: https://lore.kernel.org/r/20220223113558.232750-1-lucas.denefle@conve= rge.io Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/w1/slaves/w1_therm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 565578002d79..c7b8a8e787e2 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -2089,16 +2089,20 @@ static ssize_t w1_seq_show(struct device *device, if (sl->reg_num.id =3D=3D reg_num->id) seq =3D i; =20 + if (w1_reset_bus(sl->master)) + goto error; + + /* Put the device into chain DONE state */ + w1_write_8(sl->master, W1_MATCH_ROM); + w1_write_block(sl->master, (u8 *)&rn, 8); w1_write_8(sl->master, W1_42_CHAIN); w1_write_8(sl->master, W1_42_CHAIN_DONE); w1_write_8(sl->master, W1_42_CHAIN_DONE_INV); - w1_read_block(sl->master, &ack, sizeof(ack)); =20 /* check for acknowledgment */ ack =3D w1_read_8(sl->master); if (ack !=3D W1_42_SUCCESS_CONFIRM_BYTE) goto error; - } =20 /* Exit from CHAIN state */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4DB0FC433F5 for ; Tue, 12 Apr 2022 08:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359283AbiDLIoI (ORCPT ); Tue, 12 Apr 2022 04:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357288AbiDLHj4 (ORCPT ); Tue, 12 Apr 2022 03:39:56 -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 C9EB31EAC1; Tue, 12 Apr 2022 00:14: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 6961561045; Tue, 12 Apr 2022 07:14:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C678C385A5; Tue, 12 Apr 2022 07:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747685; bh=uiMvXbgy27rdH5+i+irTs27zufcuSMZzqR9sGKp8NmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hthquIilcHHmq+yE6ZIdACygfgfFbk83Pr3JFqYPuvSUn0GJLJII+58hvoNOYV5DA 1fk7Wi8VI1ftHKiO0PzGQ5bFpajwZzt0WOCLC7xFpHOOYX27FpKP4yxMbRfeDA617v PJAIMTnUm0gh/jo5Ss4rh3EDOHtBuI42gxDIEajQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Xiong , Xiyu Yang , Xin Tan , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 169/343] NFSv4.2: fix reference count leaks in _nfs42_proc_copy_notify() Date: Tue, 12 Apr 2022 08:29:47 +0200 Message-Id: <20220412062956.249038129@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xin Xiong [ Upstream commit b7f114edd54326f730a754547e7cfb197b5bc132 ] [You don't often get email from xiongx18@fudan.edu.cn. Learn why this is im= portant at http://aka.ms/LearnAboutSenderIdentification.] The reference counting issue happens in two error paths in the function _nfs42_proc_copy_notify(). In both error paths, the function simply returns the error code and forgets to balance the refcount of object `ctx`, bumped by get_nfs_open_context() earlier, which may cause refcount leaks. Fix it by balancing refcount of the `ctx` object before the function returns in both error paths. Signed-off-by: Xin Xiong Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/nfs42proc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 32129446beca..ca878d021fab 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -591,8 +591,10 @@ static int _nfs42_proc_copy_notify(struct file *src, s= truct file *dst, =20 ctx =3D get_nfs_open_context(nfs_file_open_context(src)); l_ctx =3D nfs_get_lock_context(ctx); - if (IS_ERR(l_ctx)) - return PTR_ERR(l_ctx); + if (IS_ERR(l_ctx)) { + status =3D PTR_ERR(l_ctx); + goto out; + } =20 status =3D nfs4_set_rw_stateid(&args->cna_src_stateid, ctx, l_ctx, FMODE_READ); @@ -600,7 +602,7 @@ static int _nfs42_proc_copy_notify(struct file *src, st= ruct file *dst, if (status) { if (status =3D=3D -EAGAIN) status =3D -NFS4ERR_BAD_STATEID; - return status; + goto out; } =20 status =3D nfs4_call_sync(src_server->client, src_server, &msg, @@ -609,6 +611,7 @@ static int _nfs42_proc_copy_notify(struct file *src, st= ruct file *dst, if (status =3D=3D -ENOTSUPP) src_server->caps &=3D ~NFS_CAP_COPY_NOTIFY; =20 +out: put_nfs_open_context(nfs_file_open_context(src)); return status; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 96089C433F5 for ; Tue, 12 Apr 2022 08:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359341AbiDLIof (ORCPT ); Tue, 12 Apr 2022 04:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357291AbiDLHj4 (ORCPT ); Tue, 12 Apr 2022 03:39:56 -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 E75D21EC4D; Tue, 12 Apr 2022 00:14: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 ams.source.kernel.org (Postfix) with ESMTPS id B5ACCB81B66; Tue, 12 Apr 2022 07:14:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31419C385A1; Tue, 12 Apr 2022 07:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747688; bh=qwVIw6WgvUFZD9gUIdScRL8b7hE6gR9eKQzdOTNlLwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VvGlGj2TWqum4ktSCpfEaSdhkmsj8u76Wh7c7sU7airEamzMq9zZhWgdujYjUcjfE vBjY3TKaFcoSWEkDZ23fd/LfhJPMuV+unucnaWUzoU03R7GfbeO5LqBX0SGOtGJhmC wuKWDbZvdKsodoMVrlumty4qu4CGHinvERqQjZYI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 170/343] NFSv4: Protect the state recovery thread against direct reclaim Date: Tue, 12 Apr 2022 08:29:48 +0200 Message-Id: <20220412062956.277072882@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit 3e17898aca293a24dae757a440a50aa63ca29671 ] If memory allocation triggers a direct reclaim from the state recovery thread, then we can deadlock. Use memalloc_nofs_save/restore to ensure that doesn't happen. Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/nfs4state.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index f5a62c0d999b..0f4818627ef0 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -49,6 +49,7 @@ #include #include #include +#include =20 #include =20 @@ -2560,9 +2561,17 @@ static void nfs4_layoutreturn_any_run(struct nfs_cli= ent *clp) =20 static void nfs4_state_manager(struct nfs_client *clp) { + unsigned int memflags; int status =3D 0; const char *section =3D "", *section_sep =3D ""; =20 + /* + * State recovery can deadlock if the direct reclaim code tries + * start NFS writeback. So ensure memory allocations are all + * GFP_NOFS. + */ + memflags =3D memalloc_nofs_save(); + /* Ensure exclusive access to NFSv4 state */ do { trace_nfs4_state_mgr(clp); @@ -2657,6 +2666,7 @@ static void nfs4_state_manager(struct nfs_client *clp) clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); } =20 + memalloc_nofs_restore(memflags); nfs4_end_drain_session(clp); nfs4_clear_state_manager_bit(clp); =20 @@ -2674,6 +2684,7 @@ static void nfs4_state_manager(struct nfs_client *clp) return; if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) !=3D 0) return; + memflags =3D memalloc_nofs_save(); } while (refcount_read(&clp->cl_count) > 1 && !signalled()); goto out_drain; =20 @@ -2686,6 +2697,7 @@ static void nfs4_state_manager(struct nfs_client *clp) clp->cl_hostname, -status); ssleep(1); out_drain: + memalloc_nofs_restore(memflags); nfs4_end_drain_session(clp); nfs4_clear_state_manager_bit(clp); } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 48E9EC38A06 for ; Tue, 12 Apr 2022 09:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389244AbiDLJXb (ORCPT ); Tue, 12 Apr 2022 05:23:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357310AbiDLHj6 (ORCPT ); Tue, 12 Apr 2022 03:39:58 -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 E3BA322BD7; Tue, 12 Apr 2022 00:14: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 dfw.source.kernel.org (Postfix) with ESMTPS id 101D86171D; Tue, 12 Apr 2022 07:14:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F5CEC385A6; Tue, 12 Apr 2022 07:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747691; bh=eb7nnM0s4xYIrHZ2PbOhZjzA+Mg+TlIe/T74eJ5JG9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rircHKnu1ZWbv5K3Ltmyy2rusdIg8i6jz8goSq9bL/rz+/Cx7FU0XJ7MqCtsPZjvi Dl0ADT1hpJnunjZu+hAGSEz2VbslW2p7NqxWfGi3mDYcpo3TJrWVc5j8LKy4ALUXpi g5rAmuZxVAga+KVEpOa6jKkjpV87gB9Uc1qhtOTA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ohad Sharabi , Oded Gabbay , Sasha Levin Subject: [PATCH 5.17 171/343] habanalabs: fix possible memory leak in MMU DR fini Date: Tue, 12 Apr 2022 08:29:49 +0200 Message-Id: <20220412062956.305151284@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ohad Sharabi [ Upstream commit eb85eec858c1a5c11d3a0bff403f6440b05b40dc ] This patch fixes what seems to be copy paste error. We will have a memory leak if the host-resident shadow is NULL (which will likely happen as the DR and HR are not dependent). Signed-off-by: Ohad Sharabi Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/misc/habanalabs/common/mmu/mmu_v1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/habanalabs/common/mmu/mmu_v1.c b/drivers/misc/hab= analabs/common/mmu/mmu_v1.c index 6134b6ae7615..3cadef97817d 100644 --- a/drivers/misc/habanalabs/common/mmu/mmu_v1.c +++ b/drivers/misc/habanalabs/common/mmu/mmu_v1.c @@ -467,7 +467,7 @@ static void hl_mmu_v1_fini(struct hl_device *hdev) { /* MMU H/W fini was already done in device hw_fini() */ =20 - if (!ZERO_OR_NULL_PTR(hdev->mmu_priv.hr.mmu_shadow_hop0)) { + if (!ZERO_OR_NULL_PTR(hdev->mmu_priv.dr.mmu_shadow_hop0)) { kvfree(hdev->mmu_priv.dr.mmu_shadow_hop0); gen_pool_destroy(hdev->mmu_priv.dr.mmu_pgt_pool); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 EA90EC433EF for ; Tue, 12 Apr 2022 08:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243221AbiDLIp3 (ORCPT ); Tue, 12 Apr 2022 04:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357314AbiDLHj6 (ORCPT ); Tue, 12 Apr 2022 03:39:58 -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 0513B1EC50; Tue, 12 Apr 2022 00:14: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 B3DF7B81B62; Tue, 12 Apr 2022 07:14:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03DECC385A5; Tue, 12 Apr 2022 07:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747694; bh=hVu1gpPr0uY/FdIH5Ckm7DMmE8MOGJVH0WdABw0+KkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kq/fd40+Roli2ois3ydVmruXjYHZkpD9kj9TSrKVnY3yZZE5g7eNkSLrZ+d25zZuw Tsi0tcq5sY67fLBQ+4C7FF7LFCljmqDub2e/1nMYK1KkcF4r/FTh///946Z9QBwHgw Rcco5AyABcTv0yiTl7Nqe7ou6K3zVXY2HAA96Rjk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oded Gabbay , Sasha Levin Subject: [PATCH 5.17 172/343] habanalabs: reject host map with mmu disabled Date: Tue, 12 Apr 2022 08:29:50 +0200 Message-Id: <20220412062956.333257395@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Oded Gabbay [ Upstream commit 9a79e3e4a3637c07352d9723b825490a1b04391f ] This is not something we can do a workaround. It is clearly an error and we should notify the user that it is an error. Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/misc/habanalabs/common/memory.c | 30 +++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanal= abs/common/memory.c index c1eefaebacb6..bcc6e547e071 100644 --- a/drivers/misc/habanalabs/common/memory.c +++ b/drivers/misc/habanalabs/common/memory.c @@ -1967,16 +1967,15 @@ static int export_dmabuf_from_handle(struct hl_ctx = *ctx, u64 handle, int flags, static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *arg= s) { struct hl_device *hdev =3D hpriv->hdev; - struct hl_ctx *ctx =3D hpriv->ctx; u64 block_handle, device_addr =3D 0; + struct hl_ctx *ctx =3D hpriv->ctx; u32 handle =3D 0, block_size; - int rc, dmabuf_fd =3D -EBADF; + int rc; =20 switch (args->in.op) { case HL_MEM_OP_ALLOC: if (args->in.alloc.mem_size =3D=3D 0) { - dev_err(hdev->dev, - "alloc size must be larger than 0\n"); + dev_err(hdev->dev, "alloc size must be larger than 0\n"); rc =3D -EINVAL; goto out; } @@ -1997,15 +1996,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv,= union hl_mem_args *args) =20 case HL_MEM_OP_MAP: if (args->in.flags & HL_MEM_USERPTR) { - device_addr =3D args->in.map_host.host_virt_addr; - rc =3D 0; + dev_err(hdev->dev, "Failed to map host memory when MMU is disabled\n"); + rc =3D -EPERM; } else { - rc =3D get_paddr_from_handle(ctx, &args->in, - &device_addr); + rc =3D get_paddr_from_handle(ctx, &args->in, &device_addr); + memset(args, 0, sizeof(*args)); + args->out.device_virt_addr =3D device_addr; } =20 - memset(args, 0, sizeof(*args)); - args->out.device_virt_addr =3D device_addr; break; =20 case HL_MEM_OP_UNMAP: @@ -2013,20 +2011,14 @@ static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv,= union hl_mem_args *args) break; =20 case HL_MEM_OP_MAP_BLOCK: - rc =3D map_block(hdev, args->in.map_block.block_addr, - &block_handle, &block_size); + rc =3D map_block(hdev, args->in.map_block.block_addr, &block_handle, &bl= ock_size); args->out.block_handle =3D block_handle; args->out.block_size =3D block_size; break; =20 case HL_MEM_OP_EXPORT_DMABUF_FD: - rc =3D export_dmabuf_from_addr(ctx, - args->in.export_dmabuf_fd.handle, - args->in.export_dmabuf_fd.mem_size, - args->in.flags, - &dmabuf_fd); - memset(args, 0, sizeof(*args)); - args->out.fd =3D dmabuf_fd; + dev_err(hdev->dev, "Failed to export dma-buf object when MMU is disabled= \n"); + rc =3D -EPERM; break; =20 default: --=20 2.35.1 From nobody Thu May 14 08:08:21 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 35A17C38A04 for ; Tue, 12 Apr 2022 09:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389184AbiDLJX1 (ORCPT ); Tue, 12 Apr 2022 05:23:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357315AbiDLHj6 (ORCPT ); Tue, 12 Apr 2022 03:39:58 -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 12CD223BD7; Tue, 12 Apr 2022 00:14: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 A3E626176E; Tue, 12 Apr 2022 07:14:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B46E1C385A6; Tue, 12 Apr 2022 07:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747697; bh=pTCguM5hKfS5YojLbcfsg4liUJK9KCMGfsJzuRRUdt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iK1kTBV1asbdAzKe4tlQe92rhwRyDYza7E2Ji+uj2yxvy7u/vqWNusZCxsdEPmXsV mSRTLo3zfFj556Ew1AJDyOlB3VeLErp7jcm06YeuFLS2lZ30jw9sSZaP+ah6mL9ILD 2FRoni85NSka/N82KofFS0b4Pkljw/wwhWMcY3pg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oded Gabbay , Sasha Levin Subject: [PATCH 5.17 173/343] habanalabs/gaudi: handle axi errors from NIC engines Date: Tue, 12 Apr 2022 08:29:51 +0200 Message-Id: <20220412062956.361016831@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Oded Gabbay [ Upstream commit 26ef1c000bc21a192618c9ec651dd36ba63ca00c ] Various AXI errors can occur in the NIC engines and are reported to the driver by the f/w. Add code to print the errors and ack them to the f/w. Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/misc/habanalabs/gaudi/gaudi.c | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalab= s/gaudi/gaudi.c index 013c6da2e3ca..b4dacea80151 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -7819,6 +7819,48 @@ static void gaudi_print_fw_alive_info(struct hl_devi= ce *hdev, fw_alive->thread_id, fw_alive->uptime_seconds); } =20 +static void gaudi_print_nic_axi_irq_info(struct hl_device *hdev, u16 event= _type, + void *data) +{ + char desc[64] =3D "", *type; + struct eq_nic_sei_event *eq_nic_sei =3D data; + u16 nic_id =3D event_type - GAUDI_EVENT_NIC_SEI_0; + + switch (eq_nic_sei->axi_error_cause) { + case RXB: + type =3D "RXB"; + break; + case RXE: + type =3D "RXE"; + break; + case TXS: + type =3D "TXS"; + break; + case TXE: + type =3D "TXE"; + break; + case QPC_RESP: + type =3D "QPC_RESP"; + break; + case NON_AXI_ERR: + type =3D "NON_AXI_ERR"; + break; + case TMR: + type =3D "TMR"; + break; + default: + dev_err(hdev->dev, "unknown NIC AXI cause %d\n", + eq_nic_sei->axi_error_cause); + type =3D "N/A"; + break; + } + + snprintf(desc, sizeof(desc), "NIC%d_%s%d", nic_id, type, + eq_nic_sei->id); + dev_err_ratelimited(hdev->dev, "Received H/W interrupt %d [\"%s\"]\n", + event_type, desc); +} + static int gaudi_non_hard_reset_late_init(struct hl_device *hdev) { /* GAUDI doesn't support any reset except hard-reset */ @@ -8066,6 +8108,7 @@ static void gaudi_handle_eqe(struct hl_device *hdev, struct hl_eq_entry *eq_entry) { struct gaudi_device *gaudi =3D hdev->asic_specific; + u64 data =3D le64_to_cpu(eq_entry->data[0]); u32 ctl =3D le32_to_cpu(eq_entry->hdr.ctl); u32 fw_fatal_err_flag =3D 0; u16 event_type =3D ((ctl & EQ_CTL_EVENT_TYPE_MASK) @@ -8263,6 +8306,11 @@ static void gaudi_handle_eqe(struct hl_device *hdev, hl_fw_unmask_irq(hdev, event_type); break; =20 + case GAUDI_EVENT_NIC_SEI_0 ... GAUDI_EVENT_NIC_SEI_4: + gaudi_print_nic_axi_irq_info(hdev, event_type, &data); + hl_fw_unmask_irq(hdev, event_type); + break; + case GAUDI_EVENT_DMA_IF_SEI_0 ... GAUDI_EVENT_DMA_IF_SEI_3: gaudi_print_irq_info(hdev, event_type, false); gaudi_print_sm_sei_info(hdev, event_type, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1CB82C38A05 for ; Tue, 12 Apr 2022 09:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389124AbiDLJXY (ORCPT ); Tue, 12 Apr 2022 05:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357316AbiDLHj6 (ORCPT ); Tue, 12 Apr 2022 03:39:58 -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 ABEEB245A0; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4B36761708; Tue, 12 Apr 2022 07:15:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FB27C385A6; Tue, 12 Apr 2022 07:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747699; bh=ucfA2C2SWIQgzh8yu0sdw5aNdUWtqQHKO/aIHM0aMUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C3OV+OpGyqLp5V2is4b3M+FtozUeex+n7ighfLk0yjcR1ArmZlmFF4/wtDWTTv07X DTcnJgqH6nU6HM/QSuvaLGRTfCgSMHZlkKMMr6SbHui/7/jQF0xEcKxS4YK8Szd78D 28+qHo1ztTo7vCIKtpc0jw096CgyNn6+7dtwRcQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Jin , Dongli Zhang , Boris Ostrovsky , Sasha Levin Subject: [PATCH 5.17 174/343] xen: delay xen_hvm_init_time_ops() if kdump is boot on vcpu>=32 Date: Tue, 12 Apr 2022 08:29:52 +0200 Message-Id: <20220412062956.389082244@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Dongli Zhang [ Upstream commit eed05744322da07dd7e419432dcedf3c2e017179 ] The sched_clock() can be used very early since commit 857baa87b642 ("sched/clock: Enable sched clock early"). In addition, with commit 38669ba205d1 ("x86/xen/time: Output xen sched_clock time from 0"), kdump kernel in Xen HVM guest may panic at very early stage when accessing &__this_cpu_read(xen_vcpu)->time as in below: setup_arch() -> init_hypervisor_platform() -> x86_init.hyper.init_platform =3D xen_hvm_guest_init() -> xen_hvm_init_time_ops() -> xen_clocksource_read() -> src =3D &__this_cpu_read(xen_vcpu)->time; This is because Xen HVM supports at most MAX_VIRT_CPUS=3D32 'vcpu_info' embedded inside 'shared_info' during early stage until xen_vcpu_setup() is used to allocate/relocate 'vcpu_info' for boot cpu at arbitrary address. However, when Xen HVM guest panic on vcpu >=3D 32, since xen_vcpu_info_reset(0) would set per_cpu(xen_vcpu, cpu) =3D NULL when vcpu >=3D 32, xen_clocksource_read() on vcpu >=3D 32 would panic. This patch calls xen_hvm_init_time_ops() again later in xen_hvm_smp_prepare_boot_cpu() after the 'vcpu_info' for boot vcpu is registered when the boot vcpu is >=3D 32. This issue can be reproduced on purpose via below command at the guest side when kdump/kexec is enabled: "taskset -c 33 echo c > /proc/sysrq-trigger" The bugfix for PVM is not implemented due to the lack of testing environment. [boris: xen_hvm_init_time_ops() returns on errors instead of jumping to end] Cc: Joe Jin Signed-off-by: Dongli Zhang Reviewed-by: Boris Ostrovsky Link: https://lore.kernel.org/r/20220302164032.14569-3-dongli.zhang@oracle.= com Signed-off-by: Boris Ostrovsky Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/xen/smp_hvm.c | 6 ++++++ arch/x86/xen/time.c | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/smp_hvm.c b/arch/x86/xen/smp_hvm.c index 6ff3c887e0b9..b70afdff419c 100644 --- a/arch/x86/xen/smp_hvm.c +++ b/arch/x86/xen/smp_hvm.c @@ -19,6 +19,12 @@ static void __init xen_hvm_smp_prepare_boot_cpu(void) */ xen_vcpu_setup(0); =20 + /* + * Called again in case the kernel boots on vcpu >=3D MAX_VIRT_CPUS. + * Refer to comments in xen_hvm_init_time_ops(). + */ + xen_hvm_init_time_ops(); + /* * The alternative logic (which patches the unlock/lock) runs before * the smp bootup up code is activated. Hence we need to set this up diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index d9c945ee1100..9ef0a5cca96e 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -558,6 +558,11 @@ static void xen_hvm_setup_cpu_clockevents(void) =20 void __init xen_hvm_init_time_ops(void) { + static bool hvm_time_initialized; + + if (hvm_time_initialized) + return; + /* * vector callback is needed otherwise we cannot receive interrupts * on cpu > 0 and at this point we don't know how many cpus are @@ -567,7 +572,22 @@ void __init xen_hvm_init_time_ops(void) return; =20 if (!xen_feature(XENFEAT_hvm_safe_pvclock)) { - pr_info("Xen doesn't support pvclock on HVM, disable pv timer"); + pr_info_once("Xen doesn't support pvclock on HVM, disable pv timer"); + return; + } + + /* + * Only MAX_VIRT_CPUS 'vcpu_info' are embedded inside 'shared_info'. + * The __this_cpu_read(xen_vcpu) is still NULL when Xen HVM guest + * boots on vcpu >=3D MAX_VIRT_CPUS (e.g., kexec), To access + * __this_cpu_read(xen_vcpu) via xen_clocksource_read() will panic. + * + * The xen_hvm_init_time_ops() should be called again later after + * __this_cpu_read(xen_vcpu) is available. + */ + if (!__this_cpu_read(xen_vcpu)) { + pr_info("Delay xen_init_time_common() as kernel is running on vcpu=3D%d\= n", + xen_vcpu_nr(0)); return; } =20 @@ -577,6 +597,8 @@ void __init xen_hvm_init_time_ops(void) x86_cpuinit.setup_percpu_clockev =3D xen_hvm_setup_cpu_clockevents; =20 x86_platform.set_wallclock =3D xen_set_wallclock; + + hvm_time_initialized =3D true; } #endif =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 0FA0CC433EF for ; Tue, 12 Apr 2022 08:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359540AbiDLIpR (ORCPT ); Tue, 12 Apr 2022 04:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357317AbiDLHj6 (ORCPT ); Tue, 12 Apr 2022 03:39:58 -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 0B1A1245AC; Tue, 12 Apr 2022 00:15: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 C0B82B81B4F; Tue, 12 Apr 2022 07:15:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EA89C385A1; Tue, 12 Apr 2022 07:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747702; bh=Rsjvxg+k8r2vza09ZjsYYA3qoPxRWtfGsNYwNg5EE+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RmxTZHodww+JRVFMTlm8KhElpLOlSMZ9l4scSHTf8ma87llwwTQDGPLfRgRB+1L26 +gBlK2IhDdYCTiaCr9ZJVjUBQffctJAP1a8OHzo5pY2+fIw0j42E8n6EdeZr1Zzs3Y ItsaQSX7tiAr6Eh4WQSpPMjciQHo7mr6t0Plma1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lindgren , Stephen Boyd , Sasha Levin Subject: [PATCH 5.17 175/343] clk: ti: Preserve node in ti_dt_clocks_register() Date: Tue, 12 Apr 2022 08:29:53 +0200 Message-Id: <20220412062956.418376336@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 [ Upstream commit 80864594ff2ad002e2755daf97d46ff0c86faf1f ] In preparation for making use of the clock-output-names, we want to keep node around in ti_dt_clocks_register(). This change should not needed as a fix currently. Signed-off-by: Tony Lindgren Link: https://lore.kernel.org/r/20220204071449.16762-3-tony@atomide.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/clk/ti/clk.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 3da33c786d77..29eafab4353e 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -131,7 +131,7 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops) void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) { struct ti_dt_clk *c; - struct device_node *node, *parent; + struct device_node *node, *parent, *child; struct clk *clk; struct of_phandle_args clkspec; char buf[64]; @@ -171,10 +171,13 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oc= lks[]) node =3D of_find_node_by_name(NULL, buf); if (num_args && compat_mode) { parent =3D node; - node =3D of_get_child_by_name(parent, "clock"); - if (!node) - node =3D of_get_child_by_name(parent, "clk"); - of_node_put(parent); + child =3D of_get_child_by_name(parent, "clock"); + if (!child) + child =3D of_get_child_by_name(parent, "clk"); + if (child) { + of_node_put(parent); + node =3D child; + } } =20 clkspec.np =3D node; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 F1F7FC43219 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389058AbiDLJXV (ORCPT ); Tue, 12 Apr 2022 05:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357318AbiDLHj7 (ORCPT ); Tue, 12 Apr 2022 03:39:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59587245B7; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id E869C61708; Tue, 12 Apr 2022 07:15:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 049E6C385A1; Tue, 12 Apr 2022 07:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747705; bh=U5BKBINZqkY8YG7da1WWh8GmjHRsCM7kZc6c8O3P0Vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BscrU6n2COYk9Lf8Omsw3TzV45pUc2iBP9uzBLZlHGbmyfCBwr+HvzwXz4XaWXkcU ZTuD/ux09uJ4LK/fURZoLJX2yvRk55J1bJL13aMNx4sw7jRHdRWCmpW9jS/6RFMseI MsWr6dL0gzWAfFw9WjjshdKxJHCbEWsmMeB3a85w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Ripard , Stephen Boyd , Sasha Levin Subject: [PATCH 5.17 176/343] clk: Enforce that disjoints limits are invalid Date: Tue, 12 Apr 2022 08:29:54 +0200 Message-Id: <20220412062956.446464118@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maxime Ripard [ Upstream commit 10c46f2ea914202482d19cf80dcc9c321c9ff59b ] If we were to have two users of the same clock, doing something like: clk_set_rate_range(user1, 1000, 2000); clk_set_rate_range(user2, 3000, 4000); The second call would fail with -EINVAL, preventing from getting in a situation where we end up with impossible limits. However, this is never explicitly checked against and enforced, and works by relying on an undocumented behaviour of clk_set_rate(). Indeed, on the first clk_set_rate_range will make sure the current clock rate is within the new range, so it will be between 1000 and 2000Hz. On the second clk_set_rate_range(), it will consider (rightfully), that our current clock is outside of the 3000-4000Hz range, and will call clk_core_set_rate_nolock() to set it to 3000Hz. clk_core_set_rate_nolock() will then call clk_calc_new_rates() that will eventually check that our rate 3000Hz rate is outside the min 3000Hz max 2000Hz range, will bail out, the error will propagate and we'll eventually return -EINVAL. This solely relies on the fact that clk_calc_new_rates(), and in particular clk_core_determine_round_nolock(), won't modify the new rate allowing the error to be reported. That assumption won't be true for all drivers, and most importantly we'll break that assumption in a later patch. It can also be argued that we shouldn't even reach the point where we're calling clk_core_set_rate_nolock(). Let's make an explicit check for disjoints range before we're doing anything. Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/20220225143534.405820-4-maxime@cerno.tech Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/clk/clk.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 01b64b962e76..2fdfce116087 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -632,6 +632,24 @@ static void clk_core_get_boundaries(struct clk_core *c= ore, *max_rate =3D min(*max_rate, clk_user->max_rate); } =20 +static bool clk_core_check_boundaries(struct clk_core *core, + unsigned long min_rate, + unsigned long max_rate) +{ + struct clk *user; + + lockdep_assert_held(&prepare_lock); + + if (min_rate > core->max_rate || max_rate < core->min_rate) + return false; + + hlist_for_each_entry(user, &core->clks, clks_node) + if (min_rate > user->max_rate || max_rate < user->min_rate) + return false; + + return true; +} + void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate, unsigned long max_rate) { @@ -2348,6 +2366,11 @@ int clk_set_rate_range(struct clk *clk, unsigned lon= g min, unsigned long max) clk->min_rate =3D min; clk->max_rate =3D max; =20 + if (!clk_core_check_boundaries(clk->core, min, max)) { + ret =3D -EINVAL; + goto out; + } + rate =3D clk_core_get_rate_nolock(clk->core); if (rate < min || rate > max) { /* @@ -2376,6 +2399,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long= min, unsigned long max) } } =20 +out: if (clk->exclusive_count) clk_core_rate_protect(clk->core); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 F3A8DC433FE for ; Tue, 12 Apr 2022 08:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359495AbiDLIpJ (ORCPT ); Tue, 12 Apr 2022 04:45:09 -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 S1357328AbiDLHkA (ORCPT ); Tue, 12 Apr 2022 03:40:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2BAA2496B; Tue, 12 Apr 2022 00:15:10 -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 8351FB81A8F; Tue, 12 Apr 2022 07:15:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6257C385A1; Tue, 12 Apr 2022 07:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747708; bh=X3n8AkFj/VbEyKyGxwnxLLTZbAzU7OGVumTbr82HbpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jggiz9jPox1VpuTwQixWEKz9LsvUidgGI+chUV3p4PSA7iKjzo9DT0nw/Aex56YAP Ug56NNATgyXvX3ZUufuA7sDp+lLI3zwpxkL77NXRBu78lmv1WsAuNRiPeR4iK5Jcwj Cc9KRTHnr6JiHJhH0ng+9gd/1EJi9K/ges0xHot8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 177/343] SUNRPC/xprt: async tasks mustnt block waiting for memory Date: Tue, 12 Apr 2022 08:29:55 +0200 Message-Id: <20220412062956.474609620@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: NeilBrown [ Upstream commit a721035477fb5fb8abc738fbe410b07c12af3dc5 ] When memory is short, new worker threads cannot be created and we depend on the minimum one rpciod thread to be able to handle everything. So it must not block waiting for memory. xprt_dynamic_alloc_slot can block indefinitely. This can tie up all workqueue threads and NFS can deadlock. So when called from a workqueue, set __GFP_NORETRY. The rdma alloc_slot already does not block. However it sets the error to -EAGAIN suggesting this will trigger a sleep. It does not. As we can see in call_reserveresult(), only -ENOMEM causes a sleep. -EAGAIN causes immediate retry. Signed-off-by: NeilBrown Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sunrpc/xprt.c | 5 ++++- net/sunrpc/xprtrdma/transport.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 396a74974f60..75acde97d748 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1690,12 +1690,15 @@ static bool xprt_throttle_congested(struct rpc_xprt= *xprt, struct rpc_task *task static struct rpc_rqst *xprt_dynamic_alloc_slot(struct rpc_xprt *xprt) { struct rpc_rqst *req =3D ERR_PTR(-EAGAIN); + gfp_t gfp_mask =3D GFP_KERNEL; =20 if (xprt->num_reqs >=3D xprt->max_reqs) goto out; ++xprt->num_reqs; spin_unlock(&xprt->reserve_lock); - req =3D kzalloc(sizeof(struct rpc_rqst), GFP_NOFS); + if (current->flags & PF_WQ_WORKER) + gfp_mask |=3D __GFP_NORETRY | __GFP_NOWARN; + req =3D kzalloc(sizeof(*req), gfp_mask); spin_lock(&xprt->reserve_lock); if (req !=3D NULL) goto out; diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transpor= t.c index ff78a296fa81..6b7e10e5a141 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -521,7 +521,7 @@ xprt_rdma_alloc_slot(struct rpc_xprt *xprt, struct rpc_= task *task) return; =20 out_sleep: - task->tk_status =3D -EAGAIN; + task->tk_status =3D -ENOMEM; xprt_add_backlog(xprt, task); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1C17EC433F5 for ; Tue, 12 Apr 2022 08:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354835AbiDLIru (ORCPT ); Tue, 12 Apr 2022 04:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357326AbiDLHkA (ORCPT ); Tue, 12 Apr 2022 03:40:00 -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 1568E24BDC; Tue, 12 Apr 2022 00:15: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 316C2B81B4F; Tue, 12 Apr 2022 07:15:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80073C385A1; Tue, 12 Apr 2022 07:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747713; bh=PNElRQwnnCiWitiYMu5FSLHaLbWIvloVo8Zbif/ErFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tpA7ZmBFoosmZIoKsA5tcA4SgH+f6AmK/iiCz9LsvY/kNfTURO/ibjgsR4ozqlKki 3+VIeO/b+rrxK0sG79V8boNbIV14EYjl2I9Oc1njZ2KZfbyJJDJHzFCG+YBkTAu3+M K2xa+ub0L1w8V5RHDzWR3XSHEaEJ2PCVLN+xOKBc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 178/343] SUNRPC: remove scheduling boost for "SWAPPER" tasks. Date: Tue, 12 Apr 2022 08:29:56 +0200 Message-Id: <20220412062956.503100409@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: NeilBrown [ Upstream commit a80a8461868905823609be97f91776a26befe839 ] Currently, tasks marked as "swapper" tasks get put to the front of non-priority rpc_queues, and are sorted earlier than non-swapper tasks on the transport's ->xmit_queue. This is pointless as currently *all* tasks for a mount that has swap enabled on *any* file are marked as "swapper" tasks. So the net result is that the non-priority rpc_queues are reverse-ordered (LIFO). This scheduling boost is not necessary to avoid deadlocks, and hurts fairness, so remove it. If there were a need to expedite some requests, the tk_priority mechanism is a more appropriate tool. Signed-off-by: NeilBrown Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sunrpc/sched.c | 7 ------- net/sunrpc/xprt.c | 11 ----------- 2 files changed, 18 deletions(-) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index ae295844ac55..9020cedb7c95 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -186,11 +186,6 @@ static void __rpc_add_wait_queue_priority(struct rpc_w= ait_queue *queue, =20 /* * Add new request to wait queue. - * - * Swapper tasks always get inserted at the head of the queue. - * This should avoid many nasty memory deadlocks and hopefully - * improve overall performance. - * Everyone else gets appended to the queue to ensure proper FIFO behavior. */ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task, @@ -199,8 +194,6 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue = *queue, INIT_LIST_HEAD(&task->u.tk_wait.timer_list); if (RPC_IS_PRIORITY(queue)) __rpc_add_wait_queue_priority(queue, task, queue_priority); - else if (RPC_IS_SWAPPER(task)) - list_add(&task->u.tk_wait.list, &queue->tasks[0]); else list_add_tail(&task->u.tk_wait.list, &queue->tasks[0]); task->tk_waitqueue =3D queue; diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 75acde97d748..b1bb466bbdda 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1354,17 +1354,6 @@ xprt_request_enqueue_transmit(struct rpc_task *task) INIT_LIST_HEAD(&req->rq_xmit2); goto out; } - } else if (RPC_IS_SWAPPER(task)) { - list_for_each_entry(pos, &xprt->xmit_queue, rq_xmit) { - if (pos->rq_cong || pos->rq_bytes_sent) - continue; - if (RPC_IS_SWAPPER(pos->rq_task)) - continue; - /* Note: req is added _before_ pos */ - list_add_tail(&req->rq_xmit, &pos->rq_xmit); - INIT_LIST_HEAD(&req->rq_xmit2); - goto out; - } } else if (!req->rq_seqno) { list_for_each_entry(pos, &xprt->xmit_queue, rq_xmit) { if (pos->rq_task->tk_owner !=3D task->tk_owner) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BFC1EC433F5 for ; Tue, 12 Apr 2022 08:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351475AbiDLIrP (ORCPT ); Tue, 12 Apr 2022 04:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357331AbiDLHkA (ORCPT ); Tue, 12 Apr 2022 03:40:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A952924BE6; Tue, 12 Apr 2022 00:15: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 3FD0461708; Tue, 12 Apr 2022 07:15:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E712C385A5; Tue, 12 Apr 2022 07:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747716; bh=ss7f7dSDTtFWdYQAnAkKrHMuPfMFXR9JAcBkYRHeLUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yehh5dO4HVacXdveGo9jmGzbvvAqr9c4p60SPXYkHYUPO0IvOlRHNSbtX/vKMqfIw /1kgXbIYzTx3hRmE//EL/+h3YnTfj1LmYc0sUmII5aRjOejQMyEc6HJFFDmHspXqun mOt60qvcReIZ5yyPu2KuBEc6ojRDyHpNfuQC6egU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 179/343] NFS: swap IO handling is slightly different for O_DIRECT IO Date: Tue, 12 Apr 2022 08:29:57 +0200 Message-Id: <20220412062956.530987973@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: NeilBrown [ Upstream commit 64158668ac8b31626a8ce48db4cad08496eb8340 ] 1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding possible deadlocks with "fs_reclaim". These deadlocks could, I believe, eventuate if a buffered read on the swapfile was attempted. We don't need coherence with the page cache for a swap file, and buffered writes are forbidden anyway. There is no other need for i_rwsem during direct IO. So never take it for swap_rw() 2/ generic_write_checks() explicitly forbids writes to swap, and performs checks that are not needed for swap. So bypass it for swap_rw(). Signed-off-by: NeilBrown Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/direct.c | 42 ++++++++++++++++++++++++++++-------------- fs/nfs/file.c | 4 ++-- include/linux/nfs_fs.h | 8 ++++---- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index eabfdab543c8..04aaf39a05cb 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -173,8 +173,8 @@ ssize_t nfs_direct_IO(struct kiocb *iocb, struct iov_it= er *iter) VM_BUG_ON(iov_iter_count(iter) !=3D PAGE_SIZE); =20 if (iov_iter_rw(iter) =3D=3D READ) - return nfs_file_direct_read(iocb, iter); - return nfs_file_direct_write(iocb, iter); + return nfs_file_direct_read(iocb, iter, true); + return nfs_file_direct_write(iocb, iter, true); } =20 static void nfs_direct_release_pages(struct page **pages, unsigned int npa= ges) @@ -425,6 +425,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nf= s_direct_req *dreq, * nfs_file_direct_read - file direct read operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers into which to read data + * @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct reads instead of calling * generic_file_aio_read() in order to avoid gfar's check to see if @@ -440,7 +441,8 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nf= s_direct_req *dreq, * client must read the updated atime from the server back into its * cache. */ -ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter) +ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter, + bool swap) { struct file *file =3D iocb->ki_filp; struct address_space *mapping =3D file->f_mapping; @@ -482,12 +484,14 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, stru= ct iov_iter *iter) if (iter_is_iovec(iter)) dreq->flags =3D NFS_ODIRECT_SHOULD_DIRTY; =20 - nfs_start_io_direct(inode); + if (!swap) + nfs_start_io_direct(inode); =20 NFS_I(inode)->read_io +=3D count; requested =3D nfs_direct_read_schedule_iovec(dreq, iter, iocb->ki_pos); =20 - nfs_end_io_direct(inode); + if (!swap) + nfs_end_io_direct(inode); =20 if (requested > 0) { result =3D nfs_direct_wait(dreq); @@ -876,6 +880,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct n= fs_direct_req *dreq, * nfs_file_direct_write - file direct write operation for NFS files * @iocb: target I/O control block * @iter: vector of user buffers from which to write data + * @swap: flag indicating this is swap IO, not O_DIRECT IO * * We use this function for direct writes instead of calling * generic_file_aio_write() in order to avoid taking the inode @@ -892,7 +897,8 @@ static ssize_t nfs_direct_write_schedule_iovec(struct n= fs_direct_req *dreq, * Note that O_APPEND is not supported for NFS direct writes, as there * is no atomic O_APPEND write facility in the NFS protocol. */ -ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter) +ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter, + bool swap) { ssize_t result, requested; size_t count; @@ -906,7 +912,11 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, stru= ct iov_iter *iter) dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n", file, iov_iter_count(iter), (long long) iocb->ki_pos); =20 - result =3D generic_write_checks(iocb, iter); + if (swap) + /* bypass generic checks */ + result =3D iov_iter_count(iter); + else + result =3D generic_write_checks(iocb, iter); if (result <=3D 0) return result; count =3D result; @@ -937,16 +947,20 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, str= uct iov_iter *iter) dreq->iocb =3D iocb; pnfs_init_ds_commit_info_ops(&dreq->ds_cinfo, inode); =20 - nfs_start_io_direct(inode); + if (swap) { + requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos); + } else { + nfs_start_io_direct(inode); =20 - requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos); + requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos); =20 - if (mapping->nrpages) { - invalidate_inode_pages2_range(mapping, - pos >> PAGE_SHIFT, end); - } + if (mapping->nrpages) { + invalidate_inode_pages2_range(mapping, + pos >> PAGE_SHIFT, end); + } =20 - nfs_end_io_direct(inode); + nfs_end_io_direct(inode); + } =20 if (requested > 0) { result =3D nfs_direct_wait(dreq); diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 76d76acbc594..d8583f57ff99 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -162,7 +162,7 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to) ssize_t result; =20 if (iocb->ki_flags & IOCB_DIRECT) - return nfs_file_direct_read(iocb, to); + return nfs_file_direct_read(iocb, to, false); =20 dprintk("NFS: read(%pD2, %zu@%lu)\n", iocb->ki_filp, @@ -619,7 +619,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_i= ter *from) return result; =20 if (iocb->ki_flags & IOCB_DIRECT) - return nfs_file_direct_write(iocb, from); + return nfs_file_direct_write(iocb, from, false); =20 dprintk("NFS: write(%pD2, %zu@%Ld)\n", file, iov_iter_count(from), (long long) iocb->ki_pos); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 68f81d8d36de..161e4f5ea7a0 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -513,10 +513,10 @@ static inline const struct cred *nfs_file_cred(struct= file *file) * linux/fs/nfs/direct.c */ extern ssize_t nfs_direct_IO(struct kiocb *, struct iov_iter *); -extern ssize_t nfs_file_direct_read(struct kiocb *iocb, - struct iov_iter *iter); -extern ssize_t nfs_file_direct_write(struct kiocb *iocb, - struct iov_iter *iter); +ssize_t nfs_file_direct_read(struct kiocb *iocb, + struct iov_iter *iter, bool swap); +ssize_t nfs_file_direct_write(struct kiocb *iocb, + struct iov_iter *iter, bool swap); =20 /* * linux/fs/nfs/dir.c --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E845EC46467 for ; Tue, 12 Apr 2022 09:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388992AbiDLJXR (ORCPT ); Tue, 12 Apr 2022 05:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357333AbiDLHkA (ORCPT ); Tue, 12 Apr 2022 03:40:00 -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 EA36924BE9; Tue, 12 Apr 2022 00:15: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 ams.source.kernel.org (Postfix) with ESMTPS id A3A8EB81B46; Tue, 12 Apr 2022 07:15:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18DC4C385A5; Tue, 12 Apr 2022 07:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747719; bh=vWX/olCOiZMgMIxLWD6bJ7lU8zBx3ops744NpZqiIiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=up/UhgkP5ZtVVoAqEBRv5NnGpmSFcDw4iWL2Tgb++se2qSri7f+7x/Jg0XdZ67K3T FWS51rfbOgQMJFbKbnl3PkVIFhJVmjSoFDEczwENzXPPfDr33rGict86Hh/PUAgfLO ycyGKRjOEKXgcjRrZ8zxlEPK5Gz1rYFEI237bzUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 180/343] NFS: swap-out must always use STABLE writes. Date: Tue, 12 Apr 2022 08:29:58 +0200 Message-Id: <20220412062956.559664790@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: NeilBrown [ Upstream commit c265de257f558a05c1859ee9e3fed04883b9ec0e ] The commit handling code is not safe against memory-pressure deadlocks when writing to swap. In particular, nfs_commitdata_alloc() blocks indefinitely waiting for memory, and this can consume all available workqueue threads. swap-out most likely uses STABLE writes anyway as COND_STABLE indicates that a stable write should be used if the write fits in a single request, and it normally does. However if we ever swap with a small wsize, or gather unusually large numbers of pages for a single write, this might change. For safety, make it explicit in the code that direct writes used for swap must always use FLUSH_STABLE. Signed-off-by: NeilBrown Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/direct.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 04aaf39a05cb..11c566d8769f 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -794,7 +794,7 @@ static const struct nfs_pgio_completion_ops nfs_direct_= write_completion_ops =3D { */ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, struct iov_iter *iter, - loff_t pos) + loff_t pos, int ioflags) { struct nfs_pageio_descriptor desc; struct inode *inode =3D dreq->inode; @@ -802,7 +802,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct n= fs_direct_req *dreq, size_t requested_bytes =3D 0; size_t wsize =3D max_t(size_t, NFS_SERVER(inode)->wsize, PAGE_SIZE); =20 - nfs_pageio_init_write(&desc, inode, FLUSH_COND_STABLE, false, + nfs_pageio_init_write(&desc, inode, ioflags, false, &nfs_direct_write_completion_ops); desc.pg_dreq =3D dreq; get_dreq(dreq); @@ -948,11 +948,13 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, str= uct iov_iter *iter, pnfs_init_ds_commit_info_ops(&dreq->ds_cinfo, inode); =20 if (swap) { - requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos); + requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos, + FLUSH_STABLE); } else { nfs_start_io_direct(inode); =20 - requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos); + requested =3D nfs_direct_write_schedule_iovec(dreq, iter, pos, + FLUSH_COND_STABLE); =20 if (mapping->nrpages) { invalidate_inode_pages2_range(mapping, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 D6051C4708B for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388971AbiDLJXF (ORCPT ); Tue, 12 Apr 2022 05:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357336AbiDLHkB (ORCPT ); Tue, 12 Apr 2022 03:40:01 -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 3BA2924BF0; Tue, 12 Apr 2022 00:15: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 CDD406171C; Tue, 12 Apr 2022 07:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB194C385A5; Tue, 12 Apr 2022 07:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747722; bh=qT4rRxjdgHvgFLUUTFXORG38wBgzvPAGzYgrVrQ2Wyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hrfjhwQzA6okcF8z3XuWj23M/JJlN9idMKWkPSepyFVzLKjSyMRwSTny/qdwr6CRc zLVWGR84cn/WyWz3/0GRwuy0YuHEfTB/I6gfAUeZUip1l5MIYvWihxfU0VKLUEUZgL cz5GpYyyGbpzQqICVMWA+pA9EuDjy3/J2/th8buU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Josh Poimboeuf , Sasha Levin Subject: [PATCH 5.17 181/343] x86: Annotate call_on_stack() Date: Tue, 12 Apr 2022 08:29:59 +0200 Message-Id: <20220412062956.587738563@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 be0075951fde739f14ee2b659e2fd6e2499c46c0 ] vmlinux.o: warning: objtool: page_fault_oops()+0x13c: unreachable instructi= on 0000 000000000005b460 : ... 0128 5b588: 49 89 23 mov %rsp,(%r11) 012b 5b58b: 4c 89 dc mov %r11,%rsp 012e 5b58e: 4c 89 f2 mov %r14,%rdx 0131 5b591: 48 89 ee mov %rbp,%rsi 0134 5b594: 4c 89 e7 mov %r12,%rdi 0137 5b597: e8 00 00 00 00 call 5b59c 5b598: R_X86_64_PLT32 handle_stack_overflow-0x4 013c 5b59c: 5c pop %rsp vmlinux.o: warning: objtool: sysvec_reboot()+0x6d: unreachable instruction 0000 00000000000033f0 : ... 005d 344d: 4c 89 dc mov %r11,%rsp 0060 3450: e8 00 00 00 00 call 3455 = 3451: R_X86_64_PLT32 irq_enter_rcu-0x4 0065 3455: 48 89 ef mov %rbp,%rdi 0068 3458: e8 00 00 00 00 call 345d = 3459: R_X86_64_PC32 .text+0x47d0c 006d 345d: e8 00 00 00 00 call 3462 = 345e: R_X86_64_PLT32 irq_exit_rcu-0x4 0072 3462: 5c pop %rsp Both cases are due to a call_on_stack() calling a __noreturn function. Since that's an inline asm, GCC can't do anything about the instructions after the CALL. Therefore put in an explicit ASM_REACHABLE annotation to make sure objtool and gcc are consistently confused about control flow. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20220308154319.468805622@infradead.org Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/include/asm/irq_stack.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/irq_stack.h b/arch/x86/include/asm/irq_st= ack.h index ae9d40f6c706..05af249d6bec 100644 --- a/arch/x86/include/asm/irq_stack.h +++ b/arch/x86/include/asm/irq_stack.h @@ -99,7 +99,8 @@ } =20 #define ASM_CALL_ARG0 \ - "call %P[__func] \n" + "call %P[__func] \n" \ + ASM_REACHABLE =20 #define ASM_CALL_ARG1 \ "movq %[arg1], %%rdi \n" \ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E062FC3525B for ; Tue, 12 Apr 2022 09:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388920AbiDLJXA (ORCPT ); Tue, 12 Apr 2022 05:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357337AbiDLHkC (ORCPT ); Tue, 12 Apr 2022 03:40:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1181F24BFA; Tue, 12 Apr 2022 00:15: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 A13E56171C; Tue, 12 Apr 2022 07:15:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7DDC385A1; Tue, 12 Apr 2022 07:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747725; bh=HsE/ibDeI0T3UDOURtuLfeNn+tg1uUa+iGPFTtNKkN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PC25ZEiQrzPhZsjCkAGAt19ZIYSDe+jvuWqNoH1UloN+uCBdwkvuqvG1NLbQBCBTF Q+N0UsgC81EYFGhTJPETWZ1IFaBOV6Skw7nf66dD0onn64MizNezSXv4hahSO64PEw nVMxZJcEmBWkKGGXVYBCcTCWTqILzligcPZwiZa0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Chancellor , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.17 182/343] x86/Kconfig: Do not allow CONFIG_X86_X32_ABI=y with llvm-objcopy Date: Tue, 12 Apr 2022 08:30:00 +0200 Message-Id: <20220412062956.615484188@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Nathan Chancellor [ Upstream commit aaeed6ecc1253ce1463fa1aca0b70a4ccbc9fa75 ] There are two outstanding issues with CONFIG_X86_X32_ABI and llvm-objcopy, with similar root causes: 1. llvm-objcopy does not properly convert .note.gnu.property when going from x86_64 to x86_x32, resulting in a corrupted section when linking: https://github.com/ClangBuiltLinux/linux/issues/1141 2. llvm-objcopy produces corrupted compressed debug sections when going from x86_64 to x86_x32, also resulting in an error when linking: https://github.com/ClangBuiltLinux/linux/issues/514 After commit 41c5ef31ad71 ("x86/ibt: Base IBT bits"), the .note.gnu.property section is always generated when CONFIG_X86_KERNEL_IBT is enabled, which causes the first issue to become visible with an allmodconfig build: ld.lld: error: arch/x86/entry/vdso/vclock_gettime-x32.o:(.note.gnu.proper= ty+0x1c): program property is too short To avoid this error, do not allow CONFIG_X86_X32_ABI to be selected when using llvm-objcopy. If the two issues ever get fixed in llvm-objcopy, this can be turned into a feature check. Signed-off-by: Nathan Chancellor Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220314194842.3452-3-nathan@kernel.org Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9f5bd41bf660..d0ecc4005df3 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2837,6 +2837,11 @@ config IA32_AOUT config X86_X32 bool "x32 ABI for 64-bit mode" depends on X86_64 + # llvm-objcopy does not convert x86_64 .note.gnu.property or + # compressed debug sections to x86_x32 properly: + # https://github.com/ClangBuiltLinux/linux/issues/514 + # https://github.com/ClangBuiltLinux/linux/issues/1141 + depends on $(success,$(OBJCOPY) --version | head -n1 | grep -qv llvm) help Include code to run binaries for the x32 native 32-bit ABI for 64-bit processors. An x32 process gets access to the --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BFAE4C433EF for ; Tue, 12 Apr 2022 08:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355204AbiDLIqt (ORCPT ); Tue, 12 Apr 2022 04:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357339AbiDLHkD (ORCPT ); Tue, 12 Apr 2022 03:40: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 94F2C24F02; Tue, 12 Apr 2022 00:15:30 -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 4BB87B81B60; Tue, 12 Apr 2022 07:15:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B999C385A1; Tue, 12 Apr 2022 07:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747728; bh=C4yne+Z/DojZktf5UC6PByQdHGZAAL1WTE7lxkx6L+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HChuQOXm9etAdKds5CFRHLyZFERwpNNpkOORWqDMIxHmzFRS4VXUGYIq9EkCmNMa2 CxuHOl5hDJ54uMz+MkeDal+/jqioHnmsX5igbKPndM45UQfx7iQ4ffy1NNmmnszfd8 Cj17qL1NZUYZtPQp8o6bbXe08HpGWeT0UWRGyVFU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Abraham , Kyungmin Park , Hyeonkook Kim , Jiri Slaby , Sasha Levin Subject: [PATCH 5.17 183/343] serial: samsung_tty: do not unlock port->lock for uart_write_wakeup() Date: Tue, 12 Apr 2022 08:30:01 +0200 Message-Id: <20220412062956.642836447@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jiri Slaby [ Upstream commit 988c7c00691008ea1daaa1235680a0da49dab4e8 ] The commit c15c3747ee32 (serial: samsung: fix potential soft lockup during uart write) added an unlock of port->lock before uart_write_wakeup() and a lock after it. It was always problematic to write data from tty_ldisc_ops::write_wakeup and it was even documented that way. We fixed the line disciplines to conform to this recently. So if there is still a missed one, we should fix them instead of this workaround. On the top of that, s3c24xx_serial_tx_dma_complete() in this driver still holds the port->lock while calling uart_write_wakeup(). So revert the wrap added by the commit above. Cc: Thomas Abraham Cc: Kyungmin Park Cc: Hyeonkook Kim Signed-off-by: Jiri Slaby Link: https://lore.kernel.org/r/20220308115153.4225-1-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/tty/serial/samsung_tty.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_= tty.c index d002a4e48ed9..0d94a7cb275e 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -921,11 +921,8 @@ static void s3c24xx_serial_tx_chars(struct s3c24xx_uar= t_port *ourport) return; } =20 - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) { - spin_unlock(&port->lock); + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(port); - spin_lock(&port->lock); - } =20 if (uart_circ_empty(xmit)) s3c24xx_serial_stop_tx(port); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C6E20C38A02 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388885AbiDLJWy (ORCPT ); Tue, 12 Apr 2022 05:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357338AbiDLHkC (ORCPT ); Tue, 12 Apr 2022 03:40: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 58D1A24F29; Tue, 12 Apr 2022 00:15: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 0FF15B81B60; Tue, 12 Apr 2022 07:15:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6250BC385A1; Tue, 12 Apr 2022 07:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747730; bh=nx/TWIU0HuF/BcME479M9j/gXDlBWROJsyjyROKFzQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cl3a6DIvzsGBYIsN5pj4Z+r+0TxRZ5kS9JK3KntZERvGDQHwoBbZHbzlhNjGTsQy6 mD3PtMmP8Iae41OkvOEABNl0sQspvfl4E0q9MxEPb3/KFdr2mLQu8IpyWbaK9lenxU D0+y7b9a36ir9OkPlAJNuqJurPV68Xwy0wH4TRFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Amit Shah , virtualization@lists.linux-foundation.org, Arnd Bergmann , Sasha Levin Subject: [PATCH 5.17 184/343] virtio_console: eliminate anonymous module_init & module_exit Date: Tue, 12 Apr 2022 08:30:02 +0200 Message-Id: <20220412062956.671343374@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Randy Dunlap [ Upstream commit fefb8a2a941338d871e2d83fbd65fbfa068857bd ] Eliminate anonymous module_init() and module_exit(), which can lead to confusion or ambiguity when reading System.map, crashes/oops/bugs, or an initcall_debug log. Give each of these init and exit functions unique driver-specific names to eliminate the anonymous names. Example 1: (System.map) ffffffff832fc78c t init ffffffff832fc79e t init ffffffff832fc8f8 t init Example 2: (initcall_debug log) calling init+0x0/0x12 @ 1 initcall init+0x0/0x12 returned 0 after 15 usecs calling init+0x0/0x60 @ 1 initcall init+0x0/0x60 returned 0 after 2 usecs calling init+0x0/0x9a @ 1 initcall init+0x0/0x9a returned 0 after 74 usecs Signed-off-by: Randy Dunlap Reviewed-by: Amit Shah Cc: virtualization@lists.linux-foundation.org Cc: Arnd Bergmann Link: https://lore.kernel.org/r/20220316192010.19001-3-rdunlap@infradead.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/char/virtio_console.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index e3c430539a17..9fa3c76a267f 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2245,7 +2245,7 @@ static struct virtio_driver virtio_rproc_serial =3D { .remove =3D virtcons_remove, }; =20 -static int __init init(void) +static int __init virtio_console_init(void) { int err; =20 @@ -2280,7 +2280,7 @@ static int __init init(void) return err; } =20 -static void __exit fini(void) +static void __exit virtio_console_fini(void) { reclaim_dma_bufs(); =20 @@ -2290,8 +2290,8 @@ static void __exit fini(void) class_destroy(pdrvdata.class); debugfs_remove_recursive(pdrvdata.debugfs_dir); } -module_init(init); -module_exit(fini); +module_init(virtio_console_init); +module_exit(virtio_console_fini); =20 MODULE_DESCRIPTION("Virtio console driver"); MODULE_LICENSE("GPL"); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E830AC433EF for ; Tue, 12 Apr 2022 08:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352804AbiDLIqf (ORCPT ); Tue, 12 Apr 2022 04:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357340AbiDLHkD (ORCPT ); Tue, 12 Apr 2022 03:40: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 8875324F30; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2601161708; Tue, 12 Apr 2022 07:15:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F0B8C385A5; Tue, 12 Apr 2022 07:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747733; bh=c+omZP6b97ce8PuNMw7NgKdL3P/XKwm+AoC4Zyoc8Sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JUnL05mh28+3tbdpNgCksYQeNHUM9+RFIcXeHCAyrulRFuM/gn6w2NhsneEERo2At D9xcHli4+7fMDGO3AAquH0CVxTKXf9OHopivJ5IQPLZU6fFD/rhIYj71UxWfcQ8A7m TMHnBLDZt4KGmmw8QpkQW80XqbOawwH88D6xCiMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TCS Robot , Haimin Zhang , Dave Kleikamp , Sasha Levin Subject: [PATCH 5.17 185/343] jfs: prevent NULL deref in diFree Date: Tue, 12 Apr 2022 08:30:03 +0200 Message-Id: <20220412062956.701501170@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Haimin Zhang [ Upstream commit a53046291020ec41e09181396c1e829287b48d47 ] Add validation check for JFS_IP(ipimap)->i_imap to prevent a NULL deref in diFree since diFree uses it without do any validations. When function jfs_mount calls diMount to initialize fileset inode allocation map, it can fail and JFS_IP(ipimap)->i_imap won't be initialized. Then it calls diFreeSpecial to close fileset inode allocation map inode and it will flow into jfs_evict_inode. Function jfs_evict_inode just validates JFS_SBI(inode->i_sb)->ipimap, then calls diFree. diFree use JFS_IP(ipimap)->i_imap directly, then it will cause a NULL deref. Reported-by: TCS Robot Signed-off-by: Haimin Zhang Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/jfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 57ab424c05ff..072821b50ab9 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -146,12 +146,13 @@ void jfs_evict_inode(struct inode *inode) dquot_initialize(inode); =20 if (JFS_IP(inode)->fileset =3D=3D FILESYSTEM_I) { + struct inode *ipimap =3D JFS_SBI(inode->i_sb)->ipimap; truncate_inode_pages_final(&inode->i_data); =20 if (test_cflag(COMMIT_Freewmap, inode)) jfs_free_zero_link(inode); =20 - if (JFS_SBI(inode->i_sb)->ipimap) + if (ipimap && JFS_IP(ipimap)->i_imap) diFree(inode); =20 /* --=20 2.35.1 From nobody Thu May 14 08:08:21 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 067E4C433F5 for ; Tue, 12 Apr 2022 08:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344221AbiDLIpi (ORCPT ); Tue, 12 Apr 2022 04:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357346AbiDLHkF (ORCPT ); Tue, 12 Apr 2022 03:40:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81AC24F3A; Tue, 12 Apr 2022 00:15: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 7C1BAB81B4F; Tue, 12 Apr 2022 07:15:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0689C385A1; Tue, 12 Apr 2022 07:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747736; bh=s3jXKWdwkdVWvSsHAFTai9wLnPC5wzkPc8r960P/19I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=prW3leIHQlF3jS3lohMucpe233Ub34yZEKsbKtyFOazoUtIFkXpFZUdglK/xozkx6 x/IN2C2se8If8FLCHO4sS86TH9YbR05Lkuw0L3OMkHYFPW7tOZKWc8TUhGOYrdgalx uzfZ8+XHEf3JR9LclNcViNldXOqWdwiqIaH+kO98= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 186/343] SUNRPC: Fix socket waits for write buffer space Date: Tue, 12 Apr 2022 08:30:04 +0200 Message-Id: <20220412062956.729801171@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit 7496b59f588dd52886fdbac7633608097543a0a5 ] The socket layer requires that we use the socket lock to protect changes to the sock->sk_write_pending field and others. Reported-by: Chuck Lever Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sunrpc/xprtsock.c | 54 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 11eab0f0333b..5eb05c2dd6d6 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -763,12 +763,12 @@ xs_stream_start_connect(struct sock_xprt *transport) /** * xs_nospace - handle transmit was incomplete * @req: pointer to RPC request + * @transport: pointer to struct sock_xprt * */ -static int xs_nospace(struct rpc_rqst *req) +static int xs_nospace(struct rpc_rqst *req, struct sock_xprt *transport) { - struct rpc_xprt *xprt =3D req->rq_xprt; - struct sock_xprt *transport =3D container_of(xprt, struct sock_xprt, xprt= ); + struct rpc_xprt *xprt =3D &transport->xprt; struct sock *sk =3D transport->inet; int ret =3D -EAGAIN; =20 @@ -779,25 +779,49 @@ static int xs_nospace(struct rpc_rqst *req) =20 /* Don't race with disconnect */ if (xprt_connected(xprt)) { + struct socket_wq *wq; + + rcu_read_lock(); + wq =3D rcu_dereference(sk->sk_wq); + set_bit(SOCKWQ_ASYNC_NOSPACE, &wq->flags); + rcu_read_unlock(); + /* wait for more buffer space */ + set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); sk->sk_write_pending++; xprt_wait_for_buffer_space(xprt); } else ret =3D -ENOTCONN; =20 spin_unlock(&xprt->transport_lock); + return ret; +} =20 - /* Race breaker in case memory is freed before above code is called */ - if (ret =3D=3D -EAGAIN) { - struct socket_wq *wq; +static int xs_sock_nospace(struct rpc_rqst *req) +{ + struct sock_xprt *transport =3D + container_of(req->rq_xprt, struct sock_xprt, xprt); + struct sock *sk =3D transport->inet; + int ret =3D -EAGAIN; =20 - rcu_read_lock(); - wq =3D rcu_dereference(sk->sk_wq); - set_bit(SOCKWQ_ASYNC_NOSPACE, &wq->flags); - rcu_read_unlock(); + lock_sock(sk); + if (!sock_writeable(sk)) + ret =3D xs_nospace(req, transport); + release_sock(sk); + return ret; +} =20 - sk->sk_write_space(sk); - } +static int xs_stream_nospace(struct rpc_rqst *req) +{ + struct sock_xprt *transport =3D + container_of(req->rq_xprt, struct sock_xprt, xprt); + struct sock *sk =3D transport->inet; + int ret =3D -EAGAIN; + + lock_sock(sk); + if (!sk_stream_memory_free(sk)) + ret =3D xs_nospace(req, transport); + release_sock(sk); return ret; } =20 @@ -887,7 +911,7 @@ static int xs_local_send_request(struct rpc_rqst *req) case -ENOBUFS: break; case -EAGAIN: - status =3D xs_nospace(req); + status =3D xs_stream_nospace(req); break; default: dprintk("RPC: sendmsg returned unrecognized error %d\n", @@ -963,7 +987,7 @@ static int xs_udp_send_request(struct rpc_rqst *req) /* Should we call xs_close() here? */ break; case -EAGAIN: - status =3D xs_nospace(req); + status =3D xs_sock_nospace(req); break; case -ENETUNREACH: case -ENOBUFS: @@ -1083,7 +1107,7 @@ static int xs_tcp_send_request(struct rpc_rqst *req) /* Should we call xs_close() here? */ break; case -EAGAIN: - status =3D xs_nospace(req); + status =3D xs_stream_nospace(req); break; case -ECONNRESET: case -ECONNREFUSED: --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B02E1C43217 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388813AbiDLJWv (ORCPT ); Tue, 12 Apr 2022 05:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357368AbiDLHkI (ORCPT ); Tue, 12 Apr 2022 03:40:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB5825291; Tue, 12 Apr 2022 00:15: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 48720B81B66; Tue, 12 Apr 2022 07:15:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0246C385A1; Tue, 12 Apr 2022 07:15:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747739; bh=gFJMmxIdjkvGWKqOpfx87ESS9X+rnP3buzs2rAUSAM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z3Kwei+ExwK5Q774ExVnOsWAb5RI+sgdf61AWqvgTGfrdT56D38IJbrTZA4nAe5TG jrvMVMe3quS3qnUepPFe3SJCmFvGX3h9+VInMDKn/DSqVVPhPQu4ZWcGOMkkzXtRvt euYgRphFSihPpRAVFrG7X+clvDwmPh9f4z4Sf8D8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 187/343] NFS: nfsiod should not block forever in mempool_alloc() Date: Tue, 12 Apr 2022 08:30:05 +0200 Message-Id: <20220412062956.758206730@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit 515dcdcd48736576c6f5c197814da6f81c60a21e ] The concern is that since nfsiod is sometimes required to kick off a commit, it can get locked up waiting forever in mempool_alloc() instead of failing gracefully and leaving the commit until later. Try to allocate from the slab first, with GFP_KERNEL | __GFP_NORETRY, then fall back to a non-blocking attempt to allocate from the memory pool. Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/internal.h | 7 +++++++ fs/nfs/pnfs_nfs.c | 8 ++++++-- fs/nfs/write.c | 24 +++++++++--------------- include/linux/nfs_fs.h | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 2de7c56a1fbe..db9f611e8efd 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -573,6 +573,13 @@ nfs_write_match_verf(const struct nfs_writeverf *verf, !nfs_write_verifier_cmp(&req->wb_verf, &verf->verifier); } =20 +static inline gfp_t nfs_io_gfp_mask(void) +{ + if (current->flags & PF_WQ_WORKER) + return GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; + return GFP_KERNEL; +} + /* unlink.c */ extern struct rpc_task * nfs_async_rename(struct inode *old_dir, struct inode *new_dir, diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index 316f68f96e57..657c242a18ff 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -419,7 +419,7 @@ static struct nfs_commit_data * pnfs_bucket_fetch_commitdata(struct pnfs_commit_bucket *bucket, struct nfs_commit_info *cinfo) { - struct nfs_commit_data *data =3D nfs_commitdata_alloc(false); + struct nfs_commit_data *data =3D nfs_commitdata_alloc(); =20 if (!data) return NULL; @@ -515,7 +515,11 @@ pnfs_generic_commit_pagelist(struct inode *inode, stru= ct list_head *mds_pages, unsigned int nreq =3D 0; =20 if (!list_empty(mds_pages)) { - data =3D nfs_commitdata_alloc(true); + data =3D nfs_commitdata_alloc(); + if (!data) { + nfs_retry_commit(mds_pages, NULL, cinfo, -1); + return -ENOMEM; + } data->ds_commit_index =3D -1; list_splice_init(mds_pages, &data->pages); list_add_tail(&data->list, &list); diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 60693ab6a032..d0b9083bbfb5 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -70,27 +70,17 @@ static mempool_t *nfs_wdata_mempool; static struct kmem_cache *nfs_cdata_cachep; static mempool_t *nfs_commit_mempool; =20 -struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail) +struct nfs_commit_data *nfs_commitdata_alloc(void) { struct nfs_commit_data *p; =20 - if (never_fail) - p =3D mempool_alloc(nfs_commit_mempool, GFP_NOIO); - else { - /* It is OK to do some reclaim, not no safe to wait - * for anything to be returned to the pool. - * mempool_alloc() cannot handle that particular combination, - * so we need two separate attempts. - */ + p =3D kmem_cache_zalloc(nfs_cdata_cachep, nfs_io_gfp_mask()); + if (!p) { p =3D mempool_alloc(nfs_commit_mempool, GFP_NOWAIT); - if (!p) - p =3D kmem_cache_alloc(nfs_cdata_cachep, GFP_NOIO | - __GFP_NOWARN | __GFP_NORETRY); if (!p) return NULL; + memset(p, 0, sizeof(*p)); } - - memset(p, 0, sizeof(*p)); INIT_LIST_HEAD(&p->pages); return p; } @@ -1826,7 +1816,11 @@ nfs_commit_list(struct inode *inode, struct list_hea= d *head, int how, if (list_empty(head)) return 0; =20 - data =3D nfs_commitdata_alloc(true); + data =3D nfs_commitdata_alloc(); + if (!data) { + nfs_retry_commit(head, NULL, cinfo, -1); + return -ENOMEM; + } =20 /* Set up the argument struct */ nfs_init_commit(data, head, NULL, cinfo); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 161e4f5ea7a0..c9d3dc79d587 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -585,7 +585,7 @@ extern int nfs_wb_all(struct inode *inode); extern int nfs_wb_page(struct inode *inode, struct page *page); extern int nfs_wb_page_cancel(struct inode *inode, struct page* page); extern int nfs_commit_inode(struct inode *, int); -extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail); +extern struct nfs_commit_data *nfs_commitdata_alloc(void); extern void nfs_commit_free(struct nfs_commit_data *data); bool nfs_commit_end(struct nfs_mds_commit_info *cinfo); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 43140C433EF for ; Tue, 12 Apr 2022 08:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356469AbiDLIsK (ORCPT ); Tue, 12 Apr 2022 04:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357393AbiDLHkM (ORCPT ); Tue, 12 Apr 2022 03:40: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 F3E5825588; Tue, 12 Apr 2022 00:15: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 ams.source.kernel.org (Postfix) with ESMTPS id AF2B1B81B62; Tue, 12 Apr 2022 07:15:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 211A2C385A5; Tue, 12 Apr 2022 07:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747744; bh=NwFJrcI0gLnOEX5b/i7EZk11FeQuEnGKI2tctsSkriE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PhfiOhnyetBqn3bUDw5V8ZJ9tOLgB5QeE0CCEXvC1p94yow2ie8xyWBjRJDaF5giZ nvmEQKeXdruvVD4fH0aM68T48sd3OEbo4b7/Dw69ltfhSSCjaF1u1jn/JRZCLJ80pr 9F1M4iJJAGLBBM5C1JRVi6DpYENAmOz//h6qYxEc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 188/343] NFS: Avoid writeback threads getting stuck in mempool_alloc() Date: Tue, 12 Apr 2022 08:30:06 +0200 Message-Id: <20220412062956.786534331@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit 0bae835b63c53f86cdc524f5962e39409585b22c ] In a low memory situation, allow the NFS writeback code to fail without getting stuck in infinite loops in mempool_alloc(). Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/pagelist.c | 10 +++++----- fs/nfs/write.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 815d63080245..9157dd19b8b4 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -90,10 +90,10 @@ void nfs_set_pgio_error(struct nfs_pgio_header *hdr, in= t error, loff_t pos) } } =20 -static inline struct nfs_page * -nfs_page_alloc(void) +static inline struct nfs_page *nfs_page_alloc(void) { - struct nfs_page *p =3D kmem_cache_zalloc(nfs_page_cachep, GFP_KERNEL); + struct nfs_page *p =3D + kmem_cache_zalloc(nfs_page_cachep, nfs_io_gfp_mask()); if (p) INIT_LIST_HEAD(&p->wb_list); return p; @@ -892,7 +892,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, struct nfs_commit_info cinfo; struct nfs_page_array *pg_array =3D &hdr->page_array; unsigned int pagecount, pageused; - gfp_t gfp_flags =3D GFP_KERNEL; + gfp_t gfp_flags =3D nfs_io_gfp_mask(); =20 pagecount =3D nfs_page_array_len(mirror->pg_base, mirror->pg_count); pg_array->npages =3D pagecount; @@ -979,7 +979,7 @@ nfs_pageio_alloc_mirrors(struct nfs_pageio_descriptor *= desc, desc->pg_mirrors_dynamic =3D NULL; if (mirror_count =3D=3D 1) return desc->pg_mirrors_static; - ret =3D kmalloc_array(mirror_count, sizeof(*ret), GFP_KERNEL); + ret =3D kmalloc_array(mirror_count, sizeof(*ret), nfs_io_gfp_mask()); if (ret !=3D NULL) { for (i =3D 0; i < mirror_count; i++) nfs_pageio_mirror_init(&ret[i], desc->pg_bsize); diff --git a/fs/nfs/write.c b/fs/nfs/write.c index d0b9083bbfb5..938850303099 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -94,9 +94,15 @@ EXPORT_SYMBOL_GPL(nfs_commit_free); =20 static struct nfs_pgio_header *nfs_writehdr_alloc(void) { - struct nfs_pgio_header *p =3D mempool_alloc(nfs_wdata_mempool, GFP_KERNEL= ); + struct nfs_pgio_header *p; =20 - memset(p, 0, sizeof(*p)); + p =3D kmem_cache_zalloc(nfs_wdata_cachep, nfs_io_gfp_mask()); + if (!p) { + p =3D mempool_alloc(nfs_wdata_mempool, GFP_NOWAIT); + if (!p) + return NULL; + memset(p, 0, sizeof(*p)); + } p->rw_mode =3D FMODE_WRITE; return p; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 123FCC4332F for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357266AbiDLIsc (ORCPT ); Tue, 12 Apr 2022 04:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357405AbiDLHkM (ORCPT ); Tue, 12 Apr 2022 03:40:12 -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 A0F4CDA2; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id E267461779; Tue, 12 Apr 2022 07:15:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E929FC385AF; Tue, 12 Apr 2022 07:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747747; bh=33wyTYRMCt/vjpaH5MwKGMEAkzb4U7cqLtDy9m2wrOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NH/BgXsG+cjvJSqTB4Qp7P4pjdOgwr61UYZmJypCMwiTz5PUd4zEIJ9wIwo2u9+AN du9EYeot9xFI6p9ctoyJZVN51PfYxLHCV4W5Y7paxdBbIdxFgSWZBvi7LI6le+nvsQ C5k3VpV6AO1ELzZSkVlyryNQ7lDsGz+vn7P57Wxg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linux Kernel Functional Testing , Naresh Kamboju , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 189/343] selftests: net: Add tls config dependency for tls selftests Date: Tue, 12 Apr 2022 08:30:07 +0200 Message-Id: <20220412062956.815044050@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Naresh Kamboju [ Upstream commit d9142e1cf3bbdaf21337767114ecab26fe702d47 ] selftest net tls test cases need TLS=3Dm without this the test hangs. Enabling config TLS solves this problem and runs to complete. - CONFIG_TLS=3Dm Reported-by: Linux Kernel Functional Testing Signed-off-by: Naresh Kamboju Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/net/config | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/n= et/config index ead7963b9bf0..cecb921a0dbf 100644 --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -43,5 +43,6 @@ CONFIG_NET_ACT_TUNNEL_KEY=3Dm CONFIG_NET_ACT_MIRRED=3Dm CONFIG_BAREUDP=3Dm CONFIG_IPV6_IOAM6_LWTUNNEL=3Dy +CONFIG_TLS=3Dm CONFIG_CRYPTO_SM4=3Dy CONFIG_AMT=3Dm --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6BD7BC4321E for ; Tue, 12 Apr 2022 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356985AbiDLJTm (ORCPT ); Tue, 12 Apr 2022 05:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357448AbiDLHkU (ORCPT ); Tue, 12 Apr 2022 03:40: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 086C32B277; Tue, 12 Apr 2022 00:15: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 6754CB81B66; Tue, 12 Apr 2022 07:15:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF005C385A5; Tue, 12 Apr 2022 07:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747750; bh=atbR4RPy9yHB2eufZS3l49htdikvABO9wcWmNNaXj4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eHI01Iq3W6z+JXidPBqCWQEBOHYM5bAxB6aB825ANTcbgPCWOIQ4q2R6syuf6SKk1 CQbHZ0joUeZ5bxgTiFi3wJL8ZlmVFunMkJjHA0+c6gfG5WaBg5jOjBh0BiNidV/cmz 7TeiJibwsDl/L0OTQkYjX1tRbm4PfX2Geq19YwpE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller , Sasha Levin Subject: [PATCH 5.17 190/343] parisc: Fix CPU affinity for Lasi, WAX and Dino chips Date: Tue, 12 Apr 2022 08:30:08 +0200 Message-Id: <20220412062956.843352201@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Helge Deller [ Upstream commit 939fc856676c266c3bc347c1c1661872a3725c0f ] Add the missing logic to allow Lasi, WAX and Dino to set the CPU affinity. This fixes IRQ migration to other CPUs when a CPU is shutdown which currently holds the IRQs for one of those chips. Signed-off-by: Helge Deller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/parisc/dino.c | 41 +++++++++++++++++++++++++++++++++-------- drivers/parisc/gsc.c | 31 +++++++++++++++++++++++++++++++ drivers/parisc/gsc.h | 1 + drivers/parisc/lasi.c | 7 +++---- drivers/parisc/wax.c | 7 +++---- 5 files changed, 71 insertions(+), 16 deletions(-) diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 952a92504df6..e33036281327 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -142,9 +142,8 @@ struct dino_device { struct pci_hba_data hba; /* 'C' inheritance - must be first */ spinlock_t dinosaur_pen; - unsigned long txn_addr; /* EIR addr to generate interrupt */=20 - u32 txn_data; /* EIR data assign to each dino */=20 u32 imr; /* IRQ's which are enabled */=20 + struct gsc_irq gsc_irq; int global_irq[DINO_LOCAL_IRQS]; /* map IMR bit to global irq */ #ifdef DINO_DEBUG unsigned int dino_irr0; /* save most recent IRQ line stat */ @@ -339,14 +338,43 @@ static void dino_unmask_irq(struct irq_data *d) if (tmp & DINO_MASK_IRQ(local_irq)) { DBG(KERN_WARNING "%s(): IRQ asserted! (ILR 0x%x)\n", __func__, tmp); - gsc_writel(dino_dev->txn_data, dino_dev->txn_addr); + gsc_writel(dino_dev->gsc_irq.txn_data, dino_dev->gsc_irq.txn_addr); } } =20 +#ifdef CONFIG_SMP +static int dino_set_affinity_irq(struct irq_data *d, const struct cpumask = *dest, + bool force) +{ + struct dino_device *dino_dev =3D irq_data_get_irq_chip_data(d); + struct cpumask tmask; + int cpu_irq; + u32 eim; + + if (!cpumask_and(&tmask, dest, cpu_online_mask)) + return -EINVAL; + + cpu_irq =3D cpu_check_affinity(d, &tmask); + if (cpu_irq < 0) + return cpu_irq; + + dino_dev->gsc_irq.txn_addr =3D txn_affinity_addr(d->irq, cpu_irq); + eim =3D ((u32) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data; + __raw_writel(eim, dino_dev->hba.base_addr+DINO_IAR0); + + irq_data_update_effective_affinity(d, &tmask); + + return IRQ_SET_MASK_OK; +} +#endif + static struct irq_chip dino_interrupt_type =3D { .name =3D "GSC-PCI", .irq_unmask =3D dino_unmask_irq, .irq_mask =3D dino_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity =3D dino_set_affinity_irq, +#endif }; =20 =20 @@ -806,7 +834,6 @@ static int __init dino_common_init(struct parisc_device= *dev, { int status; u32 eim; - struct gsc_irq gsc_irq; struct resource *res; =20 pcibios_register_hba(&dino_dev->hba); @@ -821,10 +848,8 @@ static int __init dino_common_init(struct parisc_devic= e *dev, ** still only has 11 IRQ input lines - just map some of them ** to a different processor. */ - dev->irq =3D gsc_alloc_irq(&gsc_irq); - dino_dev->txn_addr =3D gsc_irq.txn_addr; - dino_dev->txn_data =3D gsc_irq.txn_data; - eim =3D ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data; + dev->irq =3D gsc_alloc_irq(&dino_dev->gsc_irq); + eim =3D ((u32) dino_dev->gsc_irq.txn_addr) | dino_dev->gsc_irq.txn_data; =20 /*=20 ** Dino needs a PA "IRQ" to get a processor's attention. diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c index ed9371acf37e..ec175ae99873 100644 --- a/drivers/parisc/gsc.c +++ b/drivers/parisc/gsc.c @@ -135,10 +135,41 @@ static void gsc_asic_unmask_irq(struct irq_data *d) */ } =20 +#ifdef CONFIG_SMP +static int gsc_set_affinity_irq(struct irq_data *d, const struct cpumask *= dest, + bool force) +{ + struct gsc_asic *gsc_dev =3D irq_data_get_irq_chip_data(d); + struct cpumask tmask; + int cpu_irq; + + if (!cpumask_and(&tmask, dest, cpu_online_mask)) + return -EINVAL; + + cpu_irq =3D cpu_check_affinity(d, &tmask); + if (cpu_irq < 0) + return cpu_irq; + + gsc_dev->gsc_irq.txn_addr =3D txn_affinity_addr(d->irq, cpu_irq); + gsc_dev->eim =3D ((u32) gsc_dev->gsc_irq.txn_addr) | gsc_dev->gsc_irq.txn= _data; + + /* switch IRQ's for devices below LASI/WAX to other CPU */ + gsc_writel(gsc_dev->eim, gsc_dev->hpa + OFFSET_IAR); + + irq_data_update_effective_affinity(d, &tmask); + + return IRQ_SET_MASK_OK; +} +#endif + + static struct irq_chip gsc_asic_interrupt_type =3D { .name =3D "GSC-ASIC", .irq_unmask =3D gsc_asic_unmask_irq, .irq_mask =3D gsc_asic_mask_irq, +#ifdef CONFIG_SMP + .irq_set_affinity =3D gsc_set_affinity_irq, +#endif }; =20 int gsc_assign_irq(struct irq_chip *type, void *data) diff --git a/drivers/parisc/gsc.h b/drivers/parisc/gsc.h index 86abad3fa215..73cbd0bb1975 100644 --- a/drivers/parisc/gsc.h +++ b/drivers/parisc/gsc.h @@ -31,6 +31,7 @@ struct gsc_asic { int version; int type; int eim; + struct gsc_irq gsc_irq; int global_irq[32]; }; =20 diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c index 4e4fd12c2112..6ef621adb63a 100644 --- a/drivers/parisc/lasi.c +++ b/drivers/parisc/lasi.c @@ -163,7 +163,6 @@ static int __init lasi_init_chip(struct parisc_device *= dev) { extern void (*chassis_power_off)(void); struct gsc_asic *lasi; - struct gsc_irq gsc_irq; int ret; =20 lasi =3D kzalloc(sizeof(*lasi), GFP_KERNEL); @@ -185,7 +184,7 @@ static int __init lasi_init_chip(struct parisc_device *= dev) lasi_init_irq(lasi); =20 /* the IRQ lasi should use */ - dev->irq =3D gsc_alloc_irq(&gsc_irq); + dev->irq =3D gsc_alloc_irq(&lasi->gsc_irq); if (dev->irq < 0) { printk(KERN_ERR "%s(): cannot get GSC irq\n", __func__); @@ -193,9 +192,9 @@ static int __init lasi_init_chip(struct parisc_device *= dev) return -EBUSY; } =20 - lasi->eim =3D ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data; + lasi->eim =3D ((u32) lasi->gsc_irq.txn_addr) | lasi->gsc_irq.txn_data; =20 - ret =3D request_irq(gsc_irq.irq, gsc_asic_intr, 0, "lasi", lasi); + ret =3D request_irq(lasi->gsc_irq.irq, gsc_asic_intr, 0, "lasi", lasi); if (ret < 0) { kfree(lasi); return ret; diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c index 5b6df1516235..73a2b01f8d9c 100644 --- a/drivers/parisc/wax.c +++ b/drivers/parisc/wax.c @@ -68,7 +68,6 @@ static int __init wax_init_chip(struct parisc_device *dev) { struct gsc_asic *wax; struct parisc_device *parent; - struct gsc_irq gsc_irq; int ret; =20 wax =3D kzalloc(sizeof(*wax), GFP_KERNEL); @@ -85,7 +84,7 @@ static int __init wax_init_chip(struct parisc_device *dev) wax_init_irq(wax); =20 /* the IRQ wax should use */ - dev->irq =3D gsc_claim_irq(&gsc_irq, WAX_GSC_IRQ); + dev->irq =3D gsc_claim_irq(&wax->gsc_irq, WAX_GSC_IRQ); if (dev->irq < 0) { printk(KERN_ERR "%s(): cannot get GSC irq\n", __func__); @@ -93,9 +92,9 @@ static int __init wax_init_chip(struct parisc_device *dev) return -EBUSY; } =20 - wax->eim =3D ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data; + wax->eim =3D ((u32) wax->gsc_irq.txn_addr) | wax->gsc_irq.txn_data; =20 - ret =3D request_irq(gsc_irq.irq, gsc_asic_intr, 0, "wax", wax); + ret =3D request_irq(wax->gsc_irq.irq, gsc_asic_intr, 0, "wax", wax); if (ret < 0) { kfree(wax); return ret; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 29E04C46467 for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356314AbiDLJTc (ORCPT ); Tue, 12 Apr 2022 05:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357479AbiDLHkX (ORCPT ); Tue, 12 Apr 2022 03:40:23 -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 6E2912C677; Tue, 12 Apr 2022 00:15: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 dfw.source.kernel.org (Postfix) with ESMTPS id 86B9D6171C; Tue, 12 Apr 2022 07:15:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91B75C385A5; Tue, 12 Apr 2022 07:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747752; bh=mR2O/g+rjFObtLuc8qXfsCZ+aho+SVwU90zDb6t0Px0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rB6ILx6FxQPFQLPLqwgOeXomXp3QzKqVEAY4L3m8W1moyJMS80ipkGjtI+h3ibafs d0JNdvWrS1/lxvagLoNxyJpdhs2id18uiQ3HxJmaNBuvMdqCLrnGsaDkc+RWEqr2q7 A2RzRkDR4hkIeLgQDyYApNuU3iWzdhfAhpa0bl4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John David Anglin , Helge Deller , Sasha Levin Subject: [PATCH 5.17 191/343] parisc: Fix patch code locking and flushing Date: Tue, 12 Apr 2022 08:30:09 +0200 Message-Id: <20220412062956.871305193@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: John David Anglin [ Upstream commit a9fe7fa7d874a536e0540469f314772c054a0323 ] This change fixes the following: 1) The flags variable is not initialized. Always use raw_spin_lock_irqsave and raw_spin_unlock_irqrestore to serialize patching. 2) flush_kernel_vmap_range is primarily intended for DMA flushes. Since __patch_text_multiple is often called with interrupts disabled, it is better to directly call flush_kernel_dcache_range_asm and flush_kernel_icache_range_asm. This avoids an extra call. 3) The final call to flush_icache_range is unnecessary. Signed-off-by: John David Anglin Signed-off-by: Helge Deller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/parisc/kernel/patch.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/arch/parisc/kernel/patch.c b/arch/parisc/kernel/patch.c index 80a0ab372802..e59574f65e64 100644 --- a/arch/parisc/kernel/patch.c +++ b/arch/parisc/kernel/patch.c @@ -40,10 +40,7 @@ static void __kprobes *patch_map(void *addr, int fixmap,= unsigned long *flags, =20 *need_unmap =3D 1; set_fixmap(fixmap, page_to_phys(page)); - if (flags) - raw_spin_lock_irqsave(&patch_lock, *flags); - else - __acquire(&patch_lock); + raw_spin_lock_irqsave(&patch_lock, *flags); =20 return (void *) (__fix_to_virt(fixmap) + (uintaddr & ~PAGE_MASK)); } @@ -52,10 +49,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned l= ong *flags) { clear_fixmap(fixmap); =20 - if (flags) - raw_spin_unlock_irqrestore(&patch_lock, *flags); - else - __release(&patch_lock); + raw_spin_unlock_irqrestore(&patch_lock, *flags); } =20 void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int l= en) @@ -67,8 +61,9 @@ void __kprobes __patch_text_multiple(void *addr, u32 *ins= n, unsigned int len) int mapped; =20 /* Make sure we don't have any aliases in cache */ - flush_kernel_vmap_range(addr, len); - flush_icache_range(start, end); + flush_kernel_dcache_range_asm(start, end); + flush_kernel_icache_range_asm(start, end); + flush_tlb_kernel_range(start, end); =20 p =3D fixmap =3D patch_map(addr, FIX_TEXT_POKE0, &flags, &mapped); =20 @@ -81,8 +76,10 @@ void __kprobes __patch_text_multiple(void *addr, u32 *in= sn, unsigned int len) * We're crossing a page boundary, so * need to remap */ - flush_kernel_vmap_range((void *)fixmap, - (p-fixmap) * sizeof(*p)); + flush_kernel_dcache_range_asm((unsigned long)fixmap, + (unsigned long)p); + flush_tlb_kernel_range((unsigned long)fixmap, + (unsigned long)p); if (mapped) patch_unmap(FIX_TEXT_POKE0, &flags); p =3D fixmap =3D patch_map(addr, FIX_TEXT_POKE0, &flags, @@ -90,10 +87,10 @@ void __kprobes __patch_text_multiple(void *addr, u32 *i= nsn, unsigned int len) } } =20 - flush_kernel_vmap_range((void *)fixmap, (p-fixmap) * sizeof(*p)); + flush_kernel_dcache_range_asm((unsigned long)fixmap, (unsigned long)p); + flush_tlb_kernel_range((unsigned long)fixmap, (unsigned long)p); if (mapped) patch_unmap(FIX_TEXT_POKE0, &flags); - flush_icache_range(start, end); } =20 void __kprobes __patch_text(void *addr, u32 insn) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 26FA4C43219 for ; Tue, 12 Apr 2022 08:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385219AbiDLIvH (ORCPT ); Tue, 12 Apr 2022 04:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358484AbiDLHlp (ORCPT ); Tue, 12 Apr 2022 03:41:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7DBC4B436; Tue, 12 Apr 2022 00:18: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 D91F561045; Tue, 12 Apr 2022 07:18:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCF18C385A1; Tue, 12 Apr 2022 07:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747888; bh=T1MTAFzWpOweed+RZG5QoSGLueTtX7wNgBrRpqrCLlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1vvfwI0AKrtITyUak4dHcGxb9yFQwW7aCUc3F4zty+IBgUz3ywO6RxJV6qpRUVfRt +peXKGXP2n38Ry2z1H3Cc86+DsguzNJedtphfutmmL8cPNov7KHjQX+IPaVIXW6+9L 1aJeHZBgJ4iYoC2LWMfUOpZA+V5l7WYZJMEhqFJY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauricio Faria de Oliveira , "Huang, Ying" , Minchan Kim , Yu Zhao , Yang Shi , Miaohe Lin , Dan Hill , Dan Streetman , Dongdong Tao , Gavin Guo , Gerald Yang , Heitor Alves de Siqueira , Ioanna Alifieraki , Jay Vosburgh , Matthew Ruffell , Ponnuvel Palaniyappan , Christoph Hellwig , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.17 192/343] mm: fix race between MADV_FREE reclaim and blkdev direct IO read Date: Tue, 12 Apr 2022 08:30:10 +0200 Message-Id: <20220412062956.899696273@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Mauricio Faria de Oliveira commit 6c8e2a256915a223f6289f651d6b926cd7135c9e upstream. Problem: =3D=3D=3D=3D=3D=3D=3D Userspace might read the zero-page instead of actual data from a direct IO read on a block device if the buffers have been called madvise(MADV_FREE) on earlier (this is discussed below) due to a race between page reclaim on MADV_FREE and blkdev direct IO read. - Race condition: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D During page reclaim, the MADV_FREE page check in try_to_unmap_one() checks if the page is not dirty, then discards its rmap PTE(s) (vs. remap back if the page is dirty). However, after try_to_unmap_one() returns to shrink_page_list(), it might keep the page _anyway_ if page_ref_freeze() fails (it expects exactly _one_ page reference, from the isolation for page reclaim). Well, blkdev_direct_IO() gets references for all pages, and on READ operations it only sets them dirty _later_. So, if MADV_FREE'd pages (i.e., not dirty) are used as buffers for direct IO read from block devices, and page reclaim happens during __blkdev_direct_IO[_simple]() exactly AFTER bio_iov_iter_get_pages() returns, but BEFORE the pages are set dirty, the situation happens. The direct IO read eventually completes. Now, when userspace reads the buffers, the PTE is no longer there and the page fault handler do_anonymous_page() services that with the zero-page, NOT the data! A synthetic reproducer is provided. - Page faults: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D If page reclaim happens BEFORE bio_iov_iter_get_pages() the issue doesn't happen, because that faults-in all pages as writeable, so do_anonymous_page() sets up a new page/rmap/PTE, and that is used by direct IO. The userspace reads don't fault as the PTE is there (thus zero-page is not used/setup). But if page reclaim happens AFTER it / BEFORE setting pages dirty, the PTE is no longer there; the subsequent page faults can't help: The data-read from the block device probably won't generate faults due to DMA (no MMU) but even in the case it wouldn't use DMA, that happens on different virtual addresses (not user-mapped addresses) because `struct bio_vec` stores `struct page` to figure addresses out (which are different from user-mapped addresses) for the read. Thus userspace reads (to user-mapped addresses) still fault, then do_anonymous_page() gets another `struct page` that would address/ map to other memory than the `struct page` used by `struct bio_vec` for the read. (The original `struct page` is not available, since it wasn't freed, as page_ref_freeze() failed due to more page refs. And even if it were available, its data cannot be trusted anymore.) Solution: =3D=3D=3D=3D=3D=3D=3D=3D One solution is to check for the expected page reference count in try_to_unmap_one(). There should be one reference from the isolation (that is also checked in shrink_page_list() with page_ref_freeze()) plus one or more references from page mapping(s) (put in discard: label). Further references mean that rmap/PTE cannot be unmapped/nuked. (Note: there might be more than one reference from mapping due to fork()/clone() without CLONE_VM, which use the same `struct page` for references, until the copy-on-write page gets copied.) So, additional page references (e.g., from direct IO read) now prevent the rmap/PTE from being unmapped/dropped; similarly to the page is not freed per shrink_page_list()/page_ref_freeze()). - Races and Barriers: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The new check in try_to_unmap_one() should be safe in races with bio_iov_iter_get_pages() in get_user_pages() fast and slow paths, as it's done under the PTE lock. The fast path doesn't take the lock, but it checks if the PTE has changed and if so, it drops the reference and leaves the page for the slow path (which does take that lock). The fast path requires synchronization w/ full memory barrier: it writes the page reference count first then it reads the PTE later, while try_to_unmap() writes PTE first then it reads page refcount. And a second barrier is needed, as the page dirty flag should not be read before the page reference count (as in __remove_mapping()). (This can be a load memory barrier only; no writes are involved.) Call stack/comments: - try_to_unmap_one() - page_vma_mapped_walk() - map_pte() # see pte_offset_map_lock(): pte_offset_map() spin_lock() - ptep_get_and_clear() # write PTE - smp_mb() # (new barrier) GUP fast path - page_ref_count() # (new check) read refcount - page_vma_mapped_walk_done() # see pte_unmap_unlock(): pte_unmap() spin_unlock() - bio_iov_iter_get_pages() - __bio_iov_iter_get_pages() - iov_iter_get_pages() - get_user_pages_fast() - internal_get_user_pages_fast() # fast path - lockless_pages_from_mm() - gup_{pgd,p4d,pud,pmd,pte}_range() ptep =3D pte_offset_map() # not _lock() pte =3D ptep_get_lockless(ptep) page =3D pte_page(pte) try_grab_compound_head(page) # inc refcount # (RMW/barrier # on success) if (pte_val(pte) !=3D pte_val(*ptep)) # read PTE put_compound_head(page) # dec refcount # go slow path # slow path - __gup_longterm_unlocked() - get_user_pages_unlocked() - __get_user_pages_locked() - __get_user_pages() - follow_{page,p4d,pud,pmd}_mask() - follow_page_pte() ptep =3D pte_offset_map_lock() pte =3D *ptep page =3D vm_normal_page(pte) try_grab_page(page) # inc refcount pte_unmap_unlock() - Huge Pages: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Regarding transparent hugepages, that logic shouldn't change, as MADV_FREE (aka lazyfree) pages are PageAnon() && !PageSwapBacked() (madvise_free_pte_range() -> mark_page_lazyfree() -> lru_lazyfree_fn()) thus should reach shrink_page_list() -> split_huge_page_to_list() before try_to_unmap[_one](), so it deals with normal pages only. (And in case unlikely/TTU_SPLIT_HUGE_PMD/split_huge_pmd_address() happens, which should not or be rare, the page refcount should be greater than mapcount: the head page is referenced by tail pages. That also prevents checking the head `page` then incorrectly call page_remove_rmap(subpage) for a tail page, that isn't even in the shrink_page_list()'s page_list (an effect of split huge pmd/pmvw), as it might happen today in this unlikely scenario.) MADV_FREE'd buffers: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D So, back to the "if MADV_FREE pages are used as buffers" note. The case is arguable, and subject to multiple interpretations. The madvise(2) manual page on the MADV_FREE advice value says: 1) 'After a successful MADV_FREE ... data will be lost when the kernel frees the pages.' 2) 'the free operation will be canceled if the caller writes into the page' / 'subsequent writes ... will succeed and then [the] kernel cannot free those dirtied pages' 3) 'If there is no subsequent write, the kernel can free the pages at any time.' Thoughts, questions, considerations... respectively: 1) Since the kernel didn't actually free the page (page_ref_freeze() failed), should the data not have been lost? (on userspace read.) 2) Should writes performed by the direct IO read be able to cancel the free operation? - Should the direct IO read be considered as 'the caller' too, as it's been requested by 'the caller'? - Should the bio technique to dirty pages on return to userspace (bio_check_pages_dirty() is called/used by __blkdev_direct_IO()) be considered in another/special way here? 3) Should an upcoming write from a previously requested direct IO read be considered as a subsequent write, so the kernel should not free the pages? (as it's known at the time of page reclaim.) And lastly: Technically, the last point would seem a reasonable consideration and balance, as the madvise(2) manual page apparently (and fairly) seem to assume that 'writes' are memory access from the userspace process (not explicitly considering writes from the kernel or its corner cases; again, fairly).. plus the kernel fix implementation for the corner case of the largely 'non-atomic write' encompassed by a direct IO read operation, is relatively simple; and it helps. Reproducer: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @ test.c (simplified, but works) #define _GNU_SOURCE #include #include #include #include int main() { int fd, i; char *buf; fd =3D open(DEV, O_RDONLY | O_DIRECT); buf =3D mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); for (i =3D 0; i < BUF_SIZE; i +=3D PAGE_SIZE) buf[i] =3D 1; // init to non-zero madvise(buf, BUF_SIZE, MADV_FREE); read(fd, buf, BUF_SIZE); for (i =3D 0; i < BUF_SIZE; i +=3D PAGE_SIZE) printf("%p: 0x%x\n", &buf[i], buf[i]); return 0; } @ block/fops.c (formerly fs/block_dev.c) +#include ... ... __blkdev_direct_IO[_simple](...) { ... + if (!strcmp(current->comm, "good")) + shrink_all_memory(ULONG_MAX); + ret =3D bio_iov_iter_get_pages(...); + + if (!strcmp(current->comm, "bad")) + shrink_all_memory(ULONG_MAX); ... } @ shell # NUM_PAGES=3D4 # PAGE_SIZE=3D$(getconf PAGE_SIZE) # yes | dd of=3Dtest.img bs=3D${PAGE_SIZE} count=3D${NUM_PAGES} # DEV=3D$(losetup -f --show test.img) # gcc -DDEV=3D\"$DEV\" \ -DBUF_SIZE=3D$((PAGE_SIZE * NUM_PAGES)) \ -DPAGE_SIZE=3D${PAGE_SIZE} \ test.c -o test # od -tx1 $DEV 0000000 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a 79 0a * 0040000 # mv test good # ./good 0x7f7c10418000: 0x79 0x7f7c10419000: 0x79 0x7f7c1041a000: 0x79 0x7f7c1041b000: 0x79 # mv good bad # ./bad 0x7fa1b8050000: 0x0 0x7fa1b8051000: 0x0 0x7fa1b8052000: 0x0 0x7fa1b8053000: 0x0 Note: the issue is consistent on v5.17-rc3, but it's intermittent with the support of MADV_FREE on v4.5 (60%-70% error; needs swap). [wrap do_direct_IO() in do_blockdev_direct_IO() @ fs/direct-io.c]. - v5.17-rc3: # for i in {1..1000}; do ./good; done \ | cut -d: -f2 | sort | uniq -c 4000 0x79 # mv good bad # for i in {1..1000}; do ./bad; done \ | cut -d: -f2 | sort | uniq -c 4000 0x0 # free | grep Swap Swap: 0 0 0 - v4.5: # for i in {1..1000}; do ./good; done \ | cut -d: -f2 | sort | uniq -c 4000 0x79 # mv good bad # for i in {1..1000}; do ./bad; done \ | cut -d: -f2 | sort | uniq -c 2702 0x0 1298 0x79 # swapoff -av swapoff /swap # for i in {1..1000}; do ./bad; done \ | cut -d: -f2 | sort | uniq -c 4000 0x79 Ceph/TCMalloc: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D For documentation purposes, the use case driving the analysis/fix is Ceph on Ubuntu 18.04, as the TCMalloc library there still uses MADV_FREE to release unused memory to the system from the mmap'ed page heap (might be committed back/used again; it's not munmap'ed.) - PageHeap::DecommitSpan() -> TCMalloc_SystemRelease() -> madvise() - PageHeap::CommitSpan() -> TCMalloc_SystemCommit() -> do nothing. Note: TCMalloc switched back to MADV_DONTNEED a few commits after the release in Ubuntu 18.04 (google-perftools/gperftools 2.5), so the issue just 'disappeared' on Ceph on later Ubuntu releases but is still present in the kernel, and can be hit by other use cases. The observed issue seems to be the old Ceph bug #22464 [1], where checksum mismatches are observed (and instrumentation with buffer dumps shows zero-pages read from mmap'ed/MADV_FREE'd page ranges). The issue in Ceph was reasonably deemed a kernel bug (comment #50) and mostly worked around with a retry mechanism, but other parts of Ceph could still hit that (rocksdb). Anyway, it's less likely to be hit again as TCMalloc switched out of MADV_FREE by default. (Some kernel versions/reports from the Ceph bug, and relation with the MADV_FREE introduction/changes; TCMalloc versions not checked.) - 4.4 good - 4.5 (madv_free: introduction) - 4.9 bad - 4.10 good? maybe a swapless system - 4.12 (madv_free: no longer free instantly on swapless systems) - 4.13 bad [1] https://tracker.ceph.com/issues/22464 Thanks: =3D=3D=3D=3D=3D=3D Several people contributed to analysis/discussions/tests/reproducers in the first stages when drilling down on ceph/tcmalloc/linux kernel: - Dan Hill - Dan Streetman - Dongdong Tao - Gavin Guo - Gerald Yang - Heitor Alves de Siqueira - Ioanna Alifieraki - Jay Vosburgh - Matthew Ruffell - Ponnuvel Palaniyappan Reviews, suggestions, corrections, comments: - Minchan Kim - Yu Zhao - Huang, Ying - John Hubbard - Christoph Hellwig [mfo@canonical.com: v4] Link: https://lkml.kernel.org/r/20220209202659.183418-1-mfo@canonical.com= Link: https://lkml.kernel.org/r/20220131230255.789059-1-mfo@canonical.com Fixes: 802a3a92ad7a ("mm: reclaim MADV_FREE pages") Signed-off-by: Mauricio Faria de Oliveira Reviewed-by: "Huang, Ying" Cc: Minchan Kim Cc: Yu Zhao Cc: Yang Shi Cc: Miaohe Lin Cc: Dan Hill Cc: Dan Streetman Cc: Dongdong Tao Cc: Gavin Guo Cc: Gerald Yang Cc: Heitor Alves de Siqueira Cc: Ioanna Alifieraki Cc: Jay Vosburgh Cc: Matthew Ruffell Cc: Ponnuvel Palaniyappan Cc: Cc: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds [mfo: backport: replace folio/test_flag with page/flag equivalents; real Fixes: 854e9ed09ded ("mm: support madvise(MADV_FREE)") in v4.] Signed-off-by: Mauricio Faria de Oliveira Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- mm/rmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index 6a1e8c7f6213..9e27f9f038d3 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1599,7 +1599,30 @@ static bool try_to_unmap_one(struct page *page, stru= ct vm_area_struct *vma, =20 /* MADV_FREE page check */ if (!PageSwapBacked(page)) { - if (!PageDirty(page)) { + int ref_count, map_count; + + /* + * Synchronize with gup_pte_range(): + * - clear PTE; barrier; read refcount + * - inc refcount; barrier; read PTE + */ + smp_mb(); + + ref_count =3D page_ref_count(page); + map_count =3D page_mapcount(page); + + /* + * Order reads for page refcount and dirty flag + * (see comments in __remove_mapping()). + */ + smp_rmb(); + + /* + * The only page refs must be one from isolation + * plus the rmap(s) (dropped by discard:). + */ + if (ref_count =3D=3D 1 + map_count && + !PageDirty(page)) { /* Invalidate as we cleared the pte */ mmu_notifier_invalidate_range(mm, address, address + PAGE_SIZE); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4E47CC433EF for ; Tue, 12 Apr 2022 08:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376291AbiDLItP (ORCPT ); Tue, 12 Apr 2022 04:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357613AbiDLHkc (ORCPT ); Tue, 12 Apr 2022 03:40:32 -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 CDF6C31DC2; Tue, 12 Apr 2022 00:16: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 299C46176E; Tue, 12 Apr 2022 07:16:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A65EC385A1; Tue, 12 Apr 2022 07:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747772; bh=vSEirDE08DDshdO7veGpX3SMni+/P5RvHskaZiqXZ6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zJSN30QrFuICAXt+O/AsjFzOvoEhCt/iLyxtsziA+f7juTArQnfAisXza1wBjhJs0 NOCOVf1nhAciz9m1j0hZx0BgSzKXPFuv6tJqKIdBTkTZHVP/7y2dLeU7fIaKtsPtk3 pTZhdp7nE72YB2dATKK1JJatV0qWaeIfk11c5J4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 193/343] drm/amdgpu: fix off by one in amdgpu_gfx_kiq_acquire() Date: Tue, 12 Apr 2022 08:30:11 +0200 Message-Id: <20220412062956.928663949@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Dan Carpenter [ Upstream commit 1647b54ed55d4d48c7199d439f8834626576cbe9 ] This post-op should be a pre-op so that we do not pass -1 as the bit number to test_bit(). The current code will loop downwards from 63 to -1. After changing to a pre-op, it loops from 63 to 0. Fixes: 71c37505e7ea ("drm/amdgpu/gfx: move more common KIQ code to amdgpu_g= fx.c") Signed-off-by: Dan Carpenter Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_gfx.c index 1916ec84dd71..e7845df6cad2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c @@ -266,7 +266,7 @@ static int amdgpu_gfx_kiq_acquire(struct amdgpu_device = *adev, * adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_queue_per_pipe; =20 - while (queue_bit-- >=3D 0) { + while (--queue_bit >=3D 0) { if (test_bit(queue_bit, adev->gfx.mec.queue_bitmap)) continue; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 81ED1C3527D for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353357AbiDLJSM (ORCPT ); Tue, 12 Apr 2022 05:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357686AbiDLHki (ORCPT ); Tue, 12 Apr 2022 03:40:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C40E61005; Tue, 12 Apr 2022 00:16: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 60F1261708; Tue, 12 Apr 2022 07:16:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76605C385A1; Tue, 12 Apr 2022 07:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747802; bh=uyftIm97GOa/nPfrZIJfhPY3oen1ZSdn3fuNNPh3DfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TnByObOy6iCWsCIdDckhld9DEvUZMKKgi9MpkbrOCxV8OkCBxoEFfdWknOzmwULkD 86RggxdyLik7XaUMeQJm0vrm8zTJbO6DZEKkZtwcSMNerC1B/B8Xhl/N1FEZ4y6E6K 8GewlxTtftJOlrkb/44L6TjznT5myvv+9SEpcIHk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Andrea Parri (Microsoft)" , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 5.17 194/343] Drivers: hv: vmbus: Fix initialization of device object in vmbus_device_register() Date: Tue, 12 Apr 2022 08:30:12 +0200 Message-Id: <20220412062956.958068021@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Andrea Parri (Microsoft) [ Upstream commit 3a5469582c241abca22500f36a9cb8e9331969cf ] Initialize the device's dma_{mask,parms} pointers and the device's dma_mask value before invoking device_register(). Address the following trace with 5.17-rc7: [ 49.646839] WARNING: CPU: 0 PID: 189 at include/linux/dma-mapping.h:543 netvsc_probe+0x37a/0x3a0 [hv_netvsc] [ 49.646928] Call Trace: [ 49.646930] [ 49.646935] vmbus_probe+0x40/0x60 [hv_vmbus] [ 49.646942] really_probe+0x1ce/0x3b0 [ 49.646948] __driver_probe_device+0x109/0x180 [ 49.646952] driver_probe_device+0x23/0xa0 [ 49.646955] __device_attach_driver+0x76/0xe0 [ 49.646958] ? driver_allows_async_probing+0x50/0x50 [ 49.646961] bus_for_each_drv+0x84/0xd0 [ 49.646964] __device_attach+0xed/0x170 [ 49.646967] device_initial_probe+0x13/0x20 [ 49.646970] bus_probe_device+0x8f/0xa0 [ 49.646973] device_add+0x41a/0x8e0 [ 49.646975] ? hrtimer_init+0x28/0x80 [ 49.646981] device_register+0x1b/0x20 [ 49.646983] vmbus_device_register+0x5e/0xf0 [hv_vmbus] [ 49.646991] vmbus_add_channel_work+0x12d/0x190 [hv_vmbus] [ 49.646999] process_one_work+0x21d/0x3f0 [ 49.647002] worker_thread+0x4a/0x3b0 [ 49.647005] ? process_one_work+0x3f0/0x3f0 [ 49.647007] kthread+0xff/0x130 [ 49.647011] ? kthread_complete_and_exit+0x20/0x20 [ 49.647015] ret_from_fork+0x22/0x30 [ 49.647020] [ 49.647021] ---[ end trace 0000000000000000 ]--- Fixes: 743b237c3a7b0 ("scsi: storvsc: Add Isolation VM support for storvsc = driver") Signed-off-by: Andrea Parri (Microsoft) Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20220315141053.3223-1-parri.andrea@gmail.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/hv/vmbus_drv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 12a2b37e87f3..0a05e10ab36c 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2097,6 +2097,10 @@ int vmbus_device_register(struct hv_device *child_de= vice_obj) child_device_obj->device.parent =3D &hv_acpi_dev->dev; child_device_obj->device.release =3D vmbus_device_release; =20 + child_device_obj->device.dma_parms =3D &child_device_obj->dma_parms; + child_device_obj->device.dma_mask =3D &child_device_obj->dma_mask; + dma_set_mask(&child_device_obj->device, DMA_BIT_MASK(64)); + /* * Register with the LDM. This will kick off the driver/device * binding...which will eventually call vmbus_match() and vmbus_probe() @@ -2122,9 +2126,6 @@ int vmbus_device_register(struct hv_device *child_dev= ice_obj) } hv_debug_add_dev_dir(child_device_obj); =20 - child_device_obj->device.dma_parms =3D &child_device_obj->dma_parms; - child_device_obj->device.dma_mask =3D &child_device_obj->dma_mask; - dma_set_mask(&child_device_obj->device, DMA_BIT_MASK(64)); return 0; =20 err_kset_unregister: --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B2C62C433EF for ; Tue, 12 Apr 2022 09:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237190AbiDLJO7 (ORCPT ); Tue, 12 Apr 2022 05:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358021AbiDLHk7 (ORCPT ); Tue, 12 Apr 2022 03:40:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F5463D49F; Tue, 12 Apr 2022 00:17: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 8E8D46183C; Tue, 12 Apr 2022 07:17:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F83BC385AE; Tue, 12 Apr 2022 07:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747833; bh=kShmUKhk7LeU0JYZ+RZnv3yHp8XfKe090h2Ncf9GveQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQ/0G5VyVOHwbSKw9TXBgiSQa/sNRKbj7iS2GN0x39s9rTYCO0maf/7n1jfIJDsK3 Cng8jI39fM82Fl7ZmBFvHzhzVrGg/6y4npVZn346cNUwp2hJ4hXzbXBXYvXXRy7VGY SvX+bSA8PacUAZZXllBiYCMhu5aWWYqTqFBTOs18= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Guilherme G. Piccoli" , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 5.17 195/343] Drivers: hv: vmbus: Fix potential crash on module unload Date: Tue, 12 Apr 2022 08:30:13 +0200 Message-Id: <20220412062956.986128622@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Guilherme G. Piccoli [ Upstream commit 792f232d57ff28bbd5f9c4abe0466b23d5879dc8 ] The vmbus driver relies on the panic notifier infrastructure to perform some operations when a panic event is detected. Since vmbus can be built as module, it is required that the driver handles both registering and unregistering such panic notifier callback. After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic c= allback") though, the panic notifier registration is done unconditionally in the modu= le initialization routine whereas the unregistering procedure is conditionally guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability is set. This patch fixes that by unconditionally unregistering the panic notifier in the module's exit routine as well. Fixes: 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callbac= k") Signed-off-by: Guilherme G. Piccoli Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20220315203535.682306-1-gpiccoli@igalia.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/hv/vmbus_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 0a05e10ab36c..4bea1dfa41cd 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2781,10 +2781,15 @@ static void __exit vmbus_exit(void) if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { kmsg_dump_unregister(&hv_kmsg_dumper); unregister_die_notifier(&hyperv_die_block); - atomic_notifier_chain_unregister(&panic_notifier_list, - &hyperv_panic_block); } =20 + /* + * The panic notifier is always registered, hence we should + * also unconditionally unregister it here as well. + */ + atomic_notifier_chain_unregister(&panic_notifier_list, + &hyperv_panic_block); + free_page((unsigned long)hv_panic_page); unregister_sysctl_table(hv_ctl_table_hdr); hv_ctl_table_hdr =3D NULL; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CFF8CC433F5 for ; Tue, 12 Apr 2022 08:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376935AbiDLIug (ORCPT ); Tue, 12 Apr 2022 04:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358312AbiDLHlY (ORCPT ); Tue, 12 Apr 2022 03:41:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A93B45AF0; Tue, 12 Apr 2022 00:17: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 F01FD616B2; Tue, 12 Apr 2022 07:17:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03A45C385A5; Tue, 12 Apr 2022 07:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747863; bh=elrvW3bnbgmA8t2/Ex3dnVBXPkdDaZXV0P4AvBUOFSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csHy5PLqwFSR3rp75KDz5UWKpxODg8a4zWdrtUV0UnClCYbAeRFBGnUL6BPGYUaSH sfmZbY3Y0n9wGmUoZbWnE8zEcShWPCtIl2A+UUO7bCTt/Eez3/Alnq0IhOA6WE+txp cbg4Neu4NhJvRzf4VhFnUNkkCGsydZ/tjTFNsfJY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeremy Sowden , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.17 196/343] netfilter: bitwise: fix reduce comparisons Date: Tue, 12 Apr 2022 08:30:14 +0200 Message-Id: <20220412062957.013993867@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jeremy Sowden [ Upstream commit 31818213170caa51d116eb5dc1167b88523b4fe1 ] The `nft_bitwise_reduce` and `nft_bitwise_fast_reduce` functions should compare the bitwise operation in `expr` with the tracked operation associated with the destination register of `expr`. However, instead of being called on `expr` and `track->regs[priv->dreg].selector`, `nft_expr_priv` is called on `expr` twice, so both reduce functions return true even when the operations differ. Fixes: be5650f8f47e ("netfilter: nft_bitwise: track register operations") Signed-off-by: Jeremy Sowden Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/netfilter/nft_bitwise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c index 7b727d3ebf9d..04bd2f89afe8 100644 --- a/net/netfilter/nft_bitwise.c +++ b/net/netfilter/nft_bitwise.c @@ -287,7 +287,7 @@ static bool nft_bitwise_reduce(struct nft_regs_track *t= rack, if (!track->regs[priv->sreg].selector) return false; =20 - bitwise =3D nft_expr_priv(expr); + bitwise =3D nft_expr_priv(track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector =3D=3D track->regs[priv->dreg].selec= tor && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops =3D=3D expr->ops && @@ -434,7 +434,7 @@ static bool nft_bitwise_fast_reduce(struct nft_regs_tra= ck *track, if (!track->regs[priv->sreg].selector) return false; =20 - bitwise =3D nft_expr_priv(expr); + bitwise =3D nft_expr_priv(track->regs[priv->dreg].selector); if (track->regs[priv->sreg].selector =3D=3D track->regs[priv->dreg].selec= tor && track->regs[priv->dreg].bitwise && track->regs[priv->dreg].bitwise->ops =3D=3D expr->ops && --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4D7E8C433FE for ; Tue, 12 Apr 2022 08:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380838AbiDLIun (ORCPT ); Tue, 12 Apr 2022 04:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358392AbiDLHle (ORCPT ); Tue, 12 Apr 2022 03:41:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C61F84B1CC; Tue, 12 Apr 2022 00:17: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 dfw.source.kernel.org (Postfix) with ESMTPS id 0014D616E7; Tue, 12 Apr 2022 07:17:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DADCC385A5; Tue, 12 Apr 2022 07:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747874; bh=1kvO8kzrocGOeyhH3q7quzIPRU0KgSJ0xpJoB6yzKzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esBlPdLALJWjT52vkc5aH1ml7HLF3JxkGQLt9hcjqQFYNIw3Y+c8CrfmTE/v+Hzmx v1bes7OB0H+3Gl4UkDHEAy6EkhRxyusNwhAaq7V0SAV9EQQgHuA7Pq9jIC8dLQMDN3 W//5IcLguFcegjYDAsj/I/z5cMbDeWrboZCf0OSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lyu Tao , ChenXiaoSong , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 197/343] Revert "NFSv4: Handle the special Linux file open access mode" Date: Tue, 12 Apr 2022 08:30:15 +0200 Message-Id: <20220412062957.042415016@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: ChenXiaoSong [ Upstream commit ab0fc21bc7105b54bafd85bd8b82742f9e68898a ] This reverts commit 44942b4e457beda00981f616402a1a791e8c616e. After secondly opening a file with O_ACCMODE|O_DIRECT flags, nfs4_valid_open_stateid() will dereference NULL nfs4_state when lseek(). Reproducer: 1. mount -t nfs -o vers=3D4.2 $server_ip:/ /mnt/ 2. fd =3D open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT) 3. close(fd) 4. fd =3D open("/mnt/file", O_ACCMODE|O_DIRECT) 5. lseek(fd) Reported-by: Lyu Tao Signed-off-by: ChenXiaoSong Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/inode.c | 1 - fs/nfs/nfs4file.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index d96baa4450e3..e4fb939a2904 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp) nfs_fscache_open_file(inode, filp); return 0; } -EXPORT_SYMBOL_GPL(nfs_open); =20 /* * This function is called whenever some part of NFS notices that diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index e79ae4cbc395..c178db86a6e8 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) return err; =20 if ((openflags & O_ACCMODE) =3D=3D 3) - return nfs_open(inode, filp); + openflags--; =20 /* We can't create new files here */ openflags &=3D ~(O_CREAT|O_EXCL); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2E1FCC433F5 for ; Tue, 12 Apr 2022 09:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238834AbiDLJNU (ORCPT ); Tue, 12 Apr 2022 05:13:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358414AbiDLHlf (ORCPT ); Tue, 12 Apr 2022 03:41:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4364B1F4; Tue, 12 Apr 2022 00:17: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 CF13E61045; Tue, 12 Apr 2022 07:17:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D771DC385A1; Tue, 12 Apr 2022 07:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747877; bh=USiyarqyIUBp0MdGUmQeLSlDjG55mww0+ltDe3KOv4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kq2WtdtbIQf1DOvE7YPUeRZWY3YpiXUYSbo4TEk2NtpHlCHMWrpBIx6m+uo3gPZwQ tyQ0TgdCwQJUTGZOGxNnqxwbPjjfNOAY5bG4egQeFz+re8ydMuD/GoDqT1w/k5yo0p vZWJ7UiqoplSPTqcz5o1H+5YtgEYZzra9SzP2QM8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ChenXiaoSong , Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 198/343] NFSv4: fix open failure with O_ACCMODE flag Date: Tue, 12 Apr 2022 08:30:16 +0200 Message-Id: <20220412062957.070531019@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: ChenXiaoSong [ Upstream commit b243874f6f9568b2daf1a00e9222cacdc15e159c ] open() with O_ACCMODE|O_DIRECT flags secondly will fail. Reproducer: 1. mount -t nfs -o vers=3D4.2 $server_ip:/ /mnt/ 2. fd =3D open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT) 3. close(fd) 4. fd =3D open("/mnt/file", O_ACCMODE|O_DIRECT) Server nfsd4_decode_share_access() will fail with error nfserr_bad_xdr when client use incorrect share access mode of 0. Fix this by using NFS4_SHARE_ACCESS_BOTH share access mode in client, just like firstly opening. Fixes: ce4ef7c0a8a05 ("NFS: Split out NFS v4 file operations") Signed-off-by: ChenXiaoSong Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/nfs/dir.c | 10 ---------- fs/nfs/internal.h | 10 ++++++++++ fs/nfs/nfs4file.c | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 75cb1cbe4cde..911bdb35eb08 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1853,16 +1853,6 @@ const struct dentry_operations nfs4_dentry_operation= s =3D { }; EXPORT_SYMBOL_GPL(nfs4_dentry_operations); =20 -static fmode_t flags_to_mode(int flags) -{ - fmode_t res =3D (__force fmode_t)flags & FMODE_EXEC; - if ((flags & O_ACCMODE) !=3D O_WRONLY) - res |=3D FMODE_READ; - if ((flags & O_ACCMODE) !=3D O_RDONLY) - res |=3D FMODE_WRITE; - return res; -} - static struct nfs_open_context *create_nfs_open_context(struct dentry *den= try, int open_flags, struct file *filp) { return alloc_nfs_open_context(dentry, flags_to_mode(open_flags), filp); diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index db9f611e8efd..465e39ff018d 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -42,6 +42,16 @@ static inline bool nfs_lookup_is_soft_revalidate(const s= truct dentry *dentry) return true; } =20 +static inline fmode_t flags_to_mode(int flags) +{ + fmode_t res =3D (__force fmode_t)flags & FMODE_EXEC; + if ((flags & O_ACCMODE) !=3D O_WRONLY) + res |=3D FMODE_READ; + if ((flags & O_ACCMODE) !=3D O_RDONLY) + res |=3D FMODE_WRITE; + return res; +} + /* * Note: RFC 1813 doesn't limit the number of auth flavors that * a server can return, so make something up. diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index c178db86a6e8..e34af48fb4f4 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -32,6 +32,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) struct dentry *parent =3D NULL; struct inode *dir; unsigned openflags =3D filp->f_flags; + fmode_t f_mode; struct iattr attr; int err; =20 @@ -50,8 +51,9 @@ nfs4_file_open(struct inode *inode, struct file *filp) if (err) return err; =20 + f_mode =3D filp->f_mode; if ((openflags & O_ACCMODE) =3D=3D 3) - openflags--; + f_mode |=3D flags_to_mode(openflags); =20 /* We can't create new files here */ openflags &=3D ~(O_CREAT|O_EXCL); @@ -59,7 +61,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) parent =3D dget_parent(dentry); dir =3D d_inode(parent); =20 - ctx =3D alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp); + ctx =3D alloc_nfs_open_context(file_dentry(filp), f_mode, filp); err =3D PTR_ERR(ctx); if (IS_ERR(ctx)) goto out; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 899EBC43217 for ; Tue, 12 Apr 2022 08:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385177AbiDLIu4 (ORCPT ); Tue, 12 Apr 2022 04:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358424AbiDLHlh (ORCPT ); Tue, 12 Apr 2022 03:41: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 0E7B14B41C; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id 9E9176153F; Tue, 12 Apr 2022 07:18:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9B05C385A1; Tue, 12 Apr 2022 07:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747880; bh=n5yPUWkMd95tE3x0rxoJM9innYGchDcsor/IkUmA+mk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nrKBVr6nnSDMcl+bCMnvmpE9dxuribOg9sd+D7+RojZjcO4ULYo2Xzj/sSv1qtSnY 8zV8ZuIZGm447D41/s2AbsNkrL/8I8PKl2dsTlhoqGRfq0T8IdBptPGbaJ3sOXWmsK 89AcW1XBBG8TkJSaJyC1ffYD2XkprscaEIVAepJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changhui Zhong , Christoph Hellwig , Tomas Henzl , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 199/343] scsi: core: scsi_logging: Fix a BUG Date: Tue, 12 Apr 2022 08:30:17 +0200 Message-Id: <20220412062957.099091906@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Tomas Henzl [ Upstream commit f06aa52cb2723ec67e92df463827b800d6c477d1 ] The request_queue may be NULL in a request, for example when it comes from scsi_ioctl_reset(). Check it before use. Fixes: f3fa33acca9f ("block: remove the ->rq_disk field in struct request") Link: https://lore.kernel.org/r/20220324134603.28463-1-thenzl@redhat.com Reported-by: Changhui Zhong Reviewed-by: Christoph Hellwig Signed-off-by: Tomas Henzl Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/scsi_logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c index 1f8f80b2dbfc..a9f8de5e9639 100644 --- a/drivers/scsi/scsi_logging.c +++ b/drivers/scsi/scsi_logging.c @@ -30,7 +30,7 @@ static inline const char *scmd_name(const struct scsi_cmn= d *scmd) { struct request *rq =3D scsi_cmd_to_rq((struct scsi_cmnd *)scmd); =20 - if (!rq->q->disk) + if (!rq->q || !rq->q->disk) return NULL; return rq->q->disk->disk_name; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6B149C4332F for ; Tue, 12 Apr 2022 08:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382706AbiDLIut (ORCPT ); Tue, 12 Apr 2022 04:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358429AbiDLHlh (ORCPT ); Tue, 12 Apr 2022 03:41: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 C004C4B1FF; Tue, 12 Apr 2022 00:18: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 54A6861045; Tue, 12 Apr 2022 07:18:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EEEDC385A5; Tue, 12 Apr 2022 07:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747882; bh=GPpkSk4rc2KNtiaOqLhemdsMz2WcHV50oomCVtVcdMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mOsDc0laNHm8uffU0k4lLpl1ik5Nfw5oEpcTnmZMGkCrMQk6LPrwAe93mmRwXekLW 8fyzec21Ar6ZOLcLIFomP9E2EsiQtGIxgViK/2vAYzLSEcVdNkyhUlj9u4YKyb1yqO YX4PKmP33czPnSLHX2Mp2qNXZLpfMY96pVQ8fCwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Kevin Groeneveld , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 200/343] scsi: sr: Fix typo in CDROM(CLOSETRAY|EJECT) handling Date: Tue, 12 Apr 2022 08:30:18 +0200 Message-Id: <20220412062957.127204179@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kevin Groeneveld [ Upstream commit bc5519c18a32ce855bb51b9f5eceb77a9489d080 ] Commit 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl()") seems to have a typo as it is checking ret instead of cmd in the if statement checking for CDROMCLOSETRAY and CDROMEJECT. This changes the behaviour of these ioctls as the cdrom_ioctl handling of these is more restrictive than the scsi_ioctl version. Link: https://lore.kernel.org/r/20220323002242.21157-1-kgroeneveld@lenbrook= .com Fixes: 2e27f576abc6 ("scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioc= tl()") Reviewed-by: Christoph Hellwig Signed-off-by: Kevin Groeneveld Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/sr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index f925b1f1f9ad..a0beb11abdc9 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -578,7 +578,7 @@ static int sr_block_ioctl(struct block_device *bdev, fm= ode_t mode, unsigned cmd, =20 scsi_autopm_get_device(sdev); =20 - if (ret !=3D CDROMCLOSETRAY && ret !=3D CDROMEJECT) { + if (cmd !=3D CDROMCLOSETRAY && cmd !=3D CDROMEJECT) { ret =3D cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg); if (ret !=3D -ENOSYS) goto put; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 01AE2C433EF for ; Tue, 12 Apr 2022 08:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385191AbiDLIu7 (ORCPT ); Tue, 12 Apr 2022 04:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358446AbiDLHlj (ORCPT ); Tue, 12 Apr 2022 03:41:39 -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 9C5614B844; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id 15E7F61708; Tue, 12 Apr 2022 07:18:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 203F8C385A5; Tue, 12 Apr 2022 07:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747885; bh=+BvEqExuJ4YvosuiNPophXouLG3Vdl4v0/jzgo7XOL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RgEQySiSIUn4yczSLW/M6ied5HhGXvjxaRWOW67QRxUiX7PWBt0oelXFvHliF9Ks+ L/LraytGprJCXxioyFYkLWuhmB3/3RT30PDKHEl6WqbUnpYDF1ck3A/a8Rc0aiyi3O kGLweVmxL7IeSPpS3cxJ/efO/kWDB7AURy8zXBlU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Ming Lei , Bart Van Assche , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 201/343] scsi: core: Fix sbitmap depth in scsi_realloc_sdev_budget_map() Date: Tue, 12 Apr 2022 08:30:19 +0200 Message-Id: <20220412062957.155676168@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: John Garry [ Upstream commit eaba83b5b8506bbc9ee7ca2f10aeab3fff3719e7 ] In commit edb854a3680b ("scsi: core: Reallocate device's budget map on queue depth change"), the sbitmap for the device budget map may be reallocated after the slave device depth is configured. When the sbitmap is reallocated we use the result from scsi_device_max_queue_depth() for the sbitmap size, but don't resize to match the actual device queue depth. Fix by resizing the sbitmap after reallocating the budget sbitmap. We do this instead of init'ing the sbitmap to the device queue depth as the user may want to change the queue depth later via sysfs or other. Link: https://lore.kernel.org/r/1647423870-143867-1-git-send-email-john.gar= ry@huawei.com Fixes: edb854a3680b ("scsi: core: Reallocate device's budget map on queue d= epth change") Tested-by: Damien Le Moal Reviewed-by: Ming Lei Reviewed-by: Bart Van Assche Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/scsi_scan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index f4e6c68ac99e..2ef78083f1ef 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -223,6 +223,8 @@ static int scsi_realloc_sdev_budget_map(struct scsi_dev= ice *sdev, int ret; struct sbitmap sb_backup; =20 + depth =3D min_t(unsigned int, depth, scsi_device_max_queue_depth(sdev)); + /* * realloc if new shift is calculated, which is caused by setting * up one new default queue depth after calling ->slave_configure @@ -245,6 +247,9 @@ static int scsi_realloc_sdev_budget_map(struct scsi_dev= ice *sdev, scsi_device_max_queue_depth(sdev), new_shift, GFP_KERNEL, sdev->request_queue->node, false, true); + if (!ret) + sbitmap_resize(&sdev->budget_map, depth); + if (need_free) { if (ret) sdev->budget_map =3D sb_backup; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E7E1CC4167D for ; Tue, 12 Apr 2022 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353951AbiDLJSc (ORCPT ); Tue, 12 Apr 2022 05:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357639AbiDLHke (ORCPT ); Tue, 12 Apr 2022 03:40:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4E4331500; Tue, 12 Apr 2022 00:16: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 dfw.source.kernel.org (Postfix) with ESMTPS id 0E11C6171C; Tue, 12 Apr 2022 07:16:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1763FC385A1; Tue, 12 Apr 2022 07:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747775; bh=Ur7rnRKD7I0yAumOWBGWGZkPPf4CPiK8FlaCdTnTWQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5jeOfxN+rYqIsg9N8mJXJiIAprso5Q8rNj8/kRll8ORoHVlRG0zKBITzXkG+pT2W WcTNxkS97YX9sImvlZ347unsZxeRNxViINlIIY9e9M2aNFhkQx4bEcq1kkmilrmJLg +pDQBqO8G14g74rgf8Ifvbkyyb9BkJZfp4W6PaFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Christophe JAILLET , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 202/343] scsi: zorro7xx: Fix a resource leak in zorro7xx_remove_one() Date: Tue, 12 Apr 2022 08:30:20 +0200 Message-Id: <20220412062957.183725721@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Christophe JAILLET [ Upstream commit 16ed828b872d12ccba8f07bcc446ae89ba662f9c ] The error handling path of the probe releases a resource that is not freed in the remove function. In some cases, a ioremap() must be undone. Add the missing iounmap() call in the remove function. Link: https://lore.kernel.org/r/247066a3104d25f9a05de8b3270fc3c848763bcc.16= 47673264.git.christophe.jaillet@wanadoo.fr Fixes: 45804fbb00ee ("[SCSI] 53c700: Amiga Zorro NCR53c710 SCSI") Reviewed-by: Geert Uytterhoeven Signed-off-by: Christophe JAILLET Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/zorro7xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c index 27b9e2baab1a..7acf9193a9e8 100644 --- a/drivers/scsi/zorro7xx.c +++ b/drivers/scsi/zorro7xx.c @@ -159,6 +159,8 @@ static void zorro7xx_remove_one(struct zorro_dev *z) scsi_remove_host(host); =20 NCR_700_release(host); + if (host->base > 0x01000000) + iounmap(hostdata->base); kfree(hostdata); free_irq(host->irq, host); zorro_release_device(z); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BE56EC3527E for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354212AbiDLJSs (ORCPT ); Tue, 12 Apr 2022 05:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357662AbiDLHkg (ORCPT ); Tue, 12 Apr 2022 03:40:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7E53326F2; Tue, 12 Apr 2022 00:16: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 56290B81B60; Tue, 12 Apr 2022 07:16:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF57C385A5; Tue, 12 Apr 2022 07:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747778; bh=WxPLjrKQ8eRD1EGKTuVP56FWs6l0pz+Qv7AArwyle8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uo9R4QbcQkB8lJWmW/1cxnCAG6JjpVS7jAUNIbNOTNvTkXdxXNBAd6wqgrpaSS8T4 mL91MMml+evxQCmy6W3YYp9RVNIhvl1bH3I39uT0jYcZnq+6vCx8yUokwXwr/mi8Zx ItSuDXoMIWbjWq7kphBG7rzJoS+9LuGwDbNxhJEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" , Eli Cohen , Sasha Levin Subject: [PATCH 5.17 203/343] vdpa: mlx5: prevent cvq work from hogging CPU Date: Tue, 12 Apr 2022 08:30:21 +0200 Message-Id: <20220412062957.212295308@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jason Wang [ Upstream commit 55ebf0d60e3cc6c9e8593399e185842c00e12f36 ] A userspace triggerable infinite loop could happen in mlx5_cvq_kick_handler() if userspace keeps sending a huge amount of cvq requests. Fixing this by introducing a quota and re-queue the work if we're out of the budget (currently the implicit budget is one) . While at it, using a per device work struct to avoid on demand memory allocation for cvq. Fixes: 5262912ef3cfc ("vdpa/mlx5: Add support for control VQ and MAC settin= g") Signed-off-by: Jason Wang Link: https://lore.kernel.org/r/20220329042109.4029-1-jasowang@redhat.com Signed-off-by: Michael S. Tsirkin Acked-by: Eli Cohen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index 9fe1071a9644..1b5de3af1a62 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -163,6 +163,7 @@ struct mlx5_vdpa_net { u32 cur_num_vqs; struct notifier_block nb; struct vdpa_callback config_cb; + struct mlx5_vdpa_wq_ent cvq_ent; }; =20 static void free_resources(struct mlx5_vdpa_net *ndev); @@ -1616,10 +1617,10 @@ static void mlx5_cvq_kick_handler(struct work_struc= t *work) ndev =3D to_mlx5_vdpa_ndev(mvdev); cvq =3D &mvdev->cvq; if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))) - goto out; + return; =20 if (!cvq->ready) - goto out; + return; =20 while (true) { err =3D vringh_getdesc_iotlb(&cvq->vring, &cvq->riov, &cvq->wiov, &cvq->= head, @@ -1653,9 +1654,10 @@ static void mlx5_cvq_kick_handler(struct work_struct= *work) =20 if (vringh_need_notify_iotlb(&cvq->vring)) vringh_notify(&cvq->vring); + + queue_work(mvdev->wq, &wqent->work); + break; } -out: - kfree(wqent); } =20 static void mlx5_vdpa_kick_vq(struct vdpa_device *vdev, u16 idx) @@ -1663,7 +1665,6 @@ static void mlx5_vdpa_kick_vq(struct vdpa_device *vde= v, u16 idx) struct mlx5_vdpa_dev *mvdev =3D to_mvdev(vdev); struct mlx5_vdpa_net *ndev =3D to_mlx5_vdpa_ndev(mvdev); struct mlx5_vdpa_virtqueue *mvq; - struct mlx5_vdpa_wq_ent *wqent; =20 if (!is_index_valid(mvdev, idx)) return; @@ -1672,13 +1673,7 @@ static void mlx5_vdpa_kick_vq(struct vdpa_device *vd= ev, u16 idx) if (!mvdev->wq || !mvdev->cvq.ready) return; =20 - wqent =3D kzalloc(sizeof(*wqent), GFP_ATOMIC); - if (!wqent) - return; - - wqent->mvdev =3D mvdev; - INIT_WORK(&wqent->work, mlx5_cvq_kick_handler); - queue_work(mvdev->wq, &wqent->work); + queue_work(mvdev->wq, &ndev->cvq_ent.work); return; } =20 @@ -2668,6 +2663,8 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_= mdev, const char *name, if (err) goto err_mr; =20 + ndev->cvq_ent.mvdev =3D mvdev; + INIT_WORK(&ndev->cvq_ent.work, mlx5_cvq_kick_handler); mvdev->wq =3D create_singlethread_workqueue("mlx5_vdpa_wq"); if (!mvdev->wq) { err =3D -ENOMEM; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7EF18C4167E for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376385AbiDLItV (ORCPT ); Tue, 12 Apr 2022 04:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357665AbiDLHkg (ORCPT ); Tue, 12 Apr 2022 03:40:36 -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 6D8D032989; Tue, 12 Apr 2022 00:16: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 007DAB81B4F; Tue, 12 Apr 2022 07:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7094EC385A5; Tue, 12 Apr 2022 07:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747780; bh=3h0XwVx3H6DPKTZTgssESrCaK9Pgn48WCI5SKP+uMZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kxAFjuyJBH1s8VpAqtD18MuABo9qHlJ5NPQsgeRvVrQwgKwrd1W9nPcD2vJPTCM5Z D/WvJjFBmrMXdlTzLBEQB4MAGvyBnxisVgjdRt6VanBkt2zasS0bEfuUvUTRsBVwt6 8+jMEh0UP3huvG2PRNa3dgvmqrIyjXivn9EaaqXw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 204/343] net: sfc: add missing xdp queue reinitialization Date: Tue, 12 Apr 2022 08:30:22 +0200 Message-Id: <20220412062957.240319302@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 059a47f1da93811d37533556d67e72f2261b1127 ] After rx/tx ring buffer size is changed, kernel panic occurs when it acts XDP_TX or XDP_REDIRECT. When tx/rx ring buffer size is changed(ethtool -G), sfc driver reallocates and reinitializes rx and tx queues and their buffer (tx_queue->buffer). But it misses reinitializing xdp queues(efx->xdp_tx_queues). So, while it is acting XDP_TX or XDP_REDIRECT, it uses the uninitialized tx_queue->buffer. A new function efx_set_xdp_channels() is separated from efx_set_channels() to handle only xdp queues. Splat looks like: BUG: kernel NULL pointer dereference, address: 000000000000002a #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 0 P4D 0 Oops: 0002 [#4] PREEMPT SMP NOPTI RIP: 0010:efx_tx_map_chunk+0x54/0x90 [sfc] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G D 5.17.0+ #55 e8= beeee8289528f11357029357cf Code: 48 8b 8d a8 01 00 00 48 8d 14 52 4c 8d 2c d0 44 89 e0 48 85 c9 74 = 0e 44 89 e2 4c 89 f6 48 80 RSP: 0018:ffff92f121e45c60 EFLAGS: 00010297 RIP: 0010:efx_tx_map_chunk+0x54/0x90 [sfc] RAX: 0000000000000040 RBX: ffff92ea506895c0 RCX: ffffffffc0330870 RDX: 0000000000000001 RSI: 00000001139b10ce RDI: ffff92ea506895c0 RBP: ffffffffc0358a80 R08: 00000001139b110d R09: 0000000000000000 R10: 0000000000000001 R11: ffff92ea414c0088 R12: 0000000000000040 R13: 0000000000000018 R14: 00000001139b10ce R15: ffff92ea506895c0 FS: 0000000000000000(0000) GS:ffff92f121ec0000(0000) knlGS:000000000000= 0000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Code: 48 8b 8d a8 01 00 00 48 8d 14 52 4c 8d 2c d0 44 89 e0 48 85 c9 74 = 0e 44 89 e2 4c 89 f6 48 80 CR2: 000000000000002a CR3: 00000003e6810004 CR4: 00000000007706e0 RSP: 0018:ffff92f121e85c60 EFLAGS: 00010297 PKRU: 55555554 RAX: 0000000000000040 RBX: ffff92ea50689700 RCX: ffffffffc0330870 RDX: 0000000000000001 RSI: 00000001145a90ce RDI: ffff92ea50689700 RBP: ffffffffc0358a80 R08: 00000001145a910d R09: 0000000000000000 R10: 0000000000000001 R11: ffff92ea414c0088 R12: 0000000000000040 R13: 0000000000000018 R14: 00000001145a90ce R15: ffff92ea50689700 FS: 0000000000000000(0000) GS:ffff92f121e80000(0000) knlGS:000000000000= 0000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000002a CR3: 00000003e6810005 CR4: 00000000007706e0 PKRU: 55555554 Call Trace: efx_xdp_tx_buffers+0x12b/0x3d0 [sfc 84c94b8e32d44d296c17e10a634d3ad454d= e4ba5] __efx_rx_packet+0x5c3/0x930 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4b= a5] efx_rx_packet+0x28c/0x2e0 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5] efx_ef10_ev_process+0x5f8/0xf40 [sfc 84c94b8e32d44d296c17e10a634d3ad454= de4ba5] ? enqueue_task_fair+0x95/0x550 efx_poll+0xc4/0x360 [sfc 84c94b8e32d44d296c17e10a634d3ad454de4ba5] Fixes: 3990a8fffbda ("sfc: allocate channels for XDP tx queues") Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/sfc/efx_channels.c | 146 +++++++++++++----------- 1 file changed, 81 insertions(+), 65 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet= /sfc/efx_channels.c index ead550ae2709..5e587cb853b9 100644 --- a/drivers/net/ethernet/sfc/efx_channels.c +++ b/drivers/net/ethernet/sfc/efx_channels.c @@ -764,6 +764,85 @@ void efx_remove_channels(struct efx_nic *efx) kfree(efx->xdp_tx_queues); } =20 +static int efx_set_xdp_tx_queue(struct efx_nic *efx, int xdp_queue_number, + struct efx_tx_queue *tx_queue) +{ + if (xdp_queue_number >=3D efx->xdp_tx_queue_count) + return -EINVAL; + + netif_dbg(efx, drv, efx->net_dev, + "Channel %u TXQ %u is XDP %u, HW %u\n", + tx_queue->channel->channel, tx_queue->label, + xdp_queue_number, tx_queue->queue); + efx->xdp_tx_queues[xdp_queue_number] =3D tx_queue; + return 0; +} + +static void efx_set_xdp_channels(struct efx_nic *efx) +{ + struct efx_tx_queue *tx_queue; + struct efx_channel *channel; + unsigned int next_queue =3D 0; + int xdp_queue_number =3D 0; + int rc; + + /* We need to mark which channels really have RX and TX + * queues, and adjust the TX queue numbers if we have separate + * RX-only and TX-only channels. + */ + efx_for_each_channel(channel, efx) { + if (channel->channel < efx->tx_channel_offset) + continue; + + if (efx_channel_is_xdp_tx(channel)) { + efx_for_each_channel_tx_queue(tx_queue, channel) { + tx_queue->queue =3D next_queue++; + rc =3D efx_set_xdp_tx_queue(efx, xdp_queue_number, + tx_queue); + if (rc =3D=3D 0) + xdp_queue_number++; + } + } else { + efx_for_each_channel_tx_queue(tx_queue, channel) { + tx_queue->queue =3D next_queue++; + netif_dbg(efx, drv, efx->net_dev, + "Channel %u TXQ %u is HW %u\n", + channel->channel, tx_queue->label, + tx_queue->queue); + } + + /* If XDP is borrowing queues from net stack, it must + * use the queue with no csum offload, which is the + * first one of the channel + * (note: tx_queue_by_type is not initialized yet) + */ + if (efx->xdp_txq_queues_mode =3D=3D + EFX_XDP_TX_QUEUES_BORROWED) { + tx_queue =3D &channel->tx_queue[0]; + rc =3D efx_set_xdp_tx_queue(efx, xdp_queue_number, + tx_queue); + if (rc =3D=3D 0) + xdp_queue_number++; + } + } + } + WARN_ON(efx->xdp_txq_queues_mode =3D=3D EFX_XDP_TX_QUEUES_DEDICATED && + xdp_queue_number !=3D efx->xdp_tx_queue_count); + WARN_ON(efx->xdp_txq_queues_mode !=3D EFX_XDP_TX_QUEUES_DEDICATED && + xdp_queue_number > efx->xdp_tx_queue_count); + + /* If we have more CPUs than assigned XDP TX queues, assign the already + * existing queues to the exceeding CPUs + */ + next_queue =3D 0; + while (xdp_queue_number < efx->xdp_tx_queue_count) { + tx_queue =3D efx->xdp_tx_queues[next_queue++]; + rc =3D efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue); + if (rc =3D=3D 0) + xdp_queue_number++; + } +} + int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_ent= ries) { struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; @@ -835,6 +914,7 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_e= ntries, u32 txq_entries) efx_init_napi_channel(efx->channel[i]); } =20 + efx_set_xdp_channels(efx); out: /* Destroy unused channel structures */ for (i =3D 0; i < efx->n_channels; i++) { @@ -867,26 +947,9 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_= entries, u32 txq_entries) goto out; } =20 -static inline int -efx_set_xdp_tx_queue(struct efx_nic *efx, int xdp_queue_number, - struct efx_tx_queue *tx_queue) -{ - if (xdp_queue_number >=3D efx->xdp_tx_queue_count) - return -EINVAL; - - netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n", - tx_queue->channel->channel, tx_queue->label, - xdp_queue_number, tx_queue->queue); - efx->xdp_tx_queues[xdp_queue_number] =3D tx_queue; - return 0; -} - int efx_set_channels(struct efx_nic *efx) { - struct efx_tx_queue *tx_queue; struct efx_channel *channel; - unsigned int next_queue =3D 0; - int xdp_queue_number; int rc; =20 efx->tx_channel_offset =3D @@ -904,61 +967,14 @@ int efx_set_channels(struct efx_nic *efx) return -ENOMEM; } =20 - /* We need to mark which channels really have RX and TX - * queues, and adjust the TX queue numbers if we have separate - * RX-only and TX-only channels. - */ - xdp_queue_number =3D 0; efx_for_each_channel(channel, efx) { if (channel->channel < efx->n_rx_channels) channel->rx_queue.core_index =3D channel->channel; else channel->rx_queue.core_index =3D -1; - - if (channel->channel >=3D efx->tx_channel_offset) { - if (efx_channel_is_xdp_tx(channel)) { - efx_for_each_channel_tx_queue(tx_queue, channel) { - tx_queue->queue =3D next_queue++; - rc =3D efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue); - if (rc =3D=3D 0) - xdp_queue_number++; - } - } else { - efx_for_each_channel_tx_queue(tx_queue, channel) { - tx_queue->queue =3D next_queue++; - netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is HW %u\n", - channel->channel, tx_queue->label, - tx_queue->queue); - } - - /* If XDP is borrowing queues from net stack, it must use the queue - * with no csum offload, which is the first one of the channel - * (note: channel->tx_queue_by_type is not initialized yet) - */ - if (efx->xdp_txq_queues_mode =3D=3D EFX_XDP_TX_QUEUES_BORROWED) { - tx_queue =3D &channel->tx_queue[0]; - rc =3D efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue); - if (rc =3D=3D 0) - xdp_queue_number++; - } - } - } } - WARN_ON(efx->xdp_txq_queues_mode =3D=3D EFX_XDP_TX_QUEUES_DEDICATED && - xdp_queue_number !=3D efx->xdp_tx_queue_count); - WARN_ON(efx->xdp_txq_queues_mode !=3D EFX_XDP_TX_QUEUES_DEDICATED && - xdp_queue_number > efx->xdp_tx_queue_count); =20 - /* If we have more CPUs than assigned XDP TX queues, assign the already - * existing queues to the exceeding CPUs - */ - next_queue =3D 0; - while (xdp_queue_number < efx->xdp_tx_queue_count) { - tx_queue =3D efx->xdp_tx_queues[next_queue++]; - rc =3D efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue); - if (rc =3D=3D 0) - xdp_queue_number++; - } + efx_set_xdp_channels(efx); =20 rc =3D netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels); if (rc) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9B7D7C47088 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388750AbiDLJWp (ORCPT ); Tue, 12 Apr 2022 05:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357666AbiDLHkg (ORCPT ); Tue, 12 Apr 2022 03:40: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 78B163298C; Tue, 12 Apr 2022 00:16: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 dfw.source.kernel.org (Postfix) with ESMTPS id 1740361045; Tue, 12 Apr 2022 07:16:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29486C385A1; Tue, 12 Apr 2022 07:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747783; bh=/hvW6BrL+dD+5tDeRCEM3J4yR7J9VZvX5DWRVZsQhc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSXCX+2l2w3Sz0TkUPjtwGcIr22T+/e0puZGG3uNCzS4Q6lYt3f1DUHbzrcXuqBDA yTbylQvwdtpD41hFH4HIg2o83SvtvMqqJqG3dyq69sRlu3kRZqVjgTLTL0R/jCJT/J vrNNOVBTG2iwxbFL/AG4asKrfASA9TRAZkKhkg5k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ziyang Xuan , Jakub Kicinski , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 205/343] net/tls: fix slab-out-of-bounds bug in decrypt_internal Date: Tue, 12 Apr 2022 08:30:23 +0200 Message-Id: <20220412062957.268239136@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ziyang Xuan [ Upstream commit 9381fe8c849cfbe50245ac01fc077554f6eaa0e2 ] The memory size of tls_ctx->rx.iv for AES128-CCM is 12 setting in tls_set_sw_offload(). The return value of crypto_aead_ivsize() for "ccm(aes)" is 16. So memcpy() require 16 bytes from 12 bytes memory space will trigger slab-out-of-bounds bug as following: =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 BUG: KASAN: slab-out-of-bounds in decrypt_internal+0x385/0xc40 [tls] Read of size 16 at addr ffff888114e84e60 by task tls/10911 Call Trace: dump_stack_lvl+0x34/0x44 print_report.cold+0x5e/0x5db ? decrypt_internal+0x385/0xc40 [tls] kasan_report+0xab/0x120 ? decrypt_internal+0x385/0xc40 [tls] kasan_check_range+0xf9/0x1e0 memcpy+0x20/0x60 decrypt_internal+0x385/0xc40 [tls] ? tls_get_rec+0x2e0/0x2e0 [tls] ? process_rx_list+0x1a5/0x420 [tls] ? tls_setup_from_iter.constprop.0+0x2e0/0x2e0 [tls] decrypt_skb_update+0x9d/0x400 [tls] tls_sw_recvmsg+0x3c8/0xb50 [tls] Allocated by task 10911: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0x81/0xa0 tls_set_sw_offload+0x2eb/0xa20 [tls] tls_setsockopt+0x68c/0x700 [tls] __sys_setsockopt+0xfe/0x1b0 Replace the crypto_aead_ivsize() with prot->iv_size + prot->salt_size when memcpy() iv value in TLS_1_3_VERSION scenario. Fixes: f295b3ae9f59 ("net/tls: Add support of AES128-CCM based ciphers") Signed-off-by: Ziyang Xuan Reviewed-by: Jakub Kicinski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index efc84845bb6b..75a699591383 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1495,7 +1495,7 @@ static int decrypt_internal(struct sock *sk, struct s= k_buff *skb, if (prot->version =3D=3D TLS_1_3_VERSION || prot->cipher_type =3D=3D TLS_CIPHER_CHACHA20_POLY1305) memcpy(iv + iv_offset, tls_ctx->rx.iv, - crypto_aead_ivsize(ctx->aead_recv)); + prot->iv_size + prot->salt_size); else memcpy(iv + iv_offset, tls_ctx->rx.iv, prot->salt_size); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 84210C388F3 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388701AbiDLJWm (ORCPT ); Tue, 12 Apr 2022 05:22:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357672AbiDLHkh (ORCPT ); Tue, 12 Apr 2022 03:40:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 097A7FEA; Tue, 12 Apr 2022 00:16: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 A3D47B81A8F; Tue, 12 Apr 2022 07:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06F99C385A5; Tue, 12 Apr 2022 07:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747786; bh=7n1CUTwVxEhRYCfm68ufa+KXWYtqErl01OICdME7qFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O+vou0Wf3pqvGoELB6cdmWFqqpCShFUh0gkU9Xhc2sO7YqpifOFHcYZt1wgnnbyz6 6pjUimfGZnbmSWxmaGvFvRQ51ISmoIgy5Pvdr2bxs1FUm0+VGxw+7nVCHMXc9S3fei 4lw74+8YW1XZxX0FGjA6Twmi5laQ7sTTWq3bvLwo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eyal Birger , David Ahern , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 206/343] vrf: fix packet sniffing for traffic originating from ip tunnels Date: Tue, 12 Apr 2022 08:30:24 +0200 Message-Id: <20220412062957.296361838@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Eyal Birger [ Upstream commit 012d69fbfcc739f846766c1da56ef8b493b803b5 ] in commit 048939088220 ("vrf: add mac header for tunneled packets when sniffer is attached") an Ethernet header was cooked for traffic originating from tunnel devices. However, the header is added based on whether the mac_header is unset and ignores cases where the device doesn't expose a mac header to upper layers, such as in ip tunnels like ipip and gre. Traffic originating from such devices still appears garbled when capturing on the vrf device. Fix by observing whether the original device exposes a header to upper layers, similar to the logic done in af_packet. In addition, skb->mac_len needs to be adjusted after adding the Ethernet header for the skb_push/pull() surrounding dev_queue_xmit_nit() to work on these packets. Fixes: 048939088220 ("vrf: add mac header for tunneled packets when sniffer= is attached") Signed-off-by: Eyal Birger Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/vrf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index e0b1ab99a359..f37adcef4bef 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -1266,6 +1266,7 @@ static int vrf_prepare_mac_header(struct sk_buff *skb, eth =3D (struct ethhdr *)skb->data; =20 skb_reset_mac_header(skb); + skb_reset_mac_len(skb); =20 /* we set the ethernet destination and the source addresses to the * address of the VRF device. @@ -1295,9 +1296,9 @@ static int vrf_prepare_mac_header(struct sk_buff *skb, */ static int vrf_add_mac_header_if_unset(struct sk_buff *skb, struct net_device *vrf_dev, - u16 proto) + u16 proto, struct net_device *orig_dev) { - if (skb_mac_header_was_set(skb)) + if (skb_mac_header_was_set(skb) && dev_has_header(orig_dev)) return 0; =20 return vrf_prepare_mac_header(skb, vrf_dev, proto); @@ -1403,6 +1404,8 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device = *vrf_dev, =20 /* if packet is NDISC then keep the ingress interface */ if (!is_ndisc) { + struct net_device *orig_dev =3D skb->dev; + vrf_rx_stats(vrf_dev, skb->len); skb->dev =3D vrf_dev; skb->skb_iif =3D vrf_dev->ifindex; @@ -1411,7 +1414,8 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device = *vrf_dev, int err; =20 err =3D vrf_add_mac_header_if_unset(skb, vrf_dev, - ETH_P_IPV6); + ETH_P_IPV6, + orig_dev); if (likely(!err)) { skb_push(skb, skb->mac_len); dev_queue_xmit_nit(skb, vrf_dev); @@ -1441,6 +1445,8 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device = *vrf_dev, static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev, struct sk_buff *skb) { + struct net_device *orig_dev =3D skb->dev; + skb->dev =3D vrf_dev; skb->skb_iif =3D vrf_dev->ifindex; IPCB(skb)->flags |=3D IPSKB_L3SLAVE; @@ -1461,7 +1467,8 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *= vrf_dev, if (!list_empty(&vrf_dev->ptype_all)) { int err; =20 - err =3D vrf_add_mac_header_if_unset(skb, vrf_dev, ETH_P_IP); + err =3D vrf_add_mac_header_if_unset(skb, vrf_dev, ETH_P_IP, + orig_dev); if (likely(!err)) { skb_push(skb, skb->mac_len); dev_queue_xmit_nit(skb, vrf_dev); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 E186DC35294 for ; Tue, 12 Apr 2022 09:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343829AbiDLJR3 (ORCPT ); Tue, 12 Apr 2022 05:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357674AbiDLHkh (ORCPT ); Tue, 12 Apr 2022 03:40:37 -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 B186C377F7; Tue, 12 Apr 2022 00:16: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 5C4E4B81B60; Tue, 12 Apr 2022 07:16:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4DF7C385A5; Tue, 12 Apr 2022 07:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747789; bh=S3iPb50ZkG9ZYTuIpZz9Lju61ChJj1zOrSTTXOulzhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FkwGwBlc3p4geMtZ10zyomHEati4ek/+/NPXkEVAtttWq6uKbicFM22XGB2nFE5OI W17KRRoqIbufVIW99VLktEh0fwUK+Zj/DUyNI3L7u67wAliB5QQRxhIl6oayIPMAkb Eob+AoipuUOVw3W5NM5ScSNtI7Cx4nD4y1EH6dF0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Duyck , Jean-Philippe Brucker , Yunsheng Lin , Ilias Apalodimas , Jesper Dangaard Brouer , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 207/343] skbuff: fix coalescing for page_pool fragment recycling Date: Tue, 12 Apr 2022 08:30:25 +0200 Message-Id: <20220412062957.324693567@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jean-Philippe Brucker [ Upstream commit 1effe8ca4e34c34cdd9318436a4232dcb582ebf4 ] Fix a use-after-free when using page_pool with page fragments. We encountered this problem during normal RX in the hns3 driver: (1) Initially we have three descriptors in the RX queue. The first one allocates PAGE1 through page_pool, and the other two allocate one half of PAGE2 each. Page references look like this: RX_BD1 _______ PAGE1 RX_BD2 _______ PAGE2 RX_BD3 _________/ (2) Handle RX on the first descriptor. Allocate SKB1, eventually added to the receive queue by tcp_queue_rcv(). (3) Handle RX on the second descriptor. Allocate SKB2 and pass it to netif_receive_skb(): netif_receive_skb(SKB2) ip_rcv(SKB2) SKB3 =3D skb_clone(SKB2) SKB2 and SKB3 share a reference to PAGE2 through skb_shinfo()->dataref. The other ref to PAGE2 is still held by RX_BD3: SKB2 ---+- PAGE2 SKB3 __/ / RX_BD3 _________/ (3b) Now while handling TCP, coalesce SKB3 with SKB1: tcp_v4_rcv(SKB3) tcp_try_coalesce(to=3DSKB1, from=3DSKB3) // succeeds kfree_skb_partial(SKB3) skb_release_data(SKB3) // drops one dataref SKB1 _____ PAGE1 \____ SKB2 _____ PAGE2 / RX_BD3 _________/ In skb_try_coalesce(), __skb_frag_ref() takes a page reference to PAGE2, where it should instead have increased the page_pool frag reference, pp_frag_count. Without coalescing, when releasing both SKB2 and SKB3, a single reference to PAGE2 would be dropped. Now when releasing SKB1 and SKB2, two references to PAGE2 will be dropped, resulting in underflow. (3c) Drop SKB2: af_packet_rcv(SKB2) consume_skb(SKB2) skb_release_data(SKB2) // drops second dataref page_pool_return_skb_page(PAGE2) // drops one pp_frag_count SKB1 _____ PAGE1 \____ PAGE2 / RX_BD3 _________/ (4) Userspace calls recvmsg() Copies SKB1 and releases it. Since SKB3 was coalesced with SKB1, we release the SKB3 page as well: tcp_eat_recv_skb(SKB1) skb_release_data(SKB1) page_pool_return_skb_page(PAGE1) page_pool_return_skb_page(PAGE2) // drops second pp_frag_cou= nt (5) PAGE2 is freed, but the third RX descriptor was still using it! In our case this causes IOMMU faults, but it would silently corrupt memory if the IOMMU was disabled. Change the logic that checks whether pp_recycle SKBs can be coalesced. We still reject differing pp_recycle between 'from' and 'to' SKBs, but in order to avoid the situation described above, we also reject coalescing when both 'from' and 'to' are pp_recycled and 'from' is cloned. The new logic allows coalescing a cloned pp_recycle SKB into a page refcounted one, because in this case the release (4) will drop the right reference, the one taken by skb_try_coalesce(). Fixes: 53e0961da1c7 ("page_pool: add frag page recycling support in page po= ol") Suggested-by: Alexander Duyck Signed-off-by: Jean-Philippe Brucker Reviewed-by: Yunsheng Lin Reviewed-by: Alexander Duyck Acked-by: Ilias Apalodimas Acked-by: Jesper Dangaard Brouer Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/core/skbuff.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index a8a2fb745274..180fa6a26ad4 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5275,11 +5275,18 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk= _buff *from, if (skb_cloned(to)) return false; =20 - /* The page pool signature of struct page will eventually figure out - * which pages can be recycled or not but for now let's prohibit slab - * allocated and page_pool allocated SKBs from being coalesced. + /* In general, avoid mixing slab allocated and page_pool allocated + * pages within the same SKB. However when @to is not pp_recycle and + * @from is cloned, we can transition frag pages from page_pool to + * reference counted. + * + * On the other hand, don't allow coalescing two pp_recycle SKBs if + * @from is cloned, in case the SKB is using page_pool fragment + * references (PP_FLAG_PAGE_FRAG). Since we only take full page + * references for cloned SKBs at the moment that would result in + * inconsistent reference counts. */ - if (to->pp_recycle !=3D from->pp_recycle) + if (to->pp_recycle !=3D (from->pp_recycle && !skb_cloned(from))) return false; =20 if (len <=3D skb_tailroom(to)) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A9E52C41535 for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376463AbiDLItd (ORCPT ); Tue, 12 Apr 2022 04:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357675AbiDLHkh (ORCPT ); Tue, 12 Apr 2022 03:40:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 661D237A19; Tue, 12 Apr 2022 00:16: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 0AF94B81B4F; Tue, 12 Apr 2022 07:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71421C385A5; Tue, 12 Apr 2022 07:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747791; bh=VZVvP87MYgzbE+UjduvwsVvKXx0jKM82k2v4eWM5gAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w8uVWziAO6Thcmz0Thlu8gWgjxnfL0SoEyztoOYoBfn+MlEa61DmEEjpQ3S8uDtOv yekPOexG0IWYloGpZo9Lalrdv+OaAewpOOZt7p63Skel7sn+NPjIRK27dBjnhtoTtk 7GBzpnoo8p3ShY6P+I2PSkJQz39bBYUA0zuvRJ4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Angelo Daros de Luca , Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 208/343] Revert "net: dsa: stop updating master MTU from master.c" Date: Tue, 12 Apr 2022 08:30:26 +0200 Message-Id: <20220412062957.353260366@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 066dfc4290406b1b0b014ae3267d4266a344efd1 ] This reverts commit a1ff94c2973c43bc1e2677ac63ebb15b1d1ff846. Switch drivers that don't implement ->port_change_mtu() will cause the DSA master to remain with an MTU of 1500, since we've deleted the other code path. In turn, this causes a regression for those systems, where MTU-sized traffic can no longer be terminated. Revert the change taking into account the fact that rtnl_lock() is now taken top-level from the callers of dsa_master_setup() and dsa_master_teardown(). Also add a comment in order for it to be absolutely clear why it is still needed. Fixes: a1ff94c2973c ("net: dsa: stop updating master MTU from master.c") Reported-by: Luiz Angelo Daros de Luca Signed-off-by: Vladimir Oltean Tested-by: Luiz Angelo Daros de Luca Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/dsa/master.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/net/dsa/master.c b/net/dsa/master.c index 880f910b23a9..10b51ffbb6f4 100644 --- a/net/dsa/master.c +++ b/net/dsa/master.c @@ -337,11 +337,24 @@ static const struct attribute_group dsa_group =3D { =20 static struct lock_class_key dsa_master_addr_list_lock_key; =20 +static void dsa_master_reset_mtu(struct net_device *dev) +{ + int err; + + err =3D dev_set_mtu(dev, ETH_DATA_LEN); + if (err) + netdev_dbg(dev, + "Unable to reset MTU to exclude DSA overheads\n"); +} + int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) { + const struct dsa_device_ops *tag_ops =3D cpu_dp->tag_ops; struct dsa_switch *ds =3D cpu_dp->ds; struct device_link *consumer_link; - int ret; + int mtu, ret; + + mtu =3D ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops); =20 /* The DSA master must use SET_NETDEV_DEV for this to work. */ consumer_link =3D device_link_add(ds->dev, dev->dev.parent, @@ -351,6 +364,15 @@ int dsa_master_setup(struct net_device *dev, struct ds= a_port *cpu_dp) "Failed to create a device link to DSA switch %s\n", dev_name(ds->dev)); =20 + /* The switch driver may not implement ->port_change_mtu(), case in + * which dsa_slave_change_mtu() will not update the master MTU either, + * so we need to do that here. + */ + ret =3D dev_set_mtu(dev, mtu); + if (ret) + netdev_warn(dev, "error %d setting MTU to %d to include DSA overhead\n", + ret, mtu); + /* If we use a tagging format that doesn't have an ethertype * field, make sure that all packets from this point on get * sent to the tag format's receive function. @@ -388,6 +410,7 @@ void dsa_master_teardown(struct net_device *dev) sysfs_remove_group(&dev->dev.kobj, &dsa_group); dsa_netdev_ops_set(dev, NULL); dsa_master_ethtool_teardown(dev); + dsa_master_reset_mtu(dev); dsa_master_set_promiscuity(dev, -1); =20 dev->dsa_ptr =3D NULL; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 8FCF1C4167D for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376411AbiDLItZ (ORCPT ); Tue, 12 Apr 2022 04:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357678AbiDLHkh (ORCPT ); Tue, 12 Apr 2022 03:40:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36E8637A3F; Tue, 12 Apr 2022 00:16: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 E8454B81B62; Tue, 12 Apr 2022 07:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F77BC385A5; Tue, 12 Apr 2022 07:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747794; bh=6Gj3u1l9n/DaLADElMNFEcYCcb3QHToLKpQJMhKKuwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s6iKZB91Ve+saFj6wHXOAGDOR9BrYCj5n48jgNUeATEF41xiq1gops8FDxiJYrSTM nfkZaY0Fx/6EYtTXcPCKThT1LIsBtxOil9d5G9zjdqwD7Cj1KGvZEv/y8/a//hHHW2 RyVfug/WrCNN+fvU+FAAoaep9o9+PYde2aMOW14Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Vecera , Michal Swiatkowski , Maciej Fijalkowski , Alice Michael , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 209/343] ice: Clear default forwarding VSI during VSI release Date: Tue, 12 Apr 2022 08:30:27 +0200 Message-Id: <20220412062957.381340949@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ivan Vecera [ Upstream commit bd8c624c0cd59de0032752ba3001c107bba97f7b ] VSI is set as default forwarding one when promisc mode is set for PF interface, when PF is switched to switchdev mode or when VF driver asks to enable allmulticast or promisc mode for the VF interface (when vf-true-promisc-support priv flag is off). The third case is buggy because in that case VSI associated with VF remains as default one after VF removal. Reproducer: 1. Create VF echo 1 > sys/class/net/ens7f0/device/sriov_numvfs 2. Enable allmulticast or promisc mode on VF ip link set ens7f0v0 allmulticast on ip link set ens7f0v0 promisc on 3. Delete VF echo 0 > sys/class/net/ens7f0/device/sriov_numvfs 4. Try to enable promisc mode on PF ip link set ens7f0 promisc on Although it looks that promisc mode on PF is enabled the opposite is true because ice_vsi_sync_fltr() responsible for IFF_PROMISC handling first checks if any other VSI is set as default forwarding one and if so the function does not do anything. At this point it is not possible to enable promisc mode on PF without re-probe device. To resolve the issue this patch clear default forwarding VSI during ice_vsi_release() when the VSI to be released is the default one. Fixes: 01b5e89aab49 ("ice: Add VF promiscuous support") Signed-off-by: Ivan Vecera Reviewed-by: Michal Swiatkowski Reviewed-by: Maciej Fijalkowski Signed-off-by: Alice Michael Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/etherne= t/intel/ice/ice_lib.c index 53256aca27c7..20d755822d43 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -3147,6 +3147,8 @@ int ice_vsi_release(struct ice_vsi *vsi) } } =20 + if (ice_is_vsi_dflt_vsi(pf->first_sw, vsi)) + ice_clear_dflt_vsi(pf->first_sw); ice_fltr_remove_all(vsi); ice_rm_vsi_lan_cfg(vsi->port_info, vsi->idx); err =3D ice_rm_vsi_rdma_cfg(vsi->port_info, vsi->idx); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 94DF8C433EF for ; Tue, 12 Apr 2022 09:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241197AbiDLJRE (ORCPT ); Tue, 12 Apr 2022 05:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357680AbiDLHkh (ORCPT ); Tue, 12 Apr 2022 03:40:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EA2A37A86; Tue, 12 Apr 2022 00:16: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 E57D061045; Tue, 12 Apr 2022 07:16:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09C82C385A1; Tue, 12 Apr 2022 07:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747797; bh=9jNENUbCs6cw5+MzCQnWH+zyHEXcOMOtfAZicP9f8m4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zbg1pcBcKPWuHbdWWpa84TY5oSoq0F6DCk3AXeHAXkie11uCa92DkYlAeslU+RiSP AotNtaf8KRt13v8Cgx6Tps6Lo3I+41YuIInwJjraLWMXdjXTHUFavYyS9jhjq0if8c 5DC67Q9Jw0M1mf1EAUWqjmbgU29H0sVkIwq0NyYg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Vecera , Jacob Keller , Alexander Lobakin , Alice Michael , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 210/343] ice: Fix MAC address setting Date: Tue, 12 Apr 2022 08:30:28 +0200 Message-Id: <20220412062957.409137034@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ivan Vecera [ Upstream commit 2c0069f3f91f125b1b2ce66cc6bea8eb134723c3 ] Commit 2ccc1c1ccc671b ("ice: Remove excess error variables") merged the usage of 'status' and 'err' variables into single one in function ice_set_mac_address(). Unfortunately this causes a regression when call of ice_fltr_add_mac() returns -EEXIST because this return value does not indicate an error in this case but value of 'err' remains to be -EEXIST till the end of the function and is returned to caller. Prior mentioned commit this does not happen because return value of ice_fltr_add_mac() was stored to 'status' variable first and if it was -EEXIST then 'err' remains to be zero. Fix the problem by reset 'err' to zero when ice_fltr_add_mac() returns -EEXIST. Fixes: 2ccc1c1ccc671b ("ice: Remove excess error variables") Signed-off-by: Ivan Vecera Reviewed-by: Jacob Keller Acked-by: Alexander Lobakin Signed-off-by: Alice Michael Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethern= et/intel/ice/ice_main.c index 296f9d5f7408..92e0fe9316b9 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -5432,16 +5432,19 @@ static int ice_set_mac_address(struct net_device *n= etdev, void *pi) =20 /* Add filter for new MAC. If filter exists, return success */ err =3D ice_fltr_add_mac(vsi, mac, ICE_FWD_TO_VSI); - if (err =3D=3D -EEXIST) + if (err =3D=3D -EEXIST) { /* Although this MAC filter is already present in hardware it's * possible in some cases (e.g. bonding) that dev_addr was * modified outside of the driver and needs to be restored back * to this value. */ netdev_dbg(netdev, "filter for MAC %pM already exists\n", mac); - else if (err) + + return 0; + } else if (err) { /* error if the new filter addition failed */ err =3D -EADDRNOTAVAIL; + } =20 err_update_filters: if (err) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 C77EDC433EF for ; Tue, 12 Apr 2022 09:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353113AbiDLJSC (ORCPT ); Tue, 12 Apr 2022 05:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357683AbiDLHki (ORCPT ); Tue, 12 Apr 2022 03:40: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 3EC5837A2B; Tue, 12 Apr 2022 00:16: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 B792F6171C; Tue, 12 Apr 2022 07:16:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C45C1C385A5; Tue, 12 Apr 2022 07:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747800; bh=5FCLa8SESKUYBJ4ATRRqzp9RiCWwoTSFcXkravvhKjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zw4olPOLZrsVCcfDOlxexaW/zcADpB3nuXEOOfceycSPi1Ds7tT/XGTDEFSVuigZo MjdVoRAYzanLCV5HHDTaV0WeTRS4afSro7MS75c2pd6Ic6vjBqmHwJlzDHNSb101R3 L8OCXe1XCYgWi9DEhWy3GDU15EhYMq1DeiiymQ2s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matt Johnston , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 211/343] mctp: Fix check for dev_hard_header() result Date: Tue, 12 Apr 2022 08:30:29 +0200 Message-Id: <20220412062957.437294374@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Matt Johnston [ Upstream commit 60be976ac45137657b7b505d7e0d44d0e51accb7 ] dev_hard_header() returns the length of the header, so we need to test for negative errors rather than non-zero. Fixes: 889b7da23abf ("mctp: Add initial routing framework") Signed-off-by: Matt Johnston Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/mctp/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mctp/route.c b/net/mctp/route.c index 05fbd318eb98..d47438f5233d 100644 --- a/net/mctp/route.c +++ b/net/mctp/route.c @@ -507,7 +507,7 @@ static int mctp_route_output(struct mctp_route *route, = struct sk_buff *skb) =20 rc =3D dev_hard_header(skb, skb->dev, ntohs(skb->protocol), daddr, skb->dev->dev_addr, skb->len); - if (rc) { + if (rc < 0) { kfree_skb(skb); return -EHOSTUNREACH; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 815A7C433F5 for ; Tue, 12 Apr 2022 09:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345318AbiDLJQe (ORCPT ); Tue, 12 Apr 2022 05:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357712AbiDLHkl (ORCPT ); Tue, 12 Apr 2022 03:40:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CE4387AA; Tue, 12 Apr 2022 00:16: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 C2815B81B4F; Tue, 12 Apr 2022 07:16:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17FFFC385A5; Tue, 12 Apr 2022 07:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747805; bh=b6+Qsoq0oHDFLGd4vDHTBx5eQpFygbzQY1mLHRzieZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LonVzBb2Qyfq314csBFHoUpxWxEqq0fjPYardfsLF5KKnU63Yq71X4IpHMNGgqcwO RtxIZYMsukJniMii/Wpr7LoMBJ6GEQj4rqdvZTUy3NdktkZRiNhjWnV+DdxPeqbVEF wFDz/FR/93dGpFkS0tVhr3dhUl7pz5AXlPOEOcSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Rinaldi , Matt Johnston , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 212/343] mctp: Use output netdev to allocate skb headroom Date: Tue, 12 Apr 2022 08:30:30 +0200 Message-Id: <20220412062957.465760024@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Matt Johnston [ Upstream commit 4a9dda1c1da65beee994f0977a56a9a21c5db2a7 ] Previously the skb was allocated with headroom MCTP_HEADER_MAXLEN, but that isn't sufficient if we are using devs that are not MCTP specific. This also adds a check that the smctp_halen provided to sendmsg for extended addressing is the correct size for the netdev. Fixes: 833ef3b91de6 ("mctp: Populate socket implementation") Reported-by: Matthew Rinaldi Signed-off-by: Matt Johnston Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/net/mctp.h | 2 -- net/mctp/af_mctp.c | 46 +++++++++++++++++++++++++++++++++------------- net/mctp/route.c | 14 +++++++++++--- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/include/net/mctp.h b/include/net/mctp.h index 7e35ec79b909..204ae3aebc0d 100644 --- a/include/net/mctp.h +++ b/include/net/mctp.h @@ -36,8 +36,6 @@ struct mctp_hdr { #define MCTP_HDR_TAG_SHIFT 0 #define MCTP_HDR_TAG_MASK GENMASK(2, 0) =20 -#define MCTP_HEADER_MAXLEN 4 - #define MCTP_INITIAL_DEFAULT_NET 1 =20 static inline bool mctp_address_ok(mctp_eid_t eid) diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c index c921de63b494..fc05351d3a82 100644 --- a/net/mctp/af_mctp.c +++ b/net/mctp/af_mctp.c @@ -90,13 +90,13 @@ static int mctp_bind(struct socket *sock, struct sockad= dr *addr, int addrlen) static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t le= n) { DECLARE_SOCKADDR(struct sockaddr_mctp *, addr, msg->msg_name); - const int hlen =3D MCTP_HEADER_MAXLEN + sizeof(struct mctp_hdr); int rc, addrlen =3D msg->msg_namelen; struct sock *sk =3D sock->sk; struct mctp_sock *msk =3D container_of(sk, struct mctp_sock, sk); struct mctp_skb_cb *cb; struct mctp_route *rt; - struct sk_buff *skb; + struct sk_buff *skb =3D NULL; + int hlen; =20 if (addr) { if (addrlen < sizeof(struct sockaddr_mctp)) @@ -119,6 +119,34 @@ static int mctp_sendmsg(struct socket *sock, struct ms= ghdr *msg, size_t len) if (addr->smctp_network =3D=3D MCTP_NET_ANY) addr->smctp_network =3D mctp_default_net(sock_net(sk)); =20 + /* direct addressing */ + if (msk->addr_ext && addrlen >=3D sizeof(struct sockaddr_mctp_ext)) { + DECLARE_SOCKADDR(struct sockaddr_mctp_ext *, + extaddr, msg->msg_name); + struct net_device *dev; + + rc =3D -EINVAL; + rcu_read_lock(); + dev =3D dev_get_by_index_rcu(sock_net(sk), extaddr->smctp_ifindex); + /* check for correct halen */ + if (dev && extaddr->smctp_halen =3D=3D dev->addr_len) { + hlen =3D LL_RESERVED_SPACE(dev) + sizeof(struct mctp_hdr); + rc =3D 0; + } + rcu_read_unlock(); + if (rc) + goto err_free; + rt =3D NULL; + } else { + rt =3D mctp_route_lookup(sock_net(sk), addr->smctp_network, + addr->smctp_addr.s_addr); + if (!rt) { + rc =3D -EHOSTUNREACH; + goto err_free; + } + hlen =3D LL_RESERVED_SPACE(rt->dev->dev) + sizeof(struct mctp_hdr); + } + skb =3D sock_alloc_send_skb(sk, hlen + 1 + len, msg->msg_flags & MSG_DONTWAIT, &rc); if (!skb) @@ -137,8 +165,8 @@ static int mctp_sendmsg(struct socket *sock, struct msg= hdr *msg, size_t len) cb =3D __mctp_cb(skb); cb->net =3D addr->smctp_network; =20 - /* direct addressing */ - if (msk->addr_ext && addrlen >=3D sizeof(struct sockaddr_mctp_ext)) { + if (!rt) { + /* fill extended address in cb */ DECLARE_SOCKADDR(struct sockaddr_mctp_ext *, extaddr, msg->msg_name); =20 @@ -149,17 +177,9 @@ static int mctp_sendmsg(struct socket *sock, struct ms= ghdr *msg, size_t len) } =20 cb->ifindex =3D extaddr->smctp_ifindex; + /* smctp_halen is checked above */ cb->halen =3D extaddr->smctp_halen; memcpy(cb->haddr, extaddr->smctp_haddr, cb->halen); - - rt =3D NULL; - } else { - rt =3D mctp_route_lookup(sock_net(sk), addr->smctp_network, - addr->smctp_addr.s_addr); - if (!rt) { - rc =3D -EHOSTUNREACH; - goto err_free; - } } =20 rc =3D mctp_local_output(sk, rt, skb, addr->smctp_addr.s_addr, diff --git a/net/mctp/route.c b/net/mctp/route.c index d47438f5233d..1a296e211a50 100644 --- a/net/mctp/route.c +++ b/net/mctp/route.c @@ -498,6 +498,11 @@ static int mctp_route_output(struct mctp_route *route,= struct sk_buff *skb) =20 if (cb->ifindex) { /* direct route; use the hwaddr we stashed in sendmsg */ + if (cb->halen !=3D skb->dev->addr_len) { + /* sanity check, sendmsg should have already caught this */ + kfree_skb(skb); + return -EMSGSIZE; + } daddr =3D cb->haddr; } else { /* If lookup fails let the device handle daddr=3D=3DNULL */ @@ -707,7 +712,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt= , struct sk_buff *skb, { const unsigned int hlen =3D sizeof(struct mctp_hdr); struct mctp_hdr *hdr, *hdr2; - unsigned int pos, size; + unsigned int pos, size, headroom; struct sk_buff *skb2; int rc; u8 seq; @@ -721,6 +726,9 @@ static int mctp_do_fragment_route(struct mctp_route *rt= , struct sk_buff *skb, return -EMSGSIZE; } =20 + /* keep same headroom as the original skb */ + headroom =3D skb_headroom(skb); + /* we've got the header */ skb_pull(skb, hlen); =20 @@ -728,7 +736,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt= , struct sk_buff *skb, /* size of message payload */ size =3D min(mtu - hlen, skb->len - pos); =20 - skb2 =3D alloc_skb(MCTP_HEADER_MAXLEN + hlen + size, GFP_KERNEL); + skb2 =3D alloc_skb(headroom + hlen + size, GFP_KERNEL); if (!skb2) { rc =3D -ENOMEM; break; @@ -744,7 +752,7 @@ static int mctp_do_fragment_route(struct mctp_route *rt= , struct sk_buff *skb, skb_set_owner_w(skb2, skb->sk); =20 /* establish packet */ - skb_reserve(skb2, MCTP_HEADER_MAXLEN); + skb_reserve(skb2, headroom); skb_reset_network_header(skb2); skb_put(skb2, hlen + size); skb2->transport_header =3D skb2->network_header + hlen; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 237D4C4332F for ; Tue, 12 Apr 2022 09:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344108AbiDLJQJ (ORCPT ); Tue, 12 Apr 2022 05:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357711AbiDLHkl (ORCPT ); Tue, 12 Apr 2022 03:40:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C346100D; Tue, 12 Apr 2022 00:16: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 dfw.source.kernel.org (Postfix) with ESMTPS id A9C2C6177D; Tue, 12 Apr 2022 07:16:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B46A0C385C9; Tue, 12 Apr 2022 07:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747808; bh=ZLMJdHnSaLyT4g9E/mE2ZthPDMArdA3F1vNPRl4nB28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gi951u7mkK5m/7KXrNEFz4JRgS6cHhu6FkYG96JmSndH0f3xvkQ7L3TeHgLSwhwlo VtECwN/mFg1udfi7CnZgmdPCqSDOK+7RbKgmq+pq0K/6J91/g7AZ1448otuYAQ1v44 t5FuCTj19PuEVnTsHzz6gdrhQiPh7POgVt7VbMpk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Aleksandrov , David Ahern , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 213/343] net: ipv4: fix route with nexthop object delete warning Date: Tue, 12 Apr 2022 08:30:31 +0200 Message-Id: <20220412062957.493585279@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Nikolay Aleksandrov [ Upstream commit 6bf92d70e690b7ff12b24f4bfff5e5434d019b82 ] FRR folks have hit a kernel warning[1] while deleting routes[2] which is caused by trying to delete a route pointing to a nexthop id without specifying nhid but matching on an interface. That is, a route is found but we hit a warning while matching it. The warning is from fib_info_nh() in include/net/nexthop.h because we run it on a fib_info with nexthop object. The call chain is: inet_rtm_delroute -> fib_table_delete -> fib_nh_match (called with a nexthop fib_info and also with fc_oif set thus calling fib_info_nh on the fib_info and triggering the warning). The fix is to not do any matching in that branch if the fi has a nexthop object because those are managed separately. I.e. we should match when deleting without nh spec and should fail when deleting a nexthop route with old-style nh spec because nexthop objects are managed separately, e.g.: $ ip r show 1.2.3.4/32 1.2.3.4 nhid 12 via 192.168.11.2 dev dummy0 $ ip r del 1.2.3.4/32 $ ip r del 1.2.3.4/32 nhid 12 $ ip r del 1.2.3.4/32 dev dummy0 [1] [ 523.462226] ------------[ cut here ]------------ [ 523.462230] WARNING: CPU: 14 PID: 22893 at include/net/nexthop.h:468 fi= b_nh_match+0x210/0x460 [ 523.462236] Modules linked in: dummy rpcsec_gss_krb5 xt_socket nf_socke= t_ipv4 nf_socket_ipv6 ip6table_raw iptable_raw bpf_preload xt_statistic ip_= set ip_vs_sh ip_vs_wrr ip_vs_rr ip_vs xt_mark nf_tables xt_nat veth nf_conn= track_netlink nfnetlink xt_addrtype br_netfilter overlay dm_crypt nfsv3 nfs= fscache netfs vhost_net vhost vhost_iotlb tap tun xt_CHECKSUM xt_MASQUERAD= E xt_conntrack 8021q garp mrp ipt_REJECT nf_reject_ipv4 ip6table_mangle ip6= table_nat iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_= defrag_ipv4 iptable_filter bridge stp llc rfcomm snd_seq_dummy snd_hrtimer = rpcrdma rdma_cm iw_cm ib_cm ib_core ip6table_filter xt_comment ip6_tables v= boxnetadp(OE) vboxnetflt(OE) vboxdrv(OE) qrtr bnep binfmt_misc xfs vfat fat= squashfs loop nvidia_drm(POE) nvidia_modeset(POE) nvidia_uvm(POE) nvidia(P= OE) intel_rapl_msr intel_rapl_common snd_hda_codec_realtek snd_hda_codec_ge= neric ledtrig_audio snd_hda_codec_hdmi btusb btrtl iwlmvm uvcvideo btbcm sn= d_hda_intel edac_mce_amd [ 523.462274] videobuf2_vmalloc videobuf2_memops btintel snd_intel_dspcf= g videobuf2_v4l2 snd_intel_sdw_acpi bluetooth snd_usb_audio snd_hda_codec m= ac80211 snd_usbmidi_lib joydev snd_hda_core videobuf2_common kvm_amd snd_ra= wmidi snd_hwdep snd_seq videodev ccp snd_seq_device libarc4 ecdh_generic mc= snd_pcm kvm iwlwifi snd_timer drm_kms_helper snd cfg80211 cec soundcore ir= qbypass rapl wmi_bmof i2c_piix4 rfkill k10temp pcspkr acpi_cpufreq nfsd aut= h_rpcgss nfs_acl lockd grace sunrpc drm zram ip_tables crct10dif_pclmul crc= 32_pclmul crc32c_intel ghash_clmulni_intel nvme sp5100_tco r8169 nvme_core = wmi ipmi_devintf ipmi_msghandler fuse [ 523.462300] CPU: 14 PID: 22893 Comm: ip Tainted: P OE 5.1= 6.18-200.fc35.x86_64 #1 [ 523.462302] Hardware name: Micro-Star International Co., Ltd. MS-7C37/M= PG X570 GAMING EDGE WIFI (MS-7C37), BIOS 1.C0 10/29/2020 [ 523.462303] RIP: 0010:fib_nh_match+0x210/0x460 [ 523.462304] Code: 7c 24 20 48 8b b5 90 00 00 00 e8 bb ee f4 ff 48 8b 7c= 24 20 41 89 c4 e8 ee eb f4 ff 45 85 e4 0f 85 2e fe ff ff e9 4c ff ff ff <0= f> 0b e9 17 ff ff ff 3c 0a 0f 85 61 fe ff ff 48 8b b5 98 00 00 00 [ 523.462306] RSP: 0018:ffffaa53d4d87928 EFLAGS: 00010286 [ 523.462307] RAX: 0000000000000000 RBX: ffffaa53d4d87a90 RCX: ffffaa53d4= d87bb0 [ 523.462308] RDX: ffff9e3d2ee6be80 RSI: ffffaa53d4d87a90 RDI: ffffffff92= 0ed380 [ 523.462309] RBP: ffff9e3d2ee6be80 R08: 0000000000000064 R09: 0000000000= 000000 [ 523.462310] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000= 000031 [ 523.462310] R13: 0000000000000020 R14: 0000000000000000 R15: ffff9e3d33= 1054e0 [ 523.462311] FS: 00007f245517c1c0(0000) GS:ffff9e492ed80000(0000) knlGS= :0000000000000000 [ 523.462313] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 523.462313] CR2: 000055e5dfdd8268 CR3: 00000003ef488000 CR4: 0000000000= 350ee0 [ 523.462315] Call Trace: [ 523.462316] [ 523.462320] fib_table_delete+0x1a9/0x310 [ 523.462323] inet_rtm_delroute+0x93/0x110 [ 523.462325] rtnetlink_rcv_msg+0x133/0x370 [ 523.462327] ? _copy_to_iter+0xb5/0x6f0 [ 523.462330] ? rtnl_calcit.isra.0+0x110/0x110 [ 523.462331] netlink_rcv_skb+0x50/0xf0 [ 523.462334] netlink_unicast+0x211/0x330 [ 523.462336] netlink_sendmsg+0x23f/0x480 [ 523.462338] sock_sendmsg+0x5e/0x60 [ 523.462340] ____sys_sendmsg+0x22c/0x270 [ 523.462341] ? import_iovec+0x17/0x20 [ 523.462343] ? sendmsg_copy_msghdr+0x59/0x90 [ 523.462344] ? __mod_lruvec_page_state+0x85/0x110 [ 523.462348] ___sys_sendmsg+0x81/0xc0 [ 523.462350] ? netlink_seq_start+0x70/0x70 [ 523.462352] ? __dentry_kill+0x13a/0x180 [ 523.462354] ? __fput+0xff/0x250 [ 523.462356] __sys_sendmsg+0x49/0x80 [ 523.462358] do_syscall_64+0x3b/0x90 [ 523.462361] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 523.462364] RIP: 0033:0x7f24552aa337 [ 523.462365] Code: 0e 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f= 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <4= 8> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10 [ 523.462366] RSP: 002b:00007fff7f05a838 EFLAGS: 00000246 ORIG_RAX: 00000= 0000000002e [ 523.462368] RAX: ffffffffffffffda RBX: 000000006245bf91 RCX: 00007f2455= 2aa337 [ 523.462368] RDX: 0000000000000000 RSI: 00007fff7f05a8a0 RDI: 0000000000= 000003 [ 523.462369] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000= 000000 [ 523.462370] R10: 0000000000000008 R11: 0000000000000246 R12: 0000000000= 000001 [ 523.462370] R13: 00007fff7f05ce08 R14: 0000000000000000 R15: 000055e5df= dd1040 [ 523.462373] [ 523.462374] ---[ end trace ba537bc16f6bf4ed ]--- [2] https://github.com/FRRouting/frr/issues/6412 Fixes: 4c7e8084fd46 ("ipv4: Plumb support for nexthop object in a fib_info") Signed-off-by: Nikolay Aleksandrov Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/ipv4/fib_semantics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 2dd375f7407b..0a0f49770345 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -888,8 +888,13 @@ int fib_nh_match(struct net *net, struct fib_config *c= fg, struct fib_info *fi, } =20 if (cfg->fc_oif || cfg->fc_gw_family) { - struct fib_nh *nh =3D fib_info_nh(fi, 0); + struct fib_nh *nh; + + /* cannot match on nexthop object attributes */ + if (fi->nh) + return 1; =20 + nh =3D fib_info_nh(fi, 0); if (cfg->fc_encap) { if (fib_encap_match(net, cfg->fc_encap_type, cfg->fc_encap, nh, cfg, extack)) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 0DBAEC433FE for ; Tue, 12 Apr 2022 09:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349275AbiDLJPr (ORCPT ); Tue, 12 Apr 2022 05:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357757AbiDLHkm (ORCPT ); Tue, 12 Apr 2022 03:40:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A594C3917A; Tue, 12 Apr 2022 00:16: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 E0916B81A8F; Tue, 12 Apr 2022 07:16:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58360C385A1; Tue, 12 Apr 2022 07:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747810; bh=vkPmgKey2lf/3Sf8BVlNeaFbqFAGzmVNLtpEoE4dmDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YuxhyiHeo9+mDVdza6icZAnRmAgm71zGv2OcDGjopuQ8TfF6OuG+voYqOWGqeuDvU O79Zdbs3i9ryBYVft5+hQlKTS3w7W3ATfv3FSHKbLGB8u7+NbyQ6uUCPkROXGPGlA4 9eRuWdfcFr82WOpkNUk5VxE8mtE4Aki5M72tEF8w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen-Yu Tsai , "Russell King (Oracle)" , Srinivas Kandagatla , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 214/343] net: stmmac: Fix unset max_speed difference between DT and non-DT platforms Date: Tue, 12 Apr 2022 08:30:32 +0200 Message-Id: <20220412062957.522165527@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Chen-Yu Tsai [ Upstream commit c21cabb0fd0b54b8b54235fc1ecfe1195a23bcb2 ] In commit 9cbadf094d9d ("net: stmmac: support max-speed device tree property"), when DT platforms don't set "max-speed", max_speed is set to -1; for non-DT platforms, it stays the default 0. Prior to commit eeef2f6b9f6e ("net: stmmac: Start adding phylink support"), the check for a valid max_speed setting was to check if it was greater than zero. This commit got it right, but subsequent patches just checked for non-zero, which is incorrect for DT platforms. In commit 92c3807b9ac3 ("net: stmmac: convert to phylink_get_linkmodes()") the conversion switched completely to checking for non-zero value as a valid value, which caused 1000base-T to stop getting advertised by default. Instead of trying to fix all the checks, simply leave max_speed alone if DT property parsing fails. Fixes: 9cbadf094d9d ("net: stmmac: support max-speed device tree property") Fixes: 92c3807b9ac3 ("net: stmmac: convert to phylink_get_linkmodes()") Signed-off-by: Chen-Yu Tsai Acked-by: Russell King (Oracle) Reviewed-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220331184832.16316-1-wens@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_platform.c index 5d29f336315b..11e1055e8260 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -431,8 +431,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8= *mac) plat->phylink_node =3D np; =20 /* Get max speed of operation from device tree */ - if (of_property_read_u32(np, "max-speed", &plat->max_speed)) - plat->max_speed =3D -1; + of_property_read_u32(np, "max-speed", &plat->max_speed); =20 plat->bus_id =3D of_alias_get_id(np, "ethernet"); if (plat->bus_id < 0) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1B49CC433FE for ; Tue, 12 Apr 2022 09:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236853AbiDLJPd (ORCPT ); Tue, 12 Apr 2022 05:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357817AbiDLHkq (ORCPT ); Tue, 12 Apr 2022 03:40:46 -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 8E8F639143; Tue, 12 Apr 2022 00:16: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 BD28BB81B6A; Tue, 12 Apr 2022 07:16:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CBD7C385A1; Tue, 12 Apr 2022 07:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747813; bh=SuvFWyTnFtQ/epL3OQe/Re84AKAEgEnShrWO+DTOp0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQfcDxCZNMOvqH6WdU5tm50kmchBB6BqJUFJdmlL0s8KtR3NRqmMkyjxA0PXE5DbE e+GSiZudWvz6gjA/vIivpdjBG/ZJGXEczaFgIpw3VXvYgm/3BDhILwnJiVuIqbbU7D ZvNHRD1pdVD5GRk66lM3zw43o5jgpGevBzq6bb8g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Philipp Zabel , Sasha Levin Subject: [PATCH 5.17 215/343] drm/imx: imx-ldb: Check for null pointer after calling kmemdup Date: Tue, 12 Apr 2022 08:30:33 +0200 Message-Id: <20220412062957.550752834@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jiasheng Jiang [ Upstream commit 8027a9ad9b3568c5eb49c968ad6c97f279d76730 ] As the possible failure of the allocation, kmemdup() may return NULL pointer. Therefore, it should be better to check the return value of kmemdup() and return error if fails. Fixes: dc80d7038883 ("drm/imx-ldb: Add support to drm-bridge") Signed-off-by: Jiasheng Jiang Signed-off-by: Philipp Zabel Link: https://lore.kernel.org/r/20220105074729.2363657-1-jiasheng@iscas.ac.= cn Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/imx/imx-ldb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c index e5078d03020d..fb0e951248f6 100644 --- a/drivers/gpu/drm/imx/imx-ldb.c +++ b/drivers/gpu/drm/imx/imx-ldb.c @@ -572,6 +572,8 @@ static int imx_ldb_panel_ddc(struct device *dev, edidp =3D of_get_property(child, "edid", &edid_len); if (edidp) { channel->edid =3D kmemdup(edidp, edid_len, GFP_KERNEL); + if (!channel->edid) + return -ENOMEM; } else if (!channel->panel) { /* fallback to display-timings node */ ret =3D of_get_drm_display_mode(child, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CC714C3527B for ; Tue, 12 Apr 2022 08:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376568AbiDLItu (ORCPT ); Tue, 12 Apr 2022 04:49:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357825AbiDLHkr (ORCPT ); Tue, 12 Apr 2022 03:40:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47EB39825; Tue, 12 Apr 2022 00:16: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 707FAB81B4F; Tue, 12 Apr 2022 07:16:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2B24C385A5; Tue, 12 Apr 2022 07:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747816; bh=gd8iSxgW8PBNOLgAnqpE0vsod2iKWP2nUWete6C1iPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F4xRpSp5ocd3Cytdl3ARFLq60N3PCYEu7tZk91LaQv7HKwP/QayebN3X2g+dZzmiQ tIA2UdbIhcov4VEJm8X840LTHkL49mqD/Wed9A1eHLVe/14eCgUeNGYwJ1CWzQ6X5N EnUVPMYOyWuuiXfEQkK1RRIn+oSw/3sx3n8nxclU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Philipp Zabel , Sasha Levin Subject: [PATCH 5.17 216/343] drm/imx: Fix memory leak in imx_pd_connector_get_modes Date: Tue, 12 Apr 2022 08:30:34 +0200 Message-Id: <20220412062957.578295261@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jos=C3=A9 Exp=C3=B3sito [ Upstream commit bce81feb03a20fca7bbdd1c4af16b4e9d5c0e1d3 ] Avoid leaking the display mode variable if of_get_drm_display_mode fails. Fixes: 76ecd9c9fb24 ("drm/imx: parallel-display: check return code from of_= get_drm_display_mode()") Addresses-Coverity-ID: 1443943 ("Resource leak") Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Signed-off-by: Philipp Zabel Link: https://lore.kernel.org/r/20220108165230.44610-1-jose.exposito89@gmai= l.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/imx/parallel-display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/p= arallel-display.c index 06cb1a59b9bc..63ba2ad84679 100644 --- a/drivers/gpu/drm/imx/parallel-display.c +++ b/drivers/gpu/drm/imx/parallel-display.c @@ -75,8 +75,10 @@ static int imx_pd_connector_get_modes(struct drm_connect= or *connector) ret =3D of_get_drm_display_mode(np, &imxpd->mode, &imxpd->bus_flags, OF_USE_NATIVE_MODE); - if (ret) + if (ret) { + drm_mode_destroy(connector->dev, mode); return ret; + } =20 drm_mode_copy(mode, &imxpd->mode); mode->type |=3D DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 05D65C433F5 for ; Tue, 12 Apr 2022 09:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235691AbiDLJPS (ORCPT ); Tue, 12 Apr 2022 05:15:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357851AbiDLHks (ORCPT ); Tue, 12 Apr 2022 03:40:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1710539B85; Tue, 12 Apr 2022 00:16: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 dfw.source.kernel.org (Postfix) with ESMTPS id 5C180617E6; Tue, 12 Apr 2022 07:16:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 476DBC385DF; Tue, 12 Apr 2022 07:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747818; bh=dvOuvkLBEN4EUP6zEmDLAeop9VeIEiE+x9OuTkj65Xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EE1wGx2EWHCDnwiDXaJLS6zPE4QZr7dGdjTae798/UrO4xK5ZdKQJO9MoDsG6zmIu 9wyZb//HmbHmUtaP4NiF0fZM6rY/nZdKDMvUDqz1vceJwn59gk6qD63OwzASWVGLIC 8SVusRTrw8VaXBlURXSmErY+BuxkfHwUqhfFPGSw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Liu Ying , Sasha Levin Subject: [PATCH 5.17 217/343] drm/imx: dw_hdmi-imx: Fix bailout in error cases of probe Date: Tue, 12 Apr 2022 08:30:35 +0200 Message-Id: <20220412062957.606464113@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Liu Ying [ Upstream commit e8083acc3f8cc2097917018e947fd4c857f60454 ] In dw_hdmi_imx_probe(), if error happens after dw_hdmi_probe() returns successfully, dw_hdmi_remove() should be called where necessary as bailout. Fixes: c805ec7eb210 ("drm/imx: dw_hdmi-imx: move initialization into probe") Cc: Philipp Zabel Cc: David Airlie Cc: Daniel Vetter Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Signed-off-by: Liu Ying Signed-off-by: Philipp Zabel Link: https://lore.kernel.org/r/20220128091944.3831256-1-victor.liu@nxp.com Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/imx/dw_hdmi-imx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdm= i-imx.c index 87428fb23d9f..a2277a0d6d06 100644 --- a/drivers/gpu/drm/imx/dw_hdmi-imx.c +++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c @@ -222,6 +222,7 @@ static int dw_hdmi_imx_probe(struct platform_device *pd= ev) struct device_node *np =3D pdev->dev.of_node; const struct of_device_id *match =3D of_match_node(dw_hdmi_imx_dt_ids, np= ); struct imx_hdmi *hdmi; + int ret; =20 hdmi =3D devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); if (!hdmi) @@ -243,10 +244,15 @@ static int dw_hdmi_imx_probe(struct platform_device *= pdev) hdmi->bridge =3D of_drm_find_bridge(np); if (!hdmi->bridge) { dev_err(hdmi->dev, "Unable to find bridge\n"); + dw_hdmi_remove(hdmi->hdmi); return -ENODEV; } =20 - return component_add(&pdev->dev, &dw_hdmi_imx_ops); + ret =3D component_add(&pdev->dev, &dw_hdmi_imx_ops); + if (ret) + dw_hdmi_remove(hdmi->hdmi); + + return ret; } =20 static int dw_hdmi_imx_remove(struct platform_device *pdev) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 3F7EFC433F5 for ; Tue, 12 Apr 2022 08:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376612AbiDLItz (ORCPT ); Tue, 12 Apr 2022 04:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357860AbiDLHkt (ORCPT ); Tue, 12 Apr 2022 03:40:49 -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 EC22E3A182; Tue, 12 Apr 2022 00:17: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4863D617D2; Tue, 12 Apr 2022 07:17:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50AE8C385A6; Tue, 12 Apr 2022 07:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747821; bh=QglxR7xqTgao+Mu3n8Nk9NbuD0NuJMjSZJ6+4whERrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rrO3PYIEqIwOXpkIxLIPAsVCdsmDpMuAEsT4qbBGXj2bZ+Neq1MDOpheZMC1gu/+p nrfVfvNFZVJ+EyFZ/GJ0+hLieVYiqrw5Dr4UTfIsVu+msvTmnwLOjPvaLDZXmUKhgI oPF4prDsEDFicL23yGcn1asMRVBY8klhHU9tZoxE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH 5.17 218/343] regulator: rtq2134: Fix missing active_discharge_on setting Date: Tue, 12 Apr 2022 08:30:36 +0200 Message-Id: <20220412062957.635055412@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Axel Lin [ Upstream commit 17049bf9de55a42ee96fd34520aff8a484677675 ] The active_discharge_on setting was missed, so output discharge resistor is always disabled. Fix it. Fixes: 0555d41497de ("regulator: rtq2134: Add support for Richtek RTQ2134 S= ubPMIC") Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20220404022514.449231-1-axel.lin@ingics.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/regulator/rtq2134-regulator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/rtq2134-regulator.c b/drivers/regulator/rtq2= 134-regulator.c index f21e3f8b21f2..8e13dea354a2 100644 --- a/drivers/regulator/rtq2134-regulator.c +++ b/drivers/regulator/rtq2134-regulator.c @@ -285,6 +285,7 @@ static const unsigned int rtq2134_buck_ramp_delay_table= [] =3D { .enable_mask =3D RTQ2134_VOUTEN_MASK, \ .active_discharge_reg =3D RTQ2134_REG_BUCK##_id##_CFG0, \ .active_discharge_mask =3D RTQ2134_ACTDISCHG_MASK, \ + .active_discharge_on =3D RTQ2134_ACTDISCHG_MASK, \ .ramp_reg =3D RTQ2134_REG_BUCK##_id##_RSPCFG, \ .ramp_mask =3D RTQ2134_RSPUP_MASK, \ .ramp_delay_table =3D rtq2134_buck_ramp_delay_table, \ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 66929C4332F for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388631AbiDLJWf (ORCPT ); Tue, 12 Apr 2022 05:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357907AbiDLHkx (ORCPT ); Tue, 12 Apr 2022 03:40:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32733A701; Tue, 12 Apr 2022 00:17: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 dfw.source.kernel.org (Postfix) with ESMTPS id 3F66461701; Tue, 12 Apr 2022 07:17:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 421FCC385AB; Tue, 12 Apr 2022 07:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747824; bh=537283YRBjJKgJj+Nf1tX1vYfyuMABT/nm75Jj/WTxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lNdFbFNz1KfjS2zH06SOw/h0HieR0fqLJyl8Q2z8SnJz6cgKGLoc1645EaFv10spH ajWba4aaIxXg3GMzjuH/xRv7lNZKU0jV6jYEAErOkES5JdKv1QuHfOFE0OTJ6wBaPZ JUuZE1Wkn55+fxsDhVDmG87ZwjeUzftmTZq8nNis= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Wolfram Sang , Mark Brown , Sasha Levin Subject: [PATCH 5.17 219/343] spi: rpc-if: Fix RPM imbalance in probe error path Date: Tue, 12 Apr 2022 08:30:37 +0200 Message-Id: <20220412062957.663302382@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Geert Uytterhoeven [ Upstream commit 2f8cf5f642e80f8b6b0e660a9c86924a1f41cd80 ] If rpcif_hw_init() fails, Runtime PM is left enabled. Fixes: b04cc0d912eb80d3 ("memory: renesas-rpc-if: Add support for RZ/G2L") Signed-off-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Link: https://lore.kernel.org/r/1c78a1f447d019bb66b6e7787f520ae78821e2ae.16= 48562287.git.geert+renesas@glider.be Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/spi/spi-rpc-if.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c index fe82f3575df4..24ec1c83f379 100644 --- a/drivers/spi/spi-rpc-if.c +++ b/drivers/spi/spi-rpc-if.c @@ -158,14 +158,18 @@ static int rpcif_spi_probe(struct platform_device *pd= ev) =20 error =3D rpcif_hw_init(rpc, false); if (error) - return error; + goto out_disable_rpm; =20 error =3D spi_register_controller(ctlr); if (error) { dev_err(&pdev->dev, "spi_register_controller failed\n"); - rpcif_disable_rpm(rpc); + goto out_disable_rpm; } =20 + return 0; + +out_disable_rpm: + rpcif_disable_rpm(rpc); return error; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 594E7C3527C for ; Tue, 12 Apr 2022 08:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376661AbiDLIuC (ORCPT ); Tue, 12 Apr 2022 04:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357957AbiDLHk4 (ORCPT ); Tue, 12 Apr 2022 03: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 DB93E3B023; Tue, 12 Apr 2022 00:17: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 0F37F6171C; Tue, 12 Apr 2022 07:17:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EAC4C385A1; Tue, 12 Apr 2022 07:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747827; bh=LBlGdq6vz+9VNDx+bAUfEJCL60i/v7PjWpnupljX3dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YsvDVCX2/SN5A6ScWd1L/Km9b1SnzQplGLlcW/T1CzmEjBUuvnfbwfFuYkXv7Ee1U GRRd2HGjZYu5/19Z63K6Q4oPw6o1vw90ZvaeuLPR3lQHlrJ08MgH07dVQtsRLToHMs +2yZdNpjVyuc0tK+3vfNtgMyzSItfe3tqIBAeVjM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH 5.17 220/343] regulator: atc260x: Fix missing active_discharge_on setting Date: Tue, 12 Apr 2022 08:30:38 +0200 Message-Id: <20220412062957.690976788@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Axel Lin [ Upstream commit 2316f0fc0ad2aa87a568ceaf3d76be983ee555c3 ] Without active_discharge_on setting, the SWITCH1 discharge enable control is always disabled. Fix it. Fixes: 3b15ccac161a ("regulator: Add regulator driver for ATC260x PMICs") Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20220403132235.123727-1-axel.lin@ingics.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/regulator/atc260x-regulator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/atc260x-regulator.c b/drivers/regulator/atc2= 60x-regulator.c index 05147d2c3842..485e58b264c0 100644 --- a/drivers/regulator/atc260x-regulator.c +++ b/drivers/regulator/atc260x-regulator.c @@ -292,6 +292,7 @@ enum atc2603c_reg_ids { .bypass_mask =3D BIT(5), \ .active_discharge_reg =3D ATC2603C_PMU_SWITCH_CTL, \ .active_discharge_mask =3D BIT(1), \ + .active_discharge_on =3D BIT(1), \ .owner =3D THIS_MODULE, \ } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6E77CC433FE for ; Tue, 12 Apr 2022 08:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376722AbiDLIuM (ORCPT ); Tue, 12 Apr 2022 04:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358022AbiDLHk7 (ORCPT ); Tue, 12 Apr 2022 03:40: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 02D0F3BF9A; Tue, 12 Apr 2022 00:17: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 88C0AB81B7A; Tue, 12 Apr 2022 07:17:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D73D9C385A1; Tue, 12 Apr 2022 07:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747830; bh=YiaJDBbTcuhQHMi1q1uJq5SwFO2vcgROG+bHHXW7V2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FqJXmaFn5dC+1lSvJ6jRreHKZH2z8ixED2mwcADmcAb+zjGQ/RnExgH4WRfKA8leT hi0sHLbPjBUc3njjv4mStMwdMDuvlepvhymCbixvMV/ONDNyc3lAxf8Qj4w1sSmjB9 AYiWmFgPyLOYZ7iiYp+2pvKNU+pL82WLSo+lUxHo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Auld , Dietmar Eggemann , Will Deacon , Sasha Levin Subject: [PATCH 5.17 221/343] arch/arm64: Fix topology initialization for core scheduling Date: Tue, 12 Apr 2022 08:30:39 +0200 Message-Id: <20220412062957.719266199@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Phil Auld [ Upstream commit 5524cbb1bfcdff0cad0aaa9f94e6092002a07259 ] Arm64 systems rely on store_cpu_topology() to call update_siblings_masks() to transfer the toplogy to the various cpu masks. This needs to be done before the call to notify_cpu_starting() which tells the scheduler about each cpu found, otherwise the core scheduling data structures are setup in a way that does not match the actual topology. With smt_mask not setup correctly we bail on `cpumask_weight(smt_mask) =3D= =3D 1` for !leaders in: notify_cpu_starting() cpuhp_invoke_callback_range() sched_cpu_starting() sched_core_cpu_starting() which leads to rq->core not being correctly set for !leader-rq's. Without this change stress-ng (which enables core scheduling in its prctl tests in newer versions -- i.e. with PR_SCHED_CORE support) causes a warning and then a crash (trimmed for legibility): [ 1853.805168] ------------[ cut here ]------------ [ 1853.809784] task_rq(b)->core !=3D rq->core [ 1853.809792] WARNING: CPU: 117 PID: 0 at kernel/sched/fair.c:11102 cfs_pr= io_less+0x1b4/0x1c4 ... [ 1854.015210] Unable to handle kernel NULL pointer dereference at virtual = address 0000000000000010 ... [ 1854.231256] Call trace: [ 1854.233689] pick_next_task+0x3dc/0x81c [ 1854.237512] __schedule+0x10c/0x4cc [ 1854.240988] schedule_idle+0x34/0x54 Fixes: 9edeaea1bc45 ("sched: Core-wide rq->lock") Signed-off-by: Phil Auld Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Link: https://lore.kernel.org/r/20220331153926.25742-1-pauld@redhat.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 27df5c1e6baa..3b46041f2b97 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -234,6 +234,7 @@ asmlinkage notrace void secondary_start_kernel(void) * Log the CPU info before it is marked online and might get read. */ cpuinfo_store_cpu(); + store_cpu_topology(cpu); =20 /* * Enable GIC and timers. @@ -242,7 +243,6 @@ asmlinkage notrace void secondary_start_kernel(void) =20 ipi_setup(cpu); =20 - store_cpu_topology(cpu); numa_add_cpu(cpu); =20 /* --=20 2.35.1 From nobody Thu May 14 08:08:21 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 DB944C43219 for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357362AbiDLJDq (ORCPT ); Tue, 12 Apr 2022 05:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358046AbiDLHlB (ORCPT ); Tue, 12 Apr 2022 03:41:01 -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 A9EB440926; Tue, 12 Apr 2022 00:17: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 dfw.source.kernel.org (Postfix) with ESMTPS id 458D861045; Tue, 12 Apr 2022 07:17:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56389C385A1; Tue, 12 Apr 2022 07:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747835; bh=+Rqdjfhvx2D/QpvUz9W69X9XBHp0o3qpRtra3UpwWus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aORHM98Obl6SCXJ36MDXLZW98vKzryGqzhz1c61fLXLZN2BnHodb0AtwoiHF2D2Hc huTrPYwsAOvAXGzMJJ7vR/CbjrmfS20C3/X78kG1tLWnHfiHKS3L+n6Ywv2dNd7IhZ TMQVcFMEZm30G01QdmTKHKGVCCW3Z5bydrptm/bo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavan Chebbi , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 222/343] bnxt_en: Synchronize tx when xdp redirects happen on same ring Date: Tue, 12 Apr 2022 08:30:40 +0200 Message-Id: <20220412062957.747431461@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pavan Chebbi [ Upstream commit 4f81def272de17dc4bbd89ac38f49b2676c9b3d2 ] If there are more CPUs than the number of TX XDP rings, multiple XDP redirects can select the same TX ring based on the CPU on which XDP redirect is called. Add locking when needed and use static key to decide whether to take the lock. Fixes: f18c2b77b2e4 ("bnxt_en: optimized XDP_REDIRECT support") Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 8 ++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 2 ++ 4 files changed, 19 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index b1c98d1408b8..6af0ae1d0c46 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -3224,6 +3224,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp) } qidx =3D bp->tc_to_qidx[j]; ring->queue_id =3D bp->q_info[qidx].queue_id; + spin_lock_init(&txr->xdp_tx_lock); if (i < bp->tx_nr_rings_xdp) continue; if (i % bp->tx_nr_rings_per_tc =3D=3D (bp->tx_nr_rings_per_tc - 1)) @@ -10294,6 +10295,12 @@ static int __bnxt_open_nic(struct bnxt *bp, bool i= rq_re_init, bool link_re_init) if (irq_re_init) udp_tunnel_nic_reset_ntf(bp->dev); =20 + if (bp->tx_nr_rings_xdp < num_possible_cpus()) { + if (!static_key_enabled(&bnxt_xdp_locking_key)) + static_branch_enable(&bnxt_xdp_locking_key); + } else if (static_key_enabled(&bnxt_xdp_locking_key)) { + static_branch_disable(&bnxt_xdp_locking_key); + } set_bit(BNXT_STATE_OPEN, &bp->state); bnxt_enable_int(bp); /* Enable TX queues */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethern= et/broadcom/bnxt/bnxt.h index 666fc1e7a7d2..caf66a35d923 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -800,6 +800,8 @@ struct bnxt_tx_ring_info { u32 dev_state; =20 struct bnxt_ring_struct tx_ring_struct; + /* Synchronize simultaneous xdp_xmit on same ring */ + spinlock_t xdp_tx_lock; }; =20 #define BNXT_LEGACY_COAL_CMPL_PARAMS \ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/et= hernet/broadcom/bnxt/bnxt_xdp.c index 52fad0fdeacf..c0541ff00ac8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -20,6 +20,8 @@ #include "bnxt.h" #include "bnxt_xdp.h" =20 +DEFINE_STATIC_KEY_FALSE(bnxt_xdp_locking_key); + struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, dma_addr_t mapping, u32 len) @@ -227,6 +229,9 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frame= s, ring =3D smp_processor_id() % bp->tx_nr_rings_xdp; txr =3D &bp->tx_ring[ring]; =20 + if (static_branch_unlikely(&bnxt_xdp_locking_key)) + spin_lock(&txr->xdp_tx_lock); + for (i =3D 0; i < num_frames; i++) { struct xdp_frame *xdp =3D frames[i]; =20 @@ -250,6 +255,9 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frame= s, bnxt_db_write(bp, &txr->tx_db, txr->tx_prod); } =20 + if (static_branch_unlikely(&bnxt_xdp_locking_key)) + spin_unlock(&txr->xdp_tx_lock); + return nxmit; } =20 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h b/drivers/net/et= hernet/broadcom/bnxt/bnxt_xdp.h index 0df40c3beb05..067bb5e821f5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h @@ -10,6 +10,8 @@ #ifndef BNXT_XDP_H #define BNXT_XDP_H =20 +DECLARE_STATIC_KEY_FALSE(bnxt_xdp_locking_key); + struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, dma_addr_t mapping, u32 len); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 ED0E9C4167B for ; Tue, 12 Apr 2022 09:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359617AbiDLJEC (ORCPT ); Tue, 12 Apr 2022 05:04:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358100AbiDLHlF (ORCPT ); Tue, 12 Apr 2022 03:41: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 EB4D64162F; Tue, 12 Apr 2022 00:17: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 9AD19B81B7E; Tue, 12 Apr 2022 07:17:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E64C385A1; Tue, 12 Apr 2022 07:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747838; bh=9jJuB3Zce2Jl47f62to42/4RdDjyuYNV/4T3aDnM2II=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A3yQ3u0w0205/kkcwBqvEFpK3vrF0TtPIJDO7A7nFsYU3tDVREOpo16SX7NjAqEox KooBtideqGxzapsmsbK5Y68a6gZiqTr/YowJ9GrLJCrP8lBiJGPLg1MgIszzPzAc4A SmimwwSOMzcaWK4iV7HXFp46GnbEwXUUVmHFhUrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Somnath Kotur , Pavan Chebbi , Andy Gospodarek , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 223/343] bnxt_en: reserve space inside receive page for skb_shared_info Date: Tue, 12 Apr 2022 08:30:41 +0200 Message-Id: <20220412062957.775806540@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Gospodarek [ Upstream commit facc173cf700e55b2ad249ecbd3a7537f7315691 ] Insufficient space was being reserved in the page used for packet reception, so the interface MTU could be set too large to still have room for the contents of the packet when doing XDP redirect. This resulted in the following message when redirecting a packet between 3520 and 3822 bytes with an MTU of 3822: [311815.561880] XDP_WARN: xdp_update_frame_from_buff(line:200): Driver BUG:= missing reserved tailroom Fixes: f18c2b77b2e4 ("bnxt_en: optimized XDP_REDIRECT support") Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Signed-off-by: Andy Gospodarek Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethern= et/broadcom/bnxt/bnxt.h index caf66a35d923..d57bff46b587 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -593,7 +593,8 @@ struct nqe_cn { #define BNXT_MAX_MTU 9500 #define BNXT_MAX_PAGE_MODE_MTU \ ((unsigned int)PAGE_SIZE - VLAN_ETH_HLEN - NET_IP_ALIGN - \ - XDP_PACKET_HEADROOM) + XDP_PACKET_HEADROOM - \ + SKB_DATA_ALIGN((unsigned int)sizeof(struct skb_shared_info))) =20 #define BNXT_MIN_PKT_SIZE 52 =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A30C4C433FE for ; Tue, 12 Apr 2022 09:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233953AbiDLJOk (ORCPT ); Tue, 12 Apr 2022 05:14:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358106AbiDLHlF (ORCPT ); Tue, 12 Apr 2022 03:41:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187203BA5D; Tue, 12 Apr 2022 00:17: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 dfw.source.kernel.org (Postfix) with ESMTPS id 878516179E; Tue, 12 Apr 2022 07:17:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A95FC385A1; Tue, 12 Apr 2022 07:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747841; bh=O+IifnGMdoysyZqyVP0StvjROtzPsCC5zNF9Nr2ilEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iv7NxVtiPCVyZQaDhaB7CU/ZnIuj7M0FK0F7sptRuTj/fsTL5+r0joVyQbL5Lv78o wLy97tUdppMV0PqL9hoAa1FX04D8M0YoUEBP9GqS0ZyOFBB6O/kr0peSFsCWN4qZPi G8YqO4o3vZbyH4h4zHWoWwC/jIfqkV8Rk6E1vxSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Olovyannikov , Ray Jui , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 224/343] bnxt_en: Prevent XDP redirect from running when stopping TX queue Date: Tue, 12 Apr 2022 08:30:42 +0200 Message-Id: <20220412062957.804621407@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ray Jui [ Upstream commit 27d4073f8d9af0340362554414f4961643a4f4de ] Add checks in the XDP redirect callback to prevent XDP from running when the TX ring is undergoing shutdown. Also remove redundant checks in the XDP redirect callback to validate the txr and the flag that indicates the ring supports XDP. The modulo arithmetic on 'tx_nr_rings_xdp' already guarantees the derived TX ring is an XDP ring. txr is also guaranteed to be valid after checking BNXT_STATE_OPEN and within RCU grace period. Fixes: f18c2b77b2e4 ("bnxt_en: optimized XDP_REDIRECT support") Reviewed-by: Vladimir Olovyannikov Signed-off-by: Ray Jui Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/et= hernet/broadcom/bnxt/bnxt_xdp.c index c0541ff00ac8..03b1d6c04504 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -229,14 +229,16 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_fra= mes, ring =3D smp_processor_id() % bp->tx_nr_rings_xdp; txr =3D &bp->tx_ring[ring]; =20 + if (READ_ONCE(txr->dev_state) =3D=3D BNXT_DEV_STATE_CLOSING) + return -EINVAL; + if (static_branch_unlikely(&bnxt_xdp_locking_key)) spin_lock(&txr->xdp_tx_lock); =20 for (i =3D 0; i < num_frames; i++) { struct xdp_frame *xdp =3D frames[i]; =20 - if (!txr || !bnxt_tx_avail(bp, txr) || - !(bp->bnapi[ring]->flags & BNXT_NAPI_FLAG_XDP)) + if (!bnxt_tx_avail(bp, txr)) break; =20 mapping =3D dma_map_single(&pdev->dev, xdp->data, xdp->len, --=20 2.35.1 From nobody Thu May 14 08:08:21 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 82F25C3527E for ; Tue, 12 Apr 2022 08:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376763AbiDLIuQ (ORCPT ); Tue, 12 Apr 2022 04:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358132AbiDLHlH (ORCPT ); Tue, 12 Apr 2022 03:41: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 1BC3541F8B; Tue, 12 Apr 2022 00:17: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 ams.source.kernel.org (Postfix) with ESMTPS id BFCCEB81B66; Tue, 12 Apr 2022 07:17:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38A29C385A1; Tue, 12 Apr 2022 07:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747843; bh=6uhKsBVK/85T0zV+8oTAuD9p40iNznVFuvXgxUB+jLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=geeFk2Uv0jgq46cLSV5QGgakYySyO7Ck6MmLXCnk6L01h6jkcH4vn0tyhyda9AFWB dsy7uIN/sjuU1ZNtXpDGu9cY9+7zyX1ACf4ZockbBvVviYWiDgVzg0bkV+n5iqXuMI zIt84gyEH0M0z8xf23OGgeKZCzE2IF0nZ9mHSDHk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taehee Yoo , Martin Habets , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 225/343] sfc: Do not free an empty page_ring Date: Tue, 12 Apr 2022 08:30:43 +0200 Message-Id: <20220412062957.832625390@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Martin Habets [ Upstream commit 458f5d92df4807e2a7c803ed928369129996bf96 ] When the page_ring is not used page_ptr_mask is 0. Do not dereference page_ring[0] in this case. Fixes: 2768935a4660 ("sfc: reuse pages to avoid DMA mapping/unmapping costs= ") Reported-by: Taehee Yoo Signed-off-by: Martin Habets Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/sfc/rx_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sf= c/rx_common.c index 633ca77a26fd..b925de9b4302 100644 --- a/drivers/net/ethernet/sfc/rx_common.c +++ b/drivers/net/ethernet/sfc/rx_common.c @@ -166,6 +166,9 @@ static void efx_fini_rx_recycle_ring(struct efx_rx_queu= e *rx_queue) struct efx_nic *efx =3D rx_queue->efx; int i; =20 + if (unlikely(!rx_queue->page_ring)) + return; + /* Unmap and release the pages in the recycle ring. Remove the ring. */ for (i =3D 0; i <=3D rx_queue->page_ptr_mask; i++) { struct page *page =3D rx_queue->page_ring[i]; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 97B20C3527D for ; Tue, 12 Apr 2022 08:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376792AbiDLIuW (ORCPT ); Tue, 12 Apr 2022 04:50:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358147AbiDLHlH (ORCPT ); Tue, 12 Apr 2022 03:41: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 31A324248D; Tue, 12 Apr 2022 00:17:28 -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 9F5FDB81B7A; Tue, 12 Apr 2022 07:17:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF046C385A5; Tue, 12 Apr 2022 07:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747846; bh=ZQJTxnWwxn1l0rfByrfBEHx7Ho3mbw7y5PfeVOo104Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UblLsF/Vx7zWInNl+uOxT6mRh/vB1paZrXR3JjXVL4QVEpo0Hh7sf7l8uZgqW79Im OsWI8dx7NSEZlN0LUzW9lFhDDd5x6emBqHYGpHRaRv4scCpYUNTzIBc/mZlQ/FrCe3 f4+4CJuypQvK9ZEzY5TB4CQf9kNhSuDIZVUXPTJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aharon Landau , Shay Drory , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.17 226/343] RDMA/mlx5: Dont remove cache MRs when a delay is needed Date: Tue, 12 Apr 2022 08:30:44 +0200 Message-Id: <20220412062957.861565246@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Aharon Landau [ Upstream commit 84c2362fb65d69c721fec0974556378cbb36a62b ] Don't remove MRs from the cache if need to delay the removal. Fixes: b9358bdbc713 ("RDMA/mlx5: Fix locking in MR cache work queue") Link: https://lore.kernel.org/r/c3087a90ff362c8796c7eaa2715128743ce36722.16= 49062436.git.leonro@nvidia.com Signed-off-by: Aharon Landau Reviewed-by: Shay Drory Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/infiniband/hw/mlx5/mr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/m= r.c index 2910d7833313..d3b2d02a4872 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -541,8 +541,10 @@ static void __cache_work_func(struct mlx5_cache_ent *e= nt) spin_lock_irq(&ent->lock); if (ent->disabled) goto out; - if (need_delay) + if (need_delay) { queue_delayed_work(cache->wq, &ent->dwork, 300 * HZ); + goto out; + } remove_cache_mr_locked(ent); queue_adjust_cache_locked(ent); } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 26948C47089 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388551AbiDLJWb (ORCPT ); Tue, 12 Apr 2022 05:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358192AbiDLHlK (ORCPT ); Tue, 12 Apr 2022 03:41:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AA98424B8; Tue, 12 Apr 2022 00:17: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 34920B81B60; Tue, 12 Apr 2022 07:17:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A47F4C385A1; Tue, 12 Apr 2022 07:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747849; bh=CYdSPQWbDPzISEWdJ44T/uOqTRiv53C+ON7DnWkJjF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwYe9ufFGFVsAbjDXw2+MG6JR1uT5xGQz1zyQjq26eejVXXNNqjGYWowmtiXDEzB6 XpyWUuXZu+bf9STpV5J6vOkkwM5hq0TTYdXPoHA4B30R9MrmucNyWJm0SZj0kObzog 3XJTo1O2RYeUIfgGOnPhe0KpGeDVMRSxZn8oufxU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aharon Landau , Shay Drory , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.17 227/343] RDMA/mlx5: Add a missing update of cache->last_add Date: Tue, 12 Apr 2022 08:30:45 +0200 Message-Id: <20220412062957.890059764@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Aharon Landau [ Upstream commit 1d735eeee63a0beb65180ca0224f239cc0c9f804 ] Update cache->last_add when returning an MR to the cache so that the cache work won't remove it. Fixes: b9358bdbc713 ("RDMA/mlx5: Fix locking in MR cache work queue") Link: https://lore.kernel.org/r/c99f076fce4b44829d434936bbcd3b5fc4c95020.16= 49062436.git.leonro@nvidia.com Signed-off-by: Aharon Landau Reviewed-by: Shay Drory Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/m= r.c index d3b2d02a4872..d40a1460ef97 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -632,6 +632,7 @@ static void mlx5_mr_cache_free(struct mlx5_ib_dev *dev,= struct mlx5_ib_mr *mr) { struct mlx5_cache_ent *ent =3D mr->cache_ent; =20 + WRITE_ONCE(dev->cache.last_add, jiffies); spin_lock_irq(&ent->lock); list_add_tail(&mr->list, &ent->head); ent->available_mrs++; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 838ACC433F5 for ; Tue, 12 Apr 2022 09:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234425AbiDLJOL (ORCPT ); Tue, 12 Apr 2022 05:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358208AbiDLHlK (ORCPT ); Tue, 12 Apr 2022 03:41:10 -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 991CD427EB; Tue, 12 Apr 2022 00:17: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 3CCD0B81B6B; Tue, 12 Apr 2022 07:17:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3513C385A1; Tue, 12 Apr 2022 07:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747852; bh=aYjbmozvRP0Y6GF6WshL6ZK6wocwCPdx4W6SMiYjpFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LyCOaXJ9BTjFJxhRF4/eWT4KjcNOmDPreN/X9+/bSmkGmMkNiPQtp9AiBOGEHt0T1 cmNcTXiMecvZdDyi/aCmzL4whl6+Ab3FGZr8vEFcQa3DmS3QKTwlRkyvwaV98ZD7O6 GDJjnquSJ3AqsEBK1YSGU3fb6axbjxYQqJGt3MAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Zhang , Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.17 228/343] IB/cm: Cancel mad on the DREQ event when the state is MRA_REP_RCVD Date: Tue, 12 Apr 2022 08:30:46 +0200 Message-Id: <20220412062957.918468994@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Mark Zhang [ Upstream commit 107dd7beba403a363adfeb3ffe3734fe38a05cce ] On the passive side when the disconnectReq event comes, if the current state is MRA_REP_RCVD, it needs to cancel the MAD before entering the DREQ_RCVD and TIMEWAIT states, otherwise the destroy_id may block until this mad will reach timeout. Fixes: a977049dacde ("[PATCH] IB: Add the kernel CM implementation") Link: https://lore.kernel.org/r/75261c00c1d82128b1d981af9ff46e994186e621.16= 49062436.git.leonro@nvidia.com Signed-off-by: Mark Zhang Reviewed-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/infiniband/core/cm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 35f0d5e7533d..1c107d6d03b9 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -2824,6 +2824,7 @@ static int cm_dreq_handler(struct cm_work *work) switch (cm_id_priv->id.state) { case IB_CM_REP_SENT: case IB_CM_DREQ_SENT: + case IB_CM_MRA_REP_RCVD: ib_cancel_mad(cm_id_priv->msg); break; case IB_CM_ESTABLISHED: @@ -2831,8 +2832,6 @@ static int cm_dreq_handler(struct cm_work *work) cm_id_priv->id.lap_state =3D=3D IB_CM_MRA_LAP_RCVD) ib_cancel_mad(cm_id_priv->msg); break; - case IB_CM_MRA_REP_RCVD: - break; case IB_CM_TIMEWAIT: atomic_long_inc(&work->port->counters[CM_RECV_DUPLICATES] [CM_DREQ_COUNTER]); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1778CC38162 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388520AbiDLJW1 (ORCPT ); Tue, 12 Apr 2022 05:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358219AbiDLHlL (ORCPT ); Tue, 12 Apr 2022 03:41:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2034B42A17; Tue, 12 Apr 2022 00:17: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 AFECA61045; Tue, 12 Apr 2022 07:17:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C0E0C385A1; Tue, 12 Apr 2022 07:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747855; bh=HLy3qY+J5ROTEF4rwyotysIW1sSO8dDgG1rHbzkhJac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IM5zbrN3BMuJCxUpezxflmU+o+ZkGW5kB0fUPCdavQw6uze7p0LDLOvUacXxv1fCk AZy2i0SV17idNneDAxZyaq7yrWgPPbvt7jygbZ+K+R/1OP+mGIzFRFf2A+Xn3IvITd gRQrTxFci13ODH0j0/JAInFEmVim0+nAGxnQCFO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Enzo Matsumiya , Shyam Prasad N , "Paulo Alcantara (SUSE)" , Steve French , Sasha Levin Subject: [PATCH 5.17 229/343] cifs: fix potential race with cifsd thread Date: Tue, 12 Apr 2022 08:30:47 +0200 Message-Id: <20220412062957.947491639@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Paulo Alcantara [ Upstream commit 687127c81ad32c8900a3fedbc7ed8f686ca95855 ] To avoid racing with demultiplex thread while it is handling data on socket, use cifs_signal_cifsd_for_reconnect() helper for marking current server to reconnect and let the demultiplex thread handle the rest. Fixes: dca65818c80c ("cifs: use a different reconnect helper for non-cifsd = threads") Reviewed-by: Enzo Matsumiya Reviewed-by: Shyam Prasad N Signed-off-by: Paulo Alcantara (SUSE) Signed-off-by: Steve French Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/cifs/connect.c | 2 +- fs/cifs/netmisc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index d6f8ccc7bfe2..0270b412f801 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -4465,7 +4465,7 @@ static int tree_connect_dfs_target(const unsigned int= xid, struct cifs_tcon *tco */ if (rc && server->current_fullpath !=3D server->origin_fullpath) { server->current_fullpath =3D server->origin_fullpath; - cifs_reconnect(tcon->ses->server, true); + cifs_signal_cifsd_for_reconnect(server, true); } =20 dfs_cache_free_tgts(tl); diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index ebe236b9d9f5..235aa1b395eb 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -896,7 +896,7 @@ map_and_check_smb_error(struct mid_q_entry *mid, bool l= ogErr) if (class =3D=3D ERRSRV && code =3D=3D ERRbaduid) { cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n", code); - cifs_reconnect(mid->server, false); + cifs_signal_cifsd_for_reconnect(mid->server, false); } } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 AC8A8C46467 for ; Tue, 12 Apr 2022 08:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376823AbiDLIuY (ORCPT ); Tue, 12 Apr 2022 04:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358235AbiDLHlM (ORCPT ); Tue, 12 Apr 2022 03:41:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51CB742A36; Tue, 12 Apr 2022 00:17: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 6B8CF616E7; Tue, 12 Apr 2022 07:17:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C83AC385A1; Tue, 12 Apr 2022 07:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747857; bh=r8a9lHuAGZPUTvvW+D5b/UG4FvvagGtzxKifdNP/HL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bWygdz0vvz1npoX1TJeYV4XXQBjxIt0zelLZDfGBzO0bSFztYMtG3cLZN3Pv7S2pI aiuOQ1kjSfX0P1zdW4Kusb76ZpXKm84YAFYWPiwqCa3srrp31bULerxTIMC5jIaYzd VdUPyPhKk/MeiXdM9Bw9oemCyMxX3SZt0gu/JpwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Dennis Dalessandro , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.17 230/343] IB/rdmavt: add lock to call to rvt_error_qp to prevent a race condition Date: Tue, 12 Apr 2022 08:30:48 +0200 Message-Id: <20220412062957.976208346@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Niels Dossche [ Upstream commit 4d809f69695d4e7d1378b3a072fa9aef23123018 ] The documentation of the function rvt_error_qp says both r_lock and s_lock need to be held when calling that function. It also asserts using lockdep that both of those locks are held. However, the commit I referenced in Fixes accidentally makes the call to rvt_error_qp in rvt_ruc_loopback no longer covered by r_lock. This results in the lockdep assertion failing and also possibly in a race condition. Fixes: d757c60eca9b ("IB/rdmavt: Fix concurrency panics in QP post_send and= modify to error") Link: https://lore.kernel.org/r/20220228165330.41546-1-dossche.niels@gmail.= com Signed-off-by: Niels Dossche Acked-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/infiniband/sw/rdmavt/qp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdma= vt/qp.c index ae50b56e8913..8ef112f883a7 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -3190,7 +3190,11 @@ void rvt_ruc_loopback(struct rvt_qp *sqp) spin_lock_irqsave(&sqp->s_lock, flags); rvt_send_complete(sqp, wqe, send_status); if (sqp->ibqp.qp_type =3D=3D IB_QPT_RC) { - int lastwqe =3D rvt_error_qp(sqp, IB_WC_WR_FLUSH_ERR); + int lastwqe; + + spin_lock(&sqp->r_lock); + lastwqe =3D rvt_error_qp(sqp, IB_WC_WR_FLUSH_ERR); + spin_unlock(&sqp->r_lock); =20 sqp->s_flags &=3D ~RVT_S_BUSY; spin_unlock_irqrestore(&sqp->s_lock, flags); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 B76FAC433EF for ; Tue, 12 Apr 2022 08:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376847AbiDLIu3 (ORCPT ); Tue, 12 Apr 2022 04:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358261AbiDLHlN (ORCPT ); Tue, 12 Apr 2022 03:41: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 CF9FA424A3; Tue, 12 Apr 2022 00:17: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 3C6FB6153F; Tue, 12 Apr 2022 07:17:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4408CC385A6; Tue, 12 Apr 2022 07:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747860; bh=sB3ctKJpeWozzwijECZo6jSzehzrqz0vt3jr47udbag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfE+22lkoNrx8NTnyYffPW/G754CCwj7Ku1jjwx4TiJps231SLYkZ6S91V2y2523k danR6VqCweqDOagS8OsvIFLkomlRAnww8ptxmZRGrBMrZXqZXm6oy97HBhMifSjHeU jbg/N61RHocOixFli35vCw2662PRnW8dg8Satb54= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamie Bainbridge , Marcelo Ricardo Leitner , Paolo Abeni , Sasha Levin Subject: [PATCH 5.17 231/343] sctp: count singleton chunks in assoc user stats Date: Tue, 12 Apr 2022 08:30:49 +0200 Message-Id: <20220412062958.004460356@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jamie Bainbridge [ Upstream commit e3d37210df5c41c51147a2d5d465de1a4d77be7a ] Singleton chunks (INIT, HEARTBEAT PMTU probes, and SHUTDOWN- COMPLETE) are not counted in SCTP_GET_ASOC_STATS "sas_octrlchunks" counter available to the assoc owner. These are all control chunks so they should be counted as such. Add counting of singleton chunks so they are properly accounted for. Fixes: 196d67593439 ("sctp: Add support to per-association statistics via a= new SCTP_GET_ASSOC_STATS call") Signed-off-by: Jamie Bainbridge Acked-by: Marcelo Ricardo Leitner Link: https://lore.kernel.org/r/c9ba8785789880cf07923b8a5051e174442ea9ee.16= 49029663.git.jamie.bainbridge@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sctp/outqueue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index a18609f608fb..e213aaf45d67 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -914,6 +914,7 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx = *ctx) ctx->asoc->base.sk->sk_err =3D -error; return; } + ctx->asoc->stats.octrlchunks++; break; =20 case SCTP_CID_ABORT: @@ -938,7 +939,10 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx= *ctx) =20 case SCTP_CID_HEARTBEAT: if (chunk->pmtu_probe) { - sctp_packet_singleton(ctx->transport, chunk, ctx->gfp); + error =3D sctp_packet_singleton(ctx->transport, + chunk, ctx->gfp); + if (!error) + ctx->asoc->stats.octrlchunks++; break; } fallthrough; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A59DDC433F5 for ; Tue, 12 Apr 2022 09:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358716AbiDLJNk (ORCPT ); Tue, 12 Apr 2022 05:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358334AbiDLHlZ (ORCPT ); Tue, 12 Apr 2022 03:41:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D64B13F8A; Tue, 12 Apr 2022 00:17: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 6AA91B81B66; Tue, 12 Apr 2022 07:17:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4DD3C385A1; Tue, 12 Apr 2022 07:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747866; bh=9iTxZGbtSi2vsNDuzzMAyGdD7jEVaEg0CO34a/UwlTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNAqO/JU8rbb0dR4Umu2qMBk9YMIZpQ9NOi3oJfz4rf61+4nckbn7aDR1gfva3/dd UxdfBeHALILoANzYNDNZYk1BQ+8SWQ2SLVSpia1eLDBuZ7hxFiQNZ33vn49NdM1JiZ Q4nzLwFoFoFDGhbdSsSjS+M0hVDfDzwfbRlzF030= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Paolo Abeni , Sasha Levin Subject: [PATCH 5.17 232/343] dpaa2-ptp: Fix refcount leak in dpaa2_ptp_probe Date: Tue, 12 Apr 2022 08:30:50 +0200 Message-Id: <20220412062958.033253963@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 2b04bd4f03bba021959ca339314f6739710f0954 ] This node pointer is returned by of_find_compatible_node() with refcount incremented. Calling of_node_put() to aovid the refcount leak. Fixes: d346c9e86d86 ("dpaa2-ptp: reuse ptp_qoriq driver") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220404125336.13427-1-linmq006@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c b/drivers/net= /ethernet/freescale/dpaa2/dpaa2-ptp.c index 5f5f8c53c4a0..c8cb541572ff 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c @@ -167,7 +167,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) base =3D of_iomap(node, 0); if (!base) { err =3D -ENOMEM; - goto err_close; + goto err_put; } =20 err =3D fsl_mc_allocate_irqs(mc_dev); @@ -210,6 +210,8 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) fsl_mc_free_irqs(mc_dev); err_unmap: iounmap(base); +err_put: + of_node_put(node); err_close: dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); err_free_mcp: --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1EA59C433FE for ; Tue, 12 Apr 2022 09:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352230AbiDLJN3 (ORCPT ); Tue, 12 Apr 2022 05:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358342AbiDLHl0 (ORCPT ); Tue, 12 Apr 2022 03:41:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CB271EC48; Tue, 12 Apr 2022 00:17: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 9651F6153F; Tue, 12 Apr 2022 07:17:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99AF6C385C4; Tue, 12 Apr 2022 07:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747869; bh=HROHGGsBFbO4vq3IAw5etvco6016oKrSMD4SXiABxIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVS2fAVx69/TqZEzGnhu1FgOBCYOaAIsaTn4GWSIdLG6ckpw2ho56MdoxYznXaVwy 0IsdIxFyF/nIOXh61EkLqeFeIzXZwTzYSDHVakIIfyKf3ZICisex0xbEfunXbJYdHS +osTBlI8kJ0WFl1CisO7sXMRePpsKfEQPUAqfUPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anatolii Gerasymenko , Maciej Fijalkowski , Konrad Jankowski , Alice Michael , Tony Nguyen , Paolo Abeni , Sasha Levin Subject: [PATCH 5.17 233/343] ice: Set txq_teid to ICE_INVAL_TEID on ring creation Date: Tue, 12 Apr 2022 08:30:51 +0200 Message-Id: <20220412062958.061361475@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Anatolii Gerasymenko [ Upstream commit ccfee1822042b87e5135d33cad8ea353e64612d2 ] When VF is freshly created, but not brought up, ring->txq_teid value is by default set to 0. But 0 is a valid TEID. On some platforms the Root Node of Tx scheduler has a TEID =3D 0. This can cause issues as shown below. The proper way is to set ring->txq_teid to ICE_INVAL_TEID (0xFFFFFFFF). Testing Hints: echo 1 > /sys/class/net/ens785f0/device/sriov_numvfs ip link set dev ens785f0v0 up ip link set dev ens785f0v0 down If we have freshly created VF and quickly turn it on and off, so there would be no time to reach VIRTCHNL_OP_CONFIG_VSI_QUEUES stage, then VIRTCHNL_OP_DISABLE_QUEUES stage will fail with error: [ 639.531454] disable queue 89 failed 14 [ 639.532233] Failed to disable LAN Tx queues, error: ICE_ERR_AQ_ERROR [ 639.533107] ice 0000:02:00.0: Failed to stop Tx ring 0 on VSI 5 The reason for the fail is that we are trying to send AQ command to delete queue 89, which has never been created and receive an "invalid argument" error from firmware. As this queue has never been created, it's teid and ring->txq_teid have default value 0. ice_dis_vsi_txq has a check against non-existent queues: node =3D ice_sched_find_node_by_teid(pi->root, q_teids[i]); if (!node) continue; But on some platforms the Root Node of Tx scheduler has a teid =3D 0. Hence, ice_sched_find_node_by_teid finds a node with teid =3D 0 (it is pi->root), and we go further to submit an erroneous request to firmware. Fixes: 37bb83901286 ("ice: Move common functions out of ice_main.c part 7/7= ") Signed-off-by: Anatolii Gerasymenko Reviewed-by: Maciej Fijalkowski Tested-by: Konrad Jankowski Signed-off-by: Alice Michael Signed-off-by: Tony Nguyen Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/etherne= t/intel/ice/ice_lib.c index 20d755822d43..5fd2bbeab2d1 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -1452,6 +1452,7 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi) ring->tx_tstamps =3D &pf->ptp.port.tx; ring->dev =3D dev; ring->count =3D vsi->num_tx_desc; + ring->txq_teid =3D ICE_INVAL_TEID; WRITE_ONCE(vsi->tx_rings[i], ring); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 079E1C38161 for ; Tue, 12 Apr 2022 09:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388499AbiDLJWT (ORCPT ); Tue, 12 Apr 2022 05:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358378AbiDLHla (ORCPT ); Tue, 12 Apr 2022 03:41: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 57BC24991C; Tue, 12 Apr 2022 00:17: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 EF5A1B81B58; Tue, 12 Apr 2022 07:17:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5352AC385A5; Tue, 12 Apr 2022 07:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747871; bh=dgM8Q+aXLKtjfC1k5I0vZOUMijAJe+ijlT5S4O9WlF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eOhnmg1DiuQZ9agv9/lsGViJByEtOYSCUsvhqEQjyfPsmTaAcCHQjzXG1Ei3GBY1E ZxArLu55zlOLKYDd+R1sM1QhfIXfaBz0rDACoWui0U8071LhAC0G/Hn/TehuDnxXSa DIpidGG6iiVoEoinysc78v2a1NInv6P51VFfSLRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anatolii Gerasymenko , Konrad Jankowski , Alice Michael , Tony Nguyen , Paolo Abeni , Sasha Levin Subject: [PATCH 5.17 234/343] ice: Do not skip not enabled queues in ice_vc_dis_qs_msg Date: Tue, 12 Apr 2022 08:30:52 +0200 Message-Id: <20220412062958.089838285@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Anatolii Gerasymenko [ Upstream commit 05ef6813b234db3196f083b91db3963f040b65bb ] Disable check for queue being enabled in ice_vc_dis_qs_msg, because there could be a case when queues were created, but were not enabled. We still need to delete those queues. Normal workflow for VF looks like: Enable path: VIRTCHNL_OP_ADD_ETH_ADDR (opcode 10) VIRTCHNL_OP_CONFIG_VSI_QUEUES (opcode 6) VIRTCHNL_OP_ENABLE_QUEUES (opcode 8) Disable path: VIRTCHNL_OP_DISABLE_QUEUES (opcode 9) VIRTCHNL_OP_DEL_ETH_ADDR (opcode 11) The issue appears only in stress conditions when VF is enabled and disabled very fast. Eventually there will be a case, when queues are created by VIRTCHNL_OP_CONFIG_VSI_QUEUES, but are not enabled by VIRTCHNL_OP_ENABLE_QUEUES. In turn, these queues are not deleted by VIRTCHNL_OP_DISABLE_QUEUES, because there is a check whether queues are enabled in ice_vc_dis_qs_msg. When we bring up the VF again, we will see the "Failed to set LAN Tx queue context" error during VIRTCHNL_OP_CONFIG_VSI_QUEUES step. This happens because old 16 queues were not deleted and VF requests to create 16 more, but ice_sched_get_free_qparent in ice_ena_vsi_txq would fail to find a parent node for first newly requested queue (because all nodes are allocated to 16 old queues). Testing Hints: Just enable and disable VF fast enough, so it would be disabled before reaching VIRTCHNL_OP_ENABLE_QUEUES. while true; do ip link set dev ens785f0v0 up sleep 0.065 # adjust delay value for you machine ip link set dev ens785f0v0 down done Fixes: 77ca27c41705 ("ice: add support for virtchnl_queue_select.[tx|rx]_qu= eues bitmap") Signed-off-by: Anatolii Gerasymenko Tested-by: Konrad Jankowski Signed-off-by: Alice Michael Signed-off-by: Tony Nguyen Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net= /ethernet/intel/ice/ice_virtchnl_pf.c index 1be3cd4b2bef..2bee8f10ad89 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -3351,9 +3351,9 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *m= sg) goto error_param; } =20 - /* Skip queue if not enabled */ if (!test_bit(vf_q_id, vf->txq_ena)) - continue; + dev_dbg(ice_pf_to_dev(vsi->back), "Queue %u on VSI %u is not enabled, = but stopping it anyway\n", + vf_q_id, vsi->vsi_num); =20 ice_fill_txq_meta(vsi, ring, &txq_meta); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A3B94C433EF for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385757AbiDLIwy (ORCPT ); Tue, 12 Apr 2022 04:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359053AbiDLHm1 (ORCPT ); Tue, 12 Apr 2022 03:42: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 472F254FA5; Tue, 12 Apr 2022 00:20: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 dfw.source.kernel.org (Postfix) with ESMTPS id A80A86171C; Tue, 12 Apr 2022 07:20:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD9F4C385A1; Tue, 12 Apr 2022 07:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748006; bh=et5H9Lo/I7eEZHEtzI0oQ2lysaJnffjyER3MhMUSTHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDdc2IoS9SMR5WIONiSqTEqfwmwGUgxGeuWWm4I3qtV/bGKP4z1P3N9a86KZwIsi/ cCs+xyBHqdKWicWV3a337fcsl4AdEqu7qjK2SZDphnLfoF4SpXW1DayH7rYXPDV+nN LiZMRUiZlXeh6JxVcTPrFSsNOCxYBxJZZJ+iIqwU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Pudak, Filip" , "Xiao, Jiguang" , David Ahern , Paolo Abeni , Sasha Levin , Pudak@vger.kernel.org, Xiao@vger.kernel.org Subject: [PATCH 5.17 235/343] ipv6: Fix stats accounting in ip6_pkt_drop Date: Tue, 12 Apr 2022 08:30:53 +0200 Message-Id: <20220412062958.118107935@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: David Ahern [ Upstream commit 1158f79f82d437093aeed87d57df0548bdd68146 ] VRF devices are the loopbacks for VRFs, and a loopback can not be assigned to a VRF. Accordingly, the condition in ip6_pkt_drop should be '||' not '&&'. Fixes: 1d3fd8a10bed ("vrf: Use orig netdev to count Ip6InNoRoutes and a fre= sh route lookup when sending dest unreach") Reported-by: Pudak, Filip Reported-by: Xiao, Jiguang Signed-off-by: David Ahern Link: https://lore.kernel.org/r/20220404150908.2937-1-dsahern@kernel.org Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index ea1cf414a92e..da1bf48e7937 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4495,7 +4495,7 @@ static int ip6_pkt_drop(struct sk_buff *skb, u8 code,= int ipstats_mib_noroutes) struct inet6_dev *idev; int type; =20 - if (netif_is_l3_master(skb->dev) && + if (netif_is_l3_master(skb->dev) || dst->dev =3D=3D net->loopback_dev) idev =3D __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif)= ); else --=20 2.35.1 From nobody Thu May 14 08:08:21 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 118EDC4321E for ; Tue, 12 Apr 2022 08:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385204AbiDLIvC (ORCPT ); Tue, 12 Apr 2022 04:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358497AbiDLHlp (ORCPT ); Tue, 12 Apr 2022 03:41:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CA24BB92; Tue, 12 Apr 2022 00:18: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 94E576177A; Tue, 12 Apr 2022 07:18:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A86FBC385A5; Tue, 12 Apr 2022 07:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747891; bh=tbmWW+UuZEJ29EBeqQNY5NmyN2MROCfhNUsR8kpVb/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WE7nVrQHRQYsnv1kIIGlphN95wJBE40cLnR85hxSuv1JfCwGO1g8GJyYTST3MI1eQ tM2EyHq0Y30vvxiR9SJ6UPQCvDGExTrabwpHCivQNU/QCmHNTT3NTAzjWeKtpso8KW 1OAPCMmyJWq+3tFmgvvpaS3f4ZmjvDoiMiv8PUNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , Shwetha Nagaraju , Tony Nguyen , Sasha Levin Subject: [PATCH 5.17 236/343] ice: synchronize_rcu() when terminating rings Date: Tue, 12 Apr 2022 08:30:54 +0200 Message-Id: <20220412062958.146591774@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maciej Fijalkowski [ Upstream commit f9124c68f05ffdb87a47e3ea6d5fae9dad7cb6eb ] Unfortunately, the ice driver doesn't respect the RCU critical section that XSK wakeup is surrounded with. To fix this, add synchronize_rcu() calls to paths that destroy resources that might be in use. This was addressed in other AF_XDP ZC enabled drivers, for reference see for example commit b3873a5be757 ("net/i40e: Fix concurrency issues between config flow and XSK") Fixes: efc2214b6047 ("ice: Add support for XDP") Fixes: 2d4238f55697 ("ice: Add support for AF_XDP") Signed-off-by: Maciej Fijalkowski Tested-by: Shwetha Nagaraju Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice.h | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/in= tel/ice/ice.h index 2f60230d332a..9c04a71a9fca 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -674,7 +674,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct ne= t_device *netdev) =20 static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi) { - return !!vsi->xdp_prog; + return !!READ_ONCE(vsi->xdp_prog); } =20 static inline void ice_set_ring_xdp(struct ice_tx_ring *ring) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethern= et/intel/ice/ice_main.c index 92e0fe9316b9..5229bce1a4ab 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -2742,8 +2742,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi) =20 ice_for_each_xdp_txq(vsi, i) if (vsi->xdp_rings[i]) { - if (vsi->xdp_rings[i]->desc) + if (vsi->xdp_rings[i]->desc) { + synchronize_rcu(); ice_free_tx_ring(vsi->xdp_rings[i]); + } kfree_rcu(vsi->xdp_rings[i], rcu); vsi->xdp_rings[i] =3D NULL; } diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/etherne= t/intel/ice/ice_xsk.c index feb874bde171..f95560c7387e 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 = q_idx) static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx) { ice_clean_tx_ring(vsi->tx_rings[q_idx]); - if (ice_is_xdp_ena_vsi(vsi)) + if (ice_is_xdp_ena_vsi(vsi)) { + synchronize_rcu(); ice_clean_tx_ring(vsi->xdp_rings[q_idx]); + } ice_clean_rx_ring(vsi->rx_rings[q_idx]); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 2288FC41535 for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387850AbiDLJMn (ORCPT ); Tue, 12 Apr 2022 05:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358671AbiDLHmE (ORCPT ); Tue, 12 Apr 2022 03:42:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3537353A6D; Tue, 12 Apr 2022 00:18: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 ams.source.kernel.org (Postfix) with ESMTPS id A1763B81A8F; Tue, 12 Apr 2022 07:18:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAD22C385A1; Tue, 12 Apr 2022 07:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747921; bh=3Atd2Gvf+im7M06RJKu55P5mIVJ7TeC2dVIJWeEfJFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rj0CEQok97lkvK9J55BFis/OfJUqcI28lQxWJsG/CFXJ0FvyRuIioYx6Bd4bvY/35 CEWb4YlUJ0t9AMxsuPrS/Ia9fT+duSMxDhpDwG/NvJ5pT7S53nUsVExjNjgqJmSe6p y50Tb8gtAab5XtHfAWqIv7gjjvwDZ4tJkUQFX86Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , Shwetha Nagaraju , Tony Nguyen , Sasha Levin Subject: [PATCH 5.17 237/343] ice: xsk: fix VSI state check in ice_xsk_wakeup() Date: Tue, 12 Apr 2022 08:30:55 +0200 Message-Id: <20220412062958.174625517@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maciej Fijalkowski [ Upstream commit 72b915a2b444e9247c9d424a840e94263db07c27 ] ICE_DOWN is dedicated for pf->state. Check for ICE_VSI_DOWN being set on vsi->state in ice_xsk_wakeup(). Fixes: 2d4238f55697 ("ice: Add support for AF_XDP") Signed-off-by: Maciej Fijalkowski Tested-by: Shwetha Nagaraju Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/etherne= t/intel/ice/ice_xsk.c index f95560c7387e..30620b942fa0 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -765,7 +765,7 @@ ice_xsk_wakeup(struct net_device *netdev, u32 queue_id, struct ice_vsi *vsi =3D np->vsi; struct ice_tx_ring *ring; =20 - if (test_bit(ICE_DOWN, vsi->state)) + if (test_bit(ICE_VSI_DOWN, vsi->state)) return -ENETDOWN; =20 if (!ice_is_xdp_ena_vsi(vsi)) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 A4ABBC43219 for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382170AbiDLJMG (ORCPT ); Tue, 12 Apr 2022 05:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358769AbiDLHmL (ORCPT ); Tue, 12 Apr 2022 03:42: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 02FB812ADB; Tue, 12 Apr 2022 00:19: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 8B7BBB81B62; Tue, 12 Apr 2022 07:19:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0592CC385A1; Tue, 12 Apr 2022 07:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747951; bh=xQWayGB+6f6hpATCzHMRRQ/8HztQFzBaPi4TXBjj1bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mV40kF5JrxJ39W8b0qg3mp0BK0/wQLUo02iXEuPFxlioswdT/jIZzo2Njk9dxx8vR MnI6XQW5JjSVhltKwzVX6TifCd1LrBftUB/y2FxsxqxNvxWkQhGkM1taCNvLjC2CEO yssuOQ8TX/8KXcdE0WzdXycAxiEdVCGlAo6nrOMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , Shwetha Nagaraju , Tony Nguyen , Sasha Levin Subject: [PATCH 5.17 238/343] ice: clear cmd_type_offset_bsz for TX rings Date: Tue, 12 Apr 2022 08:30:56 +0200 Message-Id: <20220412062958.203119397@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maciej Fijalkowski [ Upstream commit e19778e6c911691856447c3bf9617f00b3e1347f ] Currently when XDP rings are created, each descriptor gets its DD bit set, which turns out to be the wrong approach as it can lead to a situation where more descriptors get cleaned than it was supposed to, e.g. when AF_XDP busy poll is run with a large batch size. In this situation, the driver would request for more buffers than it is able to handle. Fix this by not setting the DD bits in ice_xdp_alloc_setup_rings(). They should be initialized to zero instead. Fixes: 9610bd988df9 ("ice: optimize XDP_TX workloads") Signed-off-by: Maciej Fijalkowski Tested-by: Shwetha Nagaraju Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethern= et/intel/ice/ice_main.c index 5229bce1a4ab..db2e02e673a7 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -2546,7 +2546,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *= vsi) spin_lock_init(&xdp_ring->tx_lock); for (j =3D 0; j < xdp_ring->count; j++) { tx_desc =3D ICE_TX_DESC(xdp_ring, j); - tx_desc->cmd_type_offset_bsz =3D cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DON= E); + tx_desc->cmd_type_offset_bsz =3D 0; } } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 65C6FC4167E for ; Tue, 12 Apr 2022 08:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385633AbiDLIwT (ORCPT ); Tue, 12 Apr 2022 04:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358960AbiDLHmW (ORCPT ); Tue, 12 Apr 2022 03:42:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E5A54BDD; Tue, 12 Apr 2022 00:19: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 ams.source.kernel.org (Postfix) with ESMTPS id EF2AAB81B66; Tue, 12 Apr 2022 07:19:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44CB7C385A5; Tue, 12 Apr 2022 07:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747981; bh=vr7Wo20zHLHWbtiSd/Y1L2t36ZxOiBHBQ+ROACpAYAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJyhQ5uv5iSsITGFYasK7pA6r2tILlebTKymbTBzdxF/0sQX8/OmpARncK2YL0h7r seT6VWdKrTsomLmEnxZKniu0PCf4lwBEQuKAKRSVFS2mf685NV3NAz7MYW2UcsMm2J pYDE9m1v5mJJkZaomPD3KOMwR/Qa0mMqDnqdh4Ww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Maximets , Aaron Conole , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 239/343] net: openvswitch: dont send internal clone attribute to the userspace. Date: Tue, 12 Apr 2022 08:30:57 +0200 Message-Id: <20220412062958.231026041@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ilya Maximets [ Upstream commit 3f2a3050b4a3e7f32fc0ea3c9b0183090ae00522 ] 'OVS_CLONE_ATTR_EXEC' is an internal attribute that is used for performance optimization inside the kernel. It's added by the kernel while parsing user-provided actions and should not be sent during the flow dump as it's not part of the uAPI. The issue doesn't cause any significant problems to the ovs-vswitchd process, because reported actions are not really used in the application lifecycle and only supposed to be shown to a human via ovs-dpctl flow dump. However, the action list is still incorrect and causes the following error if the user wants to look at the datapath flows: # ovs-dpctl add-dp system@ovs-system # ovs-dpctl add-flow "" "clone(ct(commit),0)" # ovs-dpctl dump-flows , packets:0, bytes:0, used:never, actions:clone(bad length 4, expected -1 for: action0(01 00 00 00), ct(commit),0) With the fix: # ovs-dpctl dump-flows , packets:0, bytes:0, used:never, actions:clone(ct(commit),0) Additionally fixed an incorrect attribute name in the comment. Fixes: b233504033db ("openvswitch: kernel datapath clone action") Signed-off-by: Ilya Maximets Acked-by: Aaron Conole Link: https://lore.kernel.org/r/20220404104150.2865736-1-i.maximets@ovn.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/openvswitch/actions.c | 2 +- net/openvswitch/flow_netlink.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 780d9e2246f3..8955f31fa47e 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -1051,7 +1051,7 @@ static int clone(struct datapath *dp, struct sk_buff = *skb, int rem =3D nla_len(attr); bool dont_clone_flow_key; =20 - /* The first action is always 'OVS_CLONE_ATTR_ARG'. */ + /* The first action is always 'OVS_CLONE_ATTR_EXEC'. */ clone_arg =3D nla_data(attr); dont_clone_flow_key =3D nla_get_u32(clone_arg); actions =3D nla_next(clone_arg, &rem); diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 0d677c9c2c80..2679007f8aeb 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -3429,7 +3429,9 @@ static int clone_action_to_attr(const struct nlattr *= attr, if (!start) return -EMSGSIZE; =20 - err =3D ovs_nla_put_actions(nla_data(attr), rem, skb); + /* Skipping the OVS_CLONE_ATTR_EXEC that is always the first attribute. */ + attr =3D nla_next(nla_data(attr), &rem); + err =3D ovs_nla_put_actions(attr, rem, skb); =20 if (err) nla_nest_cancel(skb, start); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4E971C41535 for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385686AbiDLIwa (ORCPT ); Tue, 12 Apr 2022 04:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359000AbiDLHmZ (ORCPT ); Tue, 12 Apr 2022 03:42:25 -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 D8E8254BEA; Tue, 12 Apr 2022 00:19: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 21260616B2; Tue, 12 Apr 2022 07:19:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3363FC385A5; Tue, 12 Apr 2022 07:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747992; bh=/MhjeC+qeq6mCrT31vIqxllJ2jeahzxHNttzVwcFrsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wxq/Fn8ZaHfFhc8Q+OqjCd0Fp10+VZv4+v9t9jp+dUuha03ZyuRw57bM/yKFmJP3N HzHd0m39Fp5rBkrPHUzmwQ4i9WJqiN2jlziDHKf8seG5v8F9N/b+wpOQnbMzSgYHaJ a3un6qG/yc7Db5m6FPRFbnQxFGx4J6ZhTWawNqNY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauri Sandberg , Thomas Walther , Andrew Lunn , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 240/343] net: ethernet: mv643xx: Fix over zealous checking of_get_mac_address() Date: Tue, 12 Apr 2022 08:30:58 +0200 Message-Id: <20220412062958.260214223@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Andrew Lunn [ Upstream commit 11f8e7c122ce013fa745029fa8c94c6db69c2e54 ] There is often not a MAC address available in an EEPROM accessible by Linux with Marvell devices. Instead the bootload has the MAC address and directly programs it into the hardware. So don't consider an error from of_get_mac_address() has fatal. However, the check was added for the case where there is a MAC address in an the EEPROM, but the EEPROM has not probed yet, and -EPROBE_DEFER is returned. In that case the error should be returned. So make the check specific to this error code. Cc: Mauri Sandberg Reported-by: Thomas Walther Fixes: 42404d8f1c01 ("net: mv643xx_eth: process retval from of_get_mac_addr= ess") Signed-off-by: Andrew Lunn Link: https://lore.kernel.org/r/20220405000404.3374734-1-andrew@lunn.ch Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ether= net/marvell/mv643xx_eth.c index 143ca8be5eb5..4008596963be 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2751,7 +2751,7 @@ static int mv643xx_eth_shared_of_add_port(struct plat= form_device *pdev, } =20 ret =3D of_get_mac_address(pnp, ppd.mac_addr); - if (ret) + if (ret =3D=3D -EPROBE_DEFER) return ret; =20 mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 5DE43C3525B for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385699AbiDLIwd (ORCPT ); Tue, 12 Apr 2022 04:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359020AbiDLHm0 (ORCPT ); Tue, 12 Apr 2022 03:42:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 307AF54F97; Tue, 12 Apr 2022 00:19: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 C79A0B81B67; Tue, 12 Apr 2022 07:19:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12AD8C385A5; Tue, 12 Apr 2022 07:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747995; bh=cK5XG9/wD9csGt9BDkyE+vq4CVXvZjL5MTLufJbB8FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gk5DMfh3UpLG0DS+TM+R3ysFaMeC1eb7xu2t+a7o8I6Qg1V3CiQM+gADGRKNoF3hK dfNtYduzTM0ywMNQMdVbGjWL4+obwdPKNF9TmBSsuiUNJ1O+VpaCQhpii1vWRRYUJw Q72CpUd4vUeo15qsLjQFSsPujpcrojnfL2bbVNpQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?St=C3=A9phane=20Graber?= , Ilya Maximets , Aaron Conole , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 241/343] net: openvswitch: fix leak of nested actions Date: Tue, 12 Apr 2022 08:30:59 +0200 Message-Id: <20220412062958.288018808@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ilya Maximets [ Upstream commit 1f30fb9166d4f15a1aa19449b9da871fe0ed4796 ] While parsing user-provided actions, openvswitch module may dynamically allocate memory and store pointers in the internal copy of the actions. So this memory has to be freed while destroying the actions. Currently there are only two such actions: ct() and set(). However, there are many actions that can hold nested lists of actions and ovs_nla_free_flow_actions() just jumps over them leaking the memory. For example, removal of the flow with the following actions will lead to a leak of the memory allocated by nf_ct_tmpl_alloc(): actions:clone(ct(commit),0) Non-freed set() action may also leak the 'dst' structure for the tunnel info including device references. Under certain conditions with a high rate of flow rotation that may cause significant memory leak problem (2MB per second in reporter's case). The problem is also hard to mitigate, because the user doesn't have direct control over the datapath flows generated by OVS. Fix that by iterating over all the nested actions and freeing everything that needs to be freed recursively. New build time assertion should protect us from this problem if new actions will be added in the future. Unfortunately, openvswitch module doesn't use NLA_F_NESTED, so all attributes has to be explicitly checked. sample() and clone() actions are mixing extra attributes into the user-provided action list. That prevents some code generalization too. Fixes: 34ae932a4036 ("openvswitch: Make tunnel set action attach a metadata= dst") Link: https://mail.openvswitch.org/pipermail/ovs-dev/2022-March/392922.html Reported-by: St=C3=A9phane Graber Signed-off-by: Ilya Maximets Acked-by: Aaron Conole Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/openvswitch/flow_netlink.c | 95 ++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 2679007f8aeb..c591b923016a 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -2288,6 +2288,62 @@ static struct sw_flow_actions *nla_alloc_flow_action= s(int size) return sfa; } =20 +static void ovs_nla_free_nested_actions(const struct nlattr *actions, int = len); + +static void ovs_nla_free_check_pkt_len_action(const struct nlattr *action) +{ + const struct nlattr *a; + int rem; + + nla_for_each_nested(a, action, rem) { + switch (nla_type(a)) { + case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL: + case OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: + ovs_nla_free_nested_actions(nla_data(a), nla_len(a)); + break; + } + } +} + +static void ovs_nla_free_clone_action(const struct nlattr *action) +{ + const struct nlattr *a =3D nla_data(action); + int rem =3D nla_len(action); + + switch (nla_type(a)) { + case OVS_CLONE_ATTR_EXEC: + /* The real list of actions follows this attribute. */ + a =3D nla_next(a, &rem); + ovs_nla_free_nested_actions(a, rem); + break; + } +} + +static void ovs_nla_free_dec_ttl_action(const struct nlattr *action) +{ + const struct nlattr *a =3D nla_data(action); + + switch (nla_type(a)) { + case OVS_DEC_TTL_ATTR_ACTION: + ovs_nla_free_nested_actions(nla_data(a), nla_len(a)); + break; + } +} + +static void ovs_nla_free_sample_action(const struct nlattr *action) +{ + const struct nlattr *a =3D nla_data(action); + int rem =3D nla_len(action); + + switch (nla_type(a)) { + case OVS_SAMPLE_ATTR_ARG: + /* The real list of actions follows this attribute. */ + a =3D nla_next(a, &rem); + ovs_nla_free_nested_actions(a, rem); + break; + } +} + static void ovs_nla_free_set_action(const struct nlattr *a) { const struct nlattr *ovs_key =3D nla_data(a); @@ -2301,25 +2357,54 @@ static void ovs_nla_free_set_action(const struct nl= attr *a) } } =20 -void ovs_nla_free_flow_actions(struct sw_flow_actions *sf_acts) +static void ovs_nla_free_nested_actions(const struct nlattr *actions, int = len) { const struct nlattr *a; int rem; =20 - if (!sf_acts) + /* Whenever new actions are added, the need to update this + * function should be considered. + */ + BUILD_BUG_ON(OVS_ACTION_ATTR_MAX !=3D 23); + + if (!actions) return; =20 - nla_for_each_attr(a, sf_acts->actions, sf_acts->actions_len, rem) { + nla_for_each_attr(a, actions, len, rem) { switch (nla_type(a)) { - case OVS_ACTION_ATTR_SET: - ovs_nla_free_set_action(a); + case OVS_ACTION_ATTR_CHECK_PKT_LEN: + ovs_nla_free_check_pkt_len_action(a); + break; + + case OVS_ACTION_ATTR_CLONE: + ovs_nla_free_clone_action(a); break; + case OVS_ACTION_ATTR_CT: ovs_ct_free_action(a); break; + + case OVS_ACTION_ATTR_DEC_TTL: + ovs_nla_free_dec_ttl_action(a); + break; + + case OVS_ACTION_ATTR_SAMPLE: + ovs_nla_free_sample_action(a); + break; + + case OVS_ACTION_ATTR_SET: + ovs_nla_free_set_action(a); + break; } } +} + +void ovs_nla_free_flow_actions(struct sw_flow_actions *sf_acts) +{ + if (!sf_acts) + return; =20 + ovs_nla_free_nested_actions(sf_acts->actions, sf_acts->actions_len); kfree(sf_acts); } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6D837C3527B for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385713AbiDLIwl (ORCPT ); Tue, 12 Apr 2022 04:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359021AbiDLHm0 (ORCPT ); Tue, 12 Apr 2022 03:42:26 -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 4275C54F9D; Tue, 12 Apr 2022 00:19: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 dfw.source.kernel.org (Postfix) with ESMTPS id B3F89617E4; Tue, 12 Apr 2022 07:19:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4794C385A5; Tue, 12 Apr 2022 07:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747998; bh=FMkKOxNXuSPaY8/85RCsgzknjKn0BHCPuz34Amk2MNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9gVH5X/HfD+2mLbwgq/D1W3hDehK21fDHJJRaKZPbPrxnfBvJEan8aMLbIs9OqTD dEGDt0tMdtPHheGd4EKb4AV9FrL1vB2k1ac6QsHkFcFaPskFIFYwph+ICn+xbyiZyH VYJH9z5VVXoQ+/kY2fjzWA+RB6rk/GAwjMvvyFJQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , David Howells , Marc Dionne , linux-afs@lists.infradead.org, syzbot , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 242/343] rxrpc: fix a race in rxrpc_exit_net() Date: Tue, 12 Apr 2022 08:31:00 +0200 Message-Id: <20220412062958.316376628@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 1946014ca3b19be9e485e780e862c375c6f98bad ] Current code can lead to the following race: CPU0 CPU1 rxrpc_exit_net() rxrpc_peer_keepalive_w= orker() if (rxnet->live) rxnet->live =3D false; del_timer_sync(&rxnet->peer_keepalive_timer); timer_reduce(&= rxnet->peer_keepalive_timer, jiffies + delay); cancel_work_sync(&rxnet->peer_keepalive_work); rxrpc_exit_net() exits while peer_keepalive_timer is still armed, leading to use-after-free. syzbot report was: ODEBUG: free active (active state 0) object type: timer_list hint: rxrpc_pe= er_keepalive_timeout+0x0/0xb0 WARNING: CPU: 0 PID: 3660 at lib/debugobjects.c:505 debug_print_object+0x16= e/0x250 lib/debugobjects.c:505 Modules linked in: CPU: 0 PID: 3660 Comm: kworker/u4:6 Not tainted 5.17.0-syzkaller-13993-g88e= 6c0207623 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 01/01/2011 Workqueue: netns cleanup_net RIP: 0010:debug_print_object+0x16e/0x250 lib/debugobjects.c:505 Code: ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 af 00 00 00 48 8b 14 dd = 00 1c 26 8a 4c 89 ee 48 c7 c7 00 10 26 8a e8 b1 e7 28 05 <0f> 0b 83 05 15 e= b c5 09 01 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e c3 RSP: 0018:ffffc9000353fb00 EFLAGS: 00010082 RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000 RDX: ffff888029196140 RSI: ffffffff815efad8 RDI: fffff520006a7f52 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff815ea4ae R11: 0000000000000000 R12: ffffffff89ce23e0 R13: ffffffff8a2614e0 R14: ffffffff816628c0 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fe1f2908924 CR3: 0000000043720000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __debug_check_no_obj_freed lib/debugobjects.c:992 [inline] debug_check_no_obj_freed+0x301/0x420 lib/debugobjects.c:1023 kfree+0xd6/0x310 mm/slab.c:3809 ops_free_list.part.0+0x119/0x370 net/core/net_namespace.c:176 ops_free_list net/core/net_namespace.c:174 [inline] cleanup_net+0x591/0xb00 net/core/net_namespace.c:598 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2e9/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298 Fixes: ace45bec6d77 ("rxrpc: Fix firewall route keepalive") Signed-off-by: Eric Dumazet Cc: David Howells Cc: Marc Dionne Cc: linux-afs@lists.infradead.org Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/rxrpc/net_ns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/rxrpc/net_ns.c b/net/rxrpc/net_ns.c index 25bbc4cc8b13..f15d6942da45 100644 --- a/net/rxrpc/net_ns.c +++ b/net/rxrpc/net_ns.c @@ -113,8 +113,8 @@ static __net_exit void rxrpc_exit_net(struct net *net) struct rxrpc_net *rxnet =3D rxrpc_net(net); =20 rxnet->live =3D false; - del_timer_sync(&rxnet->peer_keepalive_timer); cancel_work_sync(&rxnet->peer_keepalive_work); + del_timer_sync(&rxnet->peer_keepalive_timer); rxrpc_destroy_all_calls(rxnet); rxrpc_destroy_all_connections(rxnet); rxrpc_destroy_all_peers(rxnet); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 91D69C46467 for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385743AbiDLIwv (ORCPT ); Tue, 12 Apr 2022 04:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359045AbiDLHm1 (ORCPT ); Tue, 12 Apr 2022 03: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 523F254FA0; Tue, 12 Apr 2022 00:20: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 09D03B81B58; Tue, 12 Apr 2022 07:20:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 713AEC385A5; Tue, 12 Apr 2022 07:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748000; bh=kHqtdHTc+UnjdaXRk1UmTLDPTA4ePYi3R842LXAyw8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HR3niHiidBvSkCu/00XMQ0FqtPYD17pAlPBah2luinT+hby43ozDixUgQT5En6xjV D6j78qObaFsyD+EuKD35BAELQfUSDHdFyzMLqMT52v3VhTwR0gPnWvPo6kibGSH6XM mXb5oB4G9YMTMX7Zm3VUWUL6ozjlMz0Ge71mP/DA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Habets , Taehee Yoo , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 243/343] net: sfc: fix using uninitialized xdp tx_queue Date: Tue, 12 Apr 2022 08:31:01 +0200 Message-Id: <20220412062958.344893398@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 fb5833d81e4333294add35d3ac7f7f52a7bf107f ] In some cases, xdp tx_queue can get used before initialization. 1. interface up/down 2. ring buffer size change When CPU cores are lower than maximum number of channels of sfc driver, it creates new channels only for XDP. When an interface is up or ring buffer size is changed, all channels are initialized. But xdp channels are always initialized later. So, the below scenario is possible. Packets are received to rx queue of normal channels and it is acted XDP_TX and tx_queue of xdp channels get used. But these tx_queues are not initialized yet. If so, TX DMA or queue error occurs. In order to avoid this problem. 1. initializes xdp tx_queues earlier than other rx_queue in efx_start_channels(). 2. checks whether tx_queue is initialized or not in efx_xdp_tx_buffers(). Splat looks like: sfc 0000:08:00.1 enp8s0f1np1: TX queue 10 spurious TX completion id 250 sfc 0000:08:00.1 enp8s0f1np1: resetting (RECOVER_OR_ALL) sfc 0000:08:00.1 enp8s0f1np1: MC command 0x80 inlen 100 failed rc=3D-22 (raw=3D22) arg=3D789 sfc 0000:08:00.1 enp8s0f1np1: has been disabled Fixes: f28100cb9c96 ("sfc: fix lack of XDP TX queues - error XDP TX failed = (-22)") Acked-by: Martin Habets Signed-off-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/sfc/efx_channels.c | 2 +- drivers/net/ethernet/sfc/tx.c | 3 +++ drivers/net/ethernet/sfc/tx_common.c | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet= /sfc/efx_channels.c index 5e587cb853b9..40bfd0ad7d05 100644 --- a/drivers/net/ethernet/sfc/efx_channels.c +++ b/drivers/net/ethernet/sfc/efx_channels.c @@ -1118,7 +1118,7 @@ void efx_start_channels(struct efx_nic *efx) struct efx_rx_queue *rx_queue; struct efx_channel *channel; =20 - efx_for_each_channel(channel, efx) { + efx_for_each_channel_rev(channel, efx) { efx_for_each_channel_tx_queue(tx_queue, channel) { efx_init_tx_queue(tx_queue); atomic_inc(&efx->active_queues); diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c index d16e031e95f4..6983799e1c05 100644 --- a/drivers/net/ethernet/sfc/tx.c +++ b/drivers/net/ethernet/sfc/tx.c @@ -443,6 +443,9 @@ int efx_xdp_tx_buffers(struct efx_nic *efx, int n, stru= ct xdp_frame **xdpfs, if (unlikely(!tx_queue)) return -EINVAL; =20 + if (!tx_queue->initialised) + return -EINVAL; + if (efx->xdp_txq_queues_mode !=3D EFX_XDP_TX_QUEUES_DEDICATED) HARD_TX_LOCK(efx->net_dev, tx_queue->core_txq, cpu); =20 diff --git a/drivers/net/ethernet/sfc/tx_common.c b/drivers/net/ethernet/sf= c/tx_common.c index d530cde2b864..9bc8281b7f5b 100644 --- a/drivers/net/ethernet/sfc/tx_common.c +++ b/drivers/net/ethernet/sfc/tx_common.c @@ -101,6 +101,8 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue) netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev, "shutting down TX queue %d\n", tx_queue->queue); =20 + tx_queue->initialised =3D false; + if (!tx_queue->buffer) return; =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7C967C3527C for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385728AbiDLIwp (ORCPT ); Tue, 12 Apr 2022 04:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359046AbiDLHm1 (ORCPT ); Tue, 12 Apr 2022 03:42:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DCAB54FAD; Tue, 12 Apr 2022 00:20: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 08DED617E4; Tue, 12 Apr 2022 07:20:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16521C385AB; Tue, 12 Apr 2022 07:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748003; bh=Z0ywCF85g7Mq7CTMi0zgdCOMKY9zQ6PXZ9PeYzZcMC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLOOt/Qven2i7CLHf6fc9yily5fLG1AvmdSw+wKFSrvfnslLvVQewQdhRZQ6c9nZf geo762SbWzGY5zy42acTp7tlJDvM3VutEyKynykt5cIEDDjOcKChczvdSOUMlq6V03 ZFR8j7MB0ahU0DzGY5IQlJ2JyLaOrpaga/vBZW4w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Andrew Lunn , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 244/343] net: phy: mscc-miim: reject clause 45 register accesses Date: Tue, 12 Apr 2022 08:31:02 +0200 Message-Id: <20220412062958.372957379@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael Walle [ Upstream commit 8d90991e5bf7fdb9f264f5f579d18969913054b7 ] The driver doesn't support clause 45 register access yet, but doesn't check if the access is a c45 one either. This leads to spurious register reads and writes. Add the check. Fixes: 542671fe4d86 ("net: phy: mscc-miim: Add MDIO driver") Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/mdio/mdio-mscc-miim.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc= -miim.c index 64fb76c1e395..08381038810d 100644 --- a/drivers/net/mdio/mdio-mscc-miim.c +++ b/drivers/net/mdio/mdio-mscc-miim.c @@ -93,6 +93,9 @@ static int mscc_miim_read(struct mii_bus *bus, int mii_id= , int regnum) u32 val; int ret; =20 + if (regnum & MII_ADDR_C45) + return -EOPNOTSUPP; + ret =3D mscc_miim_wait_pending(bus); if (ret) goto out; @@ -136,6 +139,9 @@ static int mscc_miim_write(struct mii_bus *bus, int mii= _id, struct mscc_miim_dev *miim =3D bus->priv; int ret; =20 + if (regnum & MII_ADDR_C45) + return -EOPNOTSUPP; + ret =3D mscc_miim_wait_pending(bus); if (ret < 0) goto out; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 99233C3527D for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387979AbiDLJNM (ORCPT ); Tue, 12 Apr 2022 05:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358553AbiDLHlu (ORCPT ); Tue, 12 Apr 2022 03:41:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2CE04BFDD; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id 70BAB61045; Tue, 12 Apr 2022 07:18:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E18FC385A5; Tue, 12 Apr 2022 07:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747893; bh=i5BIcfcYpCg3Y6S5c7jozCvKFHpDHhIAbFcbVRIPcpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PYVG8/PoYWR9JcoIMrktga0c+dagPQEgVYGEUBKww25+QKzXGve8PMr+uem0QzonA NzGHU8YxdiYhMhkPAADVirSA6O5AN/UY40mQyt2OBz7bDL6mylDZDmtfu0HZYxJB+8 AyMhwDwiqGSoCJ7FEy+ArZhz1+2QVFLgAK3Jf/EA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jamie Bainbridge , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 245/343] qede: confirm skb is allocated before using Date: Tue, 12 Apr 2022 08:31:03 +0200 Message-Id: <20220412062958.400945692@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jamie Bainbridge [ Upstream commit 4e910dbe36508654a896d5735b318c0b88172570 ] qede_build_skb() assumes build_skb() always works and goes straight to skb_reserve(). However, build_skb() can fail under memory pressure. This results in a kernel panic because the skb to reserve is NULL. Add a check in case build_skb() failed to allocate and return NULL. The NULL return is handled correctly in callers to qede_build_skb(). Fixes: 8a8633978b842 ("qede: Add build_skb() support.") Signed-off-by: Jamie Bainbridge Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/qlogic/qede/qede_fp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qede/qede_fp.c b/drivers/net/ether= net/qlogic/qede/qede_fp.c index b242000a77fd..b7cc36589f59 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_fp.c +++ b/drivers/net/ethernet/qlogic/qede/qede_fp.c @@ -748,6 +748,9 @@ qede_build_skb(struct qede_rx_queue *rxq, buf =3D page_address(bd->data) + bd->page_offset; skb =3D build_skb(buf, rxq->rx_buf_seg_size); =20 + if (unlikely(!skb)) + return NULL; + skb_reserve(skb, pad); skb_put(skb, len); =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7918AC3527C for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387928AbiDLJNF (ORCPT ); Tue, 12 Apr 2022 05:13:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358564AbiDLHlv (ORCPT ); Tue, 12 Apr 2022 03:41: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 F210B4BBB6; Tue, 12 Apr 2022 00:18: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 3F39F61708; Tue, 12 Apr 2022 07:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51F4AC385A5; Tue, 12 Apr 2022 07:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747896; bh=hoDrUOXChRUU6znUjkqcIZ+kWF9ROLrwh5I7FneBeKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dR1OAuk7SCrnFI5lu+F3sCxldZI54oB3TnsLCrPiK1vtLLqzgbwKnClkerN4SVIUU IIlUWO6wc1EJNdn2NnDsueOIHwV54GUmGfCh0dB4S2nKB/U1/VpQaIxElXm/ISgZ2l KXUMaVoQCoSWLT68nGLD3BSdTMJxGgb6pVOmOCCE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Dasu , Florian Fainelli , Mark Brown , Sasha Levin Subject: [PATCH 5.17 246/343] spi: bcm-qspi: fix MSPI only access with bcm_qspi_exec_mem_op() Date: Tue, 12 Apr 2022 08:31:04 +0200 Message-Id: <20220412062958.428975605@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kamal Dasu [ Upstream commit 2c7d1b281286c46049cd22b43435cecba560edde ] This fixes case where MSPI controller is used to access spi-nor flash and BSPI block is not present. Fixes: 5f195ee7d830 ("spi: bcm-qspi: Implement the spi_mem interface") Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Link: https://lore.kernel.org/r/20220328142442.7553-1-kdasu.kdev@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/spi/spi-bcm-qspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c index 86c76211b3d3..cad2d55dcd3d 100644 --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -1205,7 +1205,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, addr =3D op->addr.val; len =3D op->data.nbytes; =20 - if (bcm_qspi_bspi_ver_three(qspi) =3D=3D true) { + if (has_bspi(qspi) && bcm_qspi_bspi_ver_three(qspi) =3D=3D true) { /* * The address coming into this function is a raw flash offset. * But for BSPI <=3D V3, we need to convert it to a remapped BSPI @@ -1224,7 +1224,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, len < 4) mspi_read =3D true; =20 - if (mspi_read) + if (!has_bspi(qspi) || mspi_read) return bcm_qspi_mspi_exec_mem_op(spi, op); =20 ret =3D bcm_qspi_bspi_set_mode(qspi, op, 0); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 89BD9C4707A for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387964AbiDLJNJ (ORCPT ); Tue, 12 Apr 2022 05:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358579AbiDLHlv (ORCPT ); Tue, 12 Apr 2022 03:41: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 A3DD5532E3; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id 1561B61708; Tue, 12 Apr 2022 07:18:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CF80C385A1; Tue, 12 Apr 2022 07:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747899; bh=s/VkCHlAXjk7aA+uMA2YC/pT3rsyhNvVzzrg1lAIMno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dqWbQBqA3uhZGYz4QQYY2BERC7hgGBLdg0zdgCijYUHEnWa6duyPULGOpn47CDW7b dIlK6WnETCSVr3pzHhJesC+Wcfi+tcpLQw/I5OdJtUshpqkVS57eRXpWY6SHKMIuLp 3Pg8QYW/OBpCpRCp6AgaWlLj4+5o4GY+ydzl3f7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jun Lei , Jasdeep Dhillon , Meenakshikumar Somasundaram , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 247/343] drm/amd/display: Fix for dmub outbox notification enable Date: Tue, 12 Apr 2022 08:31:05 +0200 Message-Id: <20220412062958.457750663@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Meenakshikumar Somasundaram [ Upstream commit ed7208706448953c6f15009cf139135776c15713 ] [Why] Currently driver enables dmub outbox notification before oubox ISR is registered. During boot scenario, sometimes dmub issues hpd outbox message before driver registers ISR and those messages are missed. [How] Enable dmub outbox notification after outbox ISR is registered. Also, restructured outbox enable code to call from dm layer and renamed APIs. Reviewed-by: Jun Lei Acked-by: Jasdeep Dhillon Signed-off-by: Meenakshikumar Somasundaram Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/dc/core/dc.c | 66 +++++++++++++++++-- drivers/gpu/drm/amd/display/dc/dc.h | 3 + .../gpu/drm/amd/display/dc/dce/dmub_outbox.c | 25 +++---- .../gpu/drm/amd/display/dc/dce/dmub_outbox.h | 4 +- .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 4 -- .../drm/amd/display/dc/dcn31/dcn31_hwseq.c | 2 +- 6 files changed, 80 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd= /display/dc/core/dc.c index ba1aa994db4b..62bc6ce88753 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -76,6 +76,8 @@ =20 #include "dc_trace.h" =20 +#include "dce/dmub_outbox.h" + #define CTX \ dc->ctx =20 @@ -3707,13 +3709,23 @@ void dc_hardware_release(struct dc *dc) } #endif =20 -/** - * dc_enable_dmub_notifications - Returns whether dmub notification can be= enabled - * @dc: dc structure +/* + *************************************************************************= **** + * Function: dc_is_dmub_outbox_supported - + *=20 + * @brief=20 + * Checks whether DMUB FW supports outbox notifications, if supported + * DM should register outbox interrupt prior to actually enabling interru= pts + * via dc_enable_dmub_outbox * - * Returns: True to enable dmub notifications, False otherwise + * @param + * [in] dc: dc structure + * + * @return + * True if DMUB FW supports outbox notifications, False otherwise + *************************************************************************= **** */ -bool dc_enable_dmub_notifications(struct dc *dc) +bool dc_is_dmub_outbox_supported(struct dc *dc) { #if defined(CONFIG_DRM_AMD_DC_DCN) /* YELLOW_CARP B0 USB4 DPIA needs dmub notifications for interrupts */ @@ -3728,6 +3740,48 @@ bool dc_enable_dmub_notifications(struct dc *dc) =20 /** * dc_process_dmub_aux_transfer_async - Submits aux command to dmub via in= box message + * Function: dc_enable_dmub_notifications + * + * @brief + * Calls dc_is_dmub_outbox_supported to check if dmub fw supports outbox + * notifications. All DMs shall switch to dc_is_dmub_outbox_supported. + * This API shall be removed after switching. + * + * @param + * [in] dc: dc structure + * + * @return + * True if DMUB FW supports outbox notifications, False otherwise + *************************************************************************= **** + */ +bool dc_enable_dmub_notifications(struct dc *dc) +{ + return dc_is_dmub_outbox_supported(dc); +} + +/** + *************************************************************************= **** + * Function: dc_enable_dmub_outbox + * + * @brief + * Enables DMUB unsolicited notifications to x86 via outbox + * + * @param + * [in] dc: dc structure + * + * @return + * None + *************************************************************************= **** + */ +void dc_enable_dmub_outbox(struct dc *dc) +{ + struct dc_context *dc_ctx =3D dc->ctx; + + dmub_enable_outbox_notification(dc_ctx->dmub_srv); +} + +/** + *************************************************************************= **** * Sets port index appropriately for = legacy DDC * @dc: dc structure * @link_index: link index @@ -3829,7 +3883,7 @@ uint8_t get_link_index_from_dpia_port_index(const str= uct dc *dc, * [in] payload: aux payload * [out] notify: set_config immediate reply * - * @return + * @return * True if successful, False if failure *************************************************************************= **** */ diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/disp= lay/dc/dc.h index b51864890621..6a8c100a3688 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -1448,8 +1448,11 @@ void dc_z10_restore(const struct dc *dc); void dc_z10_save_init(struct dc *dc); #endif =20 +bool dc_is_dmub_outbox_supported(struct dc *dc); bool dc_enable_dmub_notifications(struct dc *dc); =20 +void dc_enable_dmub_outbox(struct dc *dc); + bool dc_process_dmub_aux_transfer_async(struct dc *dc, uint32_t link_index, struct aux_payload *payload); diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.c b/drivers/gpu= /drm/amd/display/dc/dce/dmub_outbox.c index faad8555ddbb..fff1d07d865d 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.c @@ -22,20 +22,23 @@ * Authors: AMD */ =20 -#include "dmub_outbox.h" +#include "dc.h" #include "dc_dmub_srv.h" +#include "dmub_outbox.h" #include "dmub/inc/dmub_cmd.h" =20 -/** - * dmub_enable_outbox_notification - Sends inbox cmd to dmub to enable ou= tbox1 - * messages with interrupt. Dmub sends = outbox1 - * message and triggers outbox1 interru= pt. - * @dc: dc structure +/* + * Function: dmub_enable_outbox_notification + * + * @brief + * Sends inbox cmd to dmub for enabling outbox notifications to x86. + * + * @param + * [in] dmub_srv: dmub_srv structure */ -void dmub_enable_outbox_notification(struct dc *dc) +void dmub_enable_outbox_notification(struct dc_dmub_srv *dmub_srv) { union dmub_rb_cmd cmd; - struct dc_context *dc_ctx =3D dc->ctx; =20 memset(&cmd, 0x0, sizeof(cmd)); cmd.outbox1_enable.header.type =3D DMUB_CMD__OUTBOX1_ENABLE; @@ -45,7 +48,7 @@ void dmub_enable_outbox_notification(struct dc *dc) sizeof(cmd.outbox1_enable.header); cmd.outbox1_enable.enable =3D true; =20 - dc_dmub_srv_cmd_queue(dc_ctx->dmub_srv, &cmd); - dc_dmub_srv_cmd_execute(dc_ctx->dmub_srv); - dc_dmub_srv_wait_idle(dc_ctx->dmub_srv); + dc_dmub_srv_cmd_queue(dmub_srv, &cmd); + dc_dmub_srv_cmd_execute(dmub_srv); + dc_dmub_srv_wait_idle(dmub_srv); } diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.h b/drivers/gpu= /drm/amd/display/dc/dce/dmub_outbox.h index 4e0aa0d1a2d5..58ceabb9d497 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.h @@ -26,8 +26,8 @@ #ifndef _DMUB_OUTBOX_H_ #define _DMUB_OUTBOX_H_ =20 -#include "dc.h" +struct dc_dmub_srv; =20 -void dmub_enable_outbox_notification(struct dc *dc); +void dmub_enable_outbox_notification(struct dc_dmub_srv *dmub_srv); =20 #endif /* _DMUB_OUTBOX_H_ */ diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/dr= ivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 530a72e3eefe..636e2d90ff93 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -1500,10 +1500,6 @@ void dcn10_init_hw(struct dc *dc) hws->funcs.dsc_pg_control(hws, res_pool->dscs[i]->inst, false); } =20 - /* Enable outbox notification feature of dmub */ - if (dc->debug.enable_dmub_aux_for_legacy_ddc) - dmub_enable_outbox_notification(dc); - /* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot) dc_link_blank_all_dp_displays(dc); diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c b/drivers/g= pu/drm/amd/display/dc/dcn31/dcn31_hwseq.c index 4206ce5bf9a9..1e156f398065 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c +++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_hwseq.c @@ -194,7 +194,7 @@ void dcn31_init_hw(struct dc *dc) =20 /* Enables outbox notifications for usb4 dpia */ if (dc->res_pool->usb4_dpia_count) - dmub_enable_outbox_notification(dc); + dmub_enable_outbox_notification(dc->ctx->dmub_srv); =20 /* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 3BDF3C4167D for ; Tue, 12 Apr 2022 08:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385247AbiDLIvK (ORCPT ); Tue, 12 Apr 2022 04:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358598AbiDLHlw (ORCPT ); Tue, 12 Apr 2022 03:41:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F06153702; Tue, 12 Apr 2022 00:18: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 78F8BB81B4F; Tue, 12 Apr 2022 07:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E24EFC385A1; Tue, 12 Apr 2022 07:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747902; bh=SpYTWM87dLN5pE3JWM5u1XNsO9uj74qw3Rk8zGXWkc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6uSb+IaQwXDmG8eg3PLUTDyQZF7VV+3U3AHSPKdjXWqsSP4ghOQXHAEbtzg5sQpe RwfvYxxhFfiZ7KeLuo8zZlMNw4lp6gQ2ojupLD/ZbQfjg3JnMeII5HRsYNd9qJUfsQ 539b/AhT+UZvUbRq5XXT6MGGf+CF1KhRrXhuTyak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anthony Koo , Eric Yang , Alex Hung , Roman Li , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 248/343] drm/amd/display: Remove redundant dsc power gating from init_hw Date: Tue, 12 Apr 2022 08:31:06 +0200 Message-Id: <20220412062958.485919743@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Roman Li [ Upstream commit 95707203407c4cf0b7e520a99d6f46d8aed4b57f ] [Why] DSC Power down code has been moved from dcn31_init_hw into init_pipes() Need to remove it from dcn10_init_hw() as well to avoid duplicated action on dcn1.x/2.x [How] Remove DSC power down code from dcn10_init_hw() Fixes: 8fa6f4c5715c ("drm/amd/display: fixed the DSC power off sequence dur= ing Driver PnP") Reviewed-by: Anthony Koo Reviewed-by: Eric Yang Acked-by: Alex Hung Signed-off-by: Roman Li Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/dr= ivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 636e2d90ff93..2cefdd96d0cb 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -1493,13 +1493,6 @@ void dcn10_init_hw(struct dc *dc) link->link_status.link_active =3D true; } =20 - /* Power gate DSCs */ - if (!is_optimized_init_done) { - for (i =3D 0; i < res_pool->res_cap->num_dsc; i++) - if (hws->funcs.dsc_pg_control !=3D NULL) - hws->funcs.dsc_pg_control(hws, res_pool->dscs[i]->inst, false); - } - /* we want to turn off all dp displays before doing detection */ if (dc->config.power_down_display_on_boot) dc_link_blank_all_dp_displays(dc); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 5314DC4167B for ; Tue, 12 Apr 2022 08:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385268AbiDLIvO (ORCPT ); Tue, 12 Apr 2022 04:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358608AbiDLHlz (ORCPT ); Tue, 12 Apr 2022 03:41:55 -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 CF9285370C; Tue, 12 Apr 2022 00:18: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 494A3B81B60; Tue, 12 Apr 2022 07:18:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB803C385A5; Tue, 12 Apr 2022 07:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747905; bh=bo5oyi2RDSbh9N7tonWPZ/m9IiFZzZv7VtlZ2TBZVPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQFmoGxYPP8G0gMEfDZLfyPShvl+CwZmLhRj5SHx5T1dJ7FXq4xn38OMbx91jpGGV TxC7OE1i3GOwo7TKBg9YX5y/BHXjK0F+jZgDFAVcu1UeWbhD3zDQrrIOCNhLsTMlCX 7C+3KBIwWt+wrJsJMw6ejX+tWLH396VdD0cDKSOY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Alexei Starovoitov , Tariq Toukan , Arthur Fabre , Sasha Levin Subject: [PATCH 5.17 249/343] bpf: Support dual-stack sockets in bpf_tcp_check_syncookie Date: Tue, 12 Apr 2022 08:31:07 +0200 Message-Id: <20220412062958.514317893@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Maxim Mikityanskiy [ Upstream commit 2e8702cc0cfa1080f29fd64003c00a3e24ac38de ] bpf_tcp_gen_syncookie looks at the IP version in the IP header and validates the address family of the socket. It supports IPv4 packets in AF_INET6 dual-stack sockets. On the other hand, bpf_tcp_check_syncookie looks only at the address family of the socket, ignoring the real IP version in headers, and validates only the packet size. This implementation has some drawbacks: 1. Packets are not validated properly, allowing a BPF program to trick bpf_tcp_check_syncookie into handling an IPv6 packet on an IPv4 socket. 2. Dual-stack sockets fail the checks on IPv4 packets. IPv4 clients end up receiving a SYNACK with the cookie, but the following ACK gets dropped. This patch fixes these issues by changing the checks in bpf_tcp_check_syncookie to match the ones in bpf_tcp_gen_syncookie. IP version from the header is taken into account, and it is validated properly with address family. Fixes: 399040847084 ("bpf: add helper to check for a valid SYN cookie") Signed-off-by: Maxim Mikityanskiy Signed-off-by: Alexei Starovoitov Reviewed-by: Tariq Toukan Acked-by: Arthur Fabre Link: https://lore.kernel.org/bpf/20220406124113.2795730-1-maximmi@nvidia.c= om Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/core/filter.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 82fcb7533663..48fc95626597 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -6777,24 +6777,33 @@ BPF_CALL_5(bpf_tcp_check_syncookie, struct sock *, = sk, void *, iph, u32, iph_len if (!th->ack || th->rst || th->syn) return -ENOENT; =20 + if (unlikely(iph_len < sizeof(struct iphdr))) + return -EINVAL; + if (tcp_synq_no_recent_overflow(sk)) return -ENOENT; =20 cookie =3D ntohl(th->ack_seq) - 1; =20 - switch (sk->sk_family) { - case AF_INET: - if (unlikely(iph_len < sizeof(struct iphdr))) + /* Both struct iphdr and struct ipv6hdr have the version field at the + * same offset so we can cast to the shorter header (struct iphdr). + */ + switch (((struct iphdr *)iph)->version) { + case 4: + if (sk->sk_family =3D=3D AF_INET6 && ipv6_only_sock(sk)) return -EINVAL; =20 ret =3D __cookie_v4_check((struct iphdr *)iph, th, cookie); break; =20 #if IS_BUILTIN(CONFIG_IPV6) - case AF_INET6: + case 6: if (unlikely(iph_len < sizeof(struct ipv6hdr))) return -EINVAL; =20 + if (sk->sk_family !=3D AF_INET6) + return -EINVAL; + ret =3D __cookie_v6_check((struct ipv6hdr *)iph, th, cookie); break; #endif /* CONFIG_IPV6 */ --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7D934C3525B for ; Tue, 12 Apr 2022 08:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385305AbiDLIv2 (ORCPT ); Tue, 12 Apr 2022 04:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358636AbiDLHmB (ORCPT ); Tue, 12 Apr 2022 03:42: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 9C79F53724; Tue, 12 Apr 2022 00:18:30 -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 35108B81B4F; Tue, 12 Apr 2022 07:18:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85B33C385A5; Tue, 12 Apr 2022 07:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747907; bh=DEMBXOgecxcJKBREFwgHPEO8T6xegsgMsPu7IOlG4mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1az3S2kF+dy5kFIdPicE+91Ix7teOXF1r9dtxl3/lrlRUp3ldWtcxbxE2ZXnweuk RaWShcP/zoJIdf8x1T5UAJafJc6Z0KerY75ANbhjEDa3CK5l8tiPwGzkEt9RzQrftb sLhnid03kheyPjA27gFDM6ZwwuHLfzCAvkBwjbx4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , Jens Axboe , Sasha Levin Subject: [PATCH 5.17 250/343] drbd: Fix five use after free bugs in get_initial_state Date: Tue, 12 Apr 2022 08:31:08 +0200 Message-Id: <20220412062958.542936532@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Lv Yunlong [ Upstream commit aadb22ba2f656581b2f733deb3a467c48cc618f6 ] In get_initial_state, it calls notify_initial_state_done(skb,..) if cb->args[5]=3D=3D1. If genlmsg_put() failed in notify_initial_state_done(), the skb will be freed by nlmsg_free(skb). Then get_initial_state will goto out and the freed skb will be used by return value skb->len, which is a uaf bug. What's worse, the same problem goes even further: skb can also be freed in the notify_*_state_change -> notify_*_state calls below. Thus 4 additional uaf bugs happened. My patch lets the problem callee functions: notify_initial_state_done and notify_*_state_change return an error code if errors happen. So that the error codes could be propagated and the uaf bugs can be avoid. v2 reports a compilation warning. This v3 fixed this warning and built successfully in my local environment with no additional warnings. v2: https://lore.kernel.org/patchwork/patch/1435218/ Fixes: a29728463b254 ("drbd: Backport the "events2" command") Signed-off-by: Lv Yunlong Reviewed-by: Christoph B=C3=B6hmwalder Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/block/drbd/drbd_int.h | 8 ++--- drivers/block/drbd/drbd_nl.c | 41 ++++++++++++++++---------- drivers/block/drbd/drbd_state.c | 18 +++++------ drivers/block/drbd/drbd_state_change.h | 8 ++--- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index f27d5b0f9a0b..a98bfcf4a5f0 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -1642,22 +1642,22 @@ struct sib_info { }; void drbd_bcast_event(struct drbd_device *device, const struct sib_info *s= ib); =20 -extern void notify_resource_state(struct sk_buff *, +extern int notify_resource_state(struct sk_buff *, unsigned int, struct drbd_resource *, struct resource_info *, enum drbd_notification_type); -extern void notify_device_state(struct sk_buff *, +extern int notify_device_state(struct sk_buff *, unsigned int, struct drbd_device *, struct device_info *, enum drbd_notification_type); -extern void notify_connection_state(struct sk_buff *, +extern int notify_connection_state(struct sk_buff *, unsigned int, struct drbd_connection *, struct connection_info *, enum drbd_notification_type); -extern void notify_peer_device_state(struct sk_buff *, +extern int notify_peer_device_state(struct sk_buff *, unsigned int, struct drbd_peer_device *, struct peer_device_info *, diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 44ccf8b4f4b2..69184cf17b6a 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -4617,7 +4617,7 @@ static int nla_put_notification_header(struct sk_buff= *msg, return drbd_notification_header_to_skb(msg, &nh, true); } =20 -void notify_resource_state(struct sk_buff *skb, +int notify_resource_state(struct sk_buff *skb, unsigned int seq, struct drbd_resource *resource, struct resource_info *resource_info, @@ -4659,16 +4659,17 @@ void notify_resource_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(resource, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 -void notify_device_state(struct sk_buff *skb, +int notify_device_state(struct sk_buff *skb, unsigned int seq, struct drbd_device *device, struct device_info *device_info, @@ -4708,16 +4709,17 @@ void notify_device_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(device, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 -void notify_connection_state(struct sk_buff *skb, +int notify_connection_state(struct sk_buff *skb, unsigned int seq, struct drbd_connection *connection, struct connection_info *connection_info, @@ -4757,16 +4759,17 @@ void notify_connection_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 -void notify_peer_device_state(struct sk_buff *skb, +int notify_peer_device_state(struct sk_buff *skb, unsigned int seq, struct drbd_peer_device *peer_device, struct peer_device_info *peer_device_info, @@ -4807,13 +4810,14 @@ void notify_peer_device_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(peer_device, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 void notify_helper(enum drbd_notification_type type, @@ -4864,7 +4868,7 @@ void notify_helper(enum drbd_notification_type type, err, seq); } =20 -static void notify_initial_state_done(struct sk_buff *skb, unsigned int se= q) +static int notify_initial_state_done(struct sk_buff *skb, unsigned int seq) { struct drbd_genlmsghdr *dh; int err; @@ -4878,11 +4882,12 @@ static void notify_initial_state_done(struct sk_buf= f *skb, unsigned int seq) if (nla_put_notification_header(skb, NOTIFY_EXISTS)) goto nla_put_failure; genlmsg_end(skb, dh); - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); pr_err("Error %d sending event. Event seq:%u\n", err, seq); + return err; } =20 static void free_state_changes(struct list_head *list) @@ -4909,6 +4914,7 @@ static int get_initial_state(struct sk_buff *skb, str= uct netlink_callback *cb) unsigned int seq =3D cb->args[2]; unsigned int n; enum drbd_notification_type flags =3D 0; + int err =3D 0; =20 /* There is no need for taking notification_mutex here: it doesn't matter if the initial state events mix with later state chage @@ -4917,32 +4923,32 @@ static int get_initial_state(struct sk_buff *skb, s= truct netlink_callback *cb) =20 cb->args[5]--; if (cb->args[5] =3D=3D 1) { - notify_initial_state_done(skb, seq); + err =3D notify_initial_state_done(skb, seq); goto out; } n =3D cb->args[4]++; if (cb->args[4] < cb->args[3]) flags |=3D NOTIFY_CONTINUES; if (n < 1) { - notify_resource_state_change(skb, seq, state_change->resource, + err =3D notify_resource_state_change(skb, seq, state_change->resource, NOTIFY_EXISTS | flags); goto next; } n--; if (n < state_change->n_connections) { - notify_connection_state_change(skb, seq, &state_change->connections[n], + err =3D notify_connection_state_change(skb, seq, &state_change->connecti= ons[n], NOTIFY_EXISTS | flags); goto next; } n -=3D state_change->n_connections; if (n < state_change->n_devices) { - notify_device_state_change(skb, seq, &state_change->devices[n], + err =3D notify_device_state_change(skb, seq, &state_change->devices[n], NOTIFY_EXISTS | flags); goto next; } n -=3D state_change->n_devices; if (n < state_change->n_devices * state_change->n_connections) { - notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n], + err =3D notify_peer_device_state_change(skb, seq, &state_change->peer_de= vices[n], NOTIFY_EXISTS | flags); goto next; } @@ -4957,7 +4963,10 @@ static int get_initial_state(struct sk_buff *skb, st= ruct netlink_callback *cb) cb->args[4] =3D 0; } out: - return skb->len; + if (err) + return err; + else + return skb->len; } =20 int drbd_adm_get_initial_state(struct sk_buff *skb, struct netlink_callbac= k *cb) diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_stat= e.c index b8a27818ab3f..4ee11aef6672 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -1537,7 +1537,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *de= vice, return rv; } =20 -void notify_resource_state_change(struct sk_buff *skb, +int notify_resource_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_resource_state_change *resource_state_change, enum drbd_notification_type type) @@ -1550,10 +1550,10 @@ void notify_resource_state_change(struct sk_buff *s= kb, .res_susp_fen =3D resource_state_change->susp_fen[NEW], }; =20 - notify_resource_state(skb, seq, resource, &resource_info, type); + return notify_resource_state(skb, seq, resource, &resource_info, type); } =20 -void notify_connection_state_change(struct sk_buff *skb, +int notify_connection_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_connection_state_change *connection_state_change, enum drbd_notification_type type) @@ -1564,10 +1564,10 @@ void notify_connection_state_change(struct sk_buff = *skb, .conn_role =3D connection_state_change->peer_role[NEW], }; =20 - notify_connection_state(skb, seq, connection, &connection_info, type); + return notify_connection_state(skb, seq, connection, &connection_info, ty= pe); } =20 -void notify_device_state_change(struct sk_buff *skb, +int notify_device_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_device_state_change *device_state_change, enum drbd_notification_type type) @@ -1577,10 +1577,10 @@ void notify_device_state_change(struct sk_buff *skb, .dev_disk_state =3D device_state_change->disk_state[NEW], }; =20 - notify_device_state(skb, seq, device, &device_info, type); + return notify_device_state(skb, seq, device, &device_info, type); } =20 -void notify_peer_device_state_change(struct sk_buff *skb, +int notify_peer_device_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_peer_device_state_change *p, enum drbd_notification_type type) @@ -1594,7 +1594,7 @@ void notify_peer_device_state_change(struct sk_buff *= skb, .peer_resync_susp_dependency =3D p->resync_susp_dependency[NEW], }; =20 - notify_peer_device_state(skb, seq, peer_device, &peer_device_info, type); + return notify_peer_device_state(skb, seq, peer_device, &peer_device_info,= type); } =20 static void broadcast_state_change(struct drbd_state_change *state_change) @@ -1602,7 +1602,7 @@ static void broadcast_state_change(struct drbd_state_= change *state_change) struct drbd_resource_state_change *resource_state_change =3D &state_chang= e->resource[0]; bool resource_state_has_changed; unsigned int n_device, n_connection, n_peer_device, n_peer_devices; - void (*last_func)(struct sk_buff *, unsigned int, void *, + int (*last_func)(struct sk_buff *, unsigned int, void *, enum drbd_notification_type) =3D NULL; void *last_arg =3D NULL; =20 diff --git a/drivers/block/drbd/drbd_state_change.h b/drivers/block/drbd/dr= bd_state_change.h index ba80f612d6ab..d5b0479bc9a6 100644 --- a/drivers/block/drbd/drbd_state_change.h +++ b/drivers/block/drbd/drbd_state_change.h @@ -44,19 +44,19 @@ extern struct drbd_state_change *remember_old_state(str= uct drbd_resource *, gfp_ extern void copy_old_to_new_state_change(struct drbd_state_change *); extern void forget_state_change(struct drbd_state_change *); =20 -extern void notify_resource_state_change(struct sk_buff *, +extern int notify_resource_state_change(struct sk_buff *, unsigned int, struct drbd_resource_state_change *, enum drbd_notification_type type); -extern void notify_connection_state_change(struct sk_buff *, +extern int notify_connection_state_change(struct sk_buff *, unsigned int, struct drbd_connection_state_change *, enum drbd_notification_type type); -extern void notify_device_state_change(struct sk_buff *, +extern int notify_device_state_change(struct sk_buff *, unsigned int, struct drbd_device_state_change *, enum drbd_notification_type type); -extern void notify_peer_device_state_change(struct sk_buff *, +extern int notify_peer_device_state_change(struct sk_buff *, unsigned int, struct drbd_peer_device_state_change *, enum drbd_notification_type type); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 687B0C4167E for ; Tue, 12 Apr 2022 08:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385283AbiDLIvT (ORCPT ); Tue, 12 Apr 2022 04:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358637AbiDLHmB (ORCPT ); Tue, 12 Apr 2022 03:42:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F04F53704; Tue, 12 Apr 2022 00:18: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 E1A2CB81B66; Tue, 12 Apr 2022 07:18:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41D6AC385A1; Tue, 12 Apr 2022 07:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747910; bh=osjarx+aiGxIzXmnAxBf/CsL3YFC+xZ9Y+B6Ql7gG4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sM5F4KhbWPC3JycjozRgsEYjo9Ylh3GvRTGgJH6Xsqqdb0Q0spHw8tQ60sl+uF+Z1 ZHMV3f3RiNn3a3NXTGU7bI7Ke0+PM58U1bYnPJuWlpQdsIVw1kBJ0tbFHkdC+FStW+ QaqcJhcfbWDaupcppEIWbPDA4S1lwO7FpMWFJD9g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Christoph Hellwig , Damien Le Moal , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 251/343] scsi: sd: sd_read_cpr() requires VPD pages Date: Tue, 12 Apr 2022 08:31:09 +0200 Message-Id: <20220412062958.571302292@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Martin K. Petersen [ Upstream commit 1700714b1ff252b634db21186db4d91e7e006043 ] As such it should be called inside the scsi_device_supports_vpd() conditional. Link: https://lore.kernel.org/r/20220302053559.32147-13-martin.petersen@ora= cle.com Fixes: e815d36548f0 ("scsi: sd: add concurrent positioning ranges support") Cc: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 66056806159a..8b5d2a4076c2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3320,6 +3320,7 @@ static int sd_revalidate_disk(struct gendisk *disk) sd_read_block_limits(sdkp); sd_read_block_characteristics(sdkp); sd_zbc_read_zones(sdkp, buffer); + sd_read_cpr(sdkp); } =20 sd_print_capacity(sdkp, old_capacity); @@ -3329,7 +3330,6 @@ static int sd_revalidate_disk(struct gendisk *disk) sd_read_app_tag_own(sdkp, buffer); sd_read_write_same(sdkp, buffer); sd_read_security(sdkp, buffer); - sd_read_cpr(sdkp); } =20 /* --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6D330C433FE for ; Tue, 12 Apr 2022 08:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385336AbiDLIvd (ORCPT ); Tue, 12 Apr 2022 04:51:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358638AbiDLHmB (ORCPT ); Tue, 12 Apr 2022 03:42:01 -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 566FB53718; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id D896D6153F; Tue, 12 Apr 2022 07:18:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E401AC385A1; Tue, 12 Apr 2022 07:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747913; bh=n98lA43wKBdGXVA3oyELJbScFNNwEk6KqYd/TBIVAmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tl2Q1WmICp/BzE3p8F2TH7nbt681uA3cyZ2MCtHS7qMDXy2Q4g0TO5D0qtUQHZWhC iFNEr0533tuXGjXau3xY0P/hTPKlxJgCeUpa3YiYESGoduBJ4VlU4Nrx/z1PVKnjAZ F/I/OtZXiOmupCw2YX2TGrkTZ9SQbdb+tOfaDgnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daejun Park , Xiaomeng Tong , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.17 252/343] scsi: ufs: ufshpb: Fix a NULL check on list iterator Date: Tue, 12 Apr 2022 08:31:10 +0200 Message-Id: <20220412062958.599553703@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiaomeng Tong [ Upstream commit bfb7789bcbd901caead43861461bc8f334c90d3b ] The list iterator is always non-NULL so the check 'if (!rgn)' is always false and the dev_err() is never called. Move the check outside the loop and determine if 'victim_rgn' is NULL, to fix this bug. Link: https://lore.kernel.org/r/20220320150733.21824-1-xiam0nd.tong@gmail.c= om Fixes: 4b5f49079c52 ("scsi: ufs: ufshpb: L2P map management for HPB read") Reviewed-by: Daejun Park Signed-off-by: Xiaomeng Tong Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/ufs/ufshpb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 2d36a0715fca..b34feba1f53d 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -869,12 +869,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(st= ruct ufshpb_lu *hpb) struct ufshpb_region *rgn, *victim_rgn =3D NULL; =20 list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) { - if (!rgn) { - dev_err(&hpb->sdev_ufs_lu->sdev_dev, - "%s: no region allocated\n", - __func__); - return NULL; - } if (ufshpb_check_srgns_issue_state(hpb, rgn)) continue; =20 @@ -890,6 +884,11 @@ static struct ufshpb_region *ufshpb_victim_lru_info(st= ruct ufshpb_lu *hpb) break; } =20 + if (!victim_rgn) + dev_err(&hpb->sdev_ufs_lu->sdev_dev, + "%s: no region allocated\n", + __func__); + return victim_rgn; } =20 --=20 2.35.1 From nobody Thu May 14 08:08:21 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 7D7AEC433EF for ; Tue, 12 Apr 2022 08:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385403AbiDLIvj (ORCPT ); Tue, 12 Apr 2022 04:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358643AbiDLHmD (ORCPT ); Tue, 12 Apr 2022 03:42:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2818C5372A; Tue, 12 Apr 2022 00:18: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 7D1FF616B2; Tue, 12 Apr 2022 07:18:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B1E6C385A1; Tue, 12 Apr 2022 07:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747915; bh=fUkDqFots+8XTufGAH2Tv2H/Ed8VwBcOzlIJyBmT3h0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ko8EwjhpQoigA9L/Eq1Kku3W7sxVy+HI6hZhr4KrpeUKnip0gBC4OP4ozzyCa9+E6 LrFCiQqO+Rd2yaLYUZjpR/07prDC/dypxLGFVr9ooyw+7Wnw5HzhdlVAP/hzWALdjv 27NE/uEBTzbUcEBDuC5XQWVU4suh9n8KF+LSKHu4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.17 253/343] io_uring: nospec index for tags on files update Date: Tue, 12 Apr 2022 08:31:11 +0200 Message-Id: <20220412062958.627766853@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pavel Begunkov [ Upstream commit 34bb77184123ae401100a4d156584f12fa630e5c ] Don't forget to array_index_nospec() for indexes before updating rsrc tags in __io_sqe_files_update(), just use already safe and precalculated index @i. Fixes: c3bdad0271834 ("io_uring: add generic rsrc update with tags") Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 5e6788ab188f..a3e82aececd9 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8700,7 +8700,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *= ctx, err =3D -EBADF; break; } - *io_get_tag_slot(data, up->offset + done) =3D tag; + *io_get_tag_slot(data, i) =3D tag; io_fixed_file_set(file_slot, file); err =3D io_sqe_file_register(ctx, file, i); if (err) { --=20 2.35.1 From nobody Thu May 14 08:08:21 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 6331FC46467 for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387903AbiDLJNC (ORCPT ); Tue, 12 Apr 2022 05:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358647AbiDLHmE (ORCPT ); Tue, 12 Apr 2022 03:42:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91C453A4A; Tue, 12 Apr 2022 00:18: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 257CE61708; Tue, 12 Apr 2022 07:18:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32D71C385A5; Tue, 12 Apr 2022 07:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747918; bh=6xwYJlK+nsxFLkpLA0QodmOLGRUu6popvkIzHN2JRYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0aIN1pNbKGN63D3YZ/+DJyklV2B+eLjFJACRnT3NYJbmXMCbDTtxHBxmQz6GJUyWT i0ELdvX61/MjJirGZeaNhQ8evs31ojRpvor/ZEHks7D3+3oWl3uGfFmXiVewrv4bjE uQEM1aYXynr2fb/J44XSFtwPHhbDnpEZjh0xZVDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.17 254/343] io_uring: dont touch scm_fp_list after queueing skb Date: Tue, 12 Apr 2022 08:31:12 +0200 Message-Id: <20220412062958.660802076@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pavel Begunkov [ Upstream commit a07211e3001435fe8591b992464cd8d5e3c98c5a ] It's safer to not touch scm_fp_list after we queued an skb to which it was assigned, there might be races lurking if we screw subtle sync guarantees on the io_uring side. Fixes: 6b06314c47e14 ("io_uring: add file set registration") Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index a3e82aececd9..0ee1d8903ffe 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8237,8 +8237,12 @@ static int __io_sqe_files_scm(struct io_ring_ctx *ct= x, int nr, int offset) refcount_add(skb->truesize, &sk->sk_wmem_alloc); skb_queue_head(&sk->sk_receive_queue, skb); =20 - for (i =3D 0; i < nr_files; i++) - fput(fpl->fp[i]); + for (i =3D 0; i < nr; i++) { + struct file *file =3D io_file_from_index(ctx, i + offset); + + if (file) + fput(file); + } } else { kfree_skb(skb); free_uid(fpl->user); --=20 2.35.1 From nobody Thu May 14 08:08:21 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 38B93C3525B for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387870AbiDLJMt (ORCPT ); Tue, 12 Apr 2022 05:12:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358675AbiDLHmE (ORCPT ); Tue, 12 Apr 2022 03:42:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4237853A73; Tue, 12 Apr 2022 00:18: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 A5E6A616B2; Tue, 12 Apr 2022 07:18:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2EE6C385A5; Tue, 12 Apr 2022 07:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747924; bh=9vXVE7hBRTZaQD7r+RaOOhVUqQdP69FtVpG2CWo9kbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IhI/B69bQqGiYEeEjYLY6tPPVChS3bYLc8+Vg/P/Osny8S9DO9XpyjCtHqPKMweTH TkqMhvsU8CQZ2SuvW3e7gDv4LYXZs2gvPMjWZ9EA0RdimwKiR5cvmK/L1YjMmT+Ff9 5LYJWP5uF4j7uIs32Lp9g2/Vkw+qEZpPyEO2xlYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 255/343] SUNRPC: Handle ENOMEM in call_transmit_status() Date: Tue, 12 Apr 2022 08:31:13 +0200 Message-Id: <20220412062958.688896689@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit d3c15033b240767d0287f1c4a529cbbe2d5ded8a ] Both call_transmit() and call_bc_transmit() can now return ENOMEM, so let's make sure that we handle the errors gracefully. Fixes: 0472e4766049 ("SUNRPC: Convert socket page send code to use iov_iter= ()") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sunrpc/clnt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b36d235d2d6d..bf1fd6caaf92 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2197,6 +2197,7 @@ call_transmit_status(struct rpc_task *task) * socket just returned a connection error, * then hold onto the transport lock. */ + case -ENOMEM: case -ENOBUFS: rpc_delay(task, HZ>>2); fallthrough; @@ -2280,6 +2281,7 @@ call_bc_transmit_status(struct rpc_task *task) case -ENOTCONN: case -EPIPE: break; + case -ENOMEM: case -ENOBUFS: rpc_delay(task, HZ>>2); fallthrough; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 4E733C3527B for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387884AbiDLJM4 (ORCPT ); Tue, 12 Apr 2022 05:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358685AbiDLHmE (ORCPT ); Tue, 12 Apr 2022 03:42:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF9C53A78; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id 7D16A6177A; Tue, 12 Apr 2022 07:18:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87581C385AB; Tue, 12 Apr 2022 07:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747926; bh=5JSIA/Lvh8ph+aTBot7Q4dH+1Hwb/0nwpJ+yIcQqTJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XVxztg9UYQwNbyKZQcjFaGR+g73vGdwAGHcJC5JsPFTpREMVgczm9D/uRttYKjka5 f/BDD/VJagAxlj9d3ldjEeOOXS+OvGFR1R1J225rU+ydkW82TkTBQqvS5lxGvscXbs nJA30ue/+NH/codpbk2can6FiNfTjlJdG9HMsmxs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 256/343] SUNRPC: Handle low memory situations in call_status() Date: Tue, 12 Apr 2022 08:31:14 +0200 Message-Id: <20220412062958.716975511@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit 9d82819d5b065348ce623f196bf601028e22ed00 ] We need to handle ENFILE, ENOBUFS, and ENOMEM, because xprt_wake_pending_tasks() can be called with any one of these due to socket creation failures. Fixes: b61d59fffd3e ("SUNRPC:=C2=A0xs_tcp_connect_worker{4,6}: merge common= code") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sunrpc/clnt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index bf1fd6caaf92..0222ad4523a9 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2364,6 +2364,11 @@ call_status(struct rpc_task *task) case -EPIPE: case -EAGAIN: break; + case -ENFILE: + case -ENOBUFS: + case -ENOMEM: + rpc_delay(task, HZ>>2); + break; case -EIO: /* shutdown or soft timeout */ goto out_exit; --=20 2.35.1 From nobody Thu May 14 08:08:21 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 9C990C433FE for ; Tue, 12 Apr 2022 08:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385440AbiDLIvo (ORCPT ); Tue, 12 Apr 2022 04:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358690AbiDLHmE (ORCPT ); Tue, 12 Apr 2022 03:42:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D86C53B56; Tue, 12 Apr 2022 00:18: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 322476153F; Tue, 12 Apr 2022 07:18:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EE99C385A1; Tue, 12 Apr 2022 07:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747929; bh=4kHxTx+nZTZet0xhrBn9ebOlglwAHA+XhrKvmS0m9VA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1vbl5brjWZ0QczEkCqMHTTHrK5z2RJ1MjbgUFU4wm1U0v3qRVkh5JR6sqRKL8Vjw Ftv3Qu+CA1Sc00zksv+bZysF5OzKlMRPI+PNYfme24bYTizzmPBxWVPgaVW9oAhJeA 17bK/MgpEfEL1rf6gnF0sMeItRZuc/K/ppAbgdFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.17 257/343] SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec() Date: Tue, 12 Apr 2022 08:31:15 +0200 Message-Id: <20220412062958.745358500@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust [ Upstream commit b056fa070814897be32d83b079dbc311375588e7 ] The allocation is done with GFP_KERNEL, but it could still fail in a low memory situation. Fixes: 4a85a6a3320b ("SUNRPC: Handle TCP socket sends with kernel_sendpage(= ) again") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/sunrpc/svcsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 478f857cdaed..6ea3d87e1147 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1096,7 +1096,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struc= t xdr_buf *xdr, int ret; =20 *sentp =3D 0; - xdr_alloc_bvec(xdr, GFP_KERNEL); + ret =3D xdr_alloc_bvec(xdr, GFP_KERNEL); + if (ret < 0) + return ret; =20 ret =3D kernel_sendmsg(sock, &msg, &rm, 1, rm.iov_len); if (ret < 0) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 BE358C433F5 for ; Tue, 12 Apr 2022 08:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385453AbiDLIvs (ORCPT ); Tue, 12 Apr 2022 04:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358703AbiDLHmF (ORCPT ); Tue, 12 Apr 2022 03:42: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 4D5F353B62; Tue, 12 Apr 2022 00:18: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 CF24A6171C; Tue, 12 Apr 2022 07:18:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E078CC385A1; Tue, 12 Apr 2022 07:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747932; bh=OlZDwkLIrhSfs14hQ3b6bvoPaxN1iOD12TvNEMCVr08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MiDp91WUTsXho3Y0Am6kBht2GngfCEsGpGAvgD8WEnkY+BnXMvGDXxopr3s55ZkMP Gxu1sdbuXKdXtIDPu+FMiDkLxV1rctfBsTb/1LgXaFFHEyKr7UPwTq51ZbLokEzq0P QDEEUJ2my9/A/pogA46yQsSedldwt3X2Y9Gc/7mE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Drew Fustini , Lu Baolu , Suman Anna , Jason Gunthorpe , Tony Lindgren , Jason Gunthorpe , Joerg Roedel , Sasha Levin Subject: [PATCH 5.17 258/343] iommu/omap: Fix regression in probe for NULL pointer dereference Date: Tue, 12 Apr 2022 08:31:16 +0200 Message-Id: <20220412062958.773402653@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 [ Upstream commit 71ff461c3f41f6465434b9e980c01782763e7ad8 ] Commit 3f6634d997db ("iommu: Use right way to retrieve iommu_ops") started triggering a NULL pointer dereference for some omap variants: __iommu_probe_device from probe_iommu_group+0x2c/0x38 probe_iommu_group from bus_for_each_dev+0x74/0xbc bus_for_each_dev from bus_iommu_probe+0x34/0x2e8 bus_iommu_probe from bus_set_iommu+0x80/0xc8 bus_set_iommu from omap_iommu_init+0x88/0xcc omap_iommu_init from do_one_initcall+0x44/0x24 This is caused by omap iommu probe returning 0 instead of ERR_PTR(-ENODEV) as noted by Jason Gunthorpe . Looks like the regression already happened with an earlier commit 6785eb9105e3 ("iommu/omap: Convert to probe/release_device() call-backs") that changed the function return type and missed converting one place. Cc: Drew Fustini Cc: Lu Baolu Cc: Suman Anna Suggested-by: Jason Gunthorpe Fixes: 6785eb9105e3 ("iommu/omap: Convert to probe/release_device() call-ba= cks") Fixes: 3f6634d997db ("iommu: Use right way to retrieve iommu_ops") Signed-off-by: Tony Lindgren Tested-by: Drew Fustini Reviewed-by: Jason Gunthorpe Link: https://lore.kernel.org/r/20220331062301.24269-1-tony@atomide.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/iommu/omap-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 980e4af3f06b..d2e82a1b56d8 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1661,7 +1661,7 @@ static struct iommu_device *omap_iommu_probe_device(s= truct device *dev) num_iommus =3D of_property_count_elems_of_size(dev->of_node, "iommus", sizeof(phandle)); if (num_iommus < 0) - return 0; + return ERR_PTR(-ENODEV); =20 arch_data =3D kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL); if (!arch_data) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 1352EC4167D for ; Tue, 12 Apr 2022 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387836AbiDLJMj (ORCPT ); Tue, 12 Apr 2022 05:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358716AbiDLHmF (ORCPT ); Tue, 12 Apr 2022 03:42:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F171953B76; Tue, 12 Apr 2022 00:18: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 dfw.source.kernel.org (Postfix) with ESMTPS id 87BD86177C; Tue, 12 Apr 2022 07:18:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67C28C385A6; Tue, 12 Apr 2022 07:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747934; bh=NfCabbv+0+SdWxdiKzNvGN6aMUjVfEGF9MvN+oyWnoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsQlJ7e9vgYkMvYkSdAByUlmmNNhp+rZnCdRKiLax1A4hQ1lRCOuFl5/Ph7WzJzI0 gbJHt8mmOHAlCstrupFvya3znbkRvGR5Qwfvj2gGTmb0VmeE1HoH8kdiWlBv5DEWrU fb+5ZTh6gn+T7xEQBUGqIv3t5D2MtjOrDjIVj1Qc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , James Clark , Alexander Shishkin , Alexandre Truong , German Gomez , Jiri Olsa , Mark Rutland , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.17 259/343] perf unwind: Dont show unwind error messages when augmenting frame pointer stack Date: Tue, 12 Apr 2022 08:31:17 +0200 Message-Id: <20220412062958.802234700@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: James Clark [ Upstream commit fa7095c5c3240bb2ecbc77f8b69be9b1d9e2cf60 ] Commit Fixes: b9f6fbb3b2c29736 ("perf arm64: Inject missing frames when using 'perf record --call-graph=3Dfp'") intended to add a 'best effort' DWARF unwind that improved the frame pointer stack in most scenarios. It's expected that the unwind will fail sometimes, but this shouldn't be reported as an error. It only works when the return address can be determined from the contents of the link register alone. Fix the error shown when the unwinder requires extra registers by adding a new flag that suppresses error messages. This flag is not set in the normal --call-graph=3Ddwarf unwind mode so that behavior is not changed. Fixes: b9f6fbb3b2c29736 ("perf arm64: Inject missing frames when using 'per= f record --call-graph=3Dfp'") Reported-by: John Garry Signed-off-by: James Clark Tested-by: John Garry Cc: Alexander Shishkin Cc: Alexandre Truong Cc: German Gomez Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Link: https://lore.kernel.org/r/20220406145651.1392529-1-james.clark@arm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/perf/tests/dwarf-unwind.c | 2 +- .../perf/util/arm64-frame-pointer-unwind-support.c | 2 +- tools/perf/util/machine.c | 2 +- tools/perf/util/unwind-libdw.c | 10 +++++++--- tools/perf/util/unwind-libdw.h | 1 + tools/perf/util/unwind-libunwind-local.c | 10 +++++++--- tools/perf/util/unwind-libunwind.c | 6 ++++-- tools/perf/util/unwind.h | 13 ++++++++++--- 8 files changed, 32 insertions(+), 14 deletions(-) diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwin= d.c index 2dab2d262060..afdca7f2959f 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -122,7 +122,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__= thread(struct thread *thr } =20 err =3D unwind__get_entries(unwind_entry, &cnt, thread, - &sample, MAX_STACK); + &sample, MAX_STACK, false); if (err) pr_debug("unwind failed\n"); else if (cnt !=3D MAX_STACK) { diff --git a/tools/perf/util/arm64-frame-pointer-unwind-support.c b/tools/p= erf/util/arm64-frame-pointer-unwind-support.c index 2242a885fbd7..4940be4a0569 100644 --- a/tools/perf/util/arm64-frame-pointer-unwind-support.c +++ b/tools/perf/util/arm64-frame-pointer-unwind-support.c @@ -53,7 +53,7 @@ u64 get_leaf_frame_caller_aarch64(struct perf_sample *sam= ple, struct thread *thr sample->user_regs.cache_regs[PERF_REG_ARM64_SP] =3D 0; } =20 - ret =3D unwind__get_entries(add_entry, &entries, thread, sample, 2); + ret =3D unwind__get_entries(add_entry, &entries, thread, sample, 2, true); sample->user_regs =3D old_regs; =20 if (ret || entries.length !=3D 2) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 394550003693..564abe17a0bd 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2983,7 +2983,7 @@ static int thread__resolve_callchain_unwind(struct th= read *thread, return 0; =20 return unwind__get_entries(unwind_entry, cursor, - thread, sample, max_stack); + thread, sample, max_stack, false); } =20 int thread__resolve_callchain(struct thread *thread, diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index a74b517f7497..94aa40f6e348 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -200,7 +200,8 @@ frame_callback(Dwfl_Frame *state, void *arg) bool isactivation; =20 if (!dwfl_frame_pc(state, &pc, NULL)) { - pr_err("%s", dwfl_errmsg(-1)); + if (!ui->best_effort) + pr_err("%s", dwfl_errmsg(-1)); return DWARF_CB_ABORT; } =20 @@ -208,7 +209,8 @@ frame_callback(Dwfl_Frame *state, void *arg) report_module(pc, ui); =20 if (!dwfl_frame_pc(state, &pc, &isactivation)) { - pr_err("%s", dwfl_errmsg(-1)); + if (!ui->best_effort) + pr_err("%s", dwfl_errmsg(-1)); return DWARF_CB_ABORT; } =20 @@ -222,7 +224,8 @@ frame_callback(Dwfl_Frame *state, void *arg) int unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct thread *thread, struct perf_sample *data, - int max_stack) + int max_stack, + bool best_effort) { struct unwind_info *ui, ui_buf =3D { .sample =3D data, @@ -231,6 +234,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, .cb =3D cb, .arg =3D arg, .max_stack =3D max_stack, + .best_effort =3D best_effort }; Dwarf_Word ip; int err =3D -EINVAL, i; diff --git a/tools/perf/util/unwind-libdw.h b/tools/perf/util/unwind-libdw.h index 0cbd2650e280..8c88bc4f2304 100644 --- a/tools/perf/util/unwind-libdw.h +++ b/tools/perf/util/unwind-libdw.h @@ -20,6 +20,7 @@ struct unwind_info { void *arg; int max_stack; int idx; + bool best_effort; struct unwind_entry entries[]; }; =20 diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unw= ind-libunwind-local.c index 71a353349181..41e29fc7648a 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -96,6 +96,7 @@ struct unwind_info { struct perf_sample *sample; struct machine *machine; struct thread *thread; + bool best_effort; }; =20 #define dw_read(ptr, type, end) ({ \ @@ -553,7 +554,8 @@ static int access_reg(unw_addr_space_t __maybe_unused a= s, =20 ret =3D perf_reg_value(&val, &ui->sample->user_regs, id); if (ret) { - pr_err("unwind: can't read reg %d\n", regnum); + if (!ui->best_effort) + pr_err("unwind: can't read reg %d\n", regnum); return ret; } =20 @@ -666,7 +668,7 @@ static int get_entries(struct unwind_info *ui, unwind_e= ntry_cb_t cb, return -1; =20 ret =3D unw_init_remote(&c, addr_space, ui); - if (ret) + if (ret && !ui->best_effort) display_error(ret); =20 while (!ret && (unw_step(&c) > 0) && i < max_stack) { @@ -704,12 +706,14 @@ static int get_entries(struct unwind_info *ui, unwind= _entry_cb_t cb, =20 static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct thread *thread, - struct perf_sample *data, int max_stack) + struct perf_sample *data, int max_stack, + bool best_effort) { struct unwind_info ui =3D { .sample =3D data, .thread =3D thread, .machine =3D thread->maps->machine, + .best_effort =3D best_effort }; =20 if (!data->user_regs.regs) diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-li= bunwind.c index e89a5479b361..509c287ee762 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c @@ -80,9 +80,11 @@ void unwind__finish_access(struct maps *maps) =20 int unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct thread *thread, - struct perf_sample *data, int max_stack) + struct perf_sample *data, int max_stack, + bool best_effort) { if (thread->maps->unwind_libunwind_ops) - return thread->maps->unwind_libunwind_ops->get_entries(cb, arg, thread, = data, max_stack); + return thread->maps->unwind_libunwind_ops->get_entries(cb, arg, thread, = data, + max_stack, best_effort); return 0; } diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h index ab8ad469c8de..b2a03fa5289b 100644 --- a/tools/perf/util/unwind.h +++ b/tools/perf/util/unwind.h @@ -23,13 +23,19 @@ struct unwind_libunwind_ops { void (*finish_access)(struct maps *maps); int (*get_entries)(unwind_entry_cb_t cb, void *arg, struct thread *thread, - struct perf_sample *data, int max_stack); + struct perf_sample *data, int max_stack, bool best_effort); }; =20 #ifdef HAVE_DWARF_UNWIND_SUPPORT +/* + * When best_effort is set, don't report errors and fail silently. This co= uld + * be expanded in the future to be more permissive about things other than + * error messages. + */ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct thread *thread, - struct perf_sample *data, int max_stack); + struct perf_sample *data, int max_stack, + bool best_effort); /* libunwind specific */ #ifdef HAVE_LIBUNWIND_SUPPORT #ifndef LIBUNWIND__ARCH_REG_ID @@ -65,7 +71,8 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, void *arg __maybe_unused, struct thread *thread __maybe_unused, struct perf_sample *data __maybe_unused, - int max_stack __maybe_unused) + int max_stack __maybe_unused, + bool best_effort __maybe_unused) { return 0; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 F1E6EC4167E for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387823AbiDLJMc (ORCPT ); Tue, 12 Apr 2022 05:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358729AbiDLHmJ (ORCPT ); Tue, 12 Apr 2022 03:42: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 6EBCC53E0D; Tue, 12 Apr 2022 00:19: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 103C3B81B4F; Tue, 12 Apr 2022 07:18:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4021EC385A1; Tue, 12 Apr 2022 07:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747937; bh=48IJ3esSaUzBji8rEvxkx01bcGDqcGgwVzYB+0ZPDAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dg7GivnYSgf1nx4h3tRubJfXC0G2Pqq1FozZe8EFOIHKL/QSGEJ3izl0Lv79h2BzX MhDLQ+WLbByFmXnIdGQ1Gj78bryoPdMX6w78rbbOW3tWcO5wrGN4cnGE8Z5oxNuokX 19zuO42QT+a1NkSGkbYYX4NfNW15BVm6VSBK7lbY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Clark , Leo Yan , Namhyung Kim , Alexander Shishkin , German Gomez , Jiri Olsa , John Garry , linux-arm-kernel@lists.infradead.org, Mark Rutland , Mathieu Poirier , Ravi Bangoria , Will Deacon , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.17 260/343] perf: arm-spe: Fix perf report --mem-mode Date: Tue, 12 Apr 2022 08:31:18 +0200 Message-Id: <20220412062958.830168914@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: James Clark [ Upstream commit ffab487052054162b3b6c9c6005777ec6cfcea05 ] Since commit bb30acae4c4dacfa ("perf report: Bail out --mem-mode if mem info is not available") "perf mem report" and "perf report --mem-mode" don't allow opening the file unless one of the events has PERF_SAMPLE_DATA_SRC set. SPE doesn't have this set even though synthetic memory data is generated after it is decoded. Fix this issue by setting DATA_SRC on SPE events. This has no effect on the data collected because the SPE driver doesn't do anything with that flag and doesn't generate samples. Fixes: bb30acae4c4dacfa ("perf report: Bail out --mem-mode if mem info is n= ot available") Signed-off-by: James Clark Tested-by: Leo Yan Acked-by: Namhyung Kim Cc: Alexander Shishkin Cc: German Gomez Cc: Jiri Olsa Cc: John Garry Cc: Leo Yan Cc: linux-arm-kernel@lists.infradead.org Cc: Mark Rutland Cc: Mathieu Poirier Cc: Ravi Bangoria Cc: Will Deacon Link: https://lore.kernel.org/r/20220408144056.1955535-1-james.clark@arm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/perf/arch/arm64/util/arm-spe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/u= til/arm-spe.c index 2100d46ccf5e..bb4ab99afa7f 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -239,6 +239,12 @@ static int arm_spe_recording_options(struct auxtrace_r= ecord *itr, arm_spe_set_timestamp(itr, arm_spe_evsel); } =20 + /* + * Set this only so that perf report knows that SPE generates memory info= . It has no effect + * on the opening of the event or the SPE data produced. + */ + evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); + /* Add dummy event to keep tracking */ err =3D parse_events(evlist, "dummy:u", NULL); if (err) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 DC12CC4321E for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384850AbiDLJM3 (ORCPT ); Tue, 12 Apr 2022 05:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358730AbiDLHmJ (ORCPT ); Tue, 12 Apr 2022 03:42:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83C8E23A; Tue, 12 Apr 2022 00:19: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 dfw.source.kernel.org (Postfix) with ESMTPS id 1FD5D616E7; Tue, 12 Apr 2022 07:19:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3142CC385A1; Tue, 12 Apr 2022 07:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747940; bh=hlP2sze5FnxNqcBlA5c2Y8VQGE+NWL4VnSSqf3dvcBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFN3hEfTjhQXMUUd+ZDid3P2ZWtq74u59JqQ3U6GrRDxAi8AI6VRFaQpn39/mguWz 5TwMKGyMfpV3Y6IURdWvbH1w1EjrJwcGnH+Zazm0OdCKEy2d2blOyixHguY3Q0fpEJ GuNQyLB3v+SEbJbQTJ8b/ihy6tV3DSYFuCfJU4rY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.17 261/343] perf tools: Fix perfs libperf_print callback Date: Tue, 12 Apr 2022 08:31:19 +0200 Message-Id: <20220412062958.858571132@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 aeee9dc53ce405d2161f9915f553114e94e5b677 ] eprintf() does not expect va_list as the type of the 4th parameter. Use veprintf() because it does. Signed-off-by: Adrian Hunter Fixes: 428dab813a56ce94 ("libperf: Merge libperf_set_print() into libperf_i= nit()") Cc: Jiri Olsa Link: https://lore.kernel.org/r/20220408132625.2451452-1-adrian.hunter@inte= l.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/perf/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 2f6b67189b42..6aae7b6c376b 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -434,7 +434,7 @@ void pthread__unblock_sigwinch(void) static int libperf_print(enum libperf_print_level level, const char *fmt, va_list ap) { - return eprintf(level, verbose, fmt, ap); + return veprintf(level, verbose, fmt, ap); } =20 int main(int argc, const char **argv) --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CD257C4332F for ; Tue, 12 Apr 2022 08:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385468AbiDLIvx (ORCPT ); Tue, 12 Apr 2022 04:51:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358746AbiDLHmK (ORCPT ); Tue, 12 Apr 2022 03:42:10 -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 2A97EBFA; Tue, 12 Apr 2022 00:19: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 C75E06178D; Tue, 12 Apr 2022 07:19:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D498EC385A1; Tue, 12 Apr 2022 07:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747943; bh=2jdeLQ93hezcJuVqD+oM3RT2cCSavnSxmemMyJ13KnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNPNGVDs2yoVXn0CKd2i7FAWoBZGtCcc4un/fBqWmKDy8mkW1NkjfXHPjxXc5uuZv Z9ABW76gISixNGaA/+mewUJ1LyGkED6n+yqoGcTxXJSJTB8bFFTBVbOzDXDtwqCHaW 9XJmDCWSjTV1h5D0u/UK/ZfmWtafkY9ioXMc4poI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Clark , Denis Nikitin , Jiri Olsa , Alexander Shishkin , Alexey Budankov , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.17 262/343] perf session: Remap buf if there is no space for event Date: Tue, 12 Apr 2022 08:31:20 +0200 Message-Id: <20220412062958.886965492@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Denis Nikitin [ Upstream commit bc21e74d4775f883ae1f542c1f1dc7205b15d925 ] If a perf event doesn't fit into remaining buffer space return NULL to remap buf and fetch the event again. Keep the logic to error out on inadequate input from fuzzing. This fixes perf failing on ChromeOS (with 32b userspace): $ perf report -v -i perf.data ... prefetch_event: head=3D0x1fffff8 event->header_size=3D0x30, mmap_size=3D0= x2000000: fuzzed or compressed perf.data? Error: failed to process sample Fixes: 57fc032ad643ffd0 ("perf session: Avoid infinite loop when seeing inv= alid header.size") Reviewed-by: James Clark Signed-off-by: Denis Nikitin Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Namhyung Kim Link: https://lore.kernel.org/r/20220330031130.2152327-1-denik@chromium.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/perf/util/session.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 498b05708db5..245dc70d1882 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2084,6 +2084,7 @@ prefetch_event(char *buf, u64 head, size_t mmap_size, bool needs_swap, union perf_event *error) { union perf_event *event; + u16 event_size; =20 /* * Ensure we have enough space remaining to read @@ -2096,15 +2097,23 @@ prefetch_event(char *buf, u64 head, size_t mmap_siz= e, if (needs_swap) perf_event_header__bswap(&event->header); =20 - if (head + event->header.size <=3D mmap_size) + event_size =3D event->header.size; + if (head + event_size <=3D mmap_size) return event; =20 /* We're not fetching the event so swap back again */ if (needs_swap) perf_event_header__bswap(&event->header); =20 - pr_debug("%s: head=3D%#" PRIx64 " event->header_size=3D%#x, mmap_size=3D%= #zx:" - " fuzzed or compressed perf.data?\n",__func__, head, event->header.size= , mmap_size); + /* Check if the event fits into the next mmapped buf. */ + if (event_size <=3D mmap_size - head % page_size) { + /* Remap buf and fetch again. */ + return NULL; + } + + /* Invalid input. Event size should never exceed mmap_size. */ + pr_debug("%s: head=3D%#" PRIx64 " event->header.size=3D%#x, mmap_size=3D%= #zx:" + " fuzzed or compressed perf.data?\n", __func__, head, event_size, mmap_= size); =20 return error; } --=20 2.35.1 From nobody Thu May 14 08:08:21 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 CC9CFC4167B for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383866AbiDLJMT (ORCPT ); Tue, 12 Apr 2022 05:12:19 -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 S1358757AbiDLHmK (ORCPT ); Tue, 12 Apr 2022 03:42:10 -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 D63971004; Tue, 12 Apr 2022 00:19: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 2BB22B81B62; Tue, 12 Apr 2022 07:19:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C510C385A1; Tue, 12 Apr 2022 07:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747945; bh=8Vq4tCwQN/t2nUnt+x188nmWSw9x8VrD9CrYBjvJx5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EllwIk88S2tzYP0mvuzecSTRPV/nFrJZAXnRCT77IC+L1R4UozfaNSkuRN4eqf20q f8mgPctz+yA8ra68dqJP5OOIx+L5mK1da76fjWGYna6PmvgSbP4pnBqbozRw3fj5m7 OsqP8qUL0BogUCMXMiCKvWH/i/xn0h9dnjscY3w4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , Mark Rutland , Will Deacon , James Morse , Chanho Park Subject: [PATCH 5.17 263/343] arm64: Add part number for Arm Cortex-A78AE Date: Tue, 12 Apr 2022 08:31:21 +0200 Message-Id: <20220412062958.915706060@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Chanho Park commit 83bea32ac7ed37bbda58733de61fc9369513f9f9 upstream. Add the MIDR part number info for the Arm Cortex-A78AE[1] and add it to spectre-BHB affected list[2]. [1]: https://developer.arm.com/Processors/Cortex-A78AE [2]: https://developer.arm.com/Arm%20Security%20Center/Spectre-BHB Cc: Catalin Marinas Cc: Mark Rutland Cc: Will Deacon Cc: James Morse Signed-off-by: Chanho Park Link: https://lore.kernel.org/r/20220407091128.8700-1-chanho61.park@samsung= .com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/arm64/include/asm/cputype.h | 2 ++ arch/arm64/kernel/proton-pack.c | 1 + 2 files changed, 3 insertions(+) --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -75,6 +75,7 @@ #define ARM_CPU_PART_CORTEX_A77 0xD0D #define ARM_CPU_PART_NEOVERSE_V1 0xD40 #define ARM_CPU_PART_CORTEX_A78 0xD41 +#define ARM_CPU_PART_CORTEX_A78AE 0xD42 #define ARM_CPU_PART_CORTEX_X1 0xD44 #define ARM_CPU_PART_CORTEX_A510 0xD46 #define ARM_CPU_PART_CORTEX_A710 0xD47 @@ -123,6 +124,7 @@ #define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTE= X_A77) #define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOV= ERSE_V1) #define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTE= X_A78) +#define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_COR= TEX_A78AE) #define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX= _X1) #define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORT= EX_A510) #define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORT= EX_A710) --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -853,6 +853,7 @@ u8 spectre_bhb_loop_affected(int scope) if (scope =3D=3D SCOPE_LOCAL_CPU) { static const struct midr_range spectre_bhb_k32_list[] =3D { MIDR_ALL_VERSIONS(MIDR_CORTEX_A78), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE), MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C), MIDR_ALL_VERSIONS(MIDR_CORTEX_X1), MIDR_ALL_VERSIONS(MIDR_CORTEX_A710), From nobody Thu May 14 08:08:21 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 B3EFEC43217 for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382719AbiDLJMO (ORCPT ); Tue, 12 Apr 2022 05:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358767AbiDLHmL (ORCPT ); Tue, 12 Apr 2022 03:42: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 935F82BF7; Tue, 12 Apr 2022 00:19:11 -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 DC523B81B66; Tue, 12 Apr 2022 07:19:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A009C385A1; Tue, 12 Apr 2022 07:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747948; bh=yFy9U19sXHN41q82kKN50sXNb/tbKR+J5nGyLCB4Wqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZFsLax5C7HOguhpTtemEzkpxqHZ3AULTNg9f7Nw+kFk5CT3474Lm0ZYPmRdXdMZMm DzbR4GFUKQ4eBvRHp/MrSL3iGR/GMrfgcSos7pn0+iKgtBOXTGahj79U6bqc0XGYif 1mGTBZbJtD+X8XVtN1ZY3vyN994LqTsMIqqCdR6Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sreekanth Reddy , Damien Le Moal , "Martin K. Petersen" Subject: [PATCH 5.17 264/343] scsi: mpt3sas: Fix use after free in _scsih_expander_node_remove() Date: Tue, 12 Apr 2022 08:31:22 +0200 Message-Id: <20220412062958.944329028@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Damien Le Moal commit 87d663d40801dffc99a5ad3b0188ad3e2b4d1557 upstream. The function mpt3sas_transport_port_remove() called in _scsih_expander_node_remove() frees the port field of the sas_expander structure, leading to the following use-after-free splat from KASAN when the ioc_info() call following that function is executed (e.g. when doing rmmod of the driver module): [ 3479.371167] =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 [ 3479.378496] BUG: KASAN: use-after-free in _scsih_expander_node_remove+0x= 710/0x750 [mpt3sas] [ 3479.386936] Read of size 1 at addr ffff8881c037691c by task rmmod/1531 [ 3479.393524] [ 3479.395035] CPU: 18 PID: 1531 Comm: rmmod Not tainted 5.17.0-rc8+ #1436 [ 3479.401712] Hardware name: Supermicro Super Server/H12SSL-NT, BIOS 2.1 0= 6/02/2021 [ 3479.409263] Call Trace: [ 3479.411743] [ 3479.413875] dump_stack_lvl+0x45/0x59 [ 3479.417582] print_address_description.constprop.0+0x1f/0x120 [ 3479.423389] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.429469] kasan_report.cold+0x83/0xdf [ 3479.433438] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.439514] _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.445411] ? _raw_spin_unlock_irqrestore+0x2d/0x40 [ 3479.452032] scsih_remove+0x525/0xc90 [mpt3sas] [ 3479.458212] ? mpt3sas_expander_remove+0x1d0/0x1d0 [mpt3sas] [ 3479.465529] ? down_write+0xde/0x150 [ 3479.470746] ? up_write+0x14d/0x460 [ 3479.475840] ? kernfs_find_ns+0x137/0x310 [ 3479.481438] pci_device_remove+0x65/0x110 [ 3479.487013] __device_release_driver+0x316/0x680 [ 3479.493180] driver_detach+0x1ec/0x2d0 [ 3479.498499] bus_remove_driver+0xe7/0x2d0 [ 3479.504081] pci_unregister_driver+0x26/0x250 [ 3479.510033] _mpt3sas_exit+0x2b/0x6cf [mpt3sas] [ 3479.516144] __x64_sys_delete_module+0x2fd/0x510 [ 3479.522315] ? free_module+0xaa0/0xaa0 [ 3479.527593] ? __cond_resched+0x1c/0x90 [ 3479.532951] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 3479.539607] ? syscall_enter_from_user_mode+0x21/0x70 [ 3479.546161] ? trace_hardirqs_on+0x1c/0x110 [ 3479.551828] do_syscall_64+0x35/0x80 [ 3479.556884] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 3479.563402] RIP: 0033:0x7f1fc482483b ... [ 3479.943087] =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 Fix this by introducing the local variable port_id to store the port ID value before executing mpt3sas_transport_port_remove(). This local variable is then used in the call to ioc_info() instead of dereferencing the freed port structure. Link: https://lore.kernel.org/r/20220322055702.95276-1-damien.lemoal@openso= urce.wdc.com Fixes: 7d310f241001 ("scsi: mpt3sas: Get device objects using sas_address &= portID") Cc: stable@vger.kernel.org Acked-by: Sreekanth Reddy Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -11035,6 +11035,7 @@ _scsih_expander_node_remove(struct MPT3S { struct _sas_port *mpt3sas_port, *next; unsigned long flags; + int port_id; =20 /* remove sibling ports attached to this expander */ list_for_each_entry_safe(mpt3sas_port, next, @@ -11055,6 +11056,8 @@ _scsih_expander_node_remove(struct MPT3S mpt3sas_port->hba_port); } =20 + port_id =3D sas_expander->port->port_id; + mpt3sas_transport_port_remove(ioc, sas_expander->sas_address, sas_expander->sas_address_parent, sas_expander->port); =20 @@ -11062,7 +11065,7 @@ _scsih_expander_node_remove(struct MPT3S "expander_remove: handle(0x%04x), sas_addr(0x%016llx), port:%d\n", sas_expander->handle, (unsigned long long) sas_expander->sas_address, - sas_expander->port->port_id); + port_id); =20 spin_lock_irqsave(&ioc->sas_node_lock, flags); list_del(&sas_expander->list); From nobody Thu May 14 08:08:21 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 78E65C4332F for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376862AbiDLJLn (ORCPT ); Tue, 12 Apr 2022 05:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358786AbiDLHmM (ORCPT ); Tue, 12 Apr 2022 03:42: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 2DFD525EBF; Tue, 12 Apr 2022 00:19: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 9862FB81B4F; Tue, 12 Apr 2022 07:19:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D70E3C385A1; Tue, 12 Apr 2022 07:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747954; bh=XAj7FCfm0M/jy4rFK9gDsnIs+X5IJ8/MZGnWY/bFg0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=maE+O00AmceMTC6XkjLveanuFUAztSEqmBbczZfPFWN5ujI2X87PsHtZ19UzAbp7b 1x49EFqlCTfjiXSGLTKda0BgdFaNLmdXP3qgQtKFHADiMoRFc26SI/X839oKbdlENl /Jr1TpqhdFDfVEIqVTZJJ96bBp3uPs+Zmtsj6HzI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Avri Altman , Bart Van Assche , Adrian Hunter , "Martin K. Petersen" Subject: [PATCH 5.17 265/343] scsi: ufs: ufs-pci: Add support for Intel MTL Date: Tue, 12 Apr 2022 08:31:23 +0200 Message-Id: <20220412062958.972479689@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 commit 4049f7acef3eb37c1ea0df45f3ffc29404f4e708 upstream. Add PCI ID and callbacks to support Intel Meteor Lake (MTL). Link: https://lore.kernel.org/r/20220404055038.2208051-1-adrian.hunter@inte= l.com Cc: stable@vger.kernel.org # v5.15+ Reviewed-by: Avri Altman Reviewed-by: Bart Van Assche Signed-off-by: Adrian Hunter Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/scsi/ufs/ufshcd-pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -428,6 +428,12 @@ static int ufs_intel_adl_init(struct ufs return ufs_intel_common_init(hba); } =20 +static int ufs_intel_mtl_init(struct ufs_hba *hba) +{ + hba->caps |=3D UFSHCD_CAP_CRYPTO | UFSHCD_CAP_WB_EN; + return ufs_intel_common_init(hba); +} + static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops =3D { .name =3D "intel-pci", .init =3D ufs_intel_common_init, @@ -465,6 +471,16 @@ static struct ufs_hba_variant_ops ufs_in .device_reset =3D ufs_intel_device_reset, }; =20 +static struct ufs_hba_variant_ops ufs_intel_mtl_hba_vops =3D { + .name =3D "intel-pci", + .init =3D ufs_intel_mtl_init, + .exit =3D ufs_intel_common_exit, + .hce_enable_notify =3D ufs_intel_hce_enable_notify, + .link_startup_notify =3D ufs_intel_link_startup_notify, + .resume =3D ufs_intel_resume, + .device_reset =3D ufs_intel_device_reset, +}; + #ifdef CONFIG_PM_SLEEP static int ufshcd_pci_restore(struct device *dev) { @@ -579,6 +595,7 @@ static const struct pci_device_id ufshcd { PCI_VDEVICE(INTEL, 0x98FA), (kernel_ulong_t)&ufs_intel_lkf_hba_vops }, { PCI_VDEVICE(INTEL, 0x51FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops }, { PCI_VDEVICE(INTEL, 0x54FF), (kernel_ulong_t)&ufs_intel_adl_hba_vops }, + { PCI_VDEVICE(INTEL, 0x7E47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, { } /* terminate list */ }; From nobody Thu May 14 08:08:21 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 8EC73C433FE for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376954AbiDLJL6 (ORCPT ); Tue, 12 Apr 2022 05:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358787AbiDLHmM (ORCPT ); Tue, 12 Apr 2022 03:42:12 -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 3137E28E29; Tue, 12 Apr 2022 00:19: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 83845616E7; Tue, 12 Apr 2022 07:19:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99C32C385A5; Tue, 12 Apr 2022 07:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747957; bh=OTYaN9cEFJk3+s8Bk6TF+yOQ9yew98O3/jc7PDaRvlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n6PzGmdrXQmQSeF4T0Urojqwrfbg9c7q9WmiQ2tgviXKzbDf7UzpPxbAjftJ2L7Q0 2/kyWyBqTEmG88f4us7Rdh31pueqJYQKJAhusjiqsLowwuT7NzXkn9nhum2PUU36B2 Ww5NulnfXuqYYwitih5/gXIP3/zxHwMyLo35JHzY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Marcin Wojtas , Ulf Hansson Subject: [PATCH 5.17 266/343] Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning" Date: Tue, 12 Apr 2022 08:31:24 +0200 Message-Id: <20220412062959.001178456@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Pali Roh=C3=A1r commit 7e2646ed47542123168d43916b84b954532e5386 upstream. This reverts commit bb32e1987bc55ce1db400faf47d85891da3c9b9f. Commit 1a3ed0dc3594 ("mmc: sdhci-xenon: fix 1.8v regulator stabilization") contains proper fix for the issue described in commit bb32e1987bc5 ("mmc: sdhci-xenon: fix annoying 1.8V regulator warning"). Fixes: 8d876bf472db ("mmc: sdhci-xenon: wait 5ms after set 1.8V signal enab= le") Cc: stable@vger.kernel.org # 1a3ed0dc3594 ("mmc: sdhci-xenon: fix 1.8v regu= lator stabilization") Signed-off-by: Pali Roh=C3=A1r Reviewed-by: Marek Beh=C3=BAn Reviewed-by: Marcin Wojtas Link: https://lore.kernel.org/r/20220318141441.32329-1-pali@kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/host/sdhci-xenon.c | 10 ---------- 1 file changed, 10 deletions(-) --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -241,16 +241,6 @@ static void xenon_voltage_switch(struct { /* Wait for 5ms after set 1.8V signal enable bit */ usleep_range(5000, 5500); - - /* - * For some reason the controller's Host Control2 register reports - * the bit representing 1.8V signaling as 0 when read after it was - * written as 1. Subsequent read reports 1. - * - * Since this may cause some issues, do an empty read of the Host - * Control2 register here to circumvent this. - */ - sdhci_readw(host, SDHCI_HOST_CONTROL2); } =20 static unsigned int xenon_get_max_clock(struct sdhci_host *host) From nobody Thu May 14 08:08:21 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 62373C433EF for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376727AbiDLJLa (ORCPT ); Tue, 12 Apr 2022 05:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358806AbiDLHmO (ORCPT ); Tue, 12 Apr 2022 03:42: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 1D6D34A908; Tue, 12 Apr 2022 00:19: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4F7096153F; Tue, 12 Apr 2022 07:19:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DC04C385A5; Tue, 12 Apr 2022 07:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747959; bh=ryXW29UIxyqDCL7e/UGe8sw6Wfpmv8xiOwJCs+jjb0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yEzo9ExNjoKFsXzwJo98Qlq27/piN7vsYX8wvHHYLL58mAHWPNYISj2b45qpd2mrW vl5Gk3NoM8zDFVeEzPwTQQGQGqW8VCgayLfd+Pm+S6ceE6gQPRLFHragW4FkS8lExq 1AR/EuFXvfzLsYQ8Xiuvx0LDFjY7zp/o4e9D4NZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Loehle , Andy Shevchenko , Ulf Hansson Subject: [PATCH 5.17 267/343] mmc: block: Check for errors after write on SPI Date: Tue, 12 Apr 2022 08:31:25 +0200 Message-Id: <20220412062959.030600828@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 L=C3=B6hle commit 5d435933376962b107bd76970912e7e80247dcc7 upstream. Introduce a SEND_STATUS check for writes through SPI to not mark an unsuccessful write as successful. Since SPI SD/MMC does not have states, after a write, the card will just hold the line LOW until it is ready again. The driver marks the write therefore as completed as soon as it reads something other than all zeroes. The driver does not distinguish from a card no longer signalling busy and it being disconnected (and the line being pulled-up by the host). This lead to writes being marked as successful when disconnecting a busy card. Now the card is ensured to be still connected by an additional CMD13, just like non-SPI is ensured to go back to TRAN state. While at it and since we already poll for the post-write status anyway, we might as well check for SPIs error bits (any of them). The disconnecting card problem is reproducable for me after continuous write activity and randomly disconnecting, around every 20-50 tries on SPI DS for some card. Fixes: 7213d175e3b6f ("MMC/SD card driver learns SPI") Cc: stable@vger.kernel.org Signed-off-by: Christian Loehle Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/76f6f5d2b35543bab3dfe438f268609c@hyperstone= .com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/core/block.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1880,6 +1880,31 @@ static inline bool mmc_blk_rq_error(stru brq->data.error || brq->cmd.resp[0] & CMD_ERRORS; } =20 +static int mmc_spi_err_check(struct mmc_card *card) +{ + u32 status =3D 0; + int err; + + /* + * SPI does not have a TRAN state we have to wait on, instead the + * card is ready again when it no longer holds the line LOW. + * We still have to ensure two things here before we know the write + * was successful: + * 1. The card has not disconnected during busy and we actually read our + * own pull-up, thinking it was still connected, so ensure it + * still responds. + * 2. Check for any error bits, in particular R1_SPI_IDLE to catch a + * just reconnected card after being disconnected during busy. + */ + err =3D __mmc_send_status(card, &status, 0); + if (err) + return err; + /* All R1 and R2 bits of SPI are errors in our case */ + if (status) + return -EIO; + return 0; +} + static int mmc_blk_busy_cb(void *cb_data, bool *busy) { struct mmc_blk_busy_data *data =3D cb_data; @@ -1903,9 +1928,16 @@ static int mmc_blk_card_busy(struct mmc_ struct mmc_blk_busy_data cb_data; int err; =20 - if (mmc_host_is_spi(card->host) || rq_data_dir(req) =3D=3D READ) + if (rq_data_dir(req) =3D=3D READ) return 0; =20 + if (mmc_host_is_spi(card->host)) { + err =3D mmc_spi_err_check(card); + if (err) + mqrq->brq.data.bytes_xfered =3D 0; + return err; + } + cb_data.card =3D card; cb_data.status =3D 0; err =3D __mmc_poll_for_busy(card->host, 0, MMC_BLK_TIMEOUT_MS, From nobody Thu May 14 08:08:21 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 E33AFC43219 for ; Tue, 12 Apr 2022 08:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385482AbiDLIv5 (ORCPT ); Tue, 12 Apr 2022 04:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358839AbiDLHmQ (ORCPT ); Tue, 12 Apr 2022 03:42:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2002753E3C; Tue, 12 Apr 2022 00:19: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 ams.source.kernel.org (Postfix) with ESMTPS id BA2DEB81A8F; Tue, 12 Apr 2022 07:19:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E0DCC385A5; Tue, 12 Apr 2022 07:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747962; bh=QhsvxtWGhK5wtgUU105j/Ut1BdLJxJR/yoBWlg8U0ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GRy/1z54+wobF+Sd+OUhWCeiuYkQ+wwZmyZp4tLX9e5NztBq8kOF6ZtuO6gS2fCER PVlN+Zgmj/vhUGwJlAUBvy+phmdooT/z2mbCFI9QHLyAS2pv86alK1szKrZ/fgdj70 /NP9ptZhTD6ktAWNyJ1hlEhGZwEVGqPYpV4Uzn34= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yann Gautier , Ulf Hansson Subject: [PATCH 5.17 268/343] mmc: mmci: stm32: correctly check all elements of sg list Date: Tue, 12 Apr 2022 08:31:26 +0200 Message-Id: <20220412062959.058808790@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Yann Gautier commit 0d319dd5a27183b75d984e3dc495248e59f99334 upstream. Use sg and not data->sg when checking sg list elements. Else only the first element alignment is checked. The last element should be checked the same way, for_each_sg already set sg to sg_next(sg). Fixes: 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant") Cc: stable@vger.kernel.org Signed-off-by: Yann Gautier Link: https://lore.kernel.org/r/20220317111944.116148-2-yann.gautier@foss.s= t.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/mmc/host/mmci_stm32_sdmmc.c +++ b/drivers/mmc/host/mmci_stm32_sdmmc.c @@ -62,8 +62,8 @@ static int sdmmc_idma_validate_data(stru * excepted the last element which has no constraint on idmasize */ for_each_sg(data->sg, sg, data->sg_len - 1, i) { - if (!IS_ALIGNED(data->sg->offset, sizeof(u32)) || - !IS_ALIGNED(data->sg->length, SDMMC_IDMA_BURST)) { + if (!IS_ALIGNED(sg->offset, sizeof(u32)) || + !IS_ALIGNED(sg->length, SDMMC_IDMA_BURST)) { dev_err(mmc_dev(host->mmc), "unaligned scatterlist: ofst:%x length:%d\n", data->sg->offset, data->sg->length); @@ -71,7 +71,7 @@ static int sdmmc_idma_validate_data(stru } } =20 - if (!IS_ALIGNED(data->sg->offset, sizeof(u32))) { + if (!IS_ALIGNED(sg->offset, sizeof(u32))) { dev_err(mmc_dev(host->mmc), "unaligned last scatterlist: ofst:%x length:%d\n", data->sg->offset, data->sg->length); From nobody Thu May 14 08:08:21 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 0F4D3C4167D for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386801AbiDLJES (ORCPT ); Tue, 12 Apr 2022 05:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358841AbiDLHmQ (ORCPT ); Tue, 12 Apr 2022 03:42:16 -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 69B5F54187; Tue, 12 Apr 2022 00:19: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 CD6EF616B2; Tue, 12 Apr 2022 07:19:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB9CFC385AB; Tue, 12 Apr 2022 07:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747965; bh=50NiPYZNS7W5h3kIdqJdXNGJ3ub+7+rCMrcv/3A7b9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DuVEBbmtKA6mbNoqJKRi5JzgZ6GyB4GXGYw4YE0f7ojbk3Spj0onVzJ0jmbIprvyW b7ubUa3qUSxsrvm+qJamdlcCkTZBXqTl9mC6rn5LowxbWGNTM1G+DgZFB93fGC2Ezj isMVJJkRN+/KA4yUNqsga9fm51GBz9XosH9NV33U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang , Ulf Hansson Subject: [PATCH 5.17 269/343] mmc: renesas_sdhi: special 4tap settings only apply to HS400 Date: Tue, 12 Apr 2022 08:31:27 +0200 Message-Id: <20220412062959.087272710@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Wolfram Sang commit 46d4820f949a3030b19ee482c68a50b06dd27590 upstream. Previous documentation was vague, so we included SDR104 for slow SDnH clock settings. It turns out now, that it is only needed for HS400. Fixes: bb6d3fa98a41 ("clk: renesas: rcar-gen3: Switch to new SD clock handl= ing") Cc: stable@vger.kernel.org Reported-by: Yoshihiro Shimoda Signed-off-by: Wolfram Sang Reviewed-by: Yoshihiro Shimoda Link: https://lore.kernel.org/r/20220404100508.3209-1-wsa+renesas@sang-engi= neering.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -144,9 +144,9 @@ static unsigned int renesas_sdhi_clk_upd return clk_get_rate(priv->clk); =20 if (priv->clkh) { + /* HS400 with 4TAP needs different clock settings */ bool use_4tap =3D priv->quirks && priv->quirks->hs400_4taps; - bool need_slow_clkh =3D (host->mmc->ios.timing =3D=3D MMC_TIMING_UHS_SDR= 104) || - (host->mmc->ios.timing =3D=3D MMC_TIMING_MMC_HS400); + bool need_slow_clkh =3D host->mmc->ios.timing =3D=3D MMC_TIMING_MMC_HS40= 0; clkh_shift =3D use_4tap && need_slow_clkh ? 1 : 2; ref_clk =3D priv->clkh; } From nobody Thu May 14 08:08:21 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 26C4FC433F5 for ; Tue, 12 Apr 2022 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376596AbiDLJLU (ORCPT ); Tue, 12 Apr 2022 05:11:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358880AbiDLHmT (ORCPT ); Tue, 12 Apr 2022 03:42: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 DF55E54689; Tue, 12 Apr 2022 00:19:30 -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 37A86B81B4F; Tue, 12 Apr 2022 07:19:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86621C385A1; Tue, 12 Apr 2022 07:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747967; bh=TicIjItdnUUdAbljP2+7kXCA1D8V7E6pwj/dcqzE28I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z+cGSOiSmdoa9H6ALG5NMOQtITk6JHcxWEOhbMVAT+52TtpgVSrkUriq6b6/bKZpY zGKbiG/fEFaUtf5GV/j3CdRUc9noaZaF2fqHgvHv/6xhotaUPcoYHVevsye37xyTQW tAld1p7quhcXvXqtum05/z4iRZezZrxXHYHJB1dk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshihiro Shimoda , Wolfram Sang , Ulf Hansson Subject: [PATCH 5.17 270/343] mmc: renesas_sdhi: dont overwrite TAP settings when HS400 tuning is complete Date: Tue, 12 Apr 2022 08:31:28 +0200 Message-Id: <20220412062959.116305353@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Wolfram Sang commit 03e59b1e2f56245163b14c69e0a830c24b1a3a47 upstream. When HS400 tuning is complete and HS400 is going to be activated, we have to keep the current number of TAPs and should not overwrite them with a hardcoded value. This was probably a copy&paste mistake when upporting HS400 support from the BSP. Fixes: 26eb2607fa28 ("mmc: renesas_sdhi: add eMMC HS400 mode support") Reported-by: Yoshihiro Shimoda Signed-off-by: Wolfram Sang Reviewed-by: Yoshihiro Shimoda Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220404114902.12175-1-wsa+renesas@sang-eng= ineering.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -396,10 +396,10 @@ static void renesas_sdhi_hs400_complete( SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) | sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2)); =20 - /* Set the sampling clock selection range of HS400 mode */ sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL, SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN | - 0x4 << SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT); + sd_scc_read32(host, priv, + SH_MOBILE_SDHI_SCC_DTCNTL)); =20 /* Avoid bad TAP */ if (bad_taps & BIT(priv->tap_set)) { From nobody Thu May 14 08:08:21 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 56317C4321E for ; Tue, 12 Apr 2022 08:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385575AbiDLIwM (ORCPT ); Tue, 12 Apr 2022 04:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358894AbiDLHmT (ORCPT ); Tue, 12 Apr 2022 03:42: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 58B59546A2; Tue, 12 Apr 2022 00:19: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 41E196153F; Tue, 12 Apr 2022 07:19:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BDA0C385A5; Tue, 12 Apr 2022 07:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747970; bh=GCdtRzbsd0giU9kuDnboH1OnpD7l/gKMxIAu4hzgLeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EznmDd6V5AJQ6tGCZBRFpohhkoiy+w41PgDgKefef1QJoJBwdJVgqc++1ih+dFSRC Gj5G8KmhFLHtGoHyrF/7/o4bCLPybEasHTUTQyFqPa2CYzRNPi8K6FU7pDiyg8xiFA 7eNEAOYyPmG69SwqQEIJI3BLNOI3y7sU/UGluHJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Avri Altman , Michael Wu , Ulf Hansson Subject: [PATCH 5.17 271/343] mmc: core: Fixup support for writeback-cache for eMMC and SD Date: Tue, 12 Apr 2022 08:31:29 +0200 Message-Id: <20220412062959.145752165@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Michael Wu commit 08ebf903af57cda6d773f3dd1671b64f73b432b8 upstream. During the card initialization process, the mmc core checks whether the eMMC/SD card supports an internal writeback-cache and then enables it inside the card. Unfortunately, this isn't according to what the mmc core reports to the upper block layer. Instead, the writeback-cache support with REQ_FLUSH and REQ_FUA, are being enabled depending on whether the host supports the CMD23 (MMC_CAP_CMD23) and whether an eMMC supports the reliable-write command. This is wrong and it may also sound awkward. In fact, it's a remnant from when both eMMC/SD cards didn't have dedicated commands/support to control the internal writeback-cache. In other words, it was the best we could do at that point in time. To fix the problem, but also without breaking backwards compatibility, let's align the REQ_FLUSH support with whether the writeback-cache became successfully enabled - for both eMMC and SD cards. Cc: stable@kernel.org Fixes: 881d1c25f765 ("mmc: core: Add cache control for eMMC4.5 device") Fixes: 130206a615a9 ("mmc: core: Add support for cache ctrl for SD cards") Depends-on: 97fce126e279 ("mmc: block: Issue a cache flush only when it's e= nabled") Reviewed-by: Avri Altman Signed-off-by: Michael Wu Link: https://lore.kernel.org/r/20220331073223.106415-1-michael@allwinnerte= ch.com [Ulf: Re-wrote the commit message] Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/mmc/core/block.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2382,6 +2382,8 @@ static struct mmc_blk_data *mmc_blk_allo struct mmc_blk_data *md; int devidx, ret; char cap_str[10]; + bool cache_enabled =3D false; + bool fua_enabled =3D false; =20 devidx =3D ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL); if (devidx < 0) { @@ -2461,13 +2463,17 @@ static struct mmc_blk_data *mmc_blk_allo md->flags |=3D MMC_BLK_CMD23; } =20 - if (mmc_card_mmc(card) && - md->flags & MMC_BLK_CMD23 && + if (md->flags & MMC_BLK_CMD23 && ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || card->ext_csd.rel_sectors)) { md->flags |=3D MMC_BLK_REL_WR; - blk_queue_write_cache(md->queue.queue, true, true); + fua_enabled =3D true; + cache_enabled =3D true; } + if (mmc_cache_enabled(card->host)) + cache_enabled =3D true; + + blk_queue_write_cache(md->queue.queue, cache_enabled, fua_enabled); =20 string_get_size((u64)size, 512, STRING_UNITS_2, cap_str, sizeof(cap_str)); From nobody Thu May 14 08:08:21 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 138DFC4167B for ; Tue, 12 Apr 2022 08:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385520AbiDLIwI (ORCPT ); Tue, 12 Apr 2022 04:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358908AbiDLHmU (ORCPT ); Tue, 12 Apr 2022 03:42: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 B8A0354686; Tue, 12 Apr 2022 00:19: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 C5B99B81A8F; Tue, 12 Apr 2022 07:19:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05D4AC385AB; Tue, 12 Apr 2022 07:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747973; bh=r7zwxBmSBYLoVuMUOCzhurkmYQox+oscdpkyavZfQGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cNOc7WgLFgNq3EgcrEqtlIMkukmu6vADF5ZkB7hvB/PLXMfJ5S0hgjDJtKIQGKzIY slzsNBNI108D3QuSkV/ReIeAf1qVKT0qOnjcjzu9PhmpBLQNJ68YNNuf/22JwNxtry /xi/70UHW0Zo+n+l1nFOgcvdfoGHDCyE0bvaUy/E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+63d688f1d899c588fb71@syzkaller.appspotmail.com, Guo Xuenan , Nick Terrell , Gao Xiang , Yann Collet , Chengyang Fan , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 272/343] lz4: fix LZ4_decompress_safe_partial read out of bound Date: Tue, 12 Apr 2022 08:31:30 +0200 Message-Id: <20220412062959.174661611@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Guo Xuenan commit eafc0a02391b7b36617b36c97c4b5d6832cf5e24 upstream. When partialDecoding, it is EOF if we've either filled the output buffer or can't proceed with reading an offset for following match. In some extreme corner cases when compressed data is suitably corrupted, UAF will occur. As reported by KASAN [1], LZ4_decompress_safe_partial may lead to read out of bound problem during decoding. lz4 upstream has fixed it [2] and this issue has been disscussed here [3] before. current decompression routine was ported from lz4 v1.8.3, bumping lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd better fix it first. [1] https://lore.kernel.org/all/000000000000830d1205cf7f0477@google.com/ [2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad24= 4ad# [3] https://lore.kernel.org/all/CC666AE8-4CA4-4951-B6FB-A2EFDE3AC03B@fb.com/ Link: https://lkml.kernel.org/r/20211111105048.2006070-1-guoxuenan@huawei.c= om Reported-by: syzbot+63d688f1d899c588fb71@syzkaller.appspotmail.com Signed-off-by: Guo Xuenan Reviewed-by: Nick Terrell Acked-by: Gao Xiang Cc: Yann Collet Cc: Chengyang Fan Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- lib/lz4/lz4_decompress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c @@ -271,8 +271,12 @@ static FORCE_INLINE int LZ4_decompress_g ip +=3D length; op +=3D length; =20 - /* Necessarily EOF, due to parsing restrictions */ - if (!partialDecoding || (cpy =3D=3D oend)) + /* Necessarily EOF when !partialDecoding. + * When partialDecoding, it is EOF if we've either + * filled the output buffer or + * can't proceed with reading an offset for following match. + */ + if (!partialDecoding || (cpy =3D=3D oend) || (ip >=3D (iend - 2))) break; } else { /* may overwrite up to WILDCOPYLENGTH beyond cpy */ From nobody Thu May 14 08:08:21 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 09CB2C4321E for ; Tue, 12 Apr 2022 09:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359521AbiDLJLB (ORCPT ); Tue, 12 Apr 2022 05:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358938AbiDLHmV (ORCPT ); Tue, 12 Apr 2022 03:42:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFDB054696; Tue, 12 Apr 2022 00:19: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 8592BB81B4F; Tue, 12 Apr 2022 07:19:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0140FC385A5; Tue, 12 Apr 2022 07:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747976; bh=ZE0SPjc+O4SDdCybQMxqSDYtYnTmByEmCyRM9DcJuWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBxFlkbPwoz8x5q5N0nCfcCCxd5uDv0rlV2Emhq2xm1uVz/SPXi+XSauHgiyrLyGs Q7/ZR35uAkDOMxDBqjk8VDi6PyXnFeubHWb7+BX3daSsuYXHVRwbUpev44cbvoF4B/ ndfIIYTyFaL2IlCSQkyROBxWQYraeHzHPwCJ7iPE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov , Thomas Gleixner , "Peter Zijlstra (Intel)" , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 273/343] highmem: fix checks in __kmap_local_sched_{in,out} Date: Tue, 12 Apr 2022 08:31:31 +0200 Message-Id: <20220412062959.202802193@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Max Filippov commit 66f133ceab7456c789f70a242991ed1b27ba1c3d upstream. When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check that even slots in the tsk->kmap_ctrl.pteval are unmapped. The slots are initialized with 0 value, but the check is done with pte_none. 0 pte however does not necessarily mean that pte_none will return true. e.g. on xtensa it returns false, resulting in the following runtime warnings: WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0= x108 CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dir= ty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_out+0x51/0x108 __schedule+0x71a/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0x= e0 CPU: 0 PID: 101 Comm: touch Tainted: G W 5.17.0-rc7-00010-g= d3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_in+0x50/0xe0 finish_task_switch$isra$0+0x1ce/0x2f8 __schedule+0x86e/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f Fix it by replacing !pte_none(pteval) with pte_val(pteval) !=3D 0. Link: https://lkml.kernel.org/r/20220403235159.3498065-1-jcmvbkbc@gmail.com Fixes: 5fbda3ecd14a ("sched: highmem: Store local kmaps in task struct") Signed-off-by: Max Filippov Reviewed-by: Thomas Gleixner Cc: "Peter Zijlstra (Intel)" Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- mm/highmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/highmem.c +++ b/mm/highmem.c @@ -624,7 +624,7 @@ void __kmap_local_sched_out(void) =20 /* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL) && !(i & 0x01)) { - WARN_ON_ONCE(!pte_none(pteval)); + WARN_ON_ONCE(pte_val(pteval) !=3D 0); continue; } if (WARN_ON_ONCE(pte_none(pteval))) @@ -661,7 +661,7 @@ void __kmap_local_sched_in(void) =20 /* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL) && !(i & 0x01)) { - WARN_ON_ONCE(!pte_none(pteval)); + WARN_ON_ONCE(pte_val(pteval) !=3D 0); continue; } if (WARN_ON_ONCE(pte_none(pteval))) From nobody Thu May 14 08:08:21 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 EE380C4167B for ; Tue, 12 Apr 2022 09:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359287AbiDLJKn (ORCPT ); Tue, 12 Apr 2022 05:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358947AbiDLHmW (ORCPT ); Tue, 12 Apr 2022 03:42:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F17554BD0; Tue, 12 Apr 2022 00:19: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 471AEB81B67; Tue, 12 Apr 2022 07:19:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98439C385AB; Tue, 12 Apr 2022 07:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747979; bh=NwKPkCap+dw1eHh5siCsbaMYWMopuS5/YjbGJCk9bjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RhUfw83NFvDBuor1kGzeItLgEXEWaOwYyu7aDS7LNxzhDA4VLnvSviJcM29UcB0zc enNNGNAN1z4ESJG17xG23dhuOxNSgPEUf75u2qoYeMqsEIuu6jkf+EtJreC5cGp7ZO 7j3rvPdDa2bq730mNt47Vzpk6MV9C8xMbYmUv5eI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com, Paolo Bonzini , Sean Christopherson , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 274/343] mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) Date: Tue, 12 Apr 2022 08:31:32 +0200 Message-Id: <20220412062959.231328521@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Paolo Bonzini commit 01e67e04c28170c47700c2c226d732bbfedb1ad0 upstream. If an mremap() syscall with old_size=3D0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range. This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue. Link: https://lkml.kernel.org/r/20220329173155.172439-1-pbonzini@redhat.com Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com Signed-off-by: Paolo Bonzini Cc: Sean Christopherson Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/mremap.c +++ b/mm/mremap.c @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm pmd_t *old_pmd, *new_pmd; pud_t *old_pud, *new_pud; =20 + if (!len) + return 0; + old_end =3D old_addr + len; flush_cache_range(vma, old_addr, old_end); From nobody Thu May 14 08:08:21 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 DE4BDC43217 for ; Tue, 12 Apr 2022 09:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359116AbiDLJK1 (ORCPT ); Tue, 12 Apr 2022 05:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358970AbiDLHmX (ORCPT ); Tue, 12 Apr 2022 03:42: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 D9C5954BD8; Tue, 12 Apr 2022 00:19: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 ams.source.kernel.org (Postfix) with ESMTPS id 78098B81B60; Tue, 12 Apr 2022 07:19:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E43D0C385BC; Tue, 12 Apr 2022 07:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747984; bh=q8OHcF16dQITAZAZK3eXGrOPswUsc2FES5AKfEGJeRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z0yfkzrLPujjuWon8+9b3DC4ag7R+AuGFOMX3UcZRtZbmEA0WDN587VNI4bqvu46Z ETMh+e5dmGQFrU7IzKpbr5GIdgZ4ckpjks+kLAsrRBTYqIDV57HpfWNhYzrLkzFqPb oUTqs6l7/K0M+kXVj0858rq8OtsOINV6MPIjHhzU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Michal Hocko , KOSAKI Motohiro , Mel Gorman , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 275/343] mm/mempolicy: fix mpol_new leak in shared_policy_replace Date: Tue, 12 Apr 2022 08:31:33 +0200 Message-Id: <20220412062959.259715401@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Miaohe Lin commit 4ad099559b00ac01c3726e5c95dc3108ef47d03e upstream. If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation. This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time: shmid =3D shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT); shm =3D shmat(shmid, 0, 0); loop many times { mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0); mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask, maxnode, 0); } Link: https://lkml.kernel.org/r/20220329111416.27954-1-linmiaohe@huawei.com Fixes: 42288fe366c4 ("mm: mempolicy: Convert shared_policy mutex to spinloc= k") Signed-off-by: Miaohe Lin Acked-by: Michal Hocko Cc: KOSAKI Motohiro Cc: Mel Gorman Cc: [3.8] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2736,6 +2736,7 @@ alloc_new: mpol_new =3D kmem_cache_alloc(policy_cache, GFP_KERNEL); if (!mpol_new) goto err_out; + atomic_set(&mpol_new->refcnt, 1); goto restart; } From nobody Thu May 14 08:08:21 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 7AAB4C4167D for ; Tue, 12 Apr 2022 08:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385650AbiDLIwY (ORCPT ); Tue, 12 Apr 2022 04:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358979AbiDLHmY (ORCPT ); Tue, 12 Apr 2022 03:42:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AEBF54BD4; Tue, 12 Apr 2022 00:19: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 dfw.source.kernel.org (Postfix) with ESMTPS id A058A6153F; Tue, 12 Apr 2022 07:19:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACE01C385A1; Tue, 12 Apr 2022 07:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747987; bh=wYgE6jyFK7WGv03kxPI2/kG/+lpmU4aK7Xwji4y+v0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+oiCuwVC6aTR7K7E4LagEWbOS7+PLQoaJkE+b8h1bdP3kYw4bD9zVQTrOzV0o2mW irC6cuLEmbWuCFI5NNJZHMLDfIgdgSBzxdcOwIzupyGCJsinVPqMJugG7tc4vEYJk1 2vleNNwyObOfk0EAuEvQruZNwjupnhaf8NTVkPPU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.17 276/343] io_uring: dont check req->file in io_fsync_prep() Date: Tue, 12 Apr 2022 08:31:34 +0200 Message-Id: <20220412062959.289235162@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit ec858afda857e361182ceafc3d2ba2b164b8e889 upstream. This is a leftover from the really old days where we weren't able to track and error early if we need a file and it wasn't assigned. Kill the check. Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 3 --- 1 file changed, 3 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4245,9 +4245,6 @@ static int io_fsync_prep(struct io_kiocb { struct io_ring_ctx *ctx =3D req->ctx; =20 - if (!req->file) - return -EBADF; - if (unlikely(ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; if (unlikely(sqe->addr || sqe->ioprio || sqe->buf_index || From nobody Thu May 14 08:08:21 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 C7BD3C43219 for ; Tue, 12 Apr 2022 09:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358100AbiDLJKH (ORCPT ); Tue, 12 Apr 2022 05:10:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358991AbiDLHmY (ORCPT ); Tue, 12 Apr 2022 03:42:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8199F275F0; Tue, 12 Apr 2022 00:19: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 2DEEFB81A8F; Tue, 12 Apr 2022 07:19:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78966C385A1; Tue, 12 Apr 2022 07:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747989; bh=a4Wb71T+g9OBqgUU9cgQ7mHXv/YD80iOH6Z0MpXZCeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CehFXo1OHCszJxl5Ts16y6j6NlTtJVGLK2hr/pBHptuLWpcagRUDdHFrVvL6eH6tw Vj5sEg/Hm3dFD1ABaEejnpR+uyl5XLz8NT5x9PLmr+TZ+r4tSVQZu8WK7hizZbRSXQ qnJmuHRXF/F5x6EDYQPrwRIlWXVmExjOn7PFAYJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.17 277/343] io_uring: defer splice/tee file validity check until command issue Date: Tue, 12 Apr 2022 08:31:35 +0200 Message-Id: <20220412062959.318721633@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit a3e4bc23d5470b2beb7cc42a86b6a3e75b704c15 upstream. In preparation for not using the file at prep time, defer checking if this file refers to a valid io_uring instance until issue time. This also means we can get rid of the cleanup flag for splice and tee. Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -621,10 +621,10 @@ struct io_epoll { =20 struct io_splice { struct file *file_out; - struct file *file_in; loff_t off_out; loff_t off_in; u64 len; + int splice_fd_in; unsigned int flags; }; =20 @@ -1551,14 +1551,6 @@ static void io_prep_async_work(struct io if (def->unbound_nonreg_file) req->work.flags |=3D IO_WQ_WORK_UNBOUND; } - - switch (req->opcode) { - case IORING_OP_SPLICE: - case IORING_OP_TEE: - if (!S_ISREG(file_inode(req->splice.file_in)->i_mode)) - req->work.flags |=3D IO_WQ_WORK_UNBOUND; - break; - } } =20 static void io_prep_async_link(struct io_kiocb *req) @@ -4144,18 +4136,11 @@ static int __io_splice_prep(struct io_ki if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; =20 - sp->file_in =3D NULL; sp->len =3D READ_ONCE(sqe->len); sp->flags =3D READ_ONCE(sqe->splice_flags); - if (unlikely(sp->flags & ~valid_flags)) return -EINVAL; - - sp->file_in =3D io_file_get(req->ctx, req, READ_ONCE(sqe->splice_fd_in), - (sp->flags & SPLICE_F_FD_IN_FIXED)); - if (!sp->file_in) - return -EBADF; - req->flags |=3D REQ_F_NEED_CLEANUP; + sp->splice_fd_in =3D READ_ONCE(sqe->splice_fd_in); return 0; } =20 @@ -4170,20 +4155,27 @@ static int io_tee_prep(struct io_kiocb * static int io_tee(struct io_kiocb *req, unsigned int issue_flags) { struct io_splice *sp =3D &req->splice; - struct file *in =3D sp->file_in; struct file *out =3D sp->file_out; unsigned int flags =3D sp->flags & ~SPLICE_F_FD_IN_FIXED; + struct file *in; long ret =3D 0; =20 if (issue_flags & IO_URING_F_NONBLOCK) return -EAGAIN; + + in =3D io_file_get(req->ctx, req, sp->splice_fd_in, + (sp->flags & SPLICE_F_FD_IN_FIXED)); + if (!in) { + ret =3D -EBADF; + goto done; + } + if (sp->len) ret =3D do_tee(in, out, sp->len, flags); =20 if (!(sp->flags & SPLICE_F_FD_IN_FIXED)) io_put_file(in); - req->flags &=3D ~REQ_F_NEED_CLEANUP; - +done: if (ret !=3D sp->len) req_set_fail(req); io_req_complete(req, ret); @@ -4202,15 +4194,22 @@ static int io_splice_prep(struct io_kioc static int io_splice(struct io_kiocb *req, unsigned int issue_flags) { struct io_splice *sp =3D &req->splice; - struct file *in =3D sp->file_in; struct file *out =3D sp->file_out; unsigned int flags =3D sp->flags & ~SPLICE_F_FD_IN_FIXED; loff_t *poff_in, *poff_out; + struct file *in; long ret =3D 0; =20 if (issue_flags & IO_URING_F_NONBLOCK) return -EAGAIN; =20 + in =3D io_file_get(req->ctx, req, sp->splice_fd_in, + (sp->flags & SPLICE_F_FD_IN_FIXED)); + if (!in) { + ret =3D -EBADF; + goto done; + } + poff_in =3D (sp->off_in =3D=3D -1) ? NULL : &sp->off_in; poff_out =3D (sp->off_out =3D=3D -1) ? NULL : &sp->off_out; =20 @@ -4219,8 +4218,7 @@ static int io_splice(struct io_kiocb *re =20 if (!(sp->flags & SPLICE_F_FD_IN_FIXED)) io_put_file(in); - req->flags &=3D ~REQ_F_NEED_CLEANUP; - +done: if (ret !=3D sp->len) req_set_fail(req); io_req_complete(req, ret); @@ -6686,11 +6684,6 @@ static void io_clean_op(struct io_kiocb kfree(io->free_iov); break; } - case IORING_OP_SPLICE: - case IORING_OP_TEE: - if (!(req->splice.flags & SPLICE_F_FD_IN_FIXED)) - io_put_file(req->splice.file_in); - break; case IORING_OP_OPENAT: case IORING_OP_OPENAT2: if (req->open.filename) From nobody Thu May 14 08:08:21 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 E0579C43219 for ; Tue, 12 Apr 2022 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386080AbiDLIyH (ORCPT ); Tue, 12 Apr 2022 04:54:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359389AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 1BE5C2C679; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id D3685B81B58; Tue, 12 Apr 2022 07:22:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B07AC385A1; Tue, 12 Apr 2022 07:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748124; bh=6XkHVmwmwN5hcX4U9xQPmanqLhUuQjq9xg1RnT15PKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bjfuMFyLb+/f8L4REeERkHGUvcqG+yYCp1tdbiUEfomH9kv4+RUUn4AlW+LQ+g6XX Fvt4JG8FKMMKDXYub8zLx07OBoxkQfot9hBpbHoPc+a8lOVZlGfpnzZtP66VVf+DbQ mcnOsuOYYpjEV4xW2pe9Wrbfn57OETt5Mm8wwxg8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugene Syromiatnikov , Jens Axboe Subject: [PATCH 5.17 278/343] io_uring: implement compat handling for IORING_REGISTER_IOWQ_AFF Date: Tue, 12 Apr 2022 08:31:36 +0200 Message-Id: <20220412062959.347659588@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Eugene Syromiatnikov commit 0f5e4b83b37a96e3643951588ed7176b9b187c0a upstream. Similarly to the way it is done im mbind syscall. Cc: stable@vger.kernel.org # 5.14 Fixes: fe76421d1da1dcdb ("io_uring: allow user configurable IO thread CPU a= ffinity") Signed-off-by: Eugene Syromiatnikov Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -10860,7 +10860,15 @@ static __cold int io_register_iowq_aff(s if (len > cpumask_size()) len =3D cpumask_size(); =20 - if (copy_from_user(new_mask, arg, len)) { + if (in_compat_syscall()) { + ret =3D compat_get_bitmap(cpumask_bits(new_mask), + (const compat_ulong_t __user *)arg, + len * 8 /* CHAR_BIT */); + } else { + ret =3D copy_from_user(new_mask, arg, len); + } + + if (ret) { free_cpumask_var(new_mask); return -EFAULT; } From nobody Thu May 14 08:08:21 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 C92ABC433FE for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385789AbiDLIw6 (ORCPT ); Tue, 12 Apr 2022 04:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359073AbiDLHm3 (ORCPT ); Tue, 12 Apr 2022 03:42:29 -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 AA35A5521E; Tue, 12 Apr 2022 00:20: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 4420361045; Tue, 12 Apr 2022 07:20:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58DADC385A1; Tue, 12 Apr 2022 07:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748008; bh=q7WSODLypYIykGAg6QQO4egcUuD69gEgMfjespz19u8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUbyBLQY0LuB+NqoDQmxGHuWoIFX9e1pmknJNclGZi00x9VP1jrq9WwGSYEolB6Qw zbDy+K1nADMeD/YPKVZcZnN7VP6oXU4Mof2rfBVHxpreIb03VZ3be2+IBppWrN2Bp/ pMFGGPUjVlBLMzKvsHjYdsw61g2E7b9ZXbMCtc/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.17 279/343] io_uring: fix race between timeout flush and removal Date: Tue, 12 Apr 2022 08:31:37 +0200 Message-Id: <20220412062959.376033708@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit e677edbcabee849bfdd43f1602bccbecf736a646 upstream. io_flush_timeouts() assumes the timeout isn't in progress of triggering or being removed/canceled, so it unconditionally removes it from the timeout list and attempts to cancel it. Leave it on the list and let the normal timeout cancelation take care of it. Cc: stable@vger.kernel.org # 5.5+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1644,12 +1644,11 @@ static __cold void io_flush_timeouts(str __must_hold(&ctx->completion_lock) { u32 seq =3D ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts); + struct io_kiocb *req, *tmp; =20 spin_lock_irq(&ctx->timeout_lock); - while (!list_empty(&ctx->timeout_list)) { + list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) { u32 events_needed, events_got; - struct io_kiocb *req =3D list_first_entry(&ctx->timeout_list, - struct io_kiocb, timeout.list); =20 if (io_is_timeout_noseq(req)) break; @@ -1666,7 +1665,6 @@ static __cold void io_flush_timeouts(str if (events_got < events_needed) break; =20 - list_del_init(&req->timeout.list); io_kill_timeout(req, 0); } ctx->cq_last_tm_flush =3D seq; @@ -6276,6 +6274,7 @@ static int io_timeout_prep(struct io_kio if (data->ts.tv_sec < 0 || data->ts.tv_nsec < 0) return -EINVAL; =20 + INIT_LIST_HEAD(&req->timeout.list); data->mode =3D io_translate_timeout_mode(flags); hrtimer_init(&data->timer, io_timeout_get_clock(data), data->mode); From nobody Thu May 14 08:08:21 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 EA319C3527E for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387123AbiDLJFk (ORCPT ); Tue, 12 Apr 2022 05:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359242AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A4695576E; Tue, 12 Apr 2022 00:20: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 594B261045; Tue, 12 Apr 2022 07:20:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68938C385A5; Tue, 12 Apr 2022 07:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748038; bh=1fAADtwZr8mUN51KJvbjJw10IrVyo6zwcuvu2c/R9yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0G8LGzA9vytDRXkP9gkAHQO702qgKRawGcNogQw88zHS9hn1Q7XFh9kMeMLiHjdV nqBmA7zPxoiOe7Fqc67ZJpl2fB2ehKz2bi39oJx2F3UffXra0Zyv5pGq1upJCHQcA1 jtJi74Cp0NaIkSddDKCQHlz+yjtpN62nFV4VW1lo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Hansen , Pawan Gupta , Borislav Petkov , Linus Torvalds Subject: [PATCH 5.17 280/343] x86/pm: Save the MSR validity status at context setup Date: Tue, 12 Apr 2022 08:31:38 +0200 Message-Id: <20220412062959.405582569@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 73924ec4d560257004d5b5116b22a3647661e364 upstream. The mechanism to save/restore MSRs during S3 suspend/resume checks for the MSR validity during suspend, and only restores the MSR if its a valid MSR. This is not optimal, as an invalid MSR will unnecessarily throw an exception for every suspend cycle. The more invalid MSRs, higher the impact will be. Check and save the MSR validity at setup. This ensures that only valid MSRs that are guaranteed to not throw an exception will be attempted during suspend. Fixes: 7a9c2dd08ead ("x86/pm: Introduce quirk framework to save/restore ext= ra MSR registers around suspend/resume") Suggested-by: Dave Hansen Signed-off-by: Pawan Gupta Reviewed-by: Dave Hansen Acked-by: Borislav Petkov Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/power/cpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -40,7 +40,8 @@ static void msr_save_context(struct save struct saved_msr *end =3D msr + ctxt->saved_msrs.num; =20 while (msr < end) { - msr->valid =3D !rdmsrl_safe(msr->info.msr_no, &msr->info.reg.q); + if (msr->valid) + rdmsrl(msr->info.msr_no, msr->info.reg.q); msr++; } } @@ -424,8 +425,10 @@ static int msr_build_context(const u32 * } =20 for (i =3D saved_msrs->num, j =3D 0; i < total_num; i++, j++) { + u64 dummy; + msr_array[i].info.msr_no =3D msr_id[j]; - msr_array[i].valid =3D false; + msr_array[i].valid =3D !rdmsrl_safe(msr_id[j], &dummy); msr_array[i].info.reg.q =3D 0; } saved_msrs->num =3D total_num; From nobody Thu May 14 08:08:21 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 C1551C3527B for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386552AbiDLI6d (ORCPT ); Tue, 12 Apr 2022 04:58:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359257AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 3B9072AC66; Tue, 12 Apr 2022 00:21:10 -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 CA8B861045; Tue, 12 Apr 2022 07:21:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1FDCC385A5; Tue, 12 Apr 2022 07:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748069; bh=KXy/IacbeYaGiCa4DIP5MYCW5TZXiRuOhqsi9RysQGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0TifdPgZ8AHsS6hhxzj+yGVVTtcX5IeFWWNnLebvXjDViZmcWeAhw8rX7+kjkUHm mV7Xi9G4Utcj5im3gxsquNKz48Dj7csrjKCmsK/AvMhB7DkroL3vW19UIBYGp8n8sg GOiZg9RrrtTMawZGrcX1hVC2RdgPXlB4Lwuz2MXE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Neelima Krishnan , Pawan Gupta , Borislav Petkov , Dave Hansen , Linus Torvalds Subject: [PATCH 5.17 281/343] x86/speculation: Restore speculation related MSRs during S3 resume Date: Tue, 12 Apr 2022 08:31:39 +0200 Message-Id: <20220412062959.433777240@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 e2a1256b17b16f9b9adf1b6fea56819e7b68e463 upstream. After resuming from suspend-to-RAM, the MSRs that control CPU's speculative execution behavior are not being restored on the boot CPU. These MSRs are used to mitigate speculative execution vulnerabilities. Not restoring them correctly may leave the CPU vulnerable. Secondary CPU's MSRs are correctly being restored at S3 resume by identify_secondary_cpu(). During S3 resume, restore these MSRs for boot CPU when restoring its processor state. Fixes: 772439717dbf ("x86/bugs/intel: Set proper CPU features and setup RDS= ") Reported-by: Neelima Krishnan Signed-off-by: Pawan Gupta Tested-by: Neelima Krishnan Acked-by: Borislav Petkov Reviewed-by: Dave Hansen Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/power/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -503,10 +503,24 @@ static int pm_cpu_check(const struct x86 return ret; } =20 +static void pm_save_spec_msr(void) +{ + u32 spec_msr_id[] =3D { + MSR_IA32_SPEC_CTRL, + MSR_IA32_TSX_CTRL, + MSR_TSX_FORCE_ABORT, + MSR_IA32_MCU_OPT_CTRL, + MSR_AMD64_LS_CFG, + }; + + msr_build_context(spec_msr_id, ARRAY_SIZE(spec_msr_id)); +} + static int pm_check_save_msr(void) { dmi_check_system(msr_save_dmi_table); pm_cpu_check(msr_save_cpu_table); + pm_save_spec_msr(); =20 return 0; } From nobody Thu May 14 08:08:21 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 79A35C3527B for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386937AbiDLJFC (ORCPT ); Tue, 12 Apr 2022 05:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359319AbiDLHm4 (ORCPT ); Tue, 12 Apr 2022 03:42:56 -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 EA76C55BCE; Tue, 12 Apr 2022 00:21: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 AA3D2B81B4F; Tue, 12 Apr 2022 07:21:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B97CC385A1; Tue, 12 Apr 2022 07:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748099; bh=i89we5TJeVE6OkMcDfmOAm0MKkNg7SRdvldGSUnPKxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+4Q7iOHEKln6M7SlzhNp39z1JuW7eWqslmFxGbx4V5zYuwVSvxIANtOoKbyIySeq E7rm9zM4Qk51X4y5h+C+bMW9BCfOur4hMKHfsTBDFm1rlxtVfORDq1Vcf/HfaJkV9D wR8RqgSmkL3oIOUCVS0xKJt60HV+3Bx8Rbbdiol4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 282/343] perf/x86/intel: Update the FRONTEND MSR mask on Sapphire Rapids Date: Tue, 12 Apr 2022 08:31:40 +0200 Message-Id: <20220412062959.462784936@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 e590928de7547454469693da9bc7ffd562e54b7e upstream. On Sapphire Rapids, the FRONTEND_RETIRED.MS_FLOWS event requires the FRONTEND MSR value 0x8. However, the current FRONTEND MSR mask doesn't support it. Update intel_spr_extra_regs[] to support it. Fixes: 61b985e3e775 ("perf/x86/intel: Add perf core PMU support for Sapphir= e Rapids") Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/1648482543-14923-2-git-send-email-kan.liang= @linux.intel.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -281,7 +281,7 @@ static struct extra_reg intel_spr_extra_ INTEL_UEVENT_EXTRA_REG(0x012a, MSR_OFFCORE_RSP_0, 0x3fffffffffull, RSP_0), INTEL_UEVENT_EXTRA_REG(0x012b, MSR_OFFCORE_RSP_1, 0x3fffffffffull, RSP_1), INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd), - INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x7fff17, FE), + INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x7fff1f, FE), INTEL_UEVENT_EXTRA_REG(0x40ad, MSR_PEBS_FRONTEND, 0x7, FE), INTEL_UEVENT_EXTRA_REG(0x04c2, MSR_PEBS_FRONTEND, 0x8, FE), EVENT_EXTRA_END From nobody Thu May 14 08:08:21 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 CA67DC43219 for ; Tue, 12 Apr 2022 08:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384610AbiDLI53 (ORCPT ); Tue, 12 Apr 2022 04:57:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359383AbiDLHm7 (ORCPT ); Tue, 12 Apr 2022 03:42: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 2EE102C113; Tue, 12 Apr 2022 00:21: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 CF714B81B4F; Tue, 12 Apr 2022 07:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43330C385A5; Tue, 12 Apr 2022 07:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748110; bh=Sh3dOBmsLvqM/A9bPwyaG++I0BeeNMWpTYmy+3cxDe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ueZHA8lOhHWsMUZJ/qealdLHjaVx+Wa43Oo7kvN1dWpfxp63Y5PXC9NAhYt6sEdvH 1kkW1eG8unvCHYuGgzPHzRwppRJzgR175OasBlg71TcYBivbsYGIZ0E2iUEBThXInt DUTkqOUBcZ4ZxqwCBzmHTsjVzA1mYCnmUdjzxMKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Ethan Lien , David Sterba Subject: [PATCH 5.17 283/343] btrfs: fix qgroup reserve overflow the qgroup limit Date: Tue, 12 Apr 2022 08:31:41 +0200 Message-Id: <20220412062959.491813829@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Ethan Lien commit b642b52d0b50f4d398cb4293f64992d0eed2e2ce upstream. We use extent_changeset->bytes_changed in qgroup_reserve_data() to record how many bytes we set for EXTENT_QGROUP_RESERVED state. Currently the bytes_changed is set as "unsigned int", and it will overflow if we try to fallocate a range larger than 4GiB. The result is we reserve less bytes and eventually break the qgroup limit. Unlike regular buffered/direct write, which we use one changeset for each ordered extent, which can never be larger than 256M. For fallocate, we use one changeset for the whole range, thus it no longer respects the 256M per extent limit, and caused the problem. The following example test script reproduces the problem: $ cat qgroup-overflow.sh #!/bin/bash DEV=3D/dev/sdj MNT=3D/mnt/sdj mkfs.btrfs -f $DEV mount $DEV $MNT # Set qgroup limit to 2GiB. btrfs quota enable $MNT btrfs qgroup limit 2G $MNT # Try to fallocate a 3GiB file. This should fail. echo echo "Try to fallocate a 3GiB file..." fallocate -l 3G $MNT/3G.file # Try to fallocate a 5GiB file. echo echo "Try to fallocate a 5GiB file..." fallocate -l 5G $MNT/5G.file # See we break the qgroup limit. echo sync btrfs qgroup show -r $MNT umount $MNT When running the test: $ ./qgroup-overflow.sh (...) Try to fallocate a 3GiB file... fallocate: fallocate failed: Disk quota exceeded Try to fallocate a 5GiB file... qgroupid=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rfer=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 excl=C2=A0=C2=A0=C2=A0=C2=A0 max_rfer --------=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ----=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ----=C2=A0=C2=A0=C2=A0=C2=A0 -------- 0/5=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 5.00GiB= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 5.00GiB=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2.00GiB Since we have no control of how bytes_changed is used, it's better to set it to u64. CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Qu Wenruo Signed-off-by: Ethan Lien Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/btrfs/extent_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -118,7 +118,7 @@ struct btrfs_bio_ctrl { */ struct extent_changeset { /* How many bytes are set/cleared in this operation */ - unsigned int bytes_changed; + u64 bytes_changed; =20 /* Changed ranges */ struct ulist range_changed; From nobody Thu May 14 08:08:21 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 A9EC4C4332F for ; Tue, 12 Apr 2022 08:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359528AbiDLI5R (ORCPT ); Tue, 12 Apr 2022 04:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359382AbiDLHm7 (ORCPT ); Tue, 12 Apr 2022 03:42:59 -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 58AD42C67B; Tue, 12 Apr 2022 00:21: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 dfw.source.kernel.org (Postfix) with ESMTPS id ECAD2616B2; Tue, 12 Apr 2022 07:21:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08E26C385A1; Tue, 12 Apr 2022 07:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748113; bh=BLL1ThT14rAdfe7KLHhuxZlKwl3O7IlydZEAE1URQJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S2wcWehQgyyspLRmIRcJuf0+cGzWQeYphntSVyllqwUpJuRWWSS7tjOm/WrK6WbMe AGISHuTRRuBCybQ6hhi9gehlvmifpF/5CN1BE9K55BSATTschdsLqWEeNfCzMNSNK7 RbS5umIuwc8peFkcjy4znSXksUcJy9RIHASUHvQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , Johannes Thumshirn , David Sterba Subject: [PATCH 5.17 284/343] btrfs: zoned: traverse devices under chunk_mutex in btrfs_can_activate_zone Date: Tue, 12 Apr 2022 08:31:42 +0200 Message-Id: <20220412062959.521602308@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Johannes Thumshirn commit 0b9e66762aa0cda2a9c2d5542d64e04dac528fa6 upstream. btrfs_can_activate_zone() can be called with the device_list_mutex already held, which will lead to a deadlock: insert_dev_extents() // Takes device_list_mutex `-> insert_dev_extent() `-> btrfs_insert_empty_item() `-> btrfs_insert_empty_items() `-> btrfs_search_slot() `-> btrfs_cow_block() `-> __btrfs_cow_block() `-> btrfs_alloc_tree_block() `-> btrfs_reserve_extent() `-> find_free_extent() `-> find_free_extent_update_loop() `-> can_allocate_chunk() `-> btrfs_can_activate_zone() // Takes device_list_mutex again Instead of using the RCU on fs_devices->device_list we can use fs_devices->alloc_list, protected by the chunk_mutex to traverse the list of active devices. We are in the chunk allocation thread. The newer chunk allocation happens from the devices in the fs_device->alloc_list protected by the chunk_mutex. btrfs_create_chunk() lockdep_assert_held(&info->chunk_mutex); gather_device_info list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) Also, a device that reappears after the mount won't join the alloc_list yet and, it will be in the dev_list, which we don't want to consider in the context of the chunk alloc. [15.166572] WARNING: possible recursive locking detected [15.167117] 5.17.0-rc6-dennis #79 Not tainted [15.167487] -------------------------------------------- [15.167733] kworker/u8:3/146 is trying to acquire lock: [15.167733] ffff888102962ee0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, a= t: find_free_extent+0x15a/0x14f0 [btrfs] [15.167733] [15.167733] but task is already holding lock: [15.167733] ffff888102962ee0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, a= t: btrfs_create_pending_block_groups+0x20a/0x560 [btrfs] [15.167733] [15.167733] other info that might help us debug this: [15.167733] Possible unsafe locking scenario: [15.167733] [15.171834] CPU0 [15.171834] ---- [15.171834] lock(&fs_devs->device_list_mutex); [15.171834] lock(&fs_devs->device_list_mutex); [15.171834] [15.171834] *** DEADLOCK *** [15.171834] [15.171834] May be due to missing lock nesting notation [15.171834] [15.171834] 5 locks held by kworker/u8:3/146: [15.171834] #0: ffff888100050938 ((wq_completion)events_unbound){+.+.}-{= 0:0}, at: process_one_work+0x1c3/0x5a0 [15.171834] #1: ffffc9000067be80 ((work_completion)(&fs_info->async_data= _reclaim_work)){+.+.}-{0:0}, at: process_one_work+0x1c3/0x5a0 [15.176244] #2: ffff88810521e620 (sb_internal){.+.+}-{0:0}, at: flush_sp= ace+0x335/0x600 [btrfs] [15.176244] #3: ffff888102962ee0 (&fs_devs->device_list_mutex){+.+.}-{3:= 3}, at: btrfs_create_pending_block_groups+0x20a/0x560 [btrfs] [15.176244] #4: ffff8881152e4b78 (btrfs-dev-00){++++}-{3:3}, at: __btrfs= _tree_lock+0x27/0x130 [btrfs] [15.179641] [15.179641] stack backtrace: [15.179641] CPU: 1 PID: 146 Comm: kworker/u8:3 Not tainted 5.17.0-rc6-den= nis #79 [15.179641] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1= .15.0-1.fc35 04/01/2014 [15.179641] Workqueue: events_unbound btrfs_async_reclaim_data_space [btr= fs] [15.179641] Call Trace: [15.179641] [15.179641] dump_stack_lvl+0x45/0x59 [15.179641] __lock_acquire.cold+0x217/0x2b2 [15.179641] lock_acquire+0xbf/0x2b0 [15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs] [15.183838] __mutex_lock+0x8e/0x970 [15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs] [15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs] [15.183838] ? lock_is_held_type+0xd7/0x130 [15.183838] ? find_free_extent+0x15a/0x14f0 [btrfs] [15.183838] find_free_extent+0x15a/0x14f0 [btrfs] [15.183838] ? _raw_spin_unlock+0x24/0x40 [15.183838] ? btrfs_get_alloc_profile+0x106/0x230 [btrfs] [15.187601] btrfs_reserve_extent+0x131/0x260 [btrfs] [15.187601] btrfs_alloc_tree_block+0xb5/0x3b0 [btrfs] [15.187601] __btrfs_cow_block+0x138/0x600 [btrfs] [15.187601] btrfs_cow_block+0x10f/0x230 [btrfs] [15.187601] btrfs_search_slot+0x55f/0xbc0 [btrfs] [15.187601] ? lock_is_held_type+0xd7/0x130 [15.187601] btrfs_insert_empty_items+0x2d/0x60 [btrfs] [15.187601] btrfs_create_pending_block_groups+0x2b3/0x560 [btrfs] [15.187601] __btrfs_end_transaction+0x36/0x2a0 [btrfs] [15.192037] flush_space+0x374/0x600 [btrfs] [15.192037] ? find_held_lock+0x2b/0x80 [15.192037] ? btrfs_async_reclaim_data_space+0x49/0x180 [btrfs] [15.192037] ? lock_release+0x131/0x2b0 [15.192037] btrfs_async_reclaim_data_space+0x70/0x180 [btrfs] [15.192037] process_one_work+0x24c/0x5a0 [15.192037] worker_thread+0x4a/0x3d0 Fixes: a85f05e59bc1 ("btrfs: zoned: avoid chunk allocation if active block = group has enough space") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Anand Jain Signed-off-by: Johannes Thumshirn Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/btrfs/zoned.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1927,18 +1927,19 @@ int btrfs_zone_finish(struct btrfs_block =20 bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flag= s) { + struct btrfs_fs_info *fs_info =3D fs_devices->fs_info; struct btrfs_device *device; bool ret =3D false; =20 - if (!btrfs_is_zoned(fs_devices->fs_info)) + if (!btrfs_is_zoned(fs_info)) return true; =20 /* Non-single profiles are not supported yet */ ASSERT((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) =3D=3D 0); =20 /* Check if there is a device with active zones left */ - mutex_lock(&fs_devices->device_list_mutex); - list_for_each_entry(device, &fs_devices->devices, dev_list) { + mutex_lock(&fs_info->chunk_mutex); + list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) { struct btrfs_zoned_device_info *zinfo =3D device->zone_info; =20 if (!device->bdev) @@ -1950,7 +1951,7 @@ bool btrfs_can_activate_zone(struct btrf break; } } - mutex_unlock(&fs_devices->device_list_mutex); + mutex_unlock(&fs_info->chunk_mutex); =20 return ret; } From nobody Thu May 14 08:08:21 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 BACB6C433F5 for ; Tue, 12 Apr 2022 08:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380356AbiDLI5X (ORCPT ); Tue, 12 Apr 2022 04:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359385AbiDLHm7 (ORCPT ); Tue, 12 Apr 2022 03:42: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 967D52B26C; Tue, 12 Apr 2022 00:21: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 500E0B81B58; Tue, 12 Apr 2022 07:21:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7812C385A5; Tue, 12 Apr 2022 07:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748116; bh=17U5fxjfDHQoUCrXh9TImuMgn8x8tcs6hOXxEMC3CU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbO6MvSzvcGMFKYcRh077jsArKvSpW7ncEoBCZMj5hsby1O6bzZRFOE5lTVmAWq7P saYrwkWLfhjzYpJ+6Ec/hypzDKgHyZrSh+zeJSi3flJ0++uuLbk73nG49Jenp1PCM0 yS7WAm6GXW8O0KJ+SH39eOrA1VsPtkWL0bo+UnDc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Luca=20B=C3=A9la=20Palkovics?= , Anand Jain , Qu Wenruo , David Sterba Subject: [PATCH 5.17 285/343] btrfs: remove device item and update super block in the same transaction Date: Tue, 12 Apr 2022 08:31:43 +0200 Message-Id: <20220412062959.551154999@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Qu Wenruo commit bbac58698a55cc0a6f0c0d69a6dcd3f9f3134c11 upstream. [BUG] There is a report that a btrfs has a bad super block num devices. This makes btrfs to reject the fs completely. BTRFS error (device sdd3): super_num_devices 3 mismatch with num_devices = 2 found here BTRFS error (device sdd3): failed to read chunk tree: -22 BTRFS error (device sdd3): open_ctree failed [CAUSE] During btrfs device removal, chunk tree and super block num devs are updated in two different transactions: btrfs_rm_device() |- btrfs_rm_dev_item(device) | |- trans =3D btrfs_start_transaction() | | Now we got transaction X | | | |- btrfs_del_item() | | Now device item is removed from chunk tree | | | |- btrfs_commit_transaction() | Transaction X got committed, super num devs untouched, | but device item removed from chunk tree. | (AKA, super num devs is already incorrect) | |- cur_devices->num_devices--; |- cur_devices->total_devices--; |- btrfs_set_super_num_devices() All those operations are not in transaction X, thus it will only be written back to disk in next transaction. So after the transaction X in btrfs_rm_dev_item() committed, but before transaction X+1 (which can be minutes away), a power loss happen, then we got the super num mismatch. [FIX] Instead of starting and committing a transaction inside btrfs_rm_dev_item(), start a transaction in side btrfs_rm_device() and pass it to btrfs_rm_dev_item(). And only commit the transaction after everything is done. Reported-by: Luca B=C3=A9la Palkovics Link: https://lore.kernel.org/linux-btrfs/CA+8xDSpvdm_U0QLBAnrH=3DzqDq_cWCO= H5TiV46CKmp3igr44okQ@mail.gmail.com/ CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Anand Jain Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/btrfs/volumes.c | 65 ++++++++++++++++++++++--------------------------= ----- 1 file changed, 28 insertions(+), 37 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1945,23 +1945,18 @@ static void update_dev_time(const char * path_put(&path); } =20 -static int btrfs_rm_dev_item(struct btrfs_device *device) +static int btrfs_rm_dev_item(struct btrfs_trans_handle *trans, + struct btrfs_device *device) { struct btrfs_root *root =3D device->fs_info->chunk_root; int ret; struct btrfs_path *path; struct btrfs_key key; - struct btrfs_trans_handle *trans; =20 path =3D btrfs_alloc_path(); if (!path) return -ENOMEM; =20 - trans =3D btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) { - btrfs_free_path(path); - return PTR_ERR(trans); - } key.objectid =3D BTRFS_DEV_ITEMS_OBJECTID; key.type =3D BTRFS_DEV_ITEM_KEY; key.offset =3D device->devid; @@ -1972,21 +1967,12 @@ static int btrfs_rm_dev_item(struct btrf if (ret) { if (ret > 0) ret =3D -ENOENT; - btrfs_abort_transaction(trans, ret); - btrfs_end_transaction(trans); goto out; } =20 ret =3D btrfs_del_item(trans, root, path); - if (ret) { - btrfs_abort_transaction(trans, ret); - btrfs_end_transaction(trans); - } - out: btrfs_free_path(path); - if (!ret) - ret =3D btrfs_commit_transaction(trans); return ret; } =20 @@ -2127,6 +2113,7 @@ int btrfs_rm_device(struct btrfs_fs_info struct btrfs_dev_lookup_args *args, struct block_device **bdev, fmode_t *mode) { + struct btrfs_trans_handle *trans; struct btrfs_device *device; struct btrfs_fs_devices *cur_devices; struct btrfs_fs_devices *fs_devices =3D fs_info->fs_devices; @@ -2142,7 +2129,7 @@ int btrfs_rm_device(struct btrfs_fs_info =20 ret =3D btrfs_check_raid_min_devices(fs_info, num_devices - 1); if (ret) - goto out; + return ret; =20 device =3D btrfs_find_device(fs_info->fs_devices, args); if (!device) { @@ -2150,27 +2137,22 @@ int btrfs_rm_device(struct btrfs_fs_info ret =3D BTRFS_ERROR_DEV_MISSING_NOT_FOUND; else ret =3D -ENOENT; - goto out; + return ret; } =20 if (btrfs_pinned_by_swapfile(fs_info, device)) { btrfs_warn_in_rcu(fs_info, "cannot remove device %s (devid %llu) due to active swapfile", rcu_str_deref(device->name), device->devid); - ret =3D -ETXTBSY; - goto out; + return -ETXTBSY; } =20 - if (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) { - ret =3D BTRFS_ERROR_DEV_TGT_REPLACE; - goto out; - } + if (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)) + return BTRFS_ERROR_DEV_TGT_REPLACE; =20 if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && - fs_info->fs_devices->rw_devices =3D=3D 1) { - ret =3D BTRFS_ERROR_DEV_ONLY_WRITABLE; - goto out; - } + fs_info->fs_devices->rw_devices =3D=3D 1) + return BTRFS_ERROR_DEV_ONLY_WRITABLE; =20 if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { mutex_lock(&fs_info->chunk_mutex); @@ -2183,14 +2165,22 @@ int btrfs_rm_device(struct btrfs_fs_info if (ret) goto error_undo; =20 - /* - * TODO: the superblock still includes this device in its num_devices - * counter although write_all_supers() is not locked out. This - * could give a filesystem state which requires a degraded mount. - */ - ret =3D btrfs_rm_dev_item(device); - if (ret) + trans =3D btrfs_start_transaction(fs_info->chunk_root, 0); + if (IS_ERR(trans)) { + ret =3D PTR_ERR(trans); goto error_undo; + } + + ret =3D btrfs_rm_dev_item(trans, device); + if (ret) { + /* Any error in dev item removal is critical */ + btrfs_crit(fs_info, + "failed to remove device item for devid %llu: %d", + device->devid, ret); + btrfs_abort_transaction(trans, ret); + btrfs_end_transaction(trans); + return ret; + } =20 clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state); btrfs_scrub_cancel_dev(device); @@ -2273,7 +2263,8 @@ int btrfs_rm_device(struct btrfs_fs_info free_fs_devices(cur_devices); } =20 -out: + ret =3D btrfs_commit_transaction(trans); + return ret; =20 error_undo: @@ -2284,7 +2275,7 @@ error_undo: device->fs_devices->rw_devices++; mutex_unlock(&fs_info->chunk_mutex); } - goto out; + return ret; } =20 void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_device *srcdev) From nobody Thu May 14 08:08:21 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 1D08EC4167B for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386408AbiDLI5z (ORCPT ); Tue, 12 Apr 2022 04:57:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359386AbiDLHm7 (ORCPT ); Tue, 12 Apr 2022 03:42:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B44EB2CC92; Tue, 12 Apr 2022 00:22: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 5BF19B81B60; Tue, 12 Apr 2022 07:22:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA537C385A1; Tue, 12 Apr 2022 07:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748119; bh=oVLVH4dSiXl6ZrohuS/jFnrjBXXcyG7ewltwzTF8/vg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B4xkqMnbkuJZNxSwkicNWWjdhRWBPJseJrp3DOrT26MpLBDWM2y9Ax5BT2Tckphp6 +K3vOnkScPRtLz4A8Nkyfhe0SFVBo0VuNblf1WAKXRGACZ63o+THWAsDaiJHK52VVT ZFu3c2yGmj53OSf9YnC3ai4HQmM3k7dYyPn6+RL4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Qu Wenruo , David Sterba Subject: [PATCH 5.17 286/343] btrfs: avoid defragging extents whose next extents are not targets Date: Tue, 12 Apr 2022 08:31:44 +0200 Message-Id: <20220412062959.581114826@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Qu Wenruo commit 75a36a7d3ea904cef2e5b56af0c58cc60dcf947a upstream. [BUG] There is a report that autodefrag is defragging single sector, which is completely waste of IO, and no help for defragging: btrfs-cleaner-808 defrag_one_locked_range: root=3D256 ino=3D651122 start= =3D0 len=3D4096 [CAUSE] In defrag_collect_targets(), we check if the current range (A) can be merged with next one (B). If mergeable, we will add range A into target for defrag. However there is a catch for autodefrag, when checking mergeability against range B, we intentionally pass 0 as @newer_than, hoping to get a higher chance to merge with the next extent. But in the next iteration, range B will looked up by defrag_lookup_extent(), with non-zero @newer_than. And if range B is not really newer, it will rejected directly, causing only range A being defragged, while we expect to defrag both range A and B. [FIX] Since the root cause is the difference in check condition of defrag_check_next_extent() and defrag_collect_targets(), we fix it by: 1. Pass @newer_than to defrag_check_next_extent() 2. Pass @extent_thresh to defrag_check_next_extent() This makes the check between defrag_collect_targets() and defrag_check_next_extent() more consistent. While there is still some minor difference, the remaining checks are focus on runtime flags like writeback/delalloc, which are mostly transient and safe to be checked only in defrag_collect_targets(). Link: https://github.com/btrfs/linux/issues/423#issuecomment-1066981856 CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Filipe Manana Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/btrfs/ioctl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1215,7 +1215,7 @@ static u32 get_extent_max_capacity(const } =20 static bool defrag_check_next_extent(struct inode *inode, struct extent_ma= p *em, - bool locked) + u32 extent_thresh, u64 newer_than, bool locked) { struct extent_map *next; bool ret =3D false; @@ -1225,11 +1225,12 @@ static bool defrag_check_next_extent(str return false; =20 /* - * We want to check if the next extent can be merged with the current - * one, which can be an extent created in a past generation, so we pass - * a minimum generation of 0 to defrag_lookup_extent(). + * Here we need to pass @newer_then when checking the next extent, or + * we will hit a case we mark current extent for defrag, but the next + * one will not be a target. + * This will just cause extra IO without really reducing the fragments. */ - next =3D defrag_lookup_extent(inode, em->start + em->len, 0, locked); + next =3D defrag_lookup_extent(inode, em->start + em->len, newer_than, loc= ked); /* No more em or hole */ if (!next || next->block_start >=3D EXTENT_MAP_LAST_BYTE) goto out; @@ -1241,6 +1242,13 @@ static bool defrag_check_next_extent(str */ if (next->len >=3D get_extent_max_capacity(em)) goto out; + /* Skip older extent */ + if (next->generation < newer_than) + goto out; + /* Also check extent size */ + if (next->len >=3D extent_thresh) + goto out; + ret =3D true; out: free_extent_map(next); @@ -1446,7 +1454,7 @@ static int defrag_collect_targets(struct goto next; =20 next_mergeable =3D defrag_check_next_extent(&inode->vfs_inode, em, - locked); + extent_thresh, newer_than, locked); if (!next_mergeable) { struct defrag_target_range *last; From nobody Thu May 14 08:08:21 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 BE318C352A7 for ; Tue, 12 Apr 2022 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386066AbiDLIyC (ORCPT ); Tue, 12 Apr 2022 04:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359388AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 75A042CC9C; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 331E5B81B58; Tue, 12 Apr 2022 07:22:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C85FC385A1; Tue, 12 Apr 2022 07:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748121; bh=PkpEYYaFN+mCmc24zaHnpXLxoDbtM4+leHpEARJnT48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MnohntWgJjGw6GQWdMXRUXj6mdMz840X2pqv+HtRWNbkmM6GlQ83SqDT4ZYKgfJ+Q wTfrGnms2/zACNZZpFYyyk249pl92OCm+V2kPau/NJNmlM34nrOJXkjfv4nmdY5wEw icxBw37e8m/IP8teemGtub6zNWykJbDq4w6lj4Ew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robbie Ko , Qu Wenruo , Filipe Manana , Kaiwen Hu , David Sterba Subject: [PATCH 5.17 287/343] btrfs: prevent subvol with swapfile from being deleted Date: Tue, 12 Apr 2022 08:31:45 +0200 Message-Id: <20220412062959.611109442@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kaiwen Hu commit 60021bd754c6ca0addc6817994f20290a321d8d6 upstream. A subvolume with an active swapfile must not be deleted otherwise it would not be possible to deactivate it. After the subvolume is deleted, we cannot swapoff the swapfile in this deleted subvolume because the path is unreachable. The swapfile is still active and holding references, the filesystem cannot be unmounted. The test looks like this: mkfs.btrfs -f $dev > /dev/null mount $dev $mnt btrfs sub create $mnt/subvol touch $mnt/subvol/swapfile chmod 600 $mnt/subvol/swapfile chattr +C $mnt/subvol/swapfile dd if=3D/dev/zero of=3D$mnt/subvol/swapfile bs=3D1K count=3D4096 mkswap $mnt/subvol/swapfile swapon $mnt/subvol/swapfile btrfs sub delete $mnt/subvol swapoff $mnt/subvol/swapfile # failed: No such file or directory swapoff --all unmount $mnt # target is busy. To prevent above issue, we simply check that whether the subvolume contains any active swapfile, and stop the deleting process. This behavior is like snapshot ioctl dealing with a swapfile. CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Robbie Ko Reviewed-by: Qu Wenruo Reviewed-by: Filipe Manana Signed-off-by: Kaiwen Hu Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/btrfs/inode.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4466,6 +4466,13 @@ int btrfs_delete_subvolume(struct inode dest->root_key.objectid); return -EPERM; } + if (atomic_read(&dest->nr_swapfiles)) { + spin_unlock(&dest->root_item_lock); + btrfs_warn(fs_info, + "attempt to delete subvolume %llu with active swapfile", + root->root_key.objectid); + return -EPERM; + } root_flags =3D btrfs_root_flags(&dest->root_item); btrfs_set_root_flags(&dest->root_item, root_flags | BTRFS_ROOT_SUBVOL_DEAD); @@ -10424,8 +10431,23 @@ static int btrfs_swap_activate(struct sw * set. We use this counter to prevent snapshots. We must increment it * before walking the extents because we don't want a concurrent * snapshot to run after we've already checked the extents. - */ + * + * It is possible that subvolume is marked for deletion but still not + * removed yet. To prevent this race, we check the root status before + * activating the swapfile. + */ + spin_lock(&root->root_item_lock); + if (btrfs_root_dead(root)) { + spin_unlock(&root->root_item_lock); + + btrfs_exclop_finish(fs_info); + btrfs_warn(fs_info, + "cannot activate swapfile because subvolume %llu is being deleted", + root->root_key.objectid); + return -EPERM; + } atomic_inc(&root->nr_swapfiles); + spin_unlock(&root->root_item_lock); =20 isize =3D ALIGN_DOWN(inode->i_size, fs_info->sectorsize); From nobody Thu May 14 08:08:21 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 D8F5BC3527E for ; Tue, 12 Apr 2022 08:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385805AbiDLIxC (ORCPT ); Tue, 12 Apr 2022 04:53:02 -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 S1359092AbiDLHma (ORCPT ); Tue, 12 Apr 2022 03:42: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 015905523C; Tue, 12 Apr 2022 00:20: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 A546FB81B6A; Tue, 12 Apr 2022 07:20:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02CF4C385A5; Tue, 12 Apr 2022 07:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748011; bh=xUTyRZPsMXwHoFuxnBfly520MoRrE/Fv7qY+hGuZ+EI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O14b2SptY1m/3b9c7Xa2L9toUNGW8HUfSyIUsBLCGuUopANFw/UKysrDA6vva6vHM TTM2PtM2mi9W6FacUU3TipI3OiGusc8sZ30cM3B36J5c/ABlrIghmIYMGOFkXiU3z3 y8YhhYVDQTL8tsOTI3pNY1Ygch5pSVB3DEIShWeY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinod Koul , Mark Brown Subject: [PATCH 5.17 288/343] spi: core: add dma_map_dev for __spi_unmap_msg() Date: Tue, 12 Apr 2022 08:31:46 +0200 Message-Id: <20220412062959.640623253@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Vinod Koul commit 409543cec01a84610029d6440c480c3fdd7214fb upstream. Commit b470e10eb43f ("spi: core: add dma_map_dev for dma device") added dma_map_dev for _spi_map_msg() but missed to add for unmap routine, __spi_unmap_msg(), so add it now. Fixes: b470e10eb43f ("spi: core: add dma_map_dev for dma device") Cc: stable@vger.kernel.org # v5.14+ Signed-off-by: Vinod Koul Link: https://lore.kernel.org/r/20220406132238.1029249-1-vkoul@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/spi/spi.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1149,11 +1149,15 @@ static int __spi_unmap_msg(struct spi_co =20 if (ctlr->dma_tx) tx_dev =3D ctlr->dma_tx->device->dev; + else if (ctlr->dma_map_dev) + tx_dev =3D ctlr->dma_map_dev; else tx_dev =3D ctlr->dev.parent; =20 if (ctlr->dma_rx) rx_dev =3D ctlr->dma_rx->device->dev; + else if (ctlr->dma_map_dev) + rx_dev =3D ctlr->dma_map_dev; else rx_dev =3D ctlr->dev.parent; From nobody Thu May 14 08:08:21 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 B238BC4332F for ; Tue, 12 Apr 2022 09:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344339AbiDLJJ6 (ORCPT ); Tue, 12 Apr 2022 05:09:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359100AbiDLHmb (ORCPT ); Tue, 12 Apr 2022 03:42:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35EAE55483; Tue, 12 Apr 2022 00:20: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 BA32E616B2; Tue, 12 Apr 2022 07:20:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C504DC385A5; Tue, 12 Apr 2022 07:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748014; bh=G4nXFvcr9Il+xgiyLJXTB2I4UFpbZB76hNekK2W5Qc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYK9HMLUjRlvwOgU9t1AZLRV0YLs1QLFmLxp0EYSCeVC8oi3a9Qr1arxN+2oe8eat byeXMIempcqcHL5RRBEFtMWKWOjzdjnZYykSucMcp8B12YooES4WAqkNYUgsLN2Q5O /U8Mrhy06wKp1MaxGvA6Qzbfo/5luI0QsIbcfmZA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Paulo Alcantara (SUSE)" , Enzo Matsumiya , Steve French Subject: [PATCH 5.17 289/343] cifs: force new session setup and tcon for dfs Date: Tue, 12 Apr 2022 08:31:47 +0200 Message-Id: <20220412062959.670188954@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Paulo Alcantara commit fb39d30e227233498c8debe6a9fe3e7cf575c85f upstream. Do not reuse existing sessions and tcons in DFS failover as it might connect to different servers and shares. Signed-off-by: Paulo Alcantara (SUSE) Cc: stable@vger.kernel.org Reviewed-by: Enzo Matsumiya Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/cifs/connect.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -453,9 +453,7 @@ static int reconnect_target_unlocked(str return rc; } =20 -static int -reconnect_dfs_server(struct TCP_Server_Info *server, - bool mark_smb_session) +static int reconnect_dfs_server(struct TCP_Server_Info *server) { int rc =3D 0; const char *refpath =3D server->current_fullpath + 1; @@ -479,7 +477,12 @@ reconnect_dfs_server(struct TCP_Server_I if (!cifs_tcp_ses_needs_reconnect(server, num_targets)) return 0; =20 - cifs_mark_tcp_ses_conns_for_reconnect(server, mark_smb_session); + /* + * Unconditionally mark all sessions & tcons for reconnect as we might be= connecting to a + * different server or share during failover. It could be improved by ad= ding some logic to + * only do that in case it connects to a different server or share, thoug= h. + */ + cifs_mark_tcp_ses_conns_for_reconnect(server, true); =20 cifs_abort_connection(server); =20 @@ -537,7 +540,7 @@ int cifs_reconnect(struct TCP_Server_Inf } spin_unlock(&cifs_tcp_ses_lock); =20 - return reconnect_dfs_server(server, mark_smb_session); + return reconnect_dfs_server(server); } #else int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) From nobody Thu May 14 08:08:21 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 9C00FC433FE for ; Tue, 12 Apr 2022 09:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235245AbiDLJJw (ORCPT ); Tue, 12 Apr 2022 05:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359132AbiDLHmd (ORCPT ); Tue, 12 Apr 2022 03:42: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 74EF355233; Tue, 12 Apr 2022 00:20: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 22AC7B81B58; Tue, 12 Apr 2022 07:20:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73A91C385A5; Tue, 12 Apr 2022 07:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748016; bh=sC+yelsbh94fJQss7tqpXVH0tAA6PB+cx7LgaWENbnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7926cvITvgsM7pzN2cmXb5age+GG9m5FaxjF9f8r8C91Wwpdi9DaPYwaYdRbJkrP 7V95HDvgtDHJmm66+NsBR2/lVRvobnnw4z92w3+SvkyuGdpfmjOmz3p8+LH1zdhVg8 guOYYA1SZDYjo5cDrq5gQ9ZVJOyQg3xRM20Ervuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tim Gardner , "David S. Miller" , Prabhakar Kushwaha , Alok Prasad , Ariel Elior , Manish Chopra Subject: [PATCH 5.17 290/343] qed: fix ethtool register dump Date: Tue, 12 Apr 2022 08:31:48 +0200 Message-Id: <20220412062959.698888922@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Manish Chopra commit 20921c0c86092b4082c91bd7c88305da74e5520b upstream. To fix a coverity complain, commit d5ac07dfbd2b ("qed: Initialize debug string array") removed "sw-platform" (one of the common global parameters) from the dump as this was used in the dump with an uninitialized string, however it did not reduce the number of common global parameters which caused the incorrect (unable to parse) register dump this patch fixes it with reducing NUM_COMMON_GLOBAL_PARAMS bye one. Cc: stable@vger.kernel.org Cc: Tim Gardner Cc: "David S. Miller" Fixes: d5ac07dfbd2b ("qed: Initialize debug string array") Signed-off-by: Prabhakar Kushwaha Signed-off-by: Alok Prasad Signed-off-by: Ariel Elior Signed-off-by: Manish Chopra Reviewed-by: Tim Gardner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/net/ethernet/qlogic/qed/qed_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/qlogic/qed/qed_debug.c +++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c @@ -489,7 +489,7 @@ struct split_type_defs { =20 #define STATIC_DEBUG_LINE_DWORDS 9 =20 -#define NUM_COMMON_GLOBAL_PARAMS 11 +#define NUM_COMMON_GLOBAL_PARAMS 10 =20 #define MAX_RECURSION_DEPTH 10 From nobody Thu May 14 08:08:21 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 01926C35296 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387295AbiDLJGk (ORCPT ); Tue, 12 Apr 2022 05:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359138AbiDLHmd (ORCPT ); Tue, 12 Apr 2022 03:42:33 -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 84F3229C9A; Tue, 12 Apr 2022 00:20: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 dfw.source.kernel.org (Postfix) with ESMTPS id 2017C616B2; Tue, 12 Apr 2022 07:20:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B716C385A5; Tue, 12 Apr 2022 07:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748019; bh=3RUt2KxfRxSsYsWSSjP4U2KH/Rhc8qyzgbW8l/zg94U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWTOMeKdRFTvk5q9m8o9rGAHltTix9wp6zXC7dT+qeU9BjzFbPxmepPBv0wXcxfsy 70q9cB4QIbdX8l9A5bknZFF9XYYAyvi99Uvve9rPzPywXy8yBdZfGMxCLKBfaJA2PH rTN9YdCV9c9LaKbxkrNOvEifpZd6WbiMc9DXqwFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Guo Ren , Catalin Marinas , Masami Hiramatsu , Will Deacon Subject: [PATCH 5.17 291/343] arm64: patch_text: Fixup last cpu should be master Date: Tue, 12 Apr 2022 08:31:49 +0200 Message-Id: <20220412062959.727297612@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Guo Ren commit 31a099dbd91e69fcab55eef4be15ed7a8c984918 upstream. These patch_text implementations are using stop_machine_cpuslocked infrastructure with atomic cpu_count. The original idea: When the master CPU patch_text, the others should wait for it. But current implementation is using the first CPU as master, which couldn't guarantee the remaining CPUs are waiting. This patch changes the last CPU as the master to solve the potential risk. Fixes: ae16480785de ("arm64: introduce interfaces to hotpatch kernel and mo= dule code") Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Catalin Marinas Reviewed-by: Masami Hiramatsu Cc: Link: https://lore.kernel.org/r/20220407073323.743224-2-guoren@kernel.org Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/arm64/kernel/patching.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm64/kernel/patching.c +++ b/arch/arm64/kernel/patching.c @@ -117,8 +117,8 @@ static int __kprobes aarch64_insn_patch_ int i, ret =3D 0; struct aarch64_insn_patch *pp =3D arg; =20 - /* The first CPU becomes master */ - if (atomic_inc_return(&pp->cpu_count) =3D=3D 1) { + /* The last CPU becomes master */ + if (atomic_inc_return(&pp->cpu_count) =3D=3D num_online_cpus()) { for (i =3D 0; ret =3D=3D 0 && i < pp->insn_cnt; i++) ret =3D aarch64_insn_patch_text_nosync(pp->text_addrs[i], pp->new_insns[i]); From nobody Thu May 14 08:08:21 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 E4ADCC47081 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387281AbiDLJGc (ORCPT ); Tue, 12 Apr 2022 05:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359185AbiDLHmk (ORCPT ); Tue, 12 Apr 2022 03:42: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 5C36F554A1; Tue, 12 Apr 2022 00:20: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 CDFFD61045; Tue, 12 Apr 2022 07:20:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7DB8C385A5; Tue, 12 Apr 2022 07:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748022; bh=U2/FILndl4co+BlYvc00C3mSRpRj6SmZahSvs4PQbsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zCmE1VjWh8ZSjvlyNgtKa7EIKWoZY1vhdMyO0uGYU6bewvbaMFPrNQvZQQfYDiw4A GCMEJwfKVDLg985EjXCYO5YtBPTjdynkoKgNGWZrQIU+omzfuO9Px+cFMWjbJvqGXl HE0GlVQT6jBVgPhaqi7eivw9RSgV4V8eCHe8hKvI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Miller , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 5.17 292/343] RDMA/hfi1: Fix use-after-free bug for mm struct Date: Tue, 12 Apr 2022 08:31:50 +0200 Message-Id: <20220412062959.756103757@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Douglas Miller commit 2bbac98d0930e8161b1957dc0ec99de39ade1b3c upstream. Under certain conditions, such as MPI_Abort, the hfi1 cleanup code may represent the last reference held on the task mm. hfi1_mmu_rb_unregister() then drops the last reference and the mm is freed before the final use in hfi1_release_user_pages(). A new task may allocate the mm structure while it is still being used, resulting in problems. One manifestation is corruption of the mmap_sem counter leading to a hang in down_write(). Another is corruption of an mm struct that is in use by another task. Fixes: 3d2a9d642512 ("IB/hfi1: Ensure correct mm is used at all times") Link: https://lore.kernel.org/r/20220408133523.122165.72975.stgit@awfm-01.c= ornelisnetworks.com Cc: Signed-off-by: Douglas Miller Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/infiniband/hw/hfi1/mmu_rb.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/infiniband/hw/hfi1/mmu_rb.c +++ b/drivers/infiniband/hw/hfi1/mmu_rb.c @@ -80,6 +80,9 @@ void hfi1_mmu_rb_unregister(struct mmu_r unsigned long flags; struct list_head del_list; =20 + /* Prevent freeing of mm until we are completely finished. */ + mmgrab(handler->mn.mm); + /* Unregister first so we don't get any more notifications. */ mmu_notifier_unregister(&handler->mn, handler->mn.mm); =20 @@ -102,6 +105,9 @@ void hfi1_mmu_rb_unregister(struct mmu_r =20 do_remove(handler, &del_list); =20 + /* Now the mm may be freed. */ + mmdrop(handler->mn.mm); + kfree(handler); } From nobody Thu May 14 08:08:21 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 15168C35280 for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385834AbiDLIxK (ORCPT ); Tue, 12 Apr 2022 04:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359204AbiDLHmm (ORCPT ); Tue, 12 Apr 2022 03:42:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9837D5574D; Tue, 12 Apr 2022 00:20: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 40C97B81A8F; Tue, 12 Apr 2022 07:20:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F4B6C385A1; Tue, 12 Apr 2022 07:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748024; bh=0KBfoJlCtolLpf0Fk7NcSiF38H54hGS9IKx9aYfxdsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9WwfkUcCanSpUaOh6SUD51q795TAKDw8rzk2KCKmUSfN3c6O9KM/OJFkfJsPYJ7z nq15yo224ZqXUbFy9MwIzQ0NJLRdxwvIDu1jt1fTCcTpFk8TtESw2RxTjEbyQQ2+OD NBl71289lQqv2CY4vVeL0laFWC61qjjkTZun6diw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , Lars Ellenberg , Jens Axboe Subject: [PATCH 5.17 293/343] drbd: fix an invalid memory access caused by incorrect use of list iterator Date: Tue, 12 Apr 2022 08:31:51 +0200 Message-Id: <20220412062959.784490497@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiaomeng Tong commit ae4d37b5df749926891583d42a6801b5da11e3c1 upstream. The bug is here: idr_remove(&connection->peer_devices, vnr); If the previous for_each_connection() don't exit early (no goto hit inside the loop), the iterator 'connection' after the loop will be a bogus pointer to an invalid structure object containing the HEAD (&resource->connections). As a result, the use of 'connection' above will lead to a invalid memory access (including a possible invalid free as idr_remove could call free_layer). The original intention should have been to remove all peer_devices, but the following lines have already done the work. So just remove this line and the unneeded label, to fix this bug. Cc: stable@vger.kernel.org Fixes: c06ece6ba6f1b ("drbd: Turn connection->volumes into connection->peer= _devices") Signed-off-by: Xiaomeng Tong Reviewed-by: Christoph B=C3=B6hmwalder Reviewed-by: Lars Ellenberg Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/block/drbd/drbd_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2793,12 +2793,12 @@ enum drbd_ret_code drbd_create_device(st =20 if (init_submitter(device)) { err =3D ERR_NOMEM; - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; } =20 err =3D add_disk(disk); if (err) - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; =20 /* inherit the connection state */ device->state.conn =3D first_connection(resource)->cstate; @@ -2812,8 +2812,6 @@ enum drbd_ret_code drbd_create_device(st drbd_debugfs_device_add(device); return NO_ERROR; =20 -out_idr_remove_vol: - idr_remove(&connection->peer_devices, vnr); out_idr_remove_from_resource: for_each_connection(connection, resource) { peer_device =3D idr_remove(&connection->peer_devices, vnr); From nobody Thu May 14 08:08:21 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 041C1C3527D for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385819AbiDLIxH (ORCPT ); Tue, 12 Apr 2022 04:53:07 -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 S1359214AbiDLHmt (ORCPT ); Tue, 12 Apr 2022 03:42:49 -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 72409554BF; Tue, 12 Apr 2022 00:20:30 -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 29E7CB81A8F; Tue, 12 Apr 2022 07:20:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73797C385A1; Tue, 12 Apr 2022 07:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748027; bh=u1+eONhLb4ECviN+wgOEn248x+H4smqRChUv5JM4SuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TZqpsO8jAS95IDRKzkUq6JBc/ccjXdDYszGZe9uSCMug3hKv0Pa2jc3wL0/HuikQO 9yNk5LOX/HJYjMyUTH53BiVWDaZpqi6EG76C4MTGfE7TaIrPEmZpYC/HCOOgIhLc5K GPESZi5kXgIADF1k4lu5ONPxxV9CtYtIn+QBCG5U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shreeya Patel , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski Subject: [PATCH 5.17 294/343] gpio: Restrict usage of GPIO chip irq members before initialization Date: Tue, 12 Apr 2022 08:31:52 +0200 Message-Id: <20220412062959.813051346@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Shreeya Patel commit 5467801f1fcbdc46bc7298a84dbf3ca1ff2a7320 upstream. GPIO chip irq members are exposed before they could be completely initialized and this leads to race conditions. One such issue was observed for the gc->irq.domain variable which was accessed through the I2C interface in gpiochip_to_irq() before it could be initialized by gpiochip_add_irqchip(). This resulted in Kernel NULL pointer dereference. Following are the logs for reference :- kernel: Call Trace: kernel: gpiod_to_irq+0x53/0x70 kernel: acpi_dev_gpio_irq_get_by+0x113/0x1f0 kernel: i2c_acpi_get_irq+0xc0/0xd0 kernel: i2c_device_probe+0x28a/0x2a0 kernel: really_probe+0xf2/0x460 kernel: RIP: 0010:gpiochip_to_irq+0x47/0xc0 To avoid such scenarios, restrict usage of GPIO chip irq members before they are completely initialized. Signed-off-by: Shreeya Patel Cc: stable@vger.kernel.org Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Signed-off-by: Bartosz Golaszewski Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpio/gpiolib.c | 19 +++++++++++++++++++ include/linux/gpio/driver.h | 9 +++++++++ 2 files changed, 28 insertions(+) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1404,6 +1404,16 @@ static int gpiochip_to_irq(struct gpio_c { struct irq_domain *domain =3D gc->irq.domain; =20 +#ifdef CONFIG_GPIOLIB_IRQCHIP + /* + * Avoid race condition with other code, which tries to lookup + * an IRQ before the irqchip has been properly registered, + * i.e. while gpiochip is still being brought up. + */ + if (!gc->irq.initialized) + return -EPROBE_DEFER; +#endif + if (!gpiochip_irqchip_irq_valid(gc, offset)) return -ENXIO; =20 @@ -1593,6 +1603,15 @@ static int gpiochip_add_irqchip(struct g =20 acpi_gpiochip_request_interrupts(gc); =20 + /* + * Using barrier() here to prevent compiler from reordering + * gc->irq.initialized before initialization of above + * GPIO chip irq members. + */ + barrier(); + + gc->irq.initialized =3D true; + return 0; } =20 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -219,6 +219,15 @@ struct gpio_irq_chip { bool per_parent_data; =20 /** + * @initialized: + * + * Flag to track GPIO chip irq member's initialization. + * This flag will make sure GPIO chip irq members are not used + * before they are initialized. + */ + bool initialized; + + /** * @init_hw: optional routine to initialize hardware before * an IRQ chip will be added. This is quite useful when * a particular driver wants to clear IRQ related registers From nobody Thu May 14 08:08:21 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 CFAADC352A1 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387250AbiDLJGW (ORCPT ); Tue, 12 Apr 2022 05:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359219AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC1155750; Tue, 12 Apr 2022 00:20: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 D6359B81B58; Tue, 12 Apr 2022 07:20:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30FFAC385A1; Tue, 12 Apr 2022 07:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748030; bh=X/kxAdyy8ubxvC4P7+q/VVC5pIvWgQr+bpFFx6PiJI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wXLOo8VTtBvD1ya6JytozOb4tASwdEh3mEJjsEZYXvvL0fwY/oIpgao1tQ6L7mc0K ggQfE+74wN1aEWWmaOUK0PDcn46qtZpcba60Kl9K0EHwf7qLzuZWuZHEbpA5nzX/oR MmAS/bLXHwLnujYm8cS5WdTuDdvk5ecPDnlRkvGM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian-Ken Rueegsegger , Reto Buerki , Thomas Gleixner Subject: [PATCH 5.17 295/343] x86/msi: Fix msi message data shadow struct Date: Tue, 12 Apr 2022 08:31:53 +0200 Message-Id: <20220412062959.841038610@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Reto Buerki commit 59b18a1e65b7a2134814106d0860010e10babe18 upstream. The x86 MSI message data is 32 bits in total and is either in compatibility or remappable format, see Intel Virtualization Technology for Directed I/O, section 5.1.2. Fixes: 6285aa50736 ("x86/msi: Provide msi message shadow structs") Co-developed-by: Adrian-Ken Rueegsegger Signed-off-by: Adrian-Ken Rueegsegger Signed-off-by: Reto Buerki Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220407110647.67372-1-reet@codelabs.ch Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/include/asm/msi.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/arch/x86/include/asm/msi.h +++ b/arch/x86/include/asm/msi.h @@ -12,14 +12,17 @@ int pci_msi_prepare(struct irq_domain *d /* Structs and defines for the X86 specific MSI message format */ =20 typedef struct x86_msi_data { - u32 vector : 8, - delivery_mode : 3, - dest_mode_logical : 1, - reserved : 2, - active_low : 1, - is_level : 1; - - u32 dmar_subhandle; + union { + struct { + u32 vector : 8, + delivery_mode : 3, + dest_mode_logical : 1, + reserved : 2, + active_low : 1, + is_level : 1; + }; + u32 dmar_subhandle; + }; } __attribute__ ((packed)) arch_msi_msg_data_t; #define arch_msi_msg_data x86_msi_data From nobody Thu May 14 08:08:21 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 0B9E4C41535 for ; Tue, 12 Apr 2022 08:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386585AbiDLI6k (ORCPT ); Tue, 12 Apr 2022 04:58:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359233AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E760355760; Tue, 12 Apr 2022 00:20: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 910BAB81B60; Tue, 12 Apr 2022 07:20:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6C08C385A5; Tue, 12 Apr 2022 07:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748033; bh=jZ9OyGMlutFC7CgIcngmbcnEnIoe5Nr2Zego+PXvzVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmFFMdA1ccWYkLkoy1uDyxLsyp6HmLVuUuSiboCZFuLJXPyaWvbackcUh+TAOgf4O Jm7/7apz+yza6oeSJIqOwHX8YI3dVE2LC7rbdV2dICgQ/3G0YLgLY3XET49SqUVpIJ tnopJDfQRxu2MjgxAxSiw04yFDya2mXPAobNf3rM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dave Hansen , Borislav Petkov , Nadav Amit Subject: [PATCH 5.17 296/343] x86/mm/tlb: Revert retpoline avoidance approach Date: Tue, 12 Apr 2022 08:31:54 +0200 Message-Id: <20220412062959.868855833@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Dave Hansen commit d39268ad24c0fd0665d0c5cf55a7c1a0ebf94766 upstream. 0day reported a regression on a microbenchmark which is intended to stress the TLB flushing path: https://lore.kernel.org/all/20220317090415.GE735@xsang-OptiPlex-9020/ It pointed at a commit from Nadav which intended to remove retpoline overhead in the TLB flushing path by taking the 'cond'-ition in on_each_cpu_cond_mask(), pre-calculating it, and incorporating it into 'cpumask'. That allowed the code to use a bunch of earlier direct calls instead of later indirect calls that need a retpoline. But, in practice, threads can go idle (and into lazy TLB mode where they don't need to flush their TLB) between the early and late calls. It works in this direction and not in the other because TLB-flushing threads tend to hold mmap_lock for write. Contention on that lock causes threads to _go_ idle right in this early/late window. There was not any performance data in the original commit specific to the retpoline overhead. I did a few tests on a system with retpolines: https://lore.kernel.org/all/dd8be93c-ded6-b962-50d4-96b1c3afb2b7@intel.com/ which showed a possible small win. But, that small win pales in comparison with the bigger loss induced on non-retpoline systems. Revert the patch that removed the retpolines. This was not a clean revert, but it was self-contained enough not to be too painful. Fixes: 6035152d8eeb ("x86/mm/tlb: Open-code on_each_cpu_cond_mask() for tlb= _is_not_lazy()") Reported-by: kernel test robot Signed-off-by: Dave Hansen Signed-off-by: Borislav Petkov Acked-by: Nadav Amit Cc: Link: https://lkml.kernel.org/r/164874672286.389.7021457716635788197.tip-bo= t2@tip-bot2 Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/mm/tlb.c | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -854,13 +854,11 @@ done: nr_invalidate); } =20 -static bool tlb_is_not_lazy(int cpu) +static bool tlb_is_not_lazy(int cpu, void *data) { return !per_cpu(cpu_tlbstate_shared.is_lazy, cpu); } =20 -static DEFINE_PER_CPU(cpumask_t, flush_tlb_mask); - DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state_shared, cpu_tlbstate_shared= ); EXPORT_PER_CPU_SYMBOL(cpu_tlbstate_shared); =20 @@ -889,36 +887,11 @@ STATIC_NOPV void native_flush_tlb_multi( * up on the new contents of what used to be page tables, while * doing a speculative memory access. */ - if (info->freed_tables) { + if (info->freed_tables) on_each_cpu_mask(cpumask, flush_tlb_func, (void *)info, true); - } else { - /* - * Although we could have used on_each_cpu_cond_mask(), - * open-coding it has performance advantages, as it eliminates - * the need for indirect calls or retpolines. In addition, it - * allows to use a designated cpumask for evaluating the - * condition, instead of allocating one. - * - * This code works under the assumption that there are no nested - * TLB flushes, an assumption that is already made in - * flush_tlb_mm_range(). - * - * cond_cpumask is logically a stack-local variable, but it is - * more efficient to have it off the stack and not to allocate - * it on demand. Preemption is disabled and this code is - * non-reentrant. - */ - struct cpumask *cond_cpumask =3D this_cpu_ptr(&flush_tlb_mask); - int cpu; - - cpumask_clear(cond_cpumask); - - for_each_cpu(cpu, cpumask) { - if (tlb_is_not_lazy(cpu)) - __cpumask_set_cpu(cpu, cond_cpumask); - } - on_each_cpu_mask(cond_cpumask, flush_tlb_func, (void *)info, true); - } + else + on_each_cpu_cond_mask(tlb_is_not_lazy, flush_tlb_func, + (void *)info, 1, cpumask); } =20 void flush_tlb_multi(const struct cpumask *cpumask, From nobody Thu May 14 08:08:21 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 26175C4707A for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385848AbiDLIxQ (ORCPT ); Tue, 12 Apr 2022 04:53:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359238AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A905C55758; Tue, 12 Apr 2022 00:20: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 5ED96B81B62; Tue, 12 Apr 2022 07:20:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A393BC385A5; Tue, 12 Apr 2022 07:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748036; bh=XVofjJ5ibd0lC46pPClYFZWxKn/UrgzU/kZncze9kwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EraJXSbBrRcei3OAVbe/KefoqWNMlItPbfUmZ34M7/lTFZ1nDV/qaijlQeaJTaLV/ g8l906csSMsY8BGsCaajrypQT0d3Bt74y81HW+k4OAru3q0q7QJm7ejlS9hHKpoUz1 PhdaUg/XJ0Dnl5D2PSsgw2DLZnkTja/Ju9L89qZY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 297/343] perf/x86/intel: Dont extend the pseudo-encoding to GP counters Date: Tue, 12 Apr 2022 08:31:55 +0200 Message-Id: <20220412062959.896992705@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 4a263bf331c512849062805ef1b4ac40301a9829 upstream. The INST_RETIRED.PREC_DIST event (0x0100) doesn't count on SPR. perf stat -e cpu/event=3D0xc0,umask=3D0x0/,cpu/event=3D0x0,umask=3D0x1/ -C0 Performance counter stats for 'CPU(s) 0': 607,246 cpu/event=3D0xc0,umask=3D0x0/ 0 cpu/event=3D0x0,umask=3D0x1/ The encoding for INST_RETIRED.PREC_DIST is pseudo-encoding, which doesn't work on the generic counters. However, current perf extends its mask to the generic counters. The pseudo event-code for a fixed counter must be 0x00. Check and avoid extending the mask for the fixed counter event which using the pseudo-encoding, e.g., ref-cycles and PREC_DIST event. With the patch, perf stat -e cpu/event=3D0xc0,umask=3D0x0/,cpu/event=3D0x0,umask=3D0x1/ -C0 Performance counter stats for 'CPU(s) 0': 583,184 cpu/event=3D0xc0,umask=3D0x0/ 583,048 cpu/event=3D0x0,umask=3D0x1/ Fixes: 2de71ee153ef ("perf/x86/intel: Fix ICL/SPR INST_RETIRED.PREC_DIST en= codings") Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/1648482543-14923-1-git-send-email-kan.liang= @linux.intel.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/events/intel/core.c | 6 +++++- arch/x86/include/asm/perf_event.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5515,7 +5515,11 @@ static void intel_pmu_check_event_constr /* Disabled fixed counters which are not in CPUID */ c->idxmsk64 &=3D intel_ctrl; =20 - if (c->idxmsk64 !=3D INTEL_PMC_MSK_FIXED_REF_CYCLES) + /* + * Don't extend the pseudo-encoding to the + * generic counters + */ + if (!use_fixed_pseudo_encoding(c->code)) c->idxmsk64 |=3D (1ULL << num_counters) - 1; } c->idxmsk64 &=3D --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -241,6 +241,11 @@ struct x86_pmu_capability { #define INTEL_PMC_IDX_FIXED_SLOTS (INTEL_PMC_IDX_FIXED + 3) #define INTEL_PMC_MSK_FIXED_SLOTS (1ULL << INTEL_PMC_IDX_FIXED_SLOTS) =20 +static inline bool use_fixed_pseudo_encoding(u64 code) +{ + return !(code & 0xff); +} + /* * We model BTS tracing as another fixed-mode PMC. * From nobody Thu May 14 08:08:21 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 97881C3525B for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386511AbiDLI6Q (ORCPT ); Tue, 12 Apr 2022 04:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359243AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -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 D7D3F55767; Tue, 12 Apr 2022 00:20: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 92B56B81B4F; Tue, 12 Apr 2022 07:20:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1028FC385A5; Tue, 12 Apr 2022 07:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748041; bh=qcBC7Iq+XgCMXLfN9mia0xFHlV/zufTYp/o7RMd+NvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUBBCn9vVOv6PF6XttnjuGuXN4KDrXSkABpJQUZwVTCXHesAXJQYHx1HrdvFjgmTO qPQMYdom0TQQpYHYNQrcY72TyxAZEY+k2cM6+EuGJbB1FgpTnoMAcvkoX74TC6DdI5 /y3t1mXNc+24mqxGXAeJARsqDEsrjR5Rqnxr77AI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lamparter , Damien Le Moal , stable@kernel.org Subject: [PATCH 5.17 298/343] ata: sata_dwc_460ex: Fix crash due to OOB write Date: Tue, 12 Apr 2022 08:31:56 +0200 Message-Id: <20220412062959.925837292@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Christian Lamparter commit 7aa8104a554713b685db729e66511b93d989dd6a upstream. the driver uses libata's "tag" values from in various arrays. Since the mentioned patch bumped the ATA_TAG_INTERNAL to 32, the value of the SATA_DWC_QCMD_MAX needs to account for that. Otherwise ATA_TAG_INTERNAL usage cause similar crashes like this as reported by Tice Rex on the OpenWrt Forum and reproduced (with symbols) here: | BUG: Kernel NULL pointer dereference at 0x00000000 | Faulting instruction address: 0xc03ed4b8 | Oops: Kernel access of bad area, sig: 11 [#1] | BE PAGE_SIZE=3D4K PowerPC 44x Platform | CPU: 0 PID: 362 Comm: scsi_eh_1 Not tainted 5.4.163 #0 | NIP: c03ed4b8 LR: c03d27e8 CTR: c03ed36c | REGS: cfa59950 TRAP: 0300 Not tainted (5.4.163) | MSR: 00021000 CR: 42000222 XER: 00000000 | DEAR: 00000000 ESR: 00000000 | GPR00: c03d27e8 cfa59a08 cfa55fe0 00000000 0fa46bc0 [...] | [..] | NIP [c03ed4b8] sata_dwc_qc_issue+0x14c/0x254 | LR [c03d27e8] ata_qc_issue+0x1c8/0x2dc | Call Trace: | [cfa59a08] [c003f4e0] __cancel_work_timer+0x124/0x194 (unreliable) | [cfa59a78] [c03d27e8] ata_qc_issue+0x1c8/0x2dc | [cfa59a98] [c03d2b3c] ata_exec_internal_sg+0x240/0x524 | [cfa59b08] [c03d2e98] ata_exec_internal+0x78/0xe0 | [cfa59b58] [c03d30fc] ata_read_log_page.part.38+0x1dc/0x204 | [cfa59bc8] [c03d324c] ata_identify_page_supported+0x68/0x130 | [...] This is because sata_dwc_dma_xfer_complete() NULLs the dma_pending's next neighbour "chan" (a *dma_chan struct) in this '32' case right here (line ~735): > hsdevp->dma_pending[tag] =3D SATA_DWC_DMA_PENDING_NONE; Then the next time, a dma gets issued; dma_dwc_xfer_setup() passes the NULL'd hsdevp->chan to the dmaengine_slave_config() which then causes the crash. With this patch, SATA_DWC_QCMD_MAX is now set to ATA_MAX_QUEUE + 1. This avoids the OOB. But please note, there was a worthwhile discussion on what ATA_TAG_INTERNAL and ATA_MAX_QUEUE is. And why there should not be a "fake" 33 command-long queue size. Ideally, the dw driver should account for the ATA_TAG_INTERNAL. In Damien Le Moal's words: "... having looked at the driver, it is a bigger change than just faking a 33rd "tag" that is in fact not a command tag at all." Fixes: 28361c403683c ("libata: add extra internal command") Cc: stable@kernel.org # 4.18+ BugLink: https://github.com/openwrt/openwrt/issues/9505 Signed-off-by: Christian Lamparter Signed-off-by: Damien Le Moal Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/ata/sata_dwc_460ex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/ata/sata_dwc_460ex.c +++ b/drivers/ata/sata_dwc_460ex.c @@ -137,7 +137,11 @@ struct sata_dwc_device { #endif }; =20 -#define SATA_DWC_QCMD_MAX 32 +/* + * Allow one extra special slot for commands and DMA management + * to account for libata internal commands. + */ +#define SATA_DWC_QCMD_MAX (ATA_MAX_QUEUE + 1) =20 struct sata_dwc_device_port { struct sata_dwc_device *hsdev; From nobody Thu May 14 08:08:21 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 DF8BCC3527C for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386571AbiDLI6h (ORCPT ); Tue, 12 Apr 2022 04:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359246AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C88605576F; Tue, 12 Apr 2022 00:20: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 ams.source.kernel.org (Postfix) with ESMTPS id 68C69B81B4F; Tue, 12 Apr 2022 07:20:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC151C385A5; Tue, 12 Apr 2022 07:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748044; bh=MIJOt/rCjVZ1I/G8JnoYtBGZqGnfCfzujr8/xisSegw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Sve3WKOwKEdV4sy/F7oDngq1zmz6M4BO/rGqY1Rxb7KcY9uXLphsuVcCUxY3qN/L U/4wLqAVlO/eosa/juLAzySiSRSrBGE5aCPsKf6s+O7u/e8jXqXB+0Pyd6gJvNahF0 WXRn4fFbNqV6Q52jo+F/mJeyvjiotpzX5XuHla8A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Will Deacon Subject: [PATCH 5.17 299/343] perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator Date: Tue, 12 Apr 2022 08:31:57 +0200 Message-Id: <20220412062959.954665608@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Xiaomeng Tong commit 2012a9e279013933885983cbe0a5fe828052563b upstream. The bug is here: return cluster; The list iterator value 'cluster' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found. To fix the bug, return 'cluster' when found, otherwise return NULL. Cc: stable@vger.kernel.org Fixes: 21bdbb7102ed ("perf: add qcom l2 cache perf events driver") Signed-off-by: Xiaomeng Tong Link: https://lore.kernel.org/r/20220327055733.4070-1-xiam0nd.tong@gmail.com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/perf/qcom_l2_pmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -736,7 +736,7 @@ static struct cluster_pmu *l2_cache_asso { u64 mpidr; int cpu_cluster_id; - struct cluster_pmu *cluster =3D NULL; + struct cluster_pmu *cluster; =20 /* * This assumes that the cluster_id is in MPIDR[aff1] for @@ -758,10 +758,10 @@ static struct cluster_pmu *l2_cache_asso cluster->cluster_id); cpumask_set_cpu(cpu, &cluster->cluster_cpus); *per_cpu_ptr(l2cache_pmu->pmu_cluster, cpu) =3D cluster; - break; + return cluster; } =20 - return cluster; + return NULL; } =20 static int l2cache_pmu_online_cpu(unsigned int cpu, struct hlist_node *nod= e) From nobody Thu May 14 08:08:21 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 BAFABC47082 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387237AbiDLJGR (ORCPT ); Tue, 12 Apr 2022 05:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359250AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ECDA55773; Tue, 12 Apr 2022 00:20: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 43368B81A8F; Tue, 12 Apr 2022 07:20:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A072EC385A5; Tue, 12 Apr 2022 07:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748047; bh=Rar/Pvhk3v1amjKZ3zbecoGXlsJVu+XTVZ7Y/z39xqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tau6P5AdOZWWvEsZ/8WmEeaTUyc/Ys+ndetngZheo+U0D1yf81RzPVsJ+d2fb1aKu /1G6LpVQIQMmxiWB5m2/OhnEdjZXWEbwXdkv2uCinQYpi5pM3Rf7aaIAHXoZK5VJEU c2uD+ChJEro6YM/bievk4nmulkWaRRJ7nIuO2/WI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 300/343] perf/core: Inherit event_caps Date: Tue, 12 Apr 2022 08:31:58 +0200 Message-Id: <20220412062959.982680382@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Namhyung Kim commit e3265a4386428d3d157d9565bb520aabff8b4bf0 upstream. It was reported that some perf event setup can make fork failed on ARM64. It was the case of a group of mixed hw and sw events and it failed in perf_event_init_task() due to armpmu_event_init(). The ARM PMU code checks if all the events in a group belong to the same PMU except for software events. But it didn't set the event_caps of inherited events and no longer identify them as software events. Therefore the test failed in a child process. A simple reproducer is: $ perf stat -e '{cycles,cs,instructions}' perf bench sched messaging # Running 'sched/messaging' benchmark: perf: fork(): Invalid argument The perf stat was fine but the perf bench failed in fork(). Let's inherit the event caps from the parent. Signed-off-by: Namhyung Kim Signed-off-by: Peter Zijlstra (Intel) Cc: Link: https://lkml.kernel.org/r/20220328200112.457740-1-namhyung@kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11640,6 +11640,9 @@ perf_event_alloc(struct perf_event_attr =20 event->state =3D PERF_EVENT_STATE_INACTIVE; =20 + if (parent_event) + event->event_caps =3D parent_event->event_caps; + if (event->attr.sigtrap) atomic_set(&event->event_limit, 1); From nobody Thu May 14 08:08:21 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 7ACD8C433FE for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387209AbiDLJGH (ORCPT ); Tue, 12 Apr 2022 05:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359232AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A4055775; Tue, 12 Apr 2022 00:20: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 408E96153F; Tue, 12 Apr 2022 07:20:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57FC8C385A1; Tue, 12 Apr 2022 07:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748049; bh=Jh0HxlaHDCPkrzXaR6A0TjXlWJhTiro1dmjnLAkCRbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tWIROBpHZbSO+lNDwRvJOnMnTjHgWvwEs0B3PPiZnhs1k6nU1EZ2TtUQ3/Ieh71E0 sNAaB/ofpKN4RyQVEdM7M+DXqAGPWDaKJmOASXP9Txnz2oOaK5lUPNxdlvtPWF8SQN eLcsNmW3wAT3FYOxX6B7u3pOX/Zh4+RmZehZSsKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Andre Przywara , Lorenzo Pieralisi Subject: [PATCH 5.17 301/343] irqchip/gic-v3: Fix GICR_CTLR.RWP polling Date: Tue, 12 Apr 2022 08:31:59 +0200 Message-Id: <20220412063000.011949903@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Zyngier commit 0df6664531a12cdd8fc873f0cac0dcb40243d3e9 upstream. It turns out that our polling of RWP is totally wrong when checking for it in the redistributors, as we test the *distributor* bit index, whereas it is a different bit number in the RDs... Oopsie boo. This is embarassing. Not only because it is wrong, but also because it took *8 years* to notice the blunder... Just fix the damn thing. Fixes: 021f653791ad ("irqchip: gic-v3: Initial support for GICv3") Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org Reviewed-by: Andre Przywara Reviewed-by: Lorenzo Pieralisi Link: https://lore.kernel.org/r/20220315165034.794482-2-maz@kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/irqchip/irq-gic-v3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -206,11 +206,11 @@ static inline void __iomem *gic_dist_bas } } =20 -static void gic_do_wait_for_rwp(void __iomem *base) +static void gic_do_wait_for_rwp(void __iomem *base, u32 bit) { u32 count =3D 1000000; /* 1s! */ =20 - while (readl_relaxed(base + GICD_CTLR) & GICD_CTLR_RWP) { + while (readl_relaxed(base + GICD_CTLR) & bit) { count--; if (!count) { pr_err_ratelimited("RWP timeout, gone fishing\n"); @@ -224,13 +224,13 @@ static void gic_do_wait_for_rwp(void __i /* Wait for completion of a distributor change */ static void gic_dist_wait_for_rwp(void) { - gic_do_wait_for_rwp(gic_data.dist_base); + gic_do_wait_for_rwp(gic_data.dist_base, GICD_CTLR_RWP); } =20 /* Wait for completion of a redistributor change */ static void gic_redist_wait_for_rwp(void) { - gic_do_wait_for_rwp(gic_data_rdist_rd_base()); + gic_do_wait_for_rwp(gic_data_rdist_rd_base(), GICR_CTLR_RWP); } =20 #ifdef CONFIG_ARM64 From nobody Thu May 14 08:08:21 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 1AC07C35280 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387158AbiDLJFv (ORCPT ); Tue, 12 Apr 2022 05:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359225AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 8DBEC29CA5; Tue, 12 Apr 2022 00:20: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 29560616B2; Tue, 12 Apr 2022 07:20:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3CD4C385A5; Tue, 12 Apr 2022 07:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748052; bh=m3tZRxMr7S8zSbKcnoVMQqq10GyW2aQbMlmVavnojeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4d5oc5leogTQ7ZP6BjcfkOJbIzCbiAw9b6yFVA+I12IMmR/WwcdO2s36GlreLuKy xugTBf7eTxlLa0PMIKdjQbckUANpoMYYL7kipAQhN1zarWQmDKXLota/V8RLieB47i XdZ+jaD8wa3lZD8ViB42/vRAAeyUP0kJKi6eeXlQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Zimmermann , Sudip Mukherjee , Daniel Vetter , Javier Martinez Canillas , Sudip Mukherjee , Zack Rusin , Hans de Goede , Helge Deller , Sam Ravnborg , Zheyu Ma , Xiyu Yang , Zhen Lei , Matthew Wilcox , Alex Deucher , Tetsuo Handa , Guenter Roeck , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 5.17 302/343] fbdev: Fix unregistering of framebuffers without device Date: Tue, 12 Apr 2022 08:32:00 +0200 Message-Id: <20220412063000.040458442@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Thomas Zimmermann commit 0f525289ff0ddeb380813bd81e0f9bdaaa1c9078 upstream. OF framebuffers do not have an underlying device in the Linux device hierarchy. Do a regular unregister call instead of hot unplugging such a non-existing device. Fixes a NULL dereference. An example error message on ppc64le is shown below. BUG: Kernel NULL pointer dereference on read at 0x00000060 Faulting instruction address: 0xc00000000080dfa4 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=3D64K MMU=3DHash SMP NR_CPUS=3D2048 NUMA pSeries [...] CPU: 2 PID: 139 Comm: systemd-udevd Not tainted 5.17.0-ae085d7f9365 #1 NIP: c00000000080dfa4 LR: c00000000080df9c CTR: c000000000797430 REGS: c000000004132fe0 TRAP: 0300 Not tainted (5.17.0-ae085d7f9365) MSR: 8000000002009033 CR: 28228282 XER: 200= 00000 CFAR: c00000000000c80c DAR: 0000000000000060 DSISR: 40000000 IRQMASK: 0 GPR00: c00000000080df9c c000000004133280 c00000000169d200 0000000000000029 GPR04: 00000000ffffefff c000000004132f90 c000000004132f88 0000000000000000 GPR08: c0000000015658f8 c0000000015cd200 c0000000014f57d0 0000000048228283 GPR12: 0000000000000000 c00000003fffe300 0000000020000000 0000000000000000 GPR16: 0000000000000000 0000000113fc4a40 0000000000000005 0000000113fcfb80 GPR20: 000001000f7283b0 0000000000000000 c000000000e4a588 c000000000e4a5b0 GPR24: 0000000000000001 00000000000a0000 c008000000db0168 c0000000021f6ec0 GPR28: c0000000016d65a8 c000000004b36460 0000000000000000 c0000000016d64b0 NIP [c00000000080dfa4] do_remove_conflicting_framebuffers+0x184/0x1d0 [c000000004133280] [c00000000080df9c] do_remove_conflicting_framebuffers+= 0x17c/0x1d0 (unreliable) [c000000004133350] [c00000000080e4d0] remove_conflicting_framebuffers+0x6= 0/0x150 [c0000000041333a0] [c00000000080e6f4] remove_conflicting_pci_framebuffers= +0x134/0x1b0 [c000000004133450] [c008000000e70438] drm_aperture_remove_conflicting_pci= _framebuffers+0x90/0x100 [drm] [c000000004133490] [c008000000da0ce4] bochs_pci_probe+0x6c/0xa64 [bochs] [...] [c000000004133db0] [c00000000002aaa0] system_call_exception+0x170/0x2d0 [c000000004133e10] [c00000000000c3cc] system_call_common+0xec/0x250 The bug [1] was introduced by commit 27599aacbaef ("fbdev: Hot-unplug firmware fb devices on forced removal"). Most firmware framebuffers have an underlying platform device, which can be hot-unplugged before loading the native graphics driver. OF framebuffers do not (yet) have that device. Fix the code by unregistering the framebuffer as before without a hot unplug. Tested with 5.17 on qemu ppc64le emulation. Signed-off-by: Thomas Zimmermann Fixes: 27599aacbaef ("fbdev: Hot-unplug firmware fb devices on forced remov= al") Reported-by: Sudip Mukherjee Reviewed-by: Daniel Vetter Reviewed-by: Javier Martinez Canillas Tested-by: Sudip Mukherjee Cc: Zack Rusin Cc: Javier Martinez Canillas Cc: Hans de Goede Cc: stable@vger.kernel.org # v5.11+ Cc: Helge Deller Cc: Daniel Vetter Cc: Sam Ravnborg Cc: Zheyu Ma Cc: Xiyu Yang Cc: Zhen Lei Cc: Matthew Wilcox Cc: Alex Deucher Cc: Tetsuo Handa Cc: Guenter Roeck Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Link: https://lore.kernel.org/all/YkHXO6LGHAN0p1pq@debian/ # [1] Link: https://patchwork.freedesktop.org/patch/msgid/20220404194402.29974-1-= tzimmermann@suse.de Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/video/fbdev/core/fbmem.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1583,7 +1583,14 @@ static void do_remove_conflicting_frameb * If it's not a platform device, at least print a warning. A * fix would add code to remove the device from the system. */ - if (dev_is_platform(device)) { + if (!device) { + /* TODO: Represent each OF framebuffer as its own + * device in the device hierarchy. For now, offb + * doesn't have such a device, so unregister the + * framebuffer as before without warning. + */ + do_unregister_framebuffer(registered_fb[i]); + } else if (dev_is_platform(device)) { registered_fb[i]->forced_out =3D true; platform_device_unregister(to_platform_device(device)); } else { From nobody Thu May 14 08:08:21 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 0B5DEC47080 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387137AbiDLJFo (ORCPT ); Tue, 12 Apr 2022 05:05:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359231AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C58829CAA; Tue, 12 Apr 2022 00:20: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 dfw.source.kernel.org (Postfix) with ESMTPS id CAAE56153F; Tue, 12 Apr 2022 07:20:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE20DC385A1; Tue, 12 Apr 2022 07:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748055; bh=7zGoYeuoPi9RAdbiPKb+irnBIcgN9hLDgptYFZeAQdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JIRfXK0piSvwh2Igu2goLn3TazXW5bdzf+wX4FviRxZ+elMG7D9oygKXl0UpwRZuF DJXBsY5FMKD+97aNdRoZlA9eUiqiBm5lXamh/KiYgjLfCKeRXOL/El0p0njYeAdBhq qaCsZQcA8oKjgNxs+qI6Bx9jeWh7IEsJFnrlY0MY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shirish S , Harry Wentland , Alex Deucher Subject: [PATCH 5.17 303/343] amd/display: set backlight only if required Date: Tue, 12 Apr 2022 08:32:01 +0200 Message-Id: <20220412063000.070566639@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Shirish S commit 4052287a75eb3fc0f487fcc5f768a38bede455c8 upstream. [Why] comparing pwm bl values (coverted) with user brightness(converted) levels in commit_tail leads to continuous setting of backlight via dmub as they don't to match. This leads overdrive in queuing of commands to DMCU that sometimes lead to depending on load on DMCU fw: "[drm:dc_dmub_srv_wait_idle] *ERROR* Error waiting for DMUB idle: status=3D= 3" [How] Store last successfully set backlight value and compare with it instead of pwm reads which is not what we should compare with. Signed-off-by: Shirish S Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 ++++--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3951,7 +3951,7 @@ static u32 convert_brightness_to_user(co max - min); } =20 -static int amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, +static void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *d= m, int bl_idx, u32 user_brightness) { @@ -3982,7 +3982,8 @@ static int amdgpu_dm_backlight_set_level DRM_DEBUG("DM: Failed to update backlight on eDP[%d]\n", bl_idx); } =20 - return rc ? 0 : 1; + if (rc) + dm->actual_brightness[bl_idx] =3D user_brightness; } =20 static int amdgpu_dm_backlight_update_status(struct backlight_device *bd) @@ -9914,7 +9915,7 @@ static void amdgpu_dm_atomic_commit_tail /* restore the backlight level */ for (i =3D 0; i < dm->num_of_edps; i++) { if (dm->backlight_dev[i] && - (amdgpu_dm_backlight_get_level(dm, i) !=3D dm->brightness[i])) + (dm->actual_brightness[i] !=3D dm->brightness[i])) amdgpu_dm_backlight_set_level(dm, i, dm->brightness[i]); } #endif --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -540,6 +540,12 @@ struct amdgpu_display_manager { * cached backlight values. */ u32 brightness[AMDGPU_DM_MAX_NUM_EDP]; + /** + * @actual_brightness: + * + * last successfully applied backlight values. + */ + u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP]; }; =20 enum dsc_clock_force_state { From nobody Thu May 14 08:08:21 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 F3CF2C35296 for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385935AbiDLIxi (ORCPT ); Tue, 12 Apr 2022 04:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359251AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92AE229C9B; Tue, 12 Apr 2022 00:21: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 509F9B81B62; Tue, 12 Apr 2022 07:20:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0E6CC385A1; Tue, 12 Apr 2022 07:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748058; bh=YMs7DdWMitcpwA45VOAPxYqNjZD+cfm5Xmc4BAEvph4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dxno26LCdcq90ndP0UOJiHUfV/GE4eCuGLulWNCSDhk/JgfgN6r3Mv2TXyXnHWSxo p53xGa0/cb935SrL1qhExy8S/I3BMQ1GzdRdHv5T9yzkGHt8yEPcuumRPAMyAVtS7H Qk0wZaEc9VEtCSn+PefRGwuZGr6u3bZ0KOtGUGUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Mack , Daniel Vetter Subject: [PATCH 5.17 304/343] drm/panel: ili9341: fix optional regulator handling Date: Tue, 12 Apr 2022 08:32:02 +0200 Message-Id: <20220412063000.099144337@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Daniel Mack commit d14eb80e27795b7b20060f7b151cdfe39722a813 upstream. If the optional regulator lookup fails, reset the pointer to NULL. Other functions such as mipi_dbi_poweron_reset_conditional() only do a NULL pointer check and will otherwise dereference the error pointer. Fixes: 5a04227326b04c15 ("drm/panel: Add ilitek ili9341 panel driver") Signed-off-by: Daniel Mack Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220317225537.826302-1= -daniel@zonque.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c @@ -612,8 +612,10 @@ static int ili9341_dbi_probe(struct spi_ int ret; =20 vcc =3D devm_regulator_get_optional(dev, "vcc"); - if (IS_ERR(vcc)) + if (IS_ERR(vcc)) { dev_err(dev, "get optional vcc failed\n"); + vcc =3D NULL; + } =20 dbidev =3D devm_drm_dev_alloc(dev, &ili9341_dbi_driver, struct mipi_dbi_dev, drm); From nobody Thu May 14 08:08:21 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 69C20C4332F for ; Tue, 12 Apr 2022 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385951AbiDLIxs (ORCPT ); Tue, 12 Apr 2022 04:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359254AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 F106529CA8; Tue, 12 Apr 2022 00:21: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 dfw.source.kernel.org (Postfix) with ESMTPS id 8B4D36153F; Tue, 12 Apr 2022 07:21:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92F26C385A1; Tue, 12 Apr 2022 07:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748061; bh=sW6g/q1XVSJnxHMPRxwCpYDjZPxGu1a7vykgCB/r26Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSlBhsb8nocprRD/d+iYdvm82cmGVxsZ2roqu5PX6aaPndOTciRd88rv2b/HT+TjK yUWvG6R5Q4ZaELARC8acdlTRHiCiD3+PyF/0Ud4RG0oyIBQvdFwqOllfIsiLrzvAjv iUZLqExn9if76LvsT82mLryRFp6AfrLoaD/klcYk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, CHANDAN VURDIGERE NATARAJ , Rodrigo Siqueira , Alex Deucher Subject: [PATCH 5.17 305/343] drm/amd/display: Fix by adding FPU protection for dcn30_internal_validate_bw Date: Tue, 12 Apr 2022 08:32:03 +0200 Message-Id: <20220412063000.127605016@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: CHANDAN VURDIGERE NATARAJ commit ca1198849ab0e7af5efb392ef6baf1138f6fc086 upstream. [Why] Below general protection fault observed when WebGL Aquarium is run for longer duration. If drm debug logs are enabled and set to 0x1f then the issue is observed within 10 minutes of run. [ 100.717056] general protection fault, probably for non-canonical address= 0x2d33302d32323032: 0000 [#1] PREEMPT SMP NOPTI [ 100.727921] CPU: 3 PID: 1906 Comm: DrmThread Tainted: G W = 5.15.30 #12 d726c6a2d6ebe5cf9223931cbca6892f916fe18b [ 100.754419] RIP: 0010:CalculateSwathWidth+0x1f7/0x44f [ 100.767109] Code: 00 00 00 f2 42 0f 11 04 f0 48 8b 85 88 00 00 00 f2 42 = 0f 10 04 f0 48 8b 85 98 00 00 00 f2 42 0f 11 04 f0 48 8b 45 10 0f 57 c0 42 0f 2a 04 b0 0f 57 c9 f3 43 0f 2a 0c b4 e8 8c e2 f3 ff 48 8b [ 100.781269] RSP: 0018:ffffa9230079eeb0 EFLAGS: 00010246 [ 100.812528] RAX: 2d33302d32323032 RBX: 0000000000000500 RCX: 00000000000= 00000 [ 100.819656] RDX: 0000000000000001 RSI: ffff99deb712c49c RDI: 00000000000= 00000 [ 100.826781] RBP: ffffa9230079ef50 R08: ffff99deb712460c R09: ffff99deb71= 2462c [ 100.833907] R10: ffff99deb7124940 R11: ffff99deb7124d70 R12: ffff99deb71= 2ae44 [ 100.841033] R13: 0000000000000001 R14: 0000000000000000 R15: ffffa923007= 9f0a0 [ 100.848159] FS: 00007af121212640(0000) GS:ffff99deba780000(0000) knlGS:= 0000000000000000 [ 100.856240] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 100.861980] CR2: 0000209000fe1000 CR3: 000000011b18c000 CR4: 00000000003= 50ee0 [ 100.869106] Call Trace: [ 100.871555] [ 100.873655] ? asm_sysvec_reschedule_ipi+0x12/0x20 [ 100.878449] CalculateSwathAndDETConfiguration+0x1a3/0x6dd [ 100.883937] dml31_ModeSupportAndSystemConfigurationFull+0x2ce4/0x76da [ 100.890467] ? kallsyms_lookup_buildid+0xc8/0x163 [ 100.895173] ? kallsyms_lookup_buildid+0xc8/0x163 [ 100.899874] ? __sprint_symbol+0x80/0x135 [ 100.903883] ? dm_update_plane_state+0x3f9/0x4d2 [ 100.908500] ? symbol_string+0xb7/0xde [ 100.912250] ? number+0x145/0x29b [ 100.915566] ? vsnprintf+0x341/0x5ff [ 100.919141] ? desc_read_finalized_seq+0x39/0x87 [ 100.923755] ? update_load_avg+0x1b9/0x607 [ 100.927849] ? compute_mst_dsc_configs_for_state+0x7d/0xd5b [ 100.933416] ? fetch_pipe_params+0xa4d/0xd0c [ 100.937686] ? dc_fpu_end+0x3d/0xa8 [ 100.941175] dml_get_voltage_level+0x16b/0x180 [ 100.945619] dcn30_internal_validate_bw+0x10e/0x89b [ 100.950495] ? dcn31_validate_bandwidth+0x68/0x1fc [ 100.955285] ? resource_build_scaling_params+0x98b/0xb8c [ 100.960595] ? dcn31_validate_bandwidth+0x68/0x1fc [ 100.965384] dcn31_validate_bandwidth+0x9a/0x1fc [ 100.970001] dc_validate_global_state+0x238/0x295 [ 100.974703] amdgpu_dm_atomic_check+0x9c1/0xbce [ 100.979235] ? _printk+0x59/0x73 [ 100.982467] drm_atomic_check_only+0x403/0x78b [ 100.986912] drm_mode_atomic_ioctl+0x49b/0x546 [ 100.991358] ? drm_ioctl+0x1c1/0x3b3 [ 100.994936] ? drm_atomic_set_property+0x92a/0x92a [ 100.999725] drm_ioctl_kernel+0xdc/0x149 [ 101.003648] drm_ioctl+0x27f/0x3b3 [ 101.007051] ? drm_atomic_set_property+0x92a/0x92a [ 101.011842] amdgpu_drm_ioctl+0x49/0x7d [ 101.015679] __se_sys_ioctl+0x7c/0xb8 [ 101.015685] do_syscall_64+0x5f/0xb8 [ 101.015690] ? __irq_exit_rcu+0x34/0x96 [How] It calles populate_dml_pipes which uses doubles to initialize. Adding FPU protection avoids context switch and probable loss of vba context as there is potential contention while drm debug logs are enabled. Signed-off-by: CHANDAN VURDIGERE NATARAJ Reviewed-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_resource.c @@ -2025,7 +2025,9 @@ bool dcn31_validate_bandwidth(struct dc =20 BW_VAL_TRACE_COUNT(); =20 + DC_FP_START(); out =3D dcn30_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel= , fast_validate); + DC_FP_END(); =20 // Disable fast_validate to set min dcfclk in alculate_wm_and_dlg if (pipe_cnt =3D=3D 0) From nobody Thu May 14 08:08:21 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 9946CC35295 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387223AbiDLJGK (ORCPT ); Tue, 12 Apr 2022 05:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359241AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 566422A268; Tue, 12 Apr 2022 00:21: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 16542B81B62; Tue, 12 Apr 2022 07:21:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C961C385A5; Tue, 12 Apr 2022 07:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748063; bh=LveDTNz49FYcxLOtDFHSOrot2rhbCYmOg4T9rw6dpMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVuE2r5KsUbeHJ4RT/lu9VHo4h6zxLR0EEVvri5IsU9rSkYE4mDzGp0St86SUMa1A WwH/Heqw6vBV4fLw+duv5bXcpYr6DlzGoDF37IXeiIAsusAX8cb3bs8aPEIk3jXkm8 vI/gscOZvfRe8WXv331GaTY561uOcHw1FKOO8w+0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Marty , Alex Deucher Subject: [PATCH 5.17 306/343] drm/amdgpu/display: change pipe policy for DCN 2.1 Date: Tue, 12 Apr 2022 08:32:04 +0200 Message-Id: <20220412063000.156159554@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Benjamin Marty commit 879791ad8bf3dc5453061cad74776a617b6e3319 upstream. Fixes crash on MST Hub disconnect. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1849 Fixes: ee2698cf79cc ("drm/amd/display: Changed pipe split policy to allow f= or multi-display pipe split") Signed-off-by: Benjamin Marty Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c @@ -873,7 +873,7 @@ static const struct dc_debug_options deb .clock_trace =3D true, .disable_pplib_clock_request =3D true, .min_disp_clk_khz =3D 100000, - .pipe_split_policy =3D MPC_SPLIT_DYNAMIC, + .pipe_split_policy =3D MPC_SPLIT_AVOID_MULT_DISP, .force_single_disp_pipe_split =3D false, .disable_dcc =3D DCC_ENABLE, .vsr_support =3D true, From nobody Thu May 14 08:08:21 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 5EBCFC35294 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387195AbiDLJGB (ORCPT ); Tue, 12 Apr 2022 05:06:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359252AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 855032A732; Tue, 12 Apr 2022 00:21: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 dfw.source.kernel.org (Postfix) with ESMTPS id 232AF616B2; Tue, 12 Apr 2022 07:21:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 348BAC385A1; Tue, 12 Apr 2022 07:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748066; bh=McsC9ZufxaUuzydXB9cDgdwI6fwZUeI+va5tpXteTiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yOeraF9OU7MskwCcYrGjyfTmC89tk33P+8FQxxECXcLZAPy9XMo3jKa50HtFACUDP zrJqeoRgAkrlX7zZSAwQDgizRRS17ayZgFMz3lCoBL8BWwwbPiT/D5vfSIs3HP6kIQ qmLLTp4u5Ug6A61YHr+wSQS1WOq26Q+Hupl1JEMo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , Alex Deucher Subject: [PATCH 5.17 307/343] drm/amdgpu/smu10: fix SoC/fclk units in auto mode Date: Tue, 12 Apr 2022 08:32:05 +0200 Message-Id: <20220412063000.184100798@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Alex Deucher commit 2f25d8ce09b7ba5d769c132ba3d4eb84a941d2cb upstream. SMU takes clock limits in Mhz units. socclk and fclk were using 10 khz units in some cases. Switch to Mhz units. Fixes higher than required SoC clocks. Fixes: 97cf32996c46d9 ("drm/amd/pm: Removed fixed clock in auto mode DPM") Reviewed-by: Paul Menzel Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c @@ -773,13 +773,13 @@ static int smu10_dpm_force_dpm_level(str smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetHardMinFclkByFreq, hwmgr->display_config->num_display > 3 ? - data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk : + (data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk / 100) : min_mclk, NULL); =20 smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetHardMinSocclkByFreq, - data->clock_vol_info.vdd_dep_on_socclk->entries[0].clk, + data->clock_vol_info.vdd_dep_on_socclk->entries[0].clk / 100, NULL); smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetHardMinVcn, @@ -792,11 +792,11 @@ static int smu10_dpm_force_dpm_level(str NULL); smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetSoftMaxFclkByFreq, - data->clock_vol_info.vdd_dep_on_fclk->entries[index_fclk].clk, + data->clock_vol_info.vdd_dep_on_fclk->entries[index_fclk].clk / 100, NULL); smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetSoftMaxSocclkByFreq, - data->clock_vol_info.vdd_dep_on_socclk->entries[index_socclk].clk, + data->clock_vol_info.vdd_dep_on_socclk->entries[index_socclk].clk / = 100, NULL); smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetSoftMaxVcn, From nobody Thu May 14 08:08:21 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 D410AC35295 for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385922AbiDLIxd (ORCPT ); Tue, 12 Apr 2022 04:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359258AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 E4DE62AE10; Tue, 12 Apr 2022 00:21: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 7F22B6153F; Tue, 12 Apr 2022 07:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90486C385A1; Tue, 12 Apr 2022 07:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748071; bh=98APagSa0U42erfRQUeR32abN7Mgn6/L5uXCLR4wu94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBJEwfNN0rNGm+SKM0vfL/e0qgHYOE+b6x0ZIi1bKUSST7ETbQTgiJYhwizzWRbj5 ZcdfGo18XbpaZIYOX4G/zTZTu4Gyfe14+b4rDE8/fRx54BYXy7StA1uWPpgKO30pSZ CwU3FI0xEg/aZAyhCJJosjfphwnyH4rGZXsL1CHE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emily Deng , James Zhu , Alex Deucher Subject: [PATCH 5.17 308/343] drm/amdgpu/vcn: Fix the register setting for vcn1 Date: Tue, 12 Apr 2022 08:32:06 +0200 Message-Id: <20220412063000.212011482@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Emily Deng commit 02fc996d5098f4c3f65bdf6cdb6b28e3f29ba789 upstream. Correct the code error for setting register UVD_GFX10_ADDR_CONFIG. Need to use inst_idx, or it only will set VCN0. Signed-off-by: Emily Deng Reviewed-by: James Zhu Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c @@ -569,8 +569,8 @@ static void vcn_v3_0_mc_resume_dpg_mode( AMDGPU_GPU_PAGE_ALIGN(sizeof(struct amdgpu_fw_shared)), 0, indirect); =20 /* VCN global tiling registers */ - WREG32_SOC15_DPG_MODE(0, SOC15_DPG_MODE_OFFSET( - UVD, 0, mmUVD_GFX10_ADDR_CONFIG), adev->gfx.config.gb_addr_config, 0, in= direct); + WREG32_SOC15_DPG_MODE(inst_idx, SOC15_DPG_MODE_OFFSET( + UVD, inst_idx, mmUVD_GFX10_ADDR_CONFIG), adev->gfx.config.gb_addr_config= , 0, indirect); } =20 static void vcn_v3_0_disable_static_power_gating(struct amdgpu_device *ade= v, int inst) From nobody Thu May 14 08:08:21 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 7C0FEC46467 for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386451AbiDLI6J (ORCPT ); Tue, 12 Apr 2022 04:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359259AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 BA4DC2B253; Tue, 12 Apr 2022 00:21: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 53B7B6153F; Tue, 12 Apr 2022 07:21:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A239C385A1; Tue, 12 Apr 2022 07:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748074; bh=qVZQZO1froVUTZ6TwlksDchw3cHLrw0uS/UZVNIs+5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WYOlBrW5XwLS6TEGR6KFD4gikTUrVl10RnYBY8RheGegig0AQGXqDjHuz7ho3xH/S JCtv/XAA4opxP5/LaPNsSPcxG1Tv7KF0Tq0SRzZ7xoveOrjW21S9FCYMCbt84ilTim RPyPo0m5HcUM/mFP4QJl897aI4JcRU7z+Zg/OTuA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Skeggs , Karol Herbst , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Lyude Paul Subject: [PATCH 5.17 309/343] drm/nouveau/pmu: Add missing callbacks for Tegra devices Date: Tue, 12 Apr 2022 08:32:07 +0200 Message-Id: <20220412063000.240457912@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Karol Herbst commit 38d4e5cf5b08798f093374e53c2f4609d5382dd5 upstream. Fixes a crash booting on those platforms with nouveau. Fixes: 4cdd2450bf73 ("drm/nouveau/pmu/gm200-: use alternate falcon reset se= quence") Cc: Ben Skeggs Cc: Karol Herbst Cc: dri-devel@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Cc: # v5.17+ Signed-off-by: Karol Herbst Reviewed-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20220322124800.2605463-= 1-kherbst@redhat.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gm20b.c | 1 + drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp102.c | 2 +- drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp10b.c | 1 + drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gm20b.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gm20b.c @@ -216,6 +216,7 @@ gm20b_pmu =3D { .intr =3D gt215_pmu_intr, .recv =3D gm20b_pmu_recv, .initmsg =3D gm20b_pmu_initmsg, + .reset =3D gf100_pmu_reset, }; =20 #if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp102.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp102.c @@ -23,7 +23,7 @@ */ #include "priv.h" =20 -static void +void gp102_pmu_reset(struct nvkm_pmu *pmu) { struct nvkm_device *device =3D pmu->subdev.device; --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp10b.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gp10b.c @@ -83,6 +83,7 @@ gp10b_pmu =3D { .intr =3D gt215_pmu_intr, .recv =3D gm20b_pmu_recv, .initmsg =3D gm20b_pmu_initmsg, + .reset =3D gp102_pmu_reset, }; =20 #if IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC) --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/priv.h @@ -41,6 +41,7 @@ int gt215_pmu_send(struct nvkm_pmu *, u3 =20 bool gf100_pmu_enabled(struct nvkm_pmu *); void gf100_pmu_reset(struct nvkm_pmu *); +void gp102_pmu_reset(struct nvkm_pmu *pmu); =20 void gk110_pmu_pgob(struct nvkm_pmu *, bool); From nobody Thu May 14 08:08:21 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 3B435C433F5 for ; Tue, 12 Apr 2022 09:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387178AbiDLJF5 (ORCPT ); Tue, 12 Apr 2022 05:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359260AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42: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 853462BB09; Tue, 12 Apr 2022 00:21: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 23CDC61045; Tue, 12 Apr 2022 07:21:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01A9CC385A1; Tue, 12 Apr 2022 07:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748077; bh=bScr1sUFM94SlTUGziiSSo1pd7DcDs5dN8ORKndYxrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xNCyJqi0D5gni5rYImrx0qVqVK8BWN5upCL7YMJLOGcgkCyZ56DUw7eelHfeDTYWw 1jYX7JE1u5WBOIsJm9UiY3CKirEH+b9EZYjfi57nb04Hfsxs6BX7hB/Ef7foeZ0lqU 1Q8pJRJMfcHcA48x5FRiyh9dMqa1bm4SzQfj0ZzU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Lee Jones Subject: [PATCH 5.17 310/343] drm/amdkfd: Create file descriptor after client is added to smi_clients list Date: Tue, 12 Apr 2022 08:32:08 +0200 Message-Id: <20220412063000.270200900@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Lee Jones commit e79a2398e1b2d47060474dca291542368183bc0f upstream. This ensures userspace cannot prematurely clean-up the client before it is fully initialised which has been proven to cause issues in the past. Cc: Felix Kuehling Cc: Alex Deucher Cc: "Christian K=C3=B6nig" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: amd-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Lee Jones Reviewed-by: Felix Kuehling Signed-off-by: Felix Kuehling Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c @@ -268,15 +268,6 @@ int kfd_smi_event_open(struct kfd_dev *d return ret; } =20 - ret =3D anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client, - O_RDWR); - if (ret < 0) { - kfifo_free(&client->fifo); - kfree(client); - return ret; - } - *fd =3D ret; - init_waitqueue_head(&client->wait_queue); spin_lock_init(&client->lock); client->events =3D 0; @@ -286,5 +277,20 @@ int kfd_smi_event_open(struct kfd_dev *d list_add_rcu(&client->list, &dev->smi_clients); spin_unlock(&dev->smi_lock); =20 + ret =3D anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client, + O_RDWR); + if (ret < 0) { + spin_lock(&dev->smi_lock); + list_del_rcu(&client->list); + spin_unlock(&dev->smi_lock); + + synchronize_rcu(); + + kfifo_free(&client->fifo); + kfree(client); + return ret; + } + *fd =3D ret; + return 0; } From nobody Thu May 14 08:08:21 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 558C1C4707E for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385906AbiDLIx3 (ORCPT ); Tue, 12 Apr 2022 04:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359261AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -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 BAA4F2C114; Tue, 12 Apr 2022 00:21: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 76229B81B58; Tue, 12 Apr 2022 07:21:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4257C385A1; Tue, 12 Apr 2022 07:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748080; bh=RThewDuSSaDhfeV7W7Ch/9tNuzdmzLS9RuWbGQ+yvVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqXwXfHc+vOVy+4KFuRsAwMRy0ox25IWcDZsvNtYF0r0CtayzTkUc80Ujmz4ksu8e pPoGK8Zaiqo7rC9HhNzGrPiW6+Y01rX37V9Pcz+zHZUWHfMsOOo7FOZz1/+ackeNSx ebkDwPjbCmED903yNGhWGSM5bpVLjxIQR0XU1ooE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lijo Lazar , Alex Deucher Subject: [PATCH 5.17 311/343] drm/amdgpu: dont use BACO for reset in S3 Date: Tue, 12 Apr 2022 08:32:09 +0200 Message-Id: <20220412063000.299598642@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Alex Deucher commit ebc002e3ee78409c42156e62e4e27ad1d09c5a75 upstream. Seems to cause a reboots or hangs on some systems. Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1924 Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1953 Fixes: daf8de0874ab5b ("drm/amdgpu: always reset the asic in suspend (v2)") Reviewed-by: Lijo Lazar Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c @@ -1045,6 +1045,17 @@ bool amdgpu_dpm_is_baco_supported(struct =20 if (!pp_funcs || !pp_funcs->get_asic_baco_capability) return false; + /* Don't use baco for reset in S3. + * This is a workaround for some platforms + * where entering BACO during suspend + * seems to cause reboots or hangs. + * This might be related to the fact that BACO controls + * power to the whole GPU including devices like audio and USB. + * Powering down/up everything may adversely affect these other + * devices. Needs more investigation. + */ + if (adev->in_s3) + return false; =20 if (pp_funcs->get_asic_baco_capability(pp_handle, &baco_cap)) return false; From nobody Thu May 14 08:08:21 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 ABB1FC433FE for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386537AbiDLI61 (ORCPT ); Tue, 12 Apr 2022 04:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359262AbiDLHmw (ORCPT ); Tue, 12 Apr 2022 03:42:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3FEA2C115; Tue, 12 Apr 2022 00:21: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 ams.source.kernel.org (Postfix) with ESMTPS id 4AD5DB81B60; Tue, 12 Apr 2022 07:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A099FC385A1; Tue, 12 Apr 2022 07:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748083; bh=IHC89Aams0XWjbco/J0P17dgBmvKn2Cdsf7vbUdm+nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Upo/voo4D7JP2da8o/xaIcduYnTTiYNEshlijUPL8gRD0/owMF+9bp4MOSyl/Twt3 EhOtVsyFrB34IZ/+8gdkiei9x6i+eyzrJtN6sY2WKsFhMAsJVDM957lHGF4oeCCWVu +Yiq7i8Qy6rrPKHXXRYNttiLXesmQe1M8f5d9gWk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Fu , Al Viro , Trond Myklebust Subject: [PATCH 5.17 312/343] SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() Date: Tue, 12 Apr 2022 08:32:10 +0200 Message-Id: <20220412063000.327988062@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Trond Myklebust commit f00432063db1a0db484e85193eccc6845435b80e upstream. We must ensure that all sockets are closed before we call xprt_free() and release the reference to the net namespace. The problem is that calling fput() will defer closing the socket until delayed_fput() gets called. Let's fix the situation by allowing rpciod and the transport teardown code (which runs on the system wq) to call __fput_sync(), and directly close the socket. Reported-by: Felix Fu Acked-by: Al Viro Fixes: a73881c96d73 ("SUNRPC: Fix an Oops in udp_poll()") Cc: stable@vger.kernel.org # 5.1.x: 3be232f11a3c: SUNRPC: Prevent immediate= close+reconnect Cc: stable@vger.kernel.org # 5.1.x: 89f42494f92f: SUNRPC: Don't call connec= t() more than once on a TCP socket Cc: stable@vger.kernel.org # 5.1.x Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/file_table.c | 1 + include/trace/events/sunrpc.h | 1 - net/sunrpc/xprt.c | 7 +------ net/sunrpc/xprtsock.c | 16 +++++++++++++--- 4 files changed, 15 insertions(+), 10 deletions(-) --- a/fs/file_table.c +++ b/fs/file_table.c @@ -412,6 +412,7 @@ void __fput_sync(struct file *file) } =20 EXPORT_SYMBOL(fput); +EXPORT_SYMBOL(__fput_sync); =20 void __init files_init(void) { --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -1005,7 +1005,6 @@ DEFINE_RPC_XPRT_LIFETIME_EVENT(connect); DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_auto); DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_done); DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_force); -DEFINE_RPC_XPRT_LIFETIME_EVENT(disconnect_cleanup); DEFINE_RPC_XPRT_LIFETIME_EVENT(destroy); =20 DECLARE_EVENT_CLASS(rpc_xprt_event, --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -929,12 +929,7 @@ void xprt_connect(struct rpc_task *task) if (!xprt_lock_write(xprt, task)) return; =20 - if (test_and_clear_bit(XPRT_CLOSE_WAIT, &xprt->state)) { - trace_xprt_disconnect_cleanup(xprt); - xprt->ops->close(xprt); - } - - if (!xprt_connected(xprt)) { + if (!xprt_connected(xprt) && !test_bit(XPRT_CLOSE_WAIT, &xprt->state)) { task->tk_rqstp->rq_connect_cookie =3D xprt->connect_cookie; rpc_sleep_on_timeout(&xprt->pending, task, NULL, xprt_request_timeout(task->tk_rqstp)); --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -880,7 +880,7 @@ static int xs_local_send_request(struct =20 /* Close the stream if the previous transmission was incomplete */ if (xs_send_request_was_aborted(transport, req)) { - xs_close(xprt); + xprt_force_disconnect(xprt); return -ENOTCONN; } =20 @@ -918,7 +918,7 @@ static int xs_local_send_request(struct -status); fallthrough; case -EPIPE: - xs_close(xprt); + xprt_force_disconnect(xprt); status =3D -ENOTCONN; } =20 @@ -1203,6 +1203,16 @@ static void xs_reset_transport(struct so =20 if (sk =3D=3D NULL) return; + /* + * Make sure we're calling this in a context from which it is safe + * to call __fput_sync(). In practice that means rpciod and the + * system workqueue. + */ + if (!(current->flags & PF_WQ_WORKER)) { + WARN_ON_ONCE(1); + set_bit(XPRT_CLOSE_WAIT, &xprt->state); + return; + } =20 if (atomic_read(&transport->xprt.swapper)) sk_clear_memalloc(sk); @@ -1226,7 +1236,7 @@ static void xs_reset_transport(struct so mutex_unlock(&transport->recv_mutex); =20 trace_rpc_socket_close(xprt, sock); - fput(filp); + __fput_sync(filp); =20 xprt_disconnect_done(xprt); } From nobody Thu May 14 08:08:21 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 7B802C433F5 for ; Tue, 12 Apr 2022 08:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385886AbiDLIx0 (ORCPT ); Tue, 12 Apr 2022 04:53:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359268AbiDLHmx (ORCPT ); Tue, 12 Apr 2022 03:42:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EFD32C128; Tue, 12 Apr 2022 00:21: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 3AA226153F; Tue, 12 Apr 2022 07:21:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B7F7C385A1; Tue, 12 Apr 2022 07:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748085; bh=Tnn2M0xaBWyd+/S1Dkmi6sGPEzK/LZOpiFyK6e9fGBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0dOT83nzU9LifjqInz6O4LPN5vT427EtgC6S5Ra1iOKf8HewRrfvtNzz4S4IAM+dc IQgXxgyP4LoO60xAhRCp0TW8OrsgvZpo6xcxQvIlRxgWavWtoo6ce6dZLhhEF8OLx4 zv+oynhdnKLVjq10+2w1H8AANIo4mv6HLI5MqvSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Akihiko Odaki , "Rafael J. Wysocki" , Ketsui Subject: [PATCH 5.17 313/343] Revert "ACPI: processor: idle: Only flush cache on entering C3" Date: Tue, 12 Apr 2022 08:32:11 +0200 Message-Id: <20220412063000.357228895@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Akihiko Odaki commit dfbba2518aac4204203b0697a894d3b2f80134d3 upstream. Revert commit 87ebbb8c612b ("ACPI: processor: idle: Only flush cache on entering C3") that broke the assumptions of the acpi_idle_play_dead() callers. Namely, the CPU cache must always be flushed in acpi_idle_play_dead(), regardless of the target C-state that is going to be requested, because this is likely to be part of a CPU offline procedure or preparation for entering a system-wide sleep state and the lack of synchronization between the CPU cache and RAM may lead to problems going forward, for example when the CPU is brought back online. In particular, it breaks resume from suspend-to-RAM on Lenovo ThinkPad C13 which fails occasionally until the problematic commit is reverted. Signed-off-by: Akihiko Odaki [ rjw: Changelog ] Signed-off-by: Rafael J. Wysocki Cc: Ketsui Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/acpi/processor_idle.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -570,8 +570,7 @@ static int acpi_idle_play_dead(struct cp { struct acpi_processor_cx *cx =3D per_cpu(acpi_cstate[index], dev->cpu); =20 - if (cx->type =3D=3D ACPI_STATE_C3) - ACPI_FLUSH_CPU_CACHE(); + ACPI_FLUSH_CPU_CACHE(); =20 while (1) { From nobody Thu May 14 08:08:21 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 350E2C35294 for ; Tue, 12 Apr 2022 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385863AbiDLIxW (ORCPT ); Tue, 12 Apr 2022 04:53:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359267AbiDLHmx (ORCPT ); Tue, 12 Apr 2022 03:42:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E602CCAA; Tue, 12 Apr 2022 00:21: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 AE9C1B81B4F; Tue, 12 Apr 2022 07:21:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07CE1C385A1; Tue, 12 Apr 2022 07:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748088; bh=9VZAPCzEDAxExx6/TXtYqfHjelitcTwOZOGjOs8mLFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+MYuLagRtWZULzRG19K5+TuhDdI37FWVCsZVN7idANXflCy5ICIPwRw/D/yJzRbq Okynhx4iEuoBKpkcTjuPe6Sl6DJvxItbuRRVZb0AwR6/71dRy9ivPTAA4+q/jGLgsA ftYMEBJnCV8+kO338sJj7ZqZfdD0nCKdrZabVLFw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Philip Yang , Harish Kasiviswanathan , Alex Deucher Subject: [PATCH 5.17 314/343] drm/amdkfd: Fix variable set but not used warning Date: Tue, 12 Apr 2022 08:32:12 +0200 Message-Id: <20220412063000.386044332@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Philip Yang commit 90c44207cdd18091ac9aa7cab8a3e7b0ef00e847 upstream. All warnings (new ones prefixed by >>): drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c: In function 'svm_range_deferred_list_work': >> drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:2067:22: warning: variable 'p' set but not used [-Wunused-but-set-variable] 2067 | struct kfd_process *p; | Fixes: 367c9b0f1b8750 ("drm/amdkfd: Ensure mm remain valid in svm deferred_= list work") Reported-by: kernel test robot Signed-off-by: Philip Yang Reviewed-By: Harish Kasiviswanathan Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 --- 1 file changed, 3 deletions(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -2066,13 +2066,10 @@ static void svm_range_deferred_list_work struct svm_range_list *svms; struct svm_range *prange; struct mm_struct *mm; - struct kfd_process *p; =20 svms =3D container_of(work, struct svm_range_list, deferred_list_work); pr_debug("enter svms 0x%p\n", svms); =20 - p =3D container_of(svms, struct kfd_process, svms); - spin_lock(&svms->deferred_list_lock); while (!list_empty(&svms->deferred_range_list)) { prange =3D list_first_entry(&svms->deferred_range_list, From nobody Thu May 14 08:08:21 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 625E6C4167E for ; Tue, 12 Apr 2022 08:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386437AbiDLI6E (ORCPT ); Tue, 12 Apr 2022 04:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359266AbiDLHmx (ORCPT ); Tue, 12 Apr 2022 03:42: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 A6CD82CE17; Tue, 12 Apr 2022 00:21: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 5C78CB81B60; Tue, 12 Apr 2022 07:21:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B428CC385A1; Tue, 12 Apr 2022 07:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748091; bh=a4WlgdswZu7LbTJK3BT3VYBsUoQBdktmcSJKsA6vEkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6qx3eOvwN/AT4Pi6j7362RR+kWjFZmyUkoTNiXsTwMabYNUwMmu3FiDF4jwQa4Jj mHvxzqNnAkuEYLlgScckru9J1/0Px8Xf/OcFv5hdT2S0ubu7G/KiAHazxTVWVf/y2K NuKJPwOECn8sshW5uD6C1AUV0kYU6FcxzgPEfccE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lu , Dust Li , "David S. Miller" Subject: [PATCH 5.17 315/343] net/smc: send directly on setting TCP_NODELAY Date: Tue, 12 Apr 2022 08:32:13 +0200 Message-Id: <20220412063000.414743238@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Dust Li commit b70a5cc045197aad9c159042621baf3c015f6cc7 upstream. In commit ea785a1a573b("net/smc: Send directly when TCP_CORK is cleared"), we don't use delayed work to implement cork. This patch use the same algorithm, removes the delayed work when setting TCP_NODELAY and send directly in setsockopt(). This also makes the TCP_NODELAY the same as TCP. Cc: Tony Lu Signed-off-by: Dust Li Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/smc/af_smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2625,8 +2625,8 @@ static int smc_setsockopt(struct socket sk->sk_state !=3D SMC_CLOSED) { if (val) { SMC_STAT_INC(smc, ndly_cnt); - mod_delayed_work(smc->conn.lgr->tx_wq, - &smc->conn.tx_work, 0); + smc_tx_pending(&smc->conn); + cancel_delayed_work(&smc->conn.tx_work); } } break; From nobody Thu May 14 08:08:21 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 8612FC433EF for ; Tue, 12 Apr 2022 09:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386979AbiDLJFH (ORCPT ); Tue, 12 Apr 2022 05:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359276AbiDLHmx (ORCPT ); Tue, 12 Apr 2022 03:42: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 7B35D55778; Tue, 12 Apr 2022 00:21: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 2AD87B81B62; Tue, 12 Apr 2022 07:21:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75BC2C385A6; Tue, 12 Apr 2022 07:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748093; bh=uBHQLW5+mpdPRS3b2MbTke8aMBxhdOu3bzGGetA00PQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ucQEU+cjfqvXWX/AMgXU4tezp0oeB9wEgwVODD2CnO/E1buQQu1JawAAiGRmqnZRg M6+SjvRFYtwc/zV/RQSzxfGxO/E34l/F2m4c1uwYLxItZAXHxVpIxV79REIvXcHLEi 5oMcIaI4/+v6Z6vSLzakneTHkKT5hLdSiL4HzXZg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski Subject: [PATCH 5.17 316/343] Revert "selftests: net: Add tls config dependency for tls selftests" Date: Tue, 12 Apr 2022 08:32:14 +0200 Message-Id: <20220412063000.443238078@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Kicinski commit 20695e9a9fd39103d1b0669470ae74030b7aa196 upstream. This reverts commit d9142e1cf3bbdaf21337767114ecab26fe702d47. The test is supposed to run cleanly with TLS is disabled, to test compatibility with TCP behavior. I can't repro the failure [1], the problem should be debugged rather than papered over. Link: https://lore.kernel.org/all/20220325161203.7000698c@kicinski-fedora-p= c1c0hjn.dhcp.thefacebook.com/ [1] Fixes: d9142e1cf3bb ("selftests: net: Add tls config dependency for tls sel= ftests") Signed-off-by: Jakub Kicinski Link: https://lore.kernel.org/r/20220328212904.2685395-1-kuba@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/net/config | 1 - 1 file changed, 1 deletion(-) --- a/tools/testing/selftests/net/config +++ b/tools/testing/selftests/net/config @@ -43,6 +43,5 @@ CONFIG_NET_ACT_TUNNEL_KEY=3Dm CONFIG_NET_ACT_MIRRED=3Dm CONFIG_BAREUDP=3Dm CONFIG_IPV6_IOAM6_LWTUNNEL=3Dy -CONFIG_TLS=3Dm CONFIG_CRYPTO_SM4=3Dy CONFIG_AMT=3Dm From nobody Thu May 14 08:08:21 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 7CFEDC352A1 for ; Tue, 12 Apr 2022 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385971AbiDLIxv (ORCPT ); Tue, 12 Apr 2022 04:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359292AbiDLHmy (ORCPT ); Tue, 12 Apr 2022 03:42:54 -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 A7FAA2CC89; Tue, 12 Apr 2022 00:21: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 40FB26177C; Tue, 12 Apr 2022 07:21:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BD3BC385A5; Tue, 12 Apr 2022 07:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748096; bh=ScQ0rtqc2sYsCyzqgZl710MjEEg7+tnFQD+SEYvELSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+ZPoPbcRwsA10Tg3/J1cdl+eFb5PoO4Qesa9tiz709kDbU1dOCnSrLvlDk6SfMIz JBsRF9e1Vwjqu+PgYSWANNwilQcGyYx6LKc6RKWtai8ecBU/KZvMCBaE5ZXTFDLioB Jz00wWS8HmsV6xbsX2UOIb8hct+cm+G3a7gxIYgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexei Starovoitov , Jakub Sitnicki Subject: [PATCH 5.17 317/343] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide Date: Tue, 12 Apr 2022 08:32:15 +0200 Message-Id: <20220412063000.471614898@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Sitnicki commit 9a69e2b385f443f244a7e8b8bcafe5ccfb0866b4 upstream. remote_port is another case of a BPF context field documented as a 32-bit value in network byte order for which the BPF context access converter generates a load of a zero-padded 16-bit integer in network byte order. First such case was dst_port in bpf_sock which got addressed in commit 4421a582718a ("bpf: Make dst_port field in struct bpf_sock 16-bit wide"). Loading 4-bytes from the remote_port offset and converting the value with bpf_ntohl() leads to surprising results, as the expected value is shifted by 16 bits. Reduce the confusion by splitting the field in two - a 16-bit field holding a big-endian integer, and a 16-bit zero-padding anonymous field that follows it. Suggested-by: Alexei Starovoitov Signed-off-by: Jakub Sitnicki Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20220209184333.654927-2-jakub@cloudflare.= com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/uapi/linux/bpf.h | 3 ++- net/bpf/test_run.c | 4 ++-- net/core/filter.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -6379,7 +6379,8 @@ struct bpf_sk_lookup { __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ __u32 remote_ip4; /* Network byte order */ __u32 remote_ip6[4]; /* Network byte order */ - __u32 remote_port; /* Network byte order */ + __be16 remote_port; /* Network byte order */ + __u16 :16; /* Zero padding */ __u32 local_ip4; /* Network byte order */ __u32 local_ip6[4]; /* Network byte order */ __u32 local_port; /* Host byte order */ --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -960,7 +960,7 @@ int bpf_prog_test_run_sk_lookup(struct b if (!range_is_zero(user_ctx, offsetofend(typeof(*user_ctx), local_port), = sizeof(*user_ctx))) goto out; =20 - if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) { + if (user_ctx->local_port > U16_MAX) { ret =3D -ERANGE; goto out; } @@ -968,7 +968,7 @@ int bpf_prog_test_run_sk_lookup(struct b ctx.family =3D (u16)user_ctx->family; ctx.protocol =3D (u16)user_ctx->protocol; ctx.dport =3D (u16)user_ctx->local_port; - ctx.sport =3D (__force __be16)user_ctx->remote_port; + ctx.sport =3D user_ctx->remote_port; =20 switch (ctx.family) { case AF_INET: --- a/net/core/filter.c +++ b/net/core/filter.c @@ -10621,7 +10621,8 @@ static bool sk_lookup_is_valid_access(in case bpf_ctx_range(struct bpf_sk_lookup, local_ip4): case bpf_ctx_range_till(struct bpf_sk_lookup, remote_ip6[0], remote_ip6[3= ]): case bpf_ctx_range_till(struct bpf_sk_lookup, local_ip6[0], local_ip6[3]): - case bpf_ctx_range(struct bpf_sk_lookup, remote_port): + case offsetof(struct bpf_sk_lookup, remote_port) ... + offsetof(struct bpf_sk_lookup, local_ip4) - 1: case bpf_ctx_range(struct bpf_sk_lookup, local_port): case bpf_ctx_range(struct bpf_sk_lookup, ingress_ifindex): bpf_ctx_record_field_size(info, sizeof(__u32)); From nobody Thu May 14 08:08:21 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 92380C352A8 for ; Tue, 12 Apr 2022 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385998AbiDLIxy (ORCPT ); Tue, 12 Apr 2022 04:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359332AbiDLHm4 (ORCPT ); Tue, 12 Apr 2022 03:42:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8286655BD5; Tue, 12 Apr 2022 00:21: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 DE6F161045; Tue, 12 Apr 2022 07:21:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC71BC385A1; Tue, 12 Apr 2022 07:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748102; bh=ukYIttTkRh32/HUCKuAwdQbcD6m6qpbo3GBE7o+PO2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eiS5FvujV2JaM0bJy1K5n+TcNmS/g2rnNOLQyT+Bd6q186g16G7Ni1kM7JBwyiZO1 t6NhVgRUXea9v8mZh10kQjYt6KGZ/hxL80FsWCs6u2eqCONFbFEzERdiFV7DSHKF3g MUDxHTmAveIaAUfE7oqx7Y0ojRwzEg5QKqiQOxXU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Leoshkevich , Jakub Sitnicki , Alexei Starovoitov , Martin KaFai Lau Subject: [PATCH 5.17 318/343] selftests/bpf: Fix u8 narrow load checks for bpf_sk_lookup remote_port Date: Tue, 12 Apr 2022 08:32:16 +0200 Message-Id: <20220412063000.500098068@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Sitnicki commit 3c69611b8926f8e74fcf76bd97ae0e5dafbeb26a upstream. In commit 9a69e2b385f4 ("bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide") ->remote_port field changed from __u32 to __be16. However, narrow load tests which exercise 1-byte sized loads from offsetof(struct bpf_sk_lookup, remote_port) were not adopted to reflect the change. As a result, on little-endian we continue testing loads from addresses: - (__u8 *)&ctx->remote_port + 3 - (__u8 *)&ctx->remote_port + 4 which map to the zero padding following the remote_port field, and don't break the tests because there is no observable change. While on big-endian, we observe breakage because tests expect to see zeros for values loaded from: - (__u8 *)&ctx->remote_port - 1 - (__u8 *)&ctx->remote_port - 2 Above addresses map to ->remote_ip6 field, which precedes ->remote_port, and are populated during the bpf_sk_lookup IPv6 tests. Unsurprisingly, on s390x we observe: #136/38 sk_lookup/narrow access to ctx v4:OK #136/39 sk_lookup/narrow access to ctx v6:FAIL Fix it by removing the checks for 1-byte loads from offsets outside of the ->remote_port field. Fixes: 9a69e2b385f4 ("bpf: Make remote_port field in struct bpf_sk_lookup 1= 6-bit wide") Suggested-by: Ilya Leoshkevich Signed-off-by: Jakub Sitnicki Signed-off-by: Alexei Starovoitov Acked-by: Martin KaFai Lau Link: https://lore.kernel.org/bpf/20220319183356.233666-3-jakub@cloudflare.= com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/testing/selftests/bpf/progs/test_sk_lookup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/tools/testing/selftests/bpf/progs/test_sk_lookup.c +++ b/tools/testing/selftests/bpf/progs/test_sk_lookup.c @@ -412,8 +412,7 @@ int ctx_narrow_access(struct bpf_sk_look =20 /* Narrow loads from remote_port field. Expect SRC_PORT. */ if (LSB(ctx->remote_port, 0) !=3D ((SRC_PORT >> 0) & 0xff) || - LSB(ctx->remote_port, 1) !=3D ((SRC_PORT >> 8) & 0xff) || - LSB(ctx->remote_port, 2) !=3D 0 || LSB(ctx->remote_port, 3) !=3D 0) + LSB(ctx->remote_port, 1) !=3D ((SRC_PORT >> 8) & 0xff)) return SK_DROP; if (LSW(ctx->remote_port, 0) !=3D SRC_PORT) return SK_DROP; From nobody Thu May 14 08:08:21 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 64613C46467 for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386921AbiDLJE5 (ORCPT ); Tue, 12 Apr 2022 05:04:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359373AbiDLHm7 (ORCPT ); Tue, 12 Apr 2022 03:42:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B31CA55BF2; Tue, 12 Apr 2022 00:21: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 667C4B81B4F; Tue, 12 Apr 2022 07:21:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD053C385A5; Tue, 12 Apr 2022 07:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748105; bh=igy8uFqpNJdtY8hu4KqetscYqZPH5xLN+xDl9o3slQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sG9lVvEAPiQtyg/8/19PsrfC8BNqo/pqD56oZKJTTX8ugYy+pseSPWUXvkoCmRliX Knv5PPkJMuGS6PHbzAyNYB3+D6VgjbY4Xk00wJpbN29omXEHkDxkhsehkNORb2kgMS E+tmTDKAiTR+FC5MNPqR5hr3gxuLL9egk+ZYqd68= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Sitnicki , Alexei Starovoitov , Martin KaFai Lau Subject: [PATCH 5.17 319/343] bpf: Treat bpf_sk_lookup remote_port as a 2-byte field Date: Tue, 12 Apr 2022 08:32:17 +0200 Message-Id: <20220412063000.528180590@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jakub Sitnicki commit 058ec4a7d9cf77238c73ad9f1e1a3ed9a29afcab upstream. In commit 9a69e2b385f4 ("bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide") the remote_port field has been split up and re-declared from u32 to be16. However, the accompanying changes to the context access converter have not been well thought through when it comes big-endian platforms. Today 2-byte wide loads from offsetof(struct bpf_sk_lookup, remote_port) are handled as narrow loads from a 4-byte wide field. This by itself is not enough to create a problem, but when we combine 1. 32-bit wide access to ->remote_port backed by a 16-wide wide load, with 2. inherent difference between litte- and big-endian in how narrow loads need have to be handled (see bpf_ctx_narrow_access_offset), we get inconsistent results for a 2-byte loads from &ctx->remote_port on LE and BE architectures. This in turn makes BPF C code for the common case of 2-byte load from ctx->remote_port not portable. To rectify it, inform the context access converter that remote_port is 2-byte wide field, and only 1-byte loads need to be treated as narrow loads. At the same time, we special-case the 4-byte load from &ctx->remote_port to continue handling it the same way as do today, in order to keep the existing BPF programs working. Fixes: 9a69e2b385f4 ("bpf: Make remote_port field in struct bpf_sk_lookup 1= 6-bit wide") Signed-off-by: Jakub Sitnicki Signed-off-by: Alexei Starovoitov Acked-by: Martin KaFai Lau Link: https://lore.kernel.org/bpf/20220319183356.233666-2-jakub@cloudflare.= com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- net/core/filter.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) --- a/net/core/filter.c +++ b/net/core/filter.c @@ -10621,13 +10621,24 @@ static bool sk_lookup_is_valid_access(in case bpf_ctx_range(struct bpf_sk_lookup, local_ip4): case bpf_ctx_range_till(struct bpf_sk_lookup, remote_ip6[0], remote_ip6[3= ]): case bpf_ctx_range_till(struct bpf_sk_lookup, local_ip6[0], local_ip6[3]): - case offsetof(struct bpf_sk_lookup, remote_port) ... - offsetof(struct bpf_sk_lookup, local_ip4) - 1: case bpf_ctx_range(struct bpf_sk_lookup, local_port): case bpf_ctx_range(struct bpf_sk_lookup, ingress_ifindex): bpf_ctx_record_field_size(info, sizeof(__u32)); return bpf_ctx_narrow_access_ok(off, size, sizeof(__u32)); =20 + case bpf_ctx_range(struct bpf_sk_lookup, remote_port): + /* Allow 4-byte access to 2-byte field for backward compatibility */ + if (size =3D=3D sizeof(__u32)) + return true; + bpf_ctx_record_field_size(info, sizeof(__be16)); + return bpf_ctx_narrow_access_ok(off, size, sizeof(__be16)); + + case offsetofend(struct bpf_sk_lookup, remote_port) ... + offsetof(struct bpf_sk_lookup, local_ip4) - 1: + /* Allow access to zero padding for backward compatibility */ + bpf_ctx_record_field_size(info, sizeof(__u16)); + return bpf_ctx_narrow_access_ok(off, size, sizeof(__u16)); + default: return false; } @@ -10709,6 +10720,11 @@ static u32 sk_lookup_convert_ctx_access( sport, 2, target_size)); break; =20 + case offsetofend(struct bpf_sk_lookup, remote_port): + *target_size =3D 2; + *insn++ =3D BPF_MOV32_IMM(si->dst_reg, 0); + break; + case offsetof(struct bpf_sk_lookup, local_port): *insn++ =3D BPF_LDX_MEM(BPF_H, si->dst_reg, si->src_reg, bpf_target_off(struct bpf_sk_lookup_kern, From nobody Thu May 14 08:08:21 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 E2A4FC43217 for ; Tue, 12 Apr 2022 08:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386364AbiDLI5h (ORCPT ); Tue, 12 Apr 2022 04:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359380AbiDLHm7 (ORCPT ); Tue, 12 Apr 2022 03:42:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B30E2A730; Tue, 12 Apr 2022 00:21: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 26737B81B60; Tue, 12 Apr 2022 07:21:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64F16C385A6; Tue, 12 Apr 2022 07:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748107; bh=AFo/Mnp4TK7EQk+OXOU2Nugko/dhcA5zUh+CtpDVwZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rTsD3e8nlDjc/7ZMiEY3WMCFmG2vhCu5fNRlNLT6+c7RFUQo86SjEIt2qrerp+WIS aJYF/A8GhFzFGjJcvyqDb4dskMCPv68hWbBDMZM9wENC5+rxGDs8gU/VAHvDTDzh7O XjrWgxsBwZfAxeWeSIKV8sksGjn8AUy+qHnKHYsw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Fangrui Song , Florian Fainelli , Ian Rogers , Jiri Olsa , John Keeping , Leo Yan , Michael Petlan , Namhyung Kim , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Arnaldo Carvalho de Melo Subject: [PATCH 5.17 320/343] perf build: Dont use -ffat-lto-objects in the python feature test when building with clang-13 Date: Tue, 12 Apr 2022 08:32:18 +0200 Message-Id: <20220412063000.557370892@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Arnaldo Carvalho de Melo commit 3a8a0475861a443f02e3a9b57d044fe2a0a99291 upstream. Using -ffat-lto-objects in the python feature test when building with clang-13 results in: clang-13: error: optimization flag '-ffat-lto-objects' is not supported [= -Werror,-Wignored-optimization-argument] error: command '/usr/sbin/clang' failed with exit code 1 cp: cannot stat '/tmp/build/perf/python_ext_build/lib/perf*.so': No such = file or directory make[2]: *** [Makefile.perf:639: /tmp/build/perf/python/perf.so] Error 1 Noticed when building on a docker.io/library/archlinux:base container. Cc: Adrian Hunter Cc: Fangrui Song Cc: Florian Fainelli Cc: Ian Rogers Cc: Jiri Olsa Cc: John Keeping Cc: Leo Yan Cc: Michael Petlan Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Sedat Dilek Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/perf/Makefile.config | 3 +++ tools/perf/util/setup.py | 2 ++ 2 files changed, 5 insertions(+) --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -272,6 +272,9 @@ ifdef PYTHON_CONFIG PYTHON_EMBED_LIBADD :=3D $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS :=3D $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/n= ull) FLAGS_PYTHON_EMBED :=3D $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) + ifeq ($(CC_NO_CLANG), 0) + PYTHON_EMBED_CCOPTS :=3D $(filter-out -ffat-lto-objects, $(PYTHON_EMBE= D_CCOPTS)) + endif endif =20 FEATURE_CHECK_CFLAGS-libpython :=3D $(PYTHON_EMBED_CCOPTS) --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py @@ -23,6 +23,8 @@ if cc_is_clang: vars[var] =3D sub("-fstack-protector-strong", "", vars[var]) if not clang_has_option("-fno-semantic-interposition"): vars[var] =3D sub("-fno-semantic-interposition", "", vars[var]) + if not clang_has_option("-ffat-lto-objects"): + vars[var] =3D sub("-ffat-lto-objects", "", vars[var]) =20 from distutils.core import setup, Extension From nobody Thu May 14 08:08:21 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 7155FC433F5 for ; Tue, 12 Apr 2022 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386115AbiDLIyT (ORCPT ); Tue, 12 Apr 2022 04:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359418AbiDLHnC (ORCPT ); Tue, 12 Apr 2022 03:43:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075012CE1C; Tue, 12 Apr 2022 00:23:11 -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 A6BF0B81B13; Tue, 12 Apr 2022 07:23:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E29FDC385A5; Tue, 12 Apr 2022 07:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748188; bh=zfD7YjenlyUPbPHuXN1cKuXgTMmzI3+KRTFSfXHPC28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkcxqHyULJ6GJWc5Tr+Q7h1BoOTH4HZwGD4Pvtsj05/Up+FOfpy3ztntS5FD9m++V Pvnf5HtjJfyZ2n/M1ZVAwV82AelNXfsDTSswo4DHka2AplXFgHiwmgRVb5nUMbXQD0 FY2PK2aHcYT/7dT1i4EdLvLFtnm453Cz9lracw4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Fangrui Song , Florian Fainelli , Ian Rogers , Jiri Olsa , John Keeping , Leo Yan , Michael Petlan , Namhyung Kim , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Arnaldo Carvalho de Melo Subject: [PATCH 5.17 321/343] perf python: Fix probing for some clang command line options Date: Tue, 12 Apr 2022 08:32:19 +0200 Message-Id: <20220412063000.586123610@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Arnaldo Carvalho de Melo commit dd6e1fe91cdd52774ca642d1da75b58a86356b56 upstream. The clang compiler complains about some options even without a source file being available, while others require one, so use the simple tools/build/feature/test-hello.c file. Then check for the "is not supported" string in its output, in addition to the "unknown argument" already being looked for. This was noticed when building with clang-13 where -ffat-lto-objects isn't supported and since we were looking just for "unknown argument" and not providing a source code to clang, was mistakenly assumed as being available and not being filtered to set of command line options provided to clang, leading to a build failure. Cc: Adrian Hunter Cc: Fangrui Song Cc: Florian Fainelli Cc: Ian Rogers Cc: Jiri Olsa Cc: John Keeping Cc: Leo Yan Cc: Michael Petlan Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Sedat Dilek Link: http://lore.kernel.org/lkml/ Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/perf/util/setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py @@ -1,12 +1,14 @@ -from os import getenv +from os import getenv, path from subprocess import Popen, PIPE from re import sub =20 cc =3D getenv("CC") cc_is_clang =3D b"clang version" in Popen([cc.split()[0], "-v"], stderr=3D= PIPE).stderr.readline() +src_feature_tests =3D getenv('srctree') + '/tools/build/feature' =20 def clang_has_option(option): - return [o for o in Popen([cc, option], stderr=3DPIPE).stderr.readlines= () if b"unknown argument" in o] =3D=3D [ ] + cc_output =3D Popen([cc, option, path.join(src_feature_tests, "test-he= llo.c") ], stderr=3DPIPE).stderr.readlines() + return [o for o in cc_output if ((b"unknown argument" in o) or (b"is n= ot supported" in o))] =3D=3D [ ] =20 if cc_is_clang: from distutils.sysconfig import get_config_vars From nobody Thu May 14 08:08:21 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 99A37C41535 for ; Tue, 12 Apr 2022 08:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359400AbiDLI5K (ORCPT ); Tue, 12 Apr 2022 04:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359390AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C07E2CCA3; Tue, 12 Apr 2022 00:22: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 082EE616B2; Tue, 12 Apr 2022 07:22:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFD0EC385A5; Tue, 12 Apr 2022 07:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748127; bh=JvIBDuRe0Vxz8C/p506SDPFuQzkiuVtuNyy6EPw/+RA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V3YpFm48tsHK3wPfsrlCD3G7zyt1x1FJ9maxaM18de42cY9BXfj3Em9swcodVz+Tz ZMWL5ao1HiLxg6Mm+W9Ixnkg85t3mNydDCDSN62u+eJJRYx/+2NOSvL+7PZvyt/Xxp IHVVw8NkD/hpVZHhYZu4WO0Jvz8zF7x7GFuYU0FU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Fangrui Song , Florian Fainelli , Ian Rogers , Jiri Olsa , John Keeping , Leo Yan , Michael Petlan , Namhyung Kim , Nathan Chancellor , Nick Desaulniers , Arnaldo Carvalho de Melo , Sedat Dilek Subject: [PATCH 5.17 322/343] tools build: Filter out options and warnings not supported by clang Date: Tue, 12 Apr 2022 08:32:20 +0200 Message-Id: <20220412063000.614654949@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Arnaldo Carvalho de Melo commit 41caff459a5b956b3e23ba9ca759dd0629ad3dda upstream. These make the feature check fail when using clang, so remove them just like is done in tools/perf/Makefile.config to build perf itself. Adding -Wno-compound-token-split-by-macro to tools/perf/Makefile.config when building with clang is also necessary to avoid these warnings turned into errors (-Werror): CC /tmp/build/perf/util/scripting-engines/trace-event-perl.o In file included from util/scripting-engines/trace-event-perl.c:35: In file included from /usr/lib64/perl5/CORE/perl.h:4085: In file included from /usr/lib64/perl5/CORE/hv.h:659: In file included from /usr/lib64/perl5/CORE/hv_func.h:34: In file included from /usr/lib64/perl5/CORE/sbox32_hash.h:4: /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '(' and '{' tokens in= troducing statement expression appear in different macro expansion contexts= [-Werror,-Wcompound-token-split-by-macro] ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib64/perl5/CORE/zaphod32_hash.h:80:38: note: expanded from macro 'Z= APHOD32_SCRAMBLE32' #define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START { \ ^~~~~~~~~~ /usr/lib64/perl5/CORE/perl.h:737:29: note: expanded from macro 'STMT_STAR= T' # define STMT_START (void)( /* gcc supports "({ STATEMENTS; })" */ ^ /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: '{' token is here ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib64/perl5/CORE/zaphod32_hash.h:80:49: note: expanded from macro 'Z= APHOD32_SCRAMBLE32' #define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START { \ ^ /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '}' and ')' tokens te= rminating statement expression appear in different macro expansion contexts= [-Werror,-Wcompound-token-split-by-macro] ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib64/perl5/CORE/zaphod32_hash.h:87:41: note: expanded from macro 'Z= APHOD32_SCRAMBLE32' v ^=3D (v>>23); \ ^ /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: ')' token is here ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/lib64/perl5/CORE/zaphod32_hash.h:88:3: note: expanded from macro 'ZA= PHOD32_SCRAMBLE32' } STMT_END ^~~~~~~~ /usr/lib64/perl5/CORE/perl.h:738:21: note: expanded from macro 'STMT_END' # define STMT_END ) ^ Please refer to the discussion on the Link: tag below, where Nathan clarifies the situation: acme> And then get to the problems at the end of this message, which seem acme> similar to the problem described here: acme> acme> From Nathan Chancellor <> acme> Subject [PATCH] mwifiex: Remove unnecessary braces from HostCmd_SET_S= EQ_NO_BSS_INFO acme> acme> https://lkml.org/lkml/2020/9/1/135 acme> acme> So perhaps in this case its better to disable that acme> -Werror,-Wcompound-token-split-by-macro when building with clang? Yes, I think that is probably the best solution. As far as I can tell, at least in this file and context, the warning appears harmless, as the "create a GNU C statement expression from two different macros" is very much intentional, based on the presence of PERL_USE_GCC_BRACE_GROUPS. The warning is fixed in upstream Perl by just avoiding creating GNU C statement expressions using STMT_START and STMT_END: https://github.com/Perl/perl5/issues/18780 https://github.com/Perl/perl5/pull/18984 If I am reading the source code correctly, an alternative to disabling the warning would be specifying -DPERL_GCC_BRACE_GROUPS_FORBIDDEN but it seems like that might end up impacting more than just this site, according to the issue discussion above. Based-on-a-patch-by: Sedat Dilek Tested-by: Sedat Dilek # Debian/Selfmade LLVM-14 (x= 86-64) Cc: Adrian Hunter Cc: Fangrui Song Cc: Florian Fainelli Cc: Ian Rogers Cc: Jiri Olsa Cc: John Keeping Cc: Leo Yan Cc: Michael Petlan Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Link: http://lore.kernel.org/lkml/YkxWcYzph5pC1EK8@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/build/feature/Makefile | 7 +++++++ tools/perf/Makefile.config | 3 +++ 2 files changed, 10 insertions(+) --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -220,6 +220,13 @@ PERL_EMBED_LIBADD =3D $(call grep-libs,$(P PERL_EMBED_CCOPTS =3D `perl -MExtUtils::Embed -e ccopts 2>/dev/null` FLAGS_PERL_EMBED=3D$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) =20 +ifeq ($(CC_NO_CLANG), 0) + PERL_EMBED_LDOPTS :=3D $(filter-out -specs=3D%,$(PERL_EMBED_LDOPTS)) + PERL_EMBED_CCOPTS :=3D $(filter-out -flto=3Dauto -ffat-lto-objects, $(PE= RL_EMBED_CCOPTS)) + PERL_EMBED_CCOPTS :=3D $(filter-out -specs=3D%,$(PERL_EMBED_CCOPTS)) + FLAGS_PERL_EMBED +=3D -Wno-compound-token-split-by-macro +endif + $(OUTPUT)test-libperl.bin: $(BUILD) $(FLAGS_PERL_EMBED) =20 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -793,6 +793,9 @@ else LDFLAGS +=3D $(PERL_EMBED_LDFLAGS) EXTLIBS +=3D $(PERL_EMBED_LIBADD) CFLAGS +=3D -DHAVE_LIBPERL_SUPPORT + ifeq ($(CC_NO_CLANG), 0) + CFLAGS +=3D -Wno-compound-token-split-by-macro + endif $(call detected,CONFIG_LIBPERL) endif endif From nobody Thu May 14 08:08:21 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 BAB20C4321E for ; Tue, 12 Apr 2022 08:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354861AbiDLIzr (ORCPT ); Tue, 12 Apr 2022 04:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359405AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E333A2CE0A; Tue, 12 Apr 2022 00:22: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 80013616B2; Tue, 12 Apr 2022 07:22:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B754C385A5; Tue, 12 Apr 2022 07:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748157; bh=PYNQeBE5FIvK7ttjTSwyhrldUg+LR6Jt9gF2vnHvEZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2S8NPbnFTJx2Mjw+EPfbBfSfn4vCkcRGjyyYXjsIsiyx+HzlVAS5JStJ3JP/jZ9/E RSOBhln0oxrqWMbCdoescdD40BT8S0TsQiNSgzPtPsCawAQFz4IefvA1ItYiSaLhTh W4m+qoO8wYxNDkiWdtciTyu+7jZLIErgtl6Lb9w0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Fangrui Song , Florian Fainelli , Ian Rogers , Jiri Olsa , John Keeping , Leo Yan , Michael Petlan , Namhyung Kim , Nathan Chancellor , Nick Desaulniers , Arnaldo Carvalho de Melo , Sedat Dilek Subject: [PATCH 5.17 323/343] tools build: Use $(shell ) instead of `` to get embedded libperls ccopts Date: Tue, 12 Apr 2022 08:32:21 +0200 Message-Id: <20220412063000.643931062@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Arnaldo Carvalho de Melo commit 541f695cbcb6932c22638b06e0cbe1d56177e2e9 upstream. Just like its done for ldopts and for both in tools/perf/Makefile.config. Using `` to initialize PERL_EMBED_CCOPTS somehow precludes using: $(filter-out SOMETHING_TO_FILTER,$(PERL_EMBED_CCOPTS)) And we need to do it to allow for building with versions of clang where some gcc options selected by distros are not available. Tested-by: Sedat Dilek # Debian/Selfmade LLVM-14 (x= 86-64) Cc: Adrian Hunter Cc: Fangrui Song Cc: Florian Fainelli Cc: Ian Rogers Cc: Jiri Olsa Cc: John Keeping Cc: Leo Yan Cc: Michael Petlan Cc: Namhyung Kim Cc: Nathan Chancellor Cc: Nick Desaulniers Link: http://lore.kernel.org/lkml/YktYX2OnLtyobRYD@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/build/feature/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -217,7 +217,7 @@ strip-libs =3D $(filter-out -l%,$(1)) PERL_EMBED_LDOPTS =3D $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS =3D $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD =3D $(call grep-libs,$(PERL_EMBED_LDOPTS)) -PERL_EMBED_CCOPTS =3D `perl -MExtUtils::Embed -e ccopts 2>/dev/null` +PERL_EMBED_CCOPTS =3D $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=3D$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) =20 ifeq ($(CC_NO_CLANG), 0) From nobody Thu May 14 08:08:21 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 F069AC4167D for ; Tue, 12 Apr 2022 08:57:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386329AbiDLIzN (ORCPT ); Tue, 12 Apr 2022 04:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359411AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43: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 A9F862CE15; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 6C794B81B46; Tue, 12 Apr 2022 07:22:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDAA2C385A6; Tue, 12 Apr 2022 07:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748169; bh=QaNOR5RKZom6VvVT+7/5NSchd1phah1uvn1QBNxVMAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDiaTUuAmgtVtX2dIVqhxY4Njjm8cqgOw3kuumtbutgbdoyqsgqT1EdPNaBEx0nOV DtQG8mIMnMON9CBNXPC1BGeXHVFo8zM/aLP3C0Knwmh3TPE8YDl5Vpn8xcH6m8oO/A 4T2Wg1R1N7ZE5mfZpnCDKqBnaA8QIOzBvX98yiAg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinod Koul Subject: [PATCH 5.17 324/343] dmaengine: Revert "dmaengine: shdma: Fix runtime PM imbalance on error" Date: Tue, 12 Apr 2022 08:32:22 +0200 Message-Id: <20220412063000.673620530@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Vinod Koul commit d143f939a95696d38ff800ada14402fa50ebbd6c upstream. This reverts commit 455896c53d5b ("dmaengine: shdma: Fix runtime PM imbalance on error") as the patch wrongly reduced the count on error and did not bail out. So drop the count by reverting the patch . Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/dma/sh/shdma-base.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c @@ -115,10 +115,8 @@ static dma_cookie_t shdma_tx_submit(stru ret =3D pm_runtime_get(schan->dev); =20 spin_unlock_irq(&schan->chan_lock); - if (ret < 0) { + if (ret < 0) dev_err(schan->dev, "%s(): GET =3D %d\n", __func__, ret); - pm_runtime_put(schan->dev); - } =20 pm_runtime_barrier(schan->dev); From nobody Thu May 14 08:08:21 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 550A4C43217 for ; Tue, 12 Apr 2022 08:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356229AbiDLI4E (ORCPT ); Tue, 12 Apr 2022 04:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359410AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E232C11F; Tue, 12 Apr 2022 00:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id 6C4376153F; Tue, 12 Apr 2022 07:22:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FD39C385A1; Tue, 12 Apr 2022 07:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748171; bh=2R3Jg6wuXoD3K4IfpFwi6Rua3esT/XHSYiQeLfWGfd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+LzTD1xcfleitD28IwW1X+U+9QMweDkDl2BkmHJCTTDLLbfgGba6wwuIJ6AogXqW lWqNNTPYMzR416syDqGfIFMOOvn7l66s1UPFLiDOaXqLe+48eDQDwE/Li48ARzVJgL iu2g4IaQDn0wSUO5Fi5da9Tny+X/iK9YSDYUsNZg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiuhao Li , Gaoning Pan , Yongkang Jia , Paolo Bonzini Subject: [PATCH 5.17 325/343] KVM: avoid NULL pointer dereference in kvm_dirty_ring_push Date: Tue, 12 Apr 2022 08:32:23 +0200 Message-Id: <20220412063000.702105259@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Paolo Bonzini commit 5593473a1e6c743764b08e3b6071cb43b5cfa6c4 upstream. kvm_vcpu_release() will call kvm_dirty_ring_free(), freeing ring->dirty_gfns and setting it to NULL. Afterwards, it calls kvm_arch_vcpu_destroy(). However, if closing the file descriptor races with KVM_RUN in such away that vcpu->arch.st.preempted =3D=3D 0, the following call stack leads to a NULL pointer dereference in kvm_dirty_run_push(): mark_page_dirty_in_slot+0x192/0x270 arch/x86/kvm/../../../virt/kvm/kvm_mai= n.c:3171 kvm_steal_time_set_preempted arch/x86/kvm/x86.c:4600 [inline] kvm_arch_vcpu_put+0x34e/0x5b0 arch/x86/kvm/x86.c:4618 vcpu_put+0x1b/0x70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:211 vmx_free_vcpu+0xcb/0x130 arch/x86/kvm/vmx/vmx.c:6985 kvm_arch_vcpu_destroy+0x76/0x290 arch/x86/kvm/x86.c:11219 kvm_vcpu_destroy arch/x86/kvm/../../../virt/kvm/kvm_main.c:441 [inline] The fix is to release the dirty page ring after kvm_arch_vcpu_destroy has run. Reported-by: Qiuhao Li Reported-by: Gaoning Pan Reported-by: Yongkang Jia Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -439,8 +439,8 @@ static void kvm_vcpu_init(struct kvm_vcp =20 static void kvm_vcpu_destroy(struct kvm_vcpu *vcpu) { - kvm_dirty_ring_free(&vcpu->dirty_ring); kvm_arch_vcpu_destroy(vcpu); + kvm_dirty_ring_free(&vcpu->dirty_ring); =20 /* * No need for rcu_read_lock as VCPU_RUN is the only place that changes From nobody Thu May 14 08:08:21 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 8E14EC43217 for ; Tue, 12 Apr 2022 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386149AbiDLIy1 (ORCPT ); Tue, 12 Apr 2022 04:54:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359412AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2AA82C11A; Tue, 12 Apr 2022 00:22: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 dfw.source.kernel.org (Postfix) with ESMTPS id 4DD1C6153F; Tue, 12 Apr 2022 07:22:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5552CC385A1; Tue, 12 Apr 2022 07:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748174; bh=x51UV5VOPeaHL0AME3MQUuSQK78drrrzIIMbVhno/eE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QgoSZt2yx/nUEWRB/dAtvPP9HC/spPT2hxd17slgmhfK55Q8GbKDAffxJt8mTOj1W fZgimVp46z1P+fNdkd0EoW5qVx8w35AIHpaj7B+sCYHpA/yTvgbcUQ+52Ox8Mb3VhB LRJ6WZvFtnp5+TcPTmehDJn60CKizNVJQfnXfsnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Andrea Parri (Microsoft)" , Wei Liu Subject: [PATCH 5.17 326/343] Drivers: hv: vmbus: Replace smp_store_mb() with virt_store_mb() Date: Tue, 12 Apr 2022 08:32:24 +0200 Message-Id: <20220412063000.730479830@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Andrea Parri (Microsoft) commit eaa03d34535872d29004cb5cf77dc9dec1ba9a25 upstream. Following the recommendation in Documentation/memory-barriers.txt for virtual machine guests. Fixes: 8b6a877c060ed ("Drivers: hv: vmbus: Replace the per-CPU channel list= s with a global array of channels") Signed-off-by: Andrea Parri (Microsoft) Link: https://lore.kernel.org/r/20220328154457.100872-1-parri.andrea@gmail.= com Signed-off-by: Wei Liu Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/hv/channel_mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -380,7 +380,7 @@ void vmbus_channel_map_relid(struct vmbu * execute: * * (a) In the "normal (i.e., not resuming from hibernation)" path, - * the full barrier in smp_store_mb() guarantees that the store + * the full barrier in virt_store_mb() guarantees that the store * is propagated to all CPUs before the add_channel_work work * is queued. In turn, add_channel_work is queued before the * channel's ring buffer is allocated/initialized and the @@ -392,14 +392,14 @@ void vmbus_channel_map_relid(struct vmbu * recv_int_page before retrieving the channel pointer from the * array of channels. * - * (b) In the "resuming from hibernation" path, the smp_store_mb() + * (b) In the "resuming from hibernation" path, the virt_store_mb() * guarantees that the store is propagated to all CPUs before * the VMBus connection is marked as ready for the resume event * (cf. check_ready_for_resume_event()). The interrupt handler * of the VMBus driver and vmbus_chan_sched() can not run before * vmbus_bus_resume() has completed execution (cf. resume_noirq). */ - smp_store_mb( + virt_store_mb( vmbus_connection.channels[channel->offermsg.child_relid], channel); } From nobody Thu May 14 08:08:21 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 3B60BC4167B for ; Tue, 12 Apr 2022 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386095AbiDLIyN (ORCPT ); Tue, 12 Apr 2022 04:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359415AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -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 6CF4D2CC91; Tue, 12 Apr 2022 00:22: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 0B5EE6177C; Tue, 12 Apr 2022 07:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15FDBC385A1; Tue, 12 Apr 2022 07:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748177; bh=yACMg3K5W5/I6pA+flBzd9n3DRtIlF1HetQbnpP/24s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ipTFErBlnIAlsu+ZKcwab04HjT4ynqwE4zv/Csbr3xFAiacgYvy50dOTJgygYd4zF rFSZn5bm16Mpu9+Ltb19u8CPN7mhQLMYnFIXopX1HKdIcs200T8tf1r3wm7Q0csBOD B/3AVGkEs+cvmJ+Th1cgGLUiqT/dMZ631H18nQVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kefeng Wang , Christophe Leroy , Michael Ellerman Subject: [PATCH 5.17 327/343] powerpc: Fix virt_addr_valid() for 64-bit Book3E & 32-bit Date: Tue, 12 Apr 2022 08:32:25 +0200 Message-Id: <20220412063000.758803730@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kefeng Wang commit ffa0b64e3be58519ae472ea29a1a1ad681e32f48 upstream. mpe: On 64-bit Book3E vmalloc space starts at 0x8000000000000000. Because of the way __pa() works we have: __pa(0x8000000000000000) =3D=3D 0, and therefore virt_to_pfn(0x8000000000000000) =3D=3D 0, and therefore virt_addr_valid(0x8000000000000000) =3D=3D true Which is wrong, virt_addr_valid() should be false for vmalloc space. In fact all vmalloc addresses that alias with a valid PFN will return true from virt_addr_valid(). That can cause bugs with hardened usercopy as described below by Kefeng Wang: When running ethtool eth0 on 64-bit Book3E, a BUG occurred: usercopy: Kernel memory exposure attempt detected from SLUB object not = in SLUB page?! (offset 0, size 1048)! kernel BUG at mm/usercopy.c:99 ... usercopy_abort+0x64/0xa0 (unreliable) __check_heap_object+0x168/0x190 __check_object_size+0x1a0/0x200 dev_ethtool+0x2494/0x2b20 dev_ioctl+0x5d0/0x770 sock_do_ioctl+0xf0/0x1d0 sock_ioctl+0x3ec/0x5a0 __se_sys_ioctl+0xf0/0x160 system_call_exception+0xfc/0x1f0 system_call_common+0xf8/0x200 The code shows below, data =3D vzalloc(array_size(gstrings.len, ETH_GSTRING_LEN)); copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN)) The data is alloced by vmalloc(), virt_addr_valid(ptr) will return true on 64-bit Book3E, which leads to the panic. As commit 4dd7554a6456 ("powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses") does, make sure the virt addr above PAGE_OFFSET in the virt_addr_valid() for 64-bit, also add upper limit check to make sure the virt is below high_memory. Meanwhile, for 32-bit PAGE_OFFSET is the virtual address of the start of lowmem, high_memory is the upper low virtual address, the check is suitable for 32-bit, this will fix the issue mentioned in commit 602946ec2f90 ("powerpc: Set max_mapnr correctly") too. On 32-bit there is a similar problem with high memory, that was fixed in commit 602946ec2f90 ("powerpc: Set max_mapnr correctly"), but that commit breaks highmem and needs to be reverted. We can't easily fix __pa(), we have code that relies on its current behaviour. So for now add extra checks to virt_addr_valid(). For 64-bit Book3S the extra checks are not necessary, the combination of virt_to_pfn() and pfn_valid() should yield the correct result, but they are harmless. Signed-off-by: Kefeng Wang Reviewed-by: Christophe Leroy [mpe: Add additional change log detail] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220406145802.538416-1-mpe@ellerman.id.au Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/include/asm/page.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -132,7 +132,11 @@ static inline bool pfn_valid(unsigned lo #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) =20 -#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) +#define virt_addr_valid(vaddr) ({ \ + unsigned long _addr =3D (unsigned long)vaddr; \ + _addr >=3D PAGE_OFFSET && _addr < (unsigned long)high_memory && \ + pfn_valid(virt_to_pfn(_addr)); \ +}) =20 /* * On Book-E parts we need __va to parse the device tree and we can't From nobody Thu May 14 08:08:21 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 90501C4332F for ; Tue, 12 Apr 2022 08:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230235AbiDLIzX (ORCPT ); Tue, 12 Apr 2022 04:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359413AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAA2C2CE16; Tue, 12 Apr 2022 00:23: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 6E418B81B13; Tue, 12 Apr 2022 07:23:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D139AC385A5; Tue, 12 Apr 2022 07:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748180; bh=eMM8OKCs1XS4pP/lEvBAbkA9WBA3mZDUkQodzz0SW4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SP1eip46TXekRyvJDQyOy/NR7EtRRpNjqo1hqP5v7FI+6+9dxPh3ceo1C4lvW+o5R tMETEv+w0odddZCBx0H/YouejJVz7o4QIvIuK7LFBdzBimXyYI/QRFmv6bTIClER1/ BRBrpfKppaWihHrMyqRybmNETehx4j3PkHkPNjV4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kefeng Wang , Christophe Leroy , "Erhard F." , Michael Ellerman Subject: [PATCH 5.17 328/343] Revert "powerpc: Set max_mapnr correctly" Date: Tue, 12 Apr 2022 08:32:26 +0200 Message-Id: <20220412063000.787106591@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Kefeng Wang commit 1ff5c8e8c835e8a81c0868e3050c76563dd56a2c upstream. This reverts commit 602946ec2f90d5bd965857753880db29d2d9a1e9. If CONFIG_HIGHMEM is enabled, no highmem will be added with max_mapnr set to max_low_pfn, see mem_init(): for (pfn =3D highmem_mapnr; pfn < max_mapnr; ++pfn) { ... free_highmem_page(); } Now that virt_addr_valid() has been fixed in the previous commit, we can revert the change to max_mapnr. Fixes: 602946ec2f90 ("powerpc: Set max_mapnr correctly") Signed-off-by: Kefeng Wang Reviewed-by: Christophe Leroy Reported-by: Erhard F. [mpe: Update change log to reflect series reordering] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220406145802.538416-2-mpe@ellerman.id.au Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/mm/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -255,7 +255,7 @@ void __init mem_init(void) #endif =20 high_memory =3D (void *) __va(max_low_pfn * PAGE_SIZE); - set_max_mapnr(max_low_pfn); + set_max_mapnr(max_pfn); =20 kasan_late_init(); From nobody Thu May 14 08:08:21 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 0DCB2C41535 for ; Tue, 12 Apr 2022 08:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386345AbiDLIzQ (ORCPT ); Tue, 12 Apr 2022 04:55:16 -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 S1359414AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94317255AE; Tue, 12 Apr 2022 00:23: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 3F69BB81B13; Tue, 12 Apr 2022 07:23:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A134DC385A1; Tue, 12 Apr 2022 07:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748183; bh=jdSrlme+ldB8gp5g95tgqulfRXTKB43uz9/V2NDGTck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QEqfOneQftJvc6t7KHCzMdWGm5Cdhg/HPQNsnv64DwPj34k1M3sk7wEMxwqO3t1Sk yNWL2FEGRgoU6jYPAiQIzWYNEUGO5tpD52ZZiz+DjGIqPrbD55lq7GVygtX1gW3qlM uoNQCzjE6zyxNsDGUMhJQdgoEWw68cAA8fwJb/QE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Mailhol , "Peter Zijlstra (Intel)" , Nick Desaulniers , Josh Poimboeuf Subject: [PATCH 5.17 329/343] x86/bug: Prevent shadowing in __WARN_FLAGS Date: Tue, 12 Apr 2022 08:32:27 +0200 Message-Id: <20220412063000.815412501@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Vincent Mailhol commit 9ce02f0fc68326dd1f87a0a3a4c6ae7fdd39e6f6 upstream. The macro __WARN_FLAGS() uses a local variable named "f". This being a common name, there is a risk of shadowing other variables. For example, GCC would yield: | In file included from ./include/linux/bug.h:5, | from ./include/linux/cpumask.h:14, | from ./arch/x86/include/asm/cpumask.h:5, | from ./arch/x86/include/asm/msr.h:11, | from ./arch/x86/include/asm/processor.h:22, | from ./arch/x86/include/asm/timex.h:5, | from ./include/linux/timex.h:65, | from ./include/linux/time32.h:13, | from ./include/linux/time.h:60, | from ./include/linux/stat.h:19, | from ./include/linux/module.h:13, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h: In function 'rcu_head_after_call_rcu': | ./arch/x86/include/asm/bug.h:80:21: warning: declaration of 'f' shadows a= parameter [-Wshadow] | 80 | __auto_type f =3D BUGFLAG_WARNING|(flags); = \ | | ^ | ./include/asm-generic/bug.h:106:17: note: in expansion of macro '__WARN_F= LAGS' | 106 | __WARN_FLAGS(BUGFLAG_ONCE | \ | | ^~~~~~~~~~~~ | ./include/linux/rcupdate.h:1007:9: note: in expansion of macro 'WARN_ON_O= NCE' | 1007 | WARN_ON_ONCE(func !=3D (rcu_callback_t)~0L); | | ^~~~~~~~~~~~ | In file included from ./include/linux/rbtree.h:24, | from ./include/linux/mm_types.h:11, | from ./include/linux/buildid.h:5, | from ./include/linux/module.h:14, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h:1001:62: note: shadowed declaration is here | 1001 | rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f) | | ~~~~~~~~~~~~~~~^ For reference, sparse also warns about it, c.f. [1]. This patch renames the variable from f to __flags (with two underscore prefixes as suggested in the Linux kernel coding style [2]) in order to prevent collisions. [1] https://lore.kernel.org/all/CAFGhKbyifH1a+nAMCvWM88TK6fpNPdzFtUXPmRGnnQ= eePV+1sw@mail.gmail.com/ [2] Linux kernel coding style, section 12) Macros, Enums and RTL, paragraph 5) namespace collisions when defining local variables in macros resembling functions https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enu= ms-and-rtl Fixes: bfb1a7c91fb7 ("x86/bug: Merge annotate_reachable() into_BUG_FLAGS() = asm") Signed-off-by: Vincent Mailhol Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Nick Desaulniers Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20220324023742.106546-1-mailhol.vincent@wan= adoo.fr Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/include/asm/bug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -77,9 +77,9 @@ do { \ */ #define __WARN_FLAGS(flags) \ do { \ - __auto_type f =3D BUGFLAG_WARNING|(flags); \ + __auto_type __flags =3D BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE); \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0) From nobody Thu May 14 08:08:21 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 AD51EC352AA for ; Tue, 12 Apr 2022 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386192AbiDLIyf (ORCPT ); Tue, 12 Apr 2022 04:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359416AbiDLHnC (ORCPT ); Tue, 12 Apr 2022 03:43: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 2FEFB2CE1A; Tue, 12 Apr 2022 00:23: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 E0845B81B33; Tue, 12 Apr 2022 07:23:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58D29C385A1; Tue, 12 Apr 2022 07:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748185; bh=puVvcVR9URWdyntTsSnOVTEqo3uaLGnngVEYbR821qc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ypCvaqY1qsWsMqIQo4I+11L2K9UtNB0RenZSz4m+f86gDIPmmlI+3QhP8zrcEFP5w Bi56pyKdXFjIzeaiXL4ht5gSgfTtLXektvN57ADh/SrQGHY3C+Cl8wgsH517/Uc9PO muxqzinrJ1PpZlhbWCiGqtT2jc0Zya1zvsDIeDnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 330/343] objtool: Fix SLS validation for kcov tail-call replacement Date: Tue, 12 Apr 2022 08:32:28 +0200 Message-Id: <20220412063000.843902940@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 7a53f408902d913cd541b4f8ad7dbcd4961f5b82 upstream. Since not all compilers have a function attribute to disable KCOV instrumentation, objtool can rewrite KCOV instrumentation in noinstr functions as per commit: f56dae88a81f ("objtool: Handle __sanitize_cov*() tail calls") However, this has subtle interaction with the SLS validation from commit: 1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation") In that when a tail-call instrucion is replaced with a RET an additional INT3 instruction is also written, but is not represented in the decoded instruction stream. This then leads to false positive missing INT3 objtool warnings in noinstr code. Instead of adding additional struct instruction objects, mark the RET instruction with retpoline_safe to suppress the warning (since we know there really is an INT3). Fixes: 1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation") Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220323230712.GA8939@worktop.programming.k= icks-ass.net Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- tools/objtool/check.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1090,6 +1090,17 @@ static void annotate_call_site(struct ob : arch_nop_insn(insn->len)); =20 insn->type =3D sibling ? INSN_RETURN : INSN_NOP; + + if (sibling) { + /* + * We've replaced the tail-call JMP insn by two new + * insn: RET; INT3, except we only have a single struct + * insn here. Mark it retpoline_safe to avoid the SLS + * warning, instead of adding another insn. + */ + insn->retpoline_safe =3D true; + } + return; } From nobody Thu May 14 08:08:21 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 755FAC4167E for ; Tue, 12 Apr 2022 08:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358022AbiDLI4e (ORCPT ); Tue, 12 Apr 2022 04:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359391AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 4AFF92B271; Tue, 12 Apr 2022 00:22:11 -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 DD8EA6171C; Tue, 12 Apr 2022 07:22:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E97C385A5; Tue, 12 Apr 2022 07:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748130; bh=FQfC2Om4wIcb1HIRf/yVr+QDGuzzRTC58mtKVCt3alY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=li28B2RER282A8uLPRhqldziNBu1ivqnOdfc2X+iKYCScGJtERpAQSvnGqTYUjPY1 VAUri0759QCa7CF1lYYyJHmd6Y8tX4lqb8tmS0HABaHCWBA24Ja6iFx+RqASkDqFJo BeKbJS7QqeVmOkDPxdKZSOCXYDaqfkINfey8FD5c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Rostedt , "Peter Zijlstra (Intel)" , "T.J. Alumbaugh" Subject: [PATCH 5.17 331/343] sched/core: Fix forceidle balancing Date: Tue, 12 Apr 2022 08:32:29 +0200 Message-Id: <20220412063000.871956573@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 5b6547ed97f4f5dfc23f8e3970af6d11d7b7ed7e upstream. Steve reported that ChromeOS encounters the forceidle balancer being ran from rt_mutex_setprio()'s balance_callback() invocation and explodes. Now, the forceidle balancer gets queued every time the idle task gets selected, set_next_task(), which is strictly too often. rt_mutex_setprio() also uses set_next_task() in the 'change' pattern: queued =3D task_on_rq_queued(p); /* p->on_rq =3D=3D TASK_ON_RQ_QUEUED */ running =3D task_current(rq, p); /* rq->curr =3D=3D p */ if (queued) dequeue_task(...); if (running) put_prev_task(...); /* change task properties */ if (queued) enqueue_task(...); if (running) set_next_task(...); However, rt_mutex_setprio() will explicitly not run this pattern on the idle task (since priority boosting the idle task is quite insane). Most other 'change' pattern users are pidhash based and would also not apply to idle. Also, the change pattern doesn't contain a __balance_callback() invocation and hence we could have an out-of-band balance-callback, which *should* trigger the WARN in rq_pin_lock() (which guards against this exact anti-pattern). So while none of that explains how this happens, it does indicate that having it in set_next_task() might not be the most robust option. Instead, explicitly queue the forceidle balancer from pick_next_task() when it does indeed result in forceidle selection. Having it here, ensures it can only be triggered under the __schedule() rq->lock instance, and hence must be ran from that context. This also happens to clean up the code a little, so win-win. Fixes: d2dfa17bc7de ("sched: Trivial forced-newidle balancer") Reported-by: Steven Rostedt Signed-off-by: Peter Zijlstra (Intel) Tested-by: T.J. Alumbaugh Link: https://lkml.kernel.org/r/20220330160535.GN8939@worktop.programming.k= icks-ass.net Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- kernel/sched/core.c | 14 ++++++++++---- kernel/sched/idle.c | 1 - kernel/sched/sched.h | 6 ------ 3 files changed, 10 insertions(+), 11 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5675,6 +5675,8 @@ static inline struct task_struct *pick_t =20 extern void task_vruntime_update(struct rq *rq, struct task_struct *p, boo= l in_fi); =20 +static void queue_core_balance(struct rq *rq); + static struct task_struct * pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *r= f) { @@ -5724,7 +5726,7 @@ pick_next_task(struct rq *rq, struct tas } =20 rq->core_pick =3D NULL; - return next; + goto out; } =20 put_prev_task_balance(rq, prev, rf); @@ -5774,7 +5776,7 @@ pick_next_task(struct rq *rq, struct tas */ WARN_ON_ONCE(fi_before); task_vruntime_update(rq, next, false); - goto done; + goto out_set_next; } } =20 @@ -5893,8 +5895,12 @@ pick_next_task(struct rq *rq, struct tas resched_curr(rq_i); } =20 -done: +out_set_next: set_next_task(rq, next); +out: + if (rq->core->core_forceidle_count && next =3D=3D rq->idle) + queue_core_balance(rq); + return next; } =20 @@ -5989,7 +5995,7 @@ static void sched_core_balance(struct rq =20 static DEFINE_PER_CPU(struct callback_head, core_balance_head); =20 -void queue_core_balance(struct rq *rq) +static void queue_core_balance(struct rq *rq) { if (!sched_core_enabled(rq)) return; --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -437,7 +437,6 @@ static void set_next_task_idle(struct rq { update_idle_core(rq); schedstat_inc(rq->sched_goidle); - queue_core_balance(rq); } =20 #ifdef CONFIG_SMP --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1247,8 +1247,6 @@ static inline bool sched_group_cookie_ma return false; } =20 -extern void queue_core_balance(struct rq *rq); - static inline bool sched_core_enqueued(struct task_struct *p) { return !RB_EMPTY_NODE(&p->core_node); @@ -1282,10 +1280,6 @@ static inline raw_spinlock_t *__rq_lockp return &rq->__lock; } =20 -static inline void queue_core_balance(struct rq *rq) -{ -} - static inline bool sched_cpu_cookie_match(struct rq *rq, struct task_struc= t *p) { return true; From nobody Thu May 14 08:08:21 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 847B1C4167D for ; Tue, 12 Apr 2022 08:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359000AbiDLI4w (ORCPT ); Tue, 12 Apr 2022 04:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359394AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 E2ED42B24E; Tue, 12 Apr 2022 00:22: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 A04F5B81B60; Tue, 12 Apr 2022 07:22:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1F03C385A5; Tue, 12 Apr 2022 07:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748133; bh=eckn+aBAdWS7OATL4W/IxONHXyEWfphSn5/jhFiGsQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLVp+ePBQw5qGD4Nx708b3KvaxeDE5i0SrmQh4dUqghiU0fhWngCUK7+VB+sjj+2Y K3RzbwVUQwF96T9Czd9bPAIqekKsspQceJetSVVOYC/mlx59LnsXr9WtdGk2p28HJd PAbJvgDmsMP9BAjZkGiS+W++B0VBufIy3A7WDQw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 332/343] sched: Teach the forced-newidle balancer about CPU affinity limitation. Date: Tue, 12 Apr 2022 08:32:30 +0200 Message-Id: <20220412063000.901688462@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Sebastian Andrzej Siewior commit 386ef214c3c6ab111d05e1790e79475363abaa05 upstream. try_steal_cookie() looks at task_struct::cpus_mask to decide if the task could be moved to `this' CPU. It ignores that the task might be in a migration disabled section while not on the CPU. In this case the task must not be moved otherwise per-CPU assumption are broken. Use is_cpu_allowed(), as suggested by Peter Zijlstra, to decide if the a task can be moved. Fixes: d2dfa17bc7de6 ("sched: Trivial forced-newidle balancer") Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/YjNK9El+3fzGmswf@linutronix.de Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5929,7 +5929,7 @@ static bool try_steal_cookie(int this, i if (p =3D=3D src->core_pick || p =3D=3D src->curr) goto next; =20 - if (!cpumask_test_cpu(this, &p->cpus_mask)) + if (!is_cpu_allowed(p, this)) goto next; =20 if (p->core_occupation > dst->idle->core_occupation) From nobody Thu May 14 08:08:21 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 64613C4167B for ; Tue, 12 Apr 2022 08:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357041AbiDLI4W (ORCPT ); Tue, 12 Apr 2022 04:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359395AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED102C133; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 6F7D3B81B4F; Tue, 12 Apr 2022 07:22:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF05C385A5; Tue, 12 Apr 2022 07:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748136; bh=uWWbWAFiJjTX83lC6DgCnZBOURJrl4U1pob1qP3NhQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WaktoVgU4crXzxOARhUi+WVok4PMs26nb0sIAPC+RsXIgZ69CKNP/PRU0p/+M7gWb J2seiakeMCn2/J8eLsBdEKukLkHkbuWhYsPvQQ+hsfvbm0N+tNnxbxHyLopyTCnf9Q BHRsqYF2+oAwpg3j/zh/vyo1EsrwCqIPalqDMvAc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , "Peter Zijlstra (Intel)" Subject: [PATCH 5.17 333/343] x86,static_call: Fix __static_call_return0 for i386 Date: Tue, 12 Apr 2022 08:32:31 +0200 Message-Id: <20220412063000.930534859@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 1cd5f059d956e6f614ba6666ecdbcf95db05d5f5 upstream. Paolo reported that the instruction sequence that is used to replace: call __static_call_return0 namely: 66 66 48 31 c0 data16 data16 xor %rax,%rax decodes to something else on i386, namely: 66 66 48 data16 dec %ax 31 c0 xor %eax,%eax Which is a nonsensical sequence that happens to have the same outcome. *However* an important distinction is that it consists of 2 instructions which is a problem when the thing needs to be overwriten with a regular call instruction again. As such, replace the instruction with something that decodes the same on both i386 and x86_64. Fixes: 3f2a8fc4b15d ("static_call/x86: Add __static_call_return0()") Reported-by: Paolo Bonzini Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220318204419.GT8939@worktop.programming.k= icks-ass.net Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/kernel/static_call.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/arch/x86/kernel/static_call.c +++ b/arch/x86/kernel/static_call.c @@ -12,10 +12,9 @@ enum insn_type { }; =20 /* - * data16 data16 xorq %rax, %rax - a single 5 byte instruction that clears= %rax - * The REX.W cancels the effect of any data16. + * cs cs cs xorl %eax, %eax - a single 5 byte instruction that clears %[er= ]ax */ -static const u8 xor5rax[] =3D { 0x66, 0x66, 0x48, 0x31, 0xc0 }; +static const u8 xor5rax[] =3D { 0x2e, 0x2e, 0x2e, 0x31, 0xc0 }; =20 static const u8 retinsn[] =3D { RET_INSN_OPCODE, 0xcc, 0xcc, 0xcc, 0xcc }; From nobody Thu May 14 08:08:21 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 A4F09C43219 for ; Tue, 12 Apr 2022 08:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351306AbiDLIze (ORCPT ); Tue, 12 Apr 2022 04:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359396AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F05A2C664; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 3D493B81B66; Tue, 12 Apr 2022 07:22:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89DE3C385A5; Tue, 12 Apr 2022 07:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748138; bh=D9WIdFhluHES3x6ARYx49n7SFgTgXokZUrYuVIU6mVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTolrNEnVeYMGNFVfcX6tP8qiU59h4KKR+Qbw9Jl64VyBJMKWJpHqnHAFzz8ztzUW jS+Ygi8X0O80SXE5WnmQI/xUONJnyMJbH8FNNzKkzvPnfghDFn8CvNwE4/W4xUbPlv pM2k49ZcMXpywmIaU4yhcnngOwb+bj8ZIXcDwwVY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bernardo Meurer Costa , Nick Desaulniers , "Peter Zijlstra (Intel)" , Nathan Chancellor Subject: [PATCH 5.17 334/343] x86/extable: Prefer local labels in .set directives Date: Tue, 12 Apr 2022 08:32:32 +0200 Message-Id: <20220412063000.959501433@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Nick Desaulniers commit 334865b2915c33080624e0d06f1c3e917036472c upstream. Bernardo reported an error that Nathan bisected down to (x86_64) defconfig+LTO_CLANG_FULL+X86_PMEM_LEGACY. LTO vmlinux.o ld.lld: error: :1:13: redefinition of 'found' .set found, 0 ^ :29:1: while in macro instantiation extable_type_reg reg=3D%eax, type=3D(17 | ((0) << 16)) ^ This appears to be another LTO specific issue similar to what was folded into commit 4b5305decc84 ("x86/extable: Extend extable functionality"), where the `.set found, 0` in DEFINE_EXTABLE_TYPE_REG in arch/x86/include/asm/asm.h conflicts with the symbol for the static function `found` in arch/x86/kernel/pmem.c. Assembler .set directive declare symbols with global visibility, so the assembler may not rename such symbols in the event of a conflict. LTO could rename static functions if there was a conflict in C sources, but it cannot see into symbols defined in inline asm. The symbols are also retained in the symbol table, regardless of LTO. Give the symbols .L prefixes making them locally visible, so that they may be renamed for LTO to avoid conflicts, and to drop them from the symbol table regardless of LTO. Fixes: 4b5305decc84 ("x86/extable: Extend extable functionality") Reported-by: Bernardo Meurer Costa Debugged-by: Nathan Chancellor Signed-off-by: Nick Desaulniers Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Link: https://lore.kernel.org/r/20220329202148.2379697-1-ndesaulniers@googl= e.com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/x86/include/asm/asm.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -154,24 +154,24 @@ =20 # define DEFINE_EXTABLE_TYPE_REG \ ".macro extable_type_reg type:req reg:req\n" \ - ".set found, 0\n" \ - ".set regnr, 0\n" \ + ".set .Lfound, 0\n" \ + ".set .Lregnr, 0\n" \ ".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n"= \ ".ifc \\reg, %%\\rs\n" \ - ".set found, found+1\n" \ - ".long \\type + (regnr << 8)\n" \ + ".set .Lfound, .Lfound+1\n" \ + ".long \\type + (.Lregnr << 8)\n" \ ".endif\n" \ - ".set regnr, regnr+1\n" \ + ".set .Lregnr, .Lregnr+1\n" \ ".endr\n" \ - ".set regnr, 0\n" \ + ".set .Lregnr, 0\n" \ ".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d= ,r15d\n" \ ".ifc \\reg, %%\\rs\n" \ - ".set found, found+1\n" \ - ".long \\type + (regnr << 8)\n" \ + ".set .Lfound, .Lfound+1\n" \ + ".long \\type + (.Lregnr << 8)\n" \ ".endif\n" \ - ".set regnr, regnr+1\n" \ + ".set .Lregnr, .Lregnr+1\n" \ ".endr\n" \ - ".if (found !=3D 1)\n" \ + ".if (.Lfound !=3D 1)\n" \ ".error \"extable_type_reg: bad register argument\"\n" \ ".endif\n" \ ".endm\n" From nobody Thu May 14 08:08:21 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 A6245C4707F for ; Tue, 12 Apr 2022 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386040AbiDLIx4 (ORCPT ); Tue, 12 Apr 2022 04:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359393AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 083752CCA6; Tue, 12 Apr 2022 00:22: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 BB537B81B4F; Tue, 12 Apr 2022 07:22:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31232C385A5; Tue, 12 Apr 2022 07:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748141; bh=gG2l95nc3o6r+Na0a2Vg2hAkYDSYrk+WcrC0aYTmvr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KdW5GiT1D0exoHLmo/S3MUSBzB3SvWi18J0z/GF/Qw4Bpjd7gZAb1+V7CK0b+Llsk u+Q60+gFx0Gxr7Fz2pJAqlM6aEynQ4DOuTej/wHCsTtXOX/DM6x7YZaClZRyOoJXkd sPWPBW7tOL3OfEturxtrdB1mhZsqU5GT90ZrrAq4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jingyi Wang , Nianyao Tang , Marc Zyngier Subject: [PATCH 5.17 335/343] irqchip/gic-v4: Wait for GICR_VPENDBASER.Dirty to clear before descheduling Date: Tue, 12 Apr 2022 08:32:33 +0200 Message-Id: <20220412063000.988387489@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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 Zyngier commit af27e41612ec7e5b4783f589b753a7c31a37aac8 upstream. The way KVM drives GICv4.{0,1} is as follows: - vcpu_load() makes the VPE resident, instructing the RD to start scanning for interrupts - just before entering the guest, we check that the RD has finished scanning and that we can start running the vcpu - on preemption, we deschedule the VPE by making it invalid on the RD However, we are preemptible between the first two steps. If it so happens *and* that the RD was still scanning, we nonetheless write to the GICR_VPENDBASER register while Dirty is set, and bad things happen (we're in UNPRED land). This affects both the 4.0 and 4.1 implementations. Make sure Dirty is cleared before performing the deschedule, meaning that its_clear_vpend_valid() becomes a sort of full VPE residency barrier. Reported-by: Jingyi Wang Tested-by: Nianyao Tang Signed-off-by: Marc Zyngier Fixes: 57e3cebd022f ("KVM: arm64: Delay the polling of the GICR_VPENDBASER.= Dirty bit") Link: https://lore.kernel.org/r/4aae10ba-b39a-5f84-754b-69c2eb0a2c03@huawei= .com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/irqchip/irq-gic-v3-its.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3011,18 +3011,12 @@ static int __init allocate_lpi_tables(vo return 0; } =20 -static u64 its_clear_vpend_valid(void __iomem *vlpi_base, u64 clr, u64 set) +static u64 read_vpend_dirty_clear(void __iomem *vlpi_base) { u32 count =3D 1000000; /* 1s! */ bool clean; u64 val; =20 - val =3D gicr_read_vpendbaser(vlpi_base + GICR_VPENDBASER); - val &=3D ~GICR_VPENDBASER_Valid; - val &=3D ~clr; - val |=3D set; - gicr_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER); - do { val =3D gicr_read_vpendbaser(vlpi_base + GICR_VPENDBASER); clean =3D !(val & GICR_VPENDBASER_Dirty); @@ -3033,10 +3027,26 @@ static u64 its_clear_vpend_valid(void __ } } while (!clean && count); =20 - if (unlikely(val & GICR_VPENDBASER_Dirty)) { + if (unlikely(!clean)) pr_err_ratelimited("ITS virtual pending table not cleaning\n"); + + return val; +} + +static u64 its_clear_vpend_valid(void __iomem *vlpi_base, u64 clr, u64 set) +{ + u64 val; + + /* Make sure we wait until the RD is done with the initial scan */ + val =3D read_vpend_dirty_clear(vlpi_base); + val &=3D ~GICR_VPENDBASER_Valid; + val &=3D ~clr; + val |=3D set; + gicr_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER); + + val =3D read_vpend_dirty_clear(vlpi_base); + if (unlikely(val & GICR_VPENDBASER_Dirty)) val |=3D GICR_VPENDBASER_PendingLast; - } =20 return val; } From nobody Thu May 14 08:08:21 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 557E8C3525B for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386902AbiDLJEw (ORCPT ); Tue, 12 Apr 2022 05:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359397AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 CCD472CE01; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id 8952CB81B58; Tue, 12 Apr 2022 07:22:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA422C385A5; Tue, 12 Apr 2022 07:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748144; bh=If+C5ynFVXd2jpH7gryV4MCjUbXoG41ZdvKY1I3iIvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lutWXk2/NtrVw2hS6D0CzNEm84tH9VmIpzfy+eOH9sLFaq5nS83vWSDW81t7rL/Sb W31u6lZDrM8gVw3zIQ6NEYgKKTe/Lw/4JN3JX7aUq8v/lNqk7ym6+GIflMX6cM74i4 umV3VMpBQmAZGm8k8ai0hsjda5bxeQs5uEVdN220= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman Subject: [PATCH 5.17 336/343] powerpc/64: Fix build failure with allyesconfig in book3s_64_entry.S Date: Tue, 12 Apr 2022 08:32:34 +0200 Message-Id: <20220412063001.016606571@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Christophe Leroy commit af41d2866f7d75bbb38d487f6ec7770425d70e45 upstream. Using conditional branches between two files is hasardous, they may get linked too far from each other. arch/powerpc/kvm/book3s_64_entry.o:(.text+0x3ec): relocation truncated to fit: R_PPC64_REL14 (stub) against symbol `system_reset_common' defined in .text section in arch/powerpc/kernel/head_64.o Reorganise the code to use non conditional branches. Fixes: 89d35b239101 ("KVM: PPC: Book3S HV P9: Implement the rest of the P9 = path in C") Signed-off-by: Christophe Leroy [mpe: Avoid odd-looking bne ., use named local labels] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/89cf27bf43ee07a0b2879b9e8e2f5cd6386a3645.16= 48366338.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- arch/powerpc/kvm/book3s_64_entry.S | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/arch/powerpc/kvm/book3s_64_entry.S +++ b/arch/powerpc/kvm/book3s_64_entry.S @@ -414,10 +414,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_DAWR1) */ ld r10,HSTATE_SCRATCH0(r13) cmpwi r10,BOOK3S_INTERRUPT_MACHINE_CHECK - beq machine_check_common + beq .Lcall_machine_check_common =20 cmpwi r10,BOOK3S_INTERRUPT_SYSTEM_RESET - beq system_reset_common + beq .Lcall_system_reset_common =20 b . + +.Lcall_machine_check_common: + b machine_check_common + +.Lcall_system_reset_common: + b system_reset_common #endif From nobody Thu May 14 08:08:21 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 40E04C41535 for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386858AbiDLJEn (ORCPT ); Tue, 12 Apr 2022 05:04:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359398AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB9A2CC9B; Tue, 12 Apr 2022 00:22: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 66716B81B60; Tue, 12 Apr 2022 07:22:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3A10C385A1; Tue, 12 Apr 2022 07:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748147; bh=e9O41xtZGrmCpXGoo/uLMcFr7AIxfezKsEgG2L32/xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EQxNVzah7xq55jAmtOJG2l5m2vqCIWWdeXxxqs4pd7bp1LTjcdWLtaSe572/N7PeV Mhxflf2JOsKwqBCwSkbEqxXtjsBgRE3R5S4QICNxfDsYGUfqrfncq5VRaGWOr+wOFS hbjk/8DRxBrWFmx2TWl+s0BEOpiunDVeDyEQmqXw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andre Przywara , Marc Zyngier Subject: [PATCH 5.17 337/343] irqchip/gic, gic-v3: Prevent GSI to SGI translations Date: Tue, 12 Apr 2022 08:32:35 +0200 Message-Id: <20220412063001.044955731@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Andre Przywara commit 544808f7e21cb9ccdb8f3aa7de594c05b1419061 upstream. At the moment the GIC IRQ domain translation routine happily converts ACPI table GSI numbers below 16 to GIC SGIs (Software Generated Interrupts aka IPIs). On the Devicetree side we explicitly forbid this translation, actually the function will never return HWIRQs below 16 when using a DT based domain translation. We expect SGIs to be handled in the first part of the function, and any further occurrence should be treated as a firmware bug, so add a check and print to report this explicitly and avoid lengthy debug sessions. Fixes: 64b499d8df40 ("irqchip/gic-v3: Configure SGIs as standard interrupts= ") Signed-off-by: Andre Przywara Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220404110842.2882446-1-andre.przywara@arm= .com Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- drivers/irqchip/irq-gic-v3.c | 6 ++++++ drivers/irqchip/irq-gic.c | 6 ++++++ 2 files changed, 12 insertions(+) --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1466,6 +1466,12 @@ static int gic_irq_domain_translate(stru if(fwspec->param_count !=3D 2) return -EINVAL; =20 + if (fwspec->param[0] < 16) { + pr_err(FW_BUG "Illegal GSI%d translation request\n", + fwspec->param[0]); + return -EINVAL; + } + *hwirq =3D fwspec->param[0]; *type =3D fwspec->param[1]; =20 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1085,6 +1085,12 @@ static int gic_irq_domain_translate(stru if(fwspec->param_count !=3D 2) return -EINVAL; =20 + if (fwspec->param[0] < 16) { + pr_err(FW_BUG "Illegal GSI%d translation request\n", + fwspec->param[0]); + return -EINVAL; + } + *hwirq =3D fwspec->param[0]; *type =3D fwspec->param[1]; From nobody Thu May 14 08:08:21 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 9D7B4C4321E for ; Tue, 12 Apr 2022 08:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386275AbiDLIy4 (ORCPT ); Tue, 12 Apr 2022 04:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359400AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 A33172CE05; Tue, 12 Apr 2022 00:22:30 -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 40774616B2; Tue, 12 Apr 2022 07:22:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5708CC385A5; Tue, 12 Apr 2022 07:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748149; bh=8NBQ5K9uRRSfDU5tznudwhA9E3UIsrOYnRLVdJ8Ujh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kcPbRGXxAQDB5QYsttkysmREC3qKjmgJFkQPT3g6qdHug55UX8RSPjhjMw/4BKFKO 6rRVPU6L2fMfUygGCttz7KNjxveIdcyAqEm/UWHDYKlWmtd9RK9pZuSjHZej7GW/KB /VN89IG7/k7fI5qwTy0vqBtHzlV8RRJVnA4d6jI4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Justin Forbes , "Kirill A . Shutemov" , Ingo Molnar , Rafael Aquini , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 338/343] mm/sparsemem: fix mem_section will never be NULL gcc 12 warning Date: Tue, 12 Apr 2022 08:32:36 +0200 Message-Id: <20220412063001.072879095@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Waiman Long commit a431dbbc540532b7465eae4fc8b56a85a9fc7d17 upstream. The gcc 12 compiler reports a "'mem_section' will never be NULL" warning on the following code: static inline struct mem_section *__nr_to_section(unsigned long nr) { #ifdef CONFIG_SPARSEMEM_EXTREME if (!mem_section) return NULL; #endif if (!mem_section[SECTION_NR_TO_ROOT(nr)]) return NULL; : It happens with CONFIG_SPARSEMEM_EXTREME off. The mem_section definition is #ifdef CONFIG_SPARSEMEM_EXTREME extern struct mem_section **mem_section; #else extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_RO= OT]; #endif In the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static 2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]" doesn't make sense. Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]" check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an explicit NR_SECTION_ROOTS check to make sure that there is no out-of-bound array access. Link: https://lkml.kernel.org/r/20220331180246.2746210-1-longman@redhat.com Fixes: 3e347261a80b ("sparsemem extreme implementation") Signed-off-by: Waiman Long Reported-by: Justin Forbes Cc: "Kirill A . Shutemov" Cc: Ingo Molnar Cc: Rafael Aquini Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1389,13 +1389,16 @@ static inline unsigned long *section_to_ =20 static inline struct mem_section *__nr_to_section(unsigned long nr) { + unsigned long root =3D SECTION_NR_TO_ROOT(nr); + + if (unlikely(root >=3D NR_SECTION_ROOTS)) + return NULL; + #ifdef CONFIG_SPARSEMEM_EXTREME - if (!mem_section) + if (!mem_section || !mem_section[root]) return NULL; #endif - if (!mem_section[SECTION_NR_TO_ROOT(nr)]) - return NULL; - return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; + return &mem_section[root][nr & SECTION_ROOT_MASK]; } extern size_t mem_section_usage_size(void); From nobody Thu May 14 08:08:21 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 B9400C433FE for ; Tue, 12 Apr 2022 08:57:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386301AbiDLIzC (ORCPT ); Tue, 12 Apr 2022 04:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359399AbiDLHnA (ORCPT ); Tue, 12 Apr 2022 03:43:00 -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 9530E2CE06; Tue, 12 Apr 2022 00:22: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 22F4B6171C; Tue, 12 Apr 2022 07:22:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0721DC385A5; Tue, 12 Apr 2022 07:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748152; bh=y8yjEqbAFvDl4CSGCScpRoyA+J58gkAQTk9OjEmdyqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qgpZxGDMEIZyNcjZQzFEzeeDJZXqpKevxMocz2J1IZdRO0WCFdgDxcdmkUOfoPmdA Kt9w2XNOcNBMVPdYvn2i/yh6Vz938p50j9N+OuCEFskLqM2AY5LMEXciTU+cpws/CQ XHuYNK/94JP6eOcx0k4huM8fQCdFUwQX3Wj3eZP4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , "Peter Zijlstra (Intel)" , Josh Poimboeuf Subject: [PATCH 5.17 339/343] static_call: Dont make __static_call_return0 static Date: Tue, 12 Apr 2022 08:32:37 +0200 Message-Id: <20220412063001.101274174@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Christophe Leroy commit 8fd4ddda2f49a66bf5dd3d0c01966c4b1971308b upstream. System.map shows that vmlinux contains several instances of __static_call_return0(): c0004fc0 t __static_call_return0 c0011518 t __static_call_return0 c00d8160 t __static_call_return0 arch_static_call_transform() uses the middle one to check whether we are setting a call to __static_call_return0 or not: c0011520 : c0011520: 3d 20 c0 01 lis r9,-16383 <=3D=3D r9 =3D 0xc001 <= < 16 c0011524: 39 29 15 18 addi r9,r9,5400 <=3D=3D r9 +=3D 0x1518 c0011528: 7c 05 48 00 cmpw r5,r9 <=3D=3D r9 has value 0xc001= 1518 here So if static_call_update() is called with one of the other instances of __static_call_return0(), arch_static_call_transform() won't recognise it. In order to work properly, global single instance of __static_call_return0(= ) is required. Fixes: 3f2a8fc4b15d ("static_call/x86: Add __static_call_return0()") Signed-off-by: Christophe Leroy Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/30821468a0e7d28251954b578e5051dc09300d04.16= 47258493.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- include/linux/static_call.h | 5=20 kernel/Makefile | 3=20 kernel/static_call.c | 542 ---------------------------------------= ---- kernel/static_call_inline.c | 543 +++++++++++++++++++++++++++++++++++++++= +++++ 4 files changed, 547 insertions(+), 546 deletions(-) create mode 100644 kernel/static_call_inline.c --- a/include/linux/static_call.h +++ b/include/linux/static_call.h @@ -248,10 +248,7 @@ static inline int static_call_text_reser return 0; } =20 -static inline long __static_call_return0(void) -{ - return 0; -} +extern long __static_call_return0(void); =20 #define EXPORT_STATIC_CALL(name) \ EXPORT_SYMBOL(STATIC_CALL_KEY(name)); \ --- a/kernel/Makefile +++ b/kernel/Makefile @@ -113,7 +113,8 @@ obj-$(CONFIG_CPU_PM) +=3D cpu_pm.o obj-$(CONFIG_BPF) +=3D bpf/ obj-$(CONFIG_KCSAN) +=3D kcsan/ obj-$(CONFIG_SHADOW_CALL_STACK) +=3D scs.o -obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D static_call.o +obj-$(CONFIG_HAVE_STATIC_CALL) +=3D static_call.o +obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D static_call_inline.o obj-$(CONFIG_CFI_CLANG) +=3D cfi.o =20 obj-$(CONFIG_PERF_EVENTS) +=3D events/ --- a/kernel/static_call.c +++ b/kernel/static_call.c @@ -1,548 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -#include #include -#include -#include -#include -#include -#include -#include -#include -#include - -extern struct static_call_site __start_static_call_sites[], - __stop_static_call_sites[]; -extern struct static_call_tramp_key __start_static_call_tramp_key[], - __stop_static_call_tramp_key[]; - -static bool static_call_initialized; - -/* mutex to protect key modules/sites */ -static DEFINE_MUTEX(static_call_mutex); - -static void static_call_lock(void) -{ - mutex_lock(&static_call_mutex); -} - -static void static_call_unlock(void) -{ - mutex_unlock(&static_call_mutex); -} - -static inline void *static_call_addr(struct static_call_site *site) -{ - return (void *)((long)site->addr + (long)&site->addr); -} - -static inline unsigned long __static_call_key(const struct static_call_sit= e *site) -{ - return (long)site->key + (long)&site->key; -} - -static inline struct static_call_key *static_call_key(const struct static_= call_site *site) -{ - return (void *)(__static_call_key(site) & ~STATIC_CALL_SITE_FLAGS); -} - -/* These assume the key is word-aligned. */ -static inline bool static_call_is_init(struct static_call_site *site) -{ - return __static_call_key(site) & STATIC_CALL_SITE_INIT; -} - -static inline bool static_call_is_tail(struct static_call_site *site) -{ - return __static_call_key(site) & STATIC_CALL_SITE_TAIL; -} - -static inline void static_call_set_init(struct static_call_site *site) -{ - site->key =3D (__static_call_key(site) | STATIC_CALL_SITE_INIT) - - (long)&site->key; -} - -static int static_call_site_cmp(const void *_a, const void *_b) -{ - const struct static_call_site *a =3D _a; - const struct static_call_site *b =3D _b; - const struct static_call_key *key_a =3D static_call_key(a); - const struct static_call_key *key_b =3D static_call_key(b); - - if (key_a < key_b) - return -1; - - if (key_a > key_b) - return 1; - - return 0; -} - -static void static_call_site_swap(void *_a, void *_b, int size) -{ - long delta =3D (unsigned long)_a - (unsigned long)_b; - struct static_call_site *a =3D _a; - struct static_call_site *b =3D _b; - struct static_call_site tmp =3D *a; - - a->addr =3D b->addr - delta; - a->key =3D b->key - delta; - - b->addr =3D tmp.addr + delta; - b->key =3D tmp.key + delta; -} - -static inline void static_call_sort_entries(struct static_call_site *start, - struct static_call_site *stop) -{ - sort(start, stop - start, sizeof(struct static_call_site), - static_call_site_cmp, static_call_site_swap); -} - -static inline bool static_call_key_has_mods(struct static_call_key *key) -{ - return !(key->type & 1); -} - -static inline struct static_call_mod *static_call_key_next(struct static_c= all_key *key) -{ - if (!static_call_key_has_mods(key)) - return NULL; - - return key->mods; -} - -static inline struct static_call_site *static_call_key_sites(struct static= _call_key *key) -{ - if (static_call_key_has_mods(key)) - return NULL; - - return (struct static_call_site *)(key->type & ~1); -} - -void __static_call_update(struct static_call_key *key, void *tramp, void *= func) -{ - struct static_call_site *site, *stop; - struct static_call_mod *site_mod, first; - - cpus_read_lock(); - static_call_lock(); - - if (key->func =3D=3D func) - goto done; - - key->func =3D func; - - arch_static_call_transform(NULL, tramp, func, false); - - /* - * If uninitialized, we'll not update the callsites, but they still - * point to the trampoline and we just patched that. - */ - if (WARN_ON_ONCE(!static_call_initialized)) - goto done; - - first =3D (struct static_call_mod){ - .next =3D static_call_key_next(key), - .mod =3D NULL, - .sites =3D static_call_key_sites(key), - }; - - for (site_mod =3D &first; site_mod; site_mod =3D site_mod->next) { - bool init =3D system_state < SYSTEM_RUNNING; - struct module *mod =3D site_mod->mod; - - if (!site_mod->sites) { - /* - * This can happen if the static call key is defined in - * a module which doesn't use it. - * - * It also happens in the has_mods case, where the - * 'first' entry has no sites associated with it. - */ - continue; - } - - stop =3D __stop_static_call_sites; - - if (mod) { -#ifdef CONFIG_MODULES - stop =3D mod->static_call_sites + - mod->num_static_call_sites; - init =3D mod->state =3D=3D MODULE_STATE_COMING; -#endif - } - - for (site =3D site_mod->sites; - site < stop && static_call_key(site) =3D=3D key; site++) { - void *site_addr =3D static_call_addr(site); - - if (!init && static_call_is_init(site)) - continue; - - if (!kernel_text_address((unsigned long)site_addr)) { - /* - * This skips patching built-in __exit, which - * is part of init_section_contains() but is - * not part of kernel_text_address(). - * - * Skipping built-in __exit is fine since it - * will never be executed. - */ - WARN_ONCE(!static_call_is_init(site), - "can't patch static call site at %pS", - site_addr); - continue; - } - - arch_static_call_transform(site_addr, NULL, func, - static_call_is_tail(site)); - } - } - -done: - static_call_unlock(); - cpus_read_unlock(); -} -EXPORT_SYMBOL_GPL(__static_call_update); - -static int __static_call_init(struct module *mod, - struct static_call_site *start, - struct static_call_site *stop) -{ - struct static_call_site *site; - struct static_call_key *key, *prev_key =3D NULL; - struct static_call_mod *site_mod; - - if (start =3D=3D stop) - return 0; - - static_call_sort_entries(start, stop); - - for (site =3D start; site < stop; site++) { - void *site_addr =3D static_call_addr(site); - - if ((mod && within_module_init((unsigned long)site_addr, mod)) || - (!mod && init_section_contains(site_addr, 1))) - static_call_set_init(site); - - key =3D static_call_key(site); - if (key !=3D prev_key) { - prev_key =3D key; - - /* - * For vmlinux (!mod) avoid the allocation by storing - * the sites pointer in the key itself. Also see - * __static_call_update()'s @first. - * - * This allows architectures (eg. x86) to call - * static_call_init() before memory allocation works. - */ - if (!mod) { - key->sites =3D site; - key->type |=3D 1; - goto do_transform; - } - - site_mod =3D kzalloc(sizeof(*site_mod), GFP_KERNEL); - if (!site_mod) - return -ENOMEM; - - /* - * When the key has a direct sites pointer, extract - * that into an explicit struct static_call_mod, so we - * can have a list of modules. - */ - if (static_call_key_sites(key)) { - site_mod->mod =3D NULL; - site_mod->next =3D NULL; - site_mod->sites =3D static_call_key_sites(key); - - key->mods =3D site_mod; - - site_mod =3D kzalloc(sizeof(*site_mod), GFP_KERNEL); - if (!site_mod) - return -ENOMEM; - } - - site_mod->mod =3D mod; - site_mod->sites =3D site; - site_mod->next =3D static_call_key_next(key); - key->mods =3D site_mod; - } - -do_transform: - arch_static_call_transform(site_addr, NULL, key->func, - static_call_is_tail(site)); - } - - return 0; -} - -static int addr_conflict(struct static_call_site *site, void *start, void = *end) -{ - unsigned long addr =3D (unsigned long)static_call_addr(site); - - if (addr <=3D (unsigned long)end && - addr + CALL_INSN_SIZE > (unsigned long)start) - return 1; - - return 0; -} - -static int __static_call_text_reserved(struct static_call_site *iter_start, - struct static_call_site *iter_stop, - void *start, void *end, bool init) -{ - struct static_call_site *iter =3D iter_start; - - while (iter < iter_stop) { - if (init || !static_call_is_init(iter)) { - if (addr_conflict(iter, start, end)) - return 1; - } - iter++; - } - - return 0; -} - -#ifdef CONFIG_MODULES - -static int __static_call_mod_text_reserved(void *start, void *end) -{ - struct module *mod; - int ret; - - preempt_disable(); - mod =3D __module_text_address((unsigned long)start); - WARN_ON_ONCE(__module_text_address((unsigned long)end) !=3D mod); - if (!try_module_get(mod)) - mod =3D NULL; - preempt_enable(); - - if (!mod) - return 0; - - ret =3D __static_call_text_reserved(mod->static_call_sites, - mod->static_call_sites + mod->num_static_call_sites, - start, end, mod->state =3D=3D MODULE_STATE_COMING); - - module_put(mod); - - return ret; -} - -static unsigned long tramp_key_lookup(unsigned long addr) -{ - struct static_call_tramp_key *start =3D __start_static_call_tramp_key; - struct static_call_tramp_key *stop =3D __stop_static_call_tramp_key; - struct static_call_tramp_key *tramp_key; - - for (tramp_key =3D start; tramp_key !=3D stop; tramp_key++) { - unsigned long tramp; - - tramp =3D (long)tramp_key->tramp + (long)&tramp_key->tramp; - if (tramp =3D=3D addr) - return (long)tramp_key->key + (long)&tramp_key->key; - } - - return 0; -} - -static int static_call_add_module(struct module *mod) -{ - struct static_call_site *start =3D mod->static_call_sites; - struct static_call_site *stop =3D start + mod->num_static_call_sites; - struct static_call_site *site; - - for (site =3D start; site !=3D stop; site++) { - unsigned long s_key =3D __static_call_key(site); - unsigned long addr =3D s_key & ~STATIC_CALL_SITE_FLAGS; - unsigned long key; - - /* - * Is the key is exported, 'addr' points to the key, which - * means modules are allowed to call static_call_update() on - * it. - * - * Otherwise, the key isn't exported, and 'addr' points to the - * trampoline so we need to lookup the key. - * - * We go through this dance to prevent crazy modules from - * abusing sensitive static calls. - */ - if (!kernel_text_address(addr)) - continue; - - key =3D tramp_key_lookup(addr); - if (!key) { - pr_warn("Failed to fixup __raw_static_call() usage at: %ps\n", - static_call_addr(site)); - return -EINVAL; - } - - key |=3D s_key & STATIC_CALL_SITE_FLAGS; - site->key =3D key - (long)&site->key; - } - - return __static_call_init(mod, start, stop); -} - -static void static_call_del_module(struct module *mod) -{ - struct static_call_site *start =3D mod->static_call_sites; - struct static_call_site *stop =3D mod->static_call_sites + - mod->num_static_call_sites; - struct static_call_key *key, *prev_key =3D NULL; - struct static_call_mod *site_mod, **prev; - struct static_call_site *site; - - for (site =3D start; site < stop; site++) { - key =3D static_call_key(site); - if (key =3D=3D prev_key) - continue; - - prev_key =3D key; - - for (prev =3D &key->mods, site_mod =3D key->mods; - site_mod && site_mod->mod !=3D mod; - prev =3D &site_mod->next, site_mod =3D site_mod->next) - ; - - if (!site_mod) - continue; - - *prev =3D site_mod->next; - kfree(site_mod); - } -} - -static int static_call_module_notify(struct notifier_block *nb, - unsigned long val, void *data) -{ - struct module *mod =3D data; - int ret =3D 0; - - cpus_read_lock(); - static_call_lock(); - - switch (val) { - case MODULE_STATE_COMING: - ret =3D static_call_add_module(mod); - if (ret) { - WARN(1, "Failed to allocate memory for static calls"); - static_call_del_module(mod); - } - break; - case MODULE_STATE_GOING: - static_call_del_module(mod); - break; - } - - static_call_unlock(); - cpus_read_unlock(); - - return notifier_from_errno(ret); -} - -static struct notifier_block static_call_module_nb =3D { - .notifier_call =3D static_call_module_notify, -}; - -#else - -static inline int __static_call_mod_text_reserved(void *start, void *end) -{ - return 0; -} - -#endif /* CONFIG_MODULES */ - -int static_call_text_reserved(void *start, void *end) -{ - bool init =3D system_state < SYSTEM_RUNNING; - int ret =3D __static_call_text_reserved(__start_static_call_sites, - __stop_static_call_sites, start, end, init); - - if (ret) - return ret; - - return __static_call_mod_text_reserved(start, end); -} - -int __init static_call_init(void) -{ - int ret; - - if (static_call_initialized) - return 0; - - cpus_read_lock(); - static_call_lock(); - ret =3D __static_call_init(NULL, __start_static_call_sites, - __stop_static_call_sites); - static_call_unlock(); - cpus_read_unlock(); - - if (ret) { - pr_err("Failed to allocate memory for static_call!\n"); - BUG(); - } - - static_call_initialized =3D true; - -#ifdef CONFIG_MODULES - register_module_notifier(&static_call_module_nb); -#endif - return 0; -} -early_initcall(static_call_init); =20 long __static_call_return0(void) { return 0; } - -#ifdef CONFIG_STATIC_CALL_SELFTEST - -static int func_a(int x) -{ - return x+1; -} - -static int func_b(int x) -{ - return x+2; -} - -DEFINE_STATIC_CALL(sc_selftest, func_a); - -static struct static_call_data { - int (*func)(int); - int val; - int expect; -} static_call_data [] __initdata =3D { - { NULL, 2, 3 }, - { func_b, 2, 4 }, - { func_a, 2, 3 } -}; - -static int __init test_static_call_init(void) -{ - int i; - - for (i =3D 0; i < ARRAY_SIZE(static_call_data); i++ ) { - struct static_call_data *scd =3D &static_call_data[i]; - - if (scd->func) - static_call_update(sc_selftest, scd->func); - - WARN_ON(static_call(sc_selftest)(scd->val) !=3D scd->expect); - } - - return 0; -} -early_initcall(test_static_call_init); - -#endif /* CONFIG_STATIC_CALL_SELFTEST */ +EXPORT_SYMBOL_GPL(__static_call_return0); --- /dev/null +++ b/kernel/static_call_inline.c @@ -0,0 +1,543 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern struct static_call_site __start_static_call_sites[], + __stop_static_call_sites[]; +extern struct static_call_tramp_key __start_static_call_tramp_key[], + __stop_static_call_tramp_key[]; + +static bool static_call_initialized; + +/* mutex to protect key modules/sites */ +static DEFINE_MUTEX(static_call_mutex); + +static void static_call_lock(void) +{ + mutex_lock(&static_call_mutex); +} + +static void static_call_unlock(void) +{ + mutex_unlock(&static_call_mutex); +} + +static inline void *static_call_addr(struct static_call_site *site) +{ + return (void *)((long)site->addr + (long)&site->addr); +} + +static inline unsigned long __static_call_key(const struct static_call_sit= e *site) +{ + return (long)site->key + (long)&site->key; +} + +static inline struct static_call_key *static_call_key(const struct static_= call_site *site) +{ + return (void *)(__static_call_key(site) & ~STATIC_CALL_SITE_FLAGS); +} + +/* These assume the key is word-aligned. */ +static inline bool static_call_is_init(struct static_call_site *site) +{ + return __static_call_key(site) & STATIC_CALL_SITE_INIT; +} + +static inline bool static_call_is_tail(struct static_call_site *site) +{ + return __static_call_key(site) & STATIC_CALL_SITE_TAIL; +} + +static inline void static_call_set_init(struct static_call_site *site) +{ + site->key =3D (__static_call_key(site) | STATIC_CALL_SITE_INIT) - + (long)&site->key; +} + +static int static_call_site_cmp(const void *_a, const void *_b) +{ + const struct static_call_site *a =3D _a; + const struct static_call_site *b =3D _b; + const struct static_call_key *key_a =3D static_call_key(a); + const struct static_call_key *key_b =3D static_call_key(b); + + if (key_a < key_b) + return -1; + + if (key_a > key_b) + return 1; + + return 0; +} + +static void static_call_site_swap(void *_a, void *_b, int size) +{ + long delta =3D (unsigned long)_a - (unsigned long)_b; + struct static_call_site *a =3D _a; + struct static_call_site *b =3D _b; + struct static_call_site tmp =3D *a; + + a->addr =3D b->addr - delta; + a->key =3D b->key - delta; + + b->addr =3D tmp.addr + delta; + b->key =3D tmp.key + delta; +} + +static inline void static_call_sort_entries(struct static_call_site *start, + struct static_call_site *stop) +{ + sort(start, stop - start, sizeof(struct static_call_site), + static_call_site_cmp, static_call_site_swap); +} + +static inline bool static_call_key_has_mods(struct static_call_key *key) +{ + return !(key->type & 1); +} + +static inline struct static_call_mod *static_call_key_next(struct static_c= all_key *key) +{ + if (!static_call_key_has_mods(key)) + return NULL; + + return key->mods; +} + +static inline struct static_call_site *static_call_key_sites(struct static= _call_key *key) +{ + if (static_call_key_has_mods(key)) + return NULL; + + return (struct static_call_site *)(key->type & ~1); +} + +void __static_call_update(struct static_call_key *key, void *tramp, void *= func) +{ + struct static_call_site *site, *stop; + struct static_call_mod *site_mod, first; + + cpus_read_lock(); + static_call_lock(); + + if (key->func =3D=3D func) + goto done; + + key->func =3D func; + + arch_static_call_transform(NULL, tramp, func, false); + + /* + * If uninitialized, we'll not update the callsites, but they still + * point to the trampoline and we just patched that. + */ + if (WARN_ON_ONCE(!static_call_initialized)) + goto done; + + first =3D (struct static_call_mod){ + .next =3D static_call_key_next(key), + .mod =3D NULL, + .sites =3D static_call_key_sites(key), + }; + + for (site_mod =3D &first; site_mod; site_mod =3D site_mod->next) { + bool init =3D system_state < SYSTEM_RUNNING; + struct module *mod =3D site_mod->mod; + + if (!site_mod->sites) { + /* + * This can happen if the static call key is defined in + * a module which doesn't use it. + * + * It also happens in the has_mods case, where the + * 'first' entry has no sites associated with it. + */ + continue; + } + + stop =3D __stop_static_call_sites; + + if (mod) { +#ifdef CONFIG_MODULES + stop =3D mod->static_call_sites + + mod->num_static_call_sites; + init =3D mod->state =3D=3D MODULE_STATE_COMING; +#endif + } + + for (site =3D site_mod->sites; + site < stop && static_call_key(site) =3D=3D key; site++) { + void *site_addr =3D static_call_addr(site); + + if (!init && static_call_is_init(site)) + continue; + + if (!kernel_text_address((unsigned long)site_addr)) { + /* + * This skips patching built-in __exit, which + * is part of init_section_contains() but is + * not part of kernel_text_address(). + * + * Skipping built-in __exit is fine since it + * will never be executed. + */ + WARN_ONCE(!static_call_is_init(site), + "can't patch static call site at %pS", + site_addr); + continue; + } + + arch_static_call_transform(site_addr, NULL, func, + static_call_is_tail(site)); + } + } + +done: + static_call_unlock(); + cpus_read_unlock(); +} +EXPORT_SYMBOL_GPL(__static_call_update); + +static int __static_call_init(struct module *mod, + struct static_call_site *start, + struct static_call_site *stop) +{ + struct static_call_site *site; + struct static_call_key *key, *prev_key =3D NULL; + struct static_call_mod *site_mod; + + if (start =3D=3D stop) + return 0; + + static_call_sort_entries(start, stop); + + for (site =3D start; site < stop; site++) { + void *site_addr =3D static_call_addr(site); + + if ((mod && within_module_init((unsigned long)site_addr, mod)) || + (!mod && init_section_contains(site_addr, 1))) + static_call_set_init(site); + + key =3D static_call_key(site); + if (key !=3D prev_key) { + prev_key =3D key; + + /* + * For vmlinux (!mod) avoid the allocation by storing + * the sites pointer in the key itself. Also see + * __static_call_update()'s @first. + * + * This allows architectures (eg. x86) to call + * static_call_init() before memory allocation works. + */ + if (!mod) { + key->sites =3D site; + key->type |=3D 1; + goto do_transform; + } + + site_mod =3D kzalloc(sizeof(*site_mod), GFP_KERNEL); + if (!site_mod) + return -ENOMEM; + + /* + * When the key has a direct sites pointer, extract + * that into an explicit struct static_call_mod, so we + * can have a list of modules. + */ + if (static_call_key_sites(key)) { + site_mod->mod =3D NULL; + site_mod->next =3D NULL; + site_mod->sites =3D static_call_key_sites(key); + + key->mods =3D site_mod; + + site_mod =3D kzalloc(sizeof(*site_mod), GFP_KERNEL); + if (!site_mod) + return -ENOMEM; + } + + site_mod->mod =3D mod; + site_mod->sites =3D site; + site_mod->next =3D static_call_key_next(key); + key->mods =3D site_mod; + } + +do_transform: + arch_static_call_transform(site_addr, NULL, key->func, + static_call_is_tail(site)); + } + + return 0; +} + +static int addr_conflict(struct static_call_site *site, void *start, void = *end) +{ + unsigned long addr =3D (unsigned long)static_call_addr(site); + + if (addr <=3D (unsigned long)end && + addr + CALL_INSN_SIZE > (unsigned long)start) + return 1; + + return 0; +} + +static int __static_call_text_reserved(struct static_call_site *iter_start, + struct static_call_site *iter_stop, + void *start, void *end, bool init) +{ + struct static_call_site *iter =3D iter_start; + + while (iter < iter_stop) { + if (init || !static_call_is_init(iter)) { + if (addr_conflict(iter, start, end)) + return 1; + } + iter++; + } + + return 0; +} + +#ifdef CONFIG_MODULES + +static int __static_call_mod_text_reserved(void *start, void *end) +{ + struct module *mod; + int ret; + + preempt_disable(); + mod =3D __module_text_address((unsigned long)start); + WARN_ON_ONCE(__module_text_address((unsigned long)end) !=3D mod); + if (!try_module_get(mod)) + mod =3D NULL; + preempt_enable(); + + if (!mod) + return 0; + + ret =3D __static_call_text_reserved(mod->static_call_sites, + mod->static_call_sites + mod->num_static_call_sites, + start, end, mod->state =3D=3D MODULE_STATE_COMING); + + module_put(mod); + + return ret; +} + +static unsigned long tramp_key_lookup(unsigned long addr) +{ + struct static_call_tramp_key *start =3D __start_static_call_tramp_key; + struct static_call_tramp_key *stop =3D __stop_static_call_tramp_key; + struct static_call_tramp_key *tramp_key; + + for (tramp_key =3D start; tramp_key !=3D stop; tramp_key++) { + unsigned long tramp; + + tramp =3D (long)tramp_key->tramp + (long)&tramp_key->tramp; + if (tramp =3D=3D addr) + return (long)tramp_key->key + (long)&tramp_key->key; + } + + return 0; +} + +static int static_call_add_module(struct module *mod) +{ + struct static_call_site *start =3D mod->static_call_sites; + struct static_call_site *stop =3D start + mod->num_static_call_sites; + struct static_call_site *site; + + for (site =3D start; site !=3D stop; site++) { + unsigned long s_key =3D __static_call_key(site); + unsigned long addr =3D s_key & ~STATIC_CALL_SITE_FLAGS; + unsigned long key; + + /* + * Is the key is exported, 'addr' points to the key, which + * means modules are allowed to call static_call_update() on + * it. + * + * Otherwise, the key isn't exported, and 'addr' points to the + * trampoline so we need to lookup the key. + * + * We go through this dance to prevent crazy modules from + * abusing sensitive static calls. + */ + if (!kernel_text_address(addr)) + continue; + + key =3D tramp_key_lookup(addr); + if (!key) { + pr_warn("Failed to fixup __raw_static_call() usage at: %ps\n", + static_call_addr(site)); + return -EINVAL; + } + + key |=3D s_key & STATIC_CALL_SITE_FLAGS; + site->key =3D key - (long)&site->key; + } + + return __static_call_init(mod, start, stop); +} + +static void static_call_del_module(struct module *mod) +{ + struct static_call_site *start =3D mod->static_call_sites; + struct static_call_site *stop =3D mod->static_call_sites + + mod->num_static_call_sites; + struct static_call_key *key, *prev_key =3D NULL; + struct static_call_mod *site_mod, **prev; + struct static_call_site *site; + + for (site =3D start; site < stop; site++) { + key =3D static_call_key(site); + if (key =3D=3D prev_key) + continue; + + prev_key =3D key; + + for (prev =3D &key->mods, site_mod =3D key->mods; + site_mod && site_mod->mod !=3D mod; + prev =3D &site_mod->next, site_mod =3D site_mod->next) + ; + + if (!site_mod) + continue; + + *prev =3D site_mod->next; + kfree(site_mod); + } +} + +static int static_call_module_notify(struct notifier_block *nb, + unsigned long val, void *data) +{ + struct module *mod =3D data; + int ret =3D 0; + + cpus_read_lock(); + static_call_lock(); + + switch (val) { + case MODULE_STATE_COMING: + ret =3D static_call_add_module(mod); + if (ret) { + WARN(1, "Failed to allocate memory for static calls"); + static_call_del_module(mod); + } + break; + case MODULE_STATE_GOING: + static_call_del_module(mod); + break; + } + + static_call_unlock(); + cpus_read_unlock(); + + return notifier_from_errno(ret); +} + +static struct notifier_block static_call_module_nb =3D { + .notifier_call =3D static_call_module_notify, +}; + +#else + +static inline int __static_call_mod_text_reserved(void *start, void *end) +{ + return 0; +} + +#endif /* CONFIG_MODULES */ + +int static_call_text_reserved(void *start, void *end) +{ + bool init =3D system_state < SYSTEM_RUNNING; + int ret =3D __static_call_text_reserved(__start_static_call_sites, + __stop_static_call_sites, start, end, init); + + if (ret) + return ret; + + return __static_call_mod_text_reserved(start, end); +} + +int __init static_call_init(void) +{ + int ret; + + if (static_call_initialized) + return 0; + + cpus_read_lock(); + static_call_lock(); + ret =3D __static_call_init(NULL, __start_static_call_sites, + __stop_static_call_sites); + static_call_unlock(); + cpus_read_unlock(); + + if (ret) { + pr_err("Failed to allocate memory for static_call!\n"); + BUG(); + } + + static_call_initialized =3D true; + +#ifdef CONFIG_MODULES + register_module_notifier(&static_call_module_nb); +#endif + return 0; +} +early_initcall(static_call_init); + +#ifdef CONFIG_STATIC_CALL_SELFTEST + +static int func_a(int x) +{ + return x+1; +} + +static int func_b(int x) +{ + return x+2; +} + +DEFINE_STATIC_CALL(sc_selftest, func_a); + +static struct static_call_data { + int (*func)(int); + int val; + int expect; +} static_call_data [] __initdata =3D { + { NULL, 2, 3 }, + { func_b, 2, 4 }, + { func_a, 2, 3 } +}; + +static int __init test_static_call_init(void) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(static_call_data); i++ ) { + struct static_call_data *scd =3D &static_call_data[i]; + + if (scd->func) + static_call_update(sc_selftest, scd->func); + + WARN_ON(static_call(sc_selftest)(scd->val) !=3D scd->expect); + } + + return 0; +} +early_initcall(test_static_call_init); + +#endif /* CONFIG_STATIC_CALL_SELFTEST */ From nobody Thu May 14 08:08:21 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 22837C47081 for ; Tue, 12 Apr 2022 08:57:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386258AbiDLIyv (ORCPT ); Tue, 12 Apr 2022 04:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359403AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43: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 D61F32CE07; Tue, 12 Apr 2022 00:22: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 921BFB81B60; Tue, 12 Apr 2022 07:22:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFD16C385A1; Tue, 12 Apr 2022 07:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748155; bh=WEz9tVLQClCMzp5STv/SjoKUKS0mGeZVPlc6NoCTe5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qj4MeQVnXL4nw4ruwm96aWe0+NrsuNCcc/U6xfTbkr7Gr31DZgiQaMQH+MoT7d0r8 eIyk3S0X8jFDjBgsaPzc1BVczM5zOJexPZLBRhzEKdHXa2IE5pAzJqHZPkS/+7z0Te +BgVK/UbBkwerppV/0tJzzVeUaHBoC4eoiFmcPZw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.17 340/343] io_uring: move read/write file prep state into actual opcode handler Date: Tue, 12 Apr 2022 08:32:38 +0200 Message-Id: <20220412063001.129759703@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit 584b0180f0f4d67d7145950fe68c625f06c88b10 upstream. In preparation for not necessarily having a file assigned at prep time, defer any initialization associated with the file to when the opcode handler is run. Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 119 ++++++++++++++++++++++++++++++-----------------------= ----- 1 file changed, 62 insertions(+), 57 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -560,7 +560,8 @@ struct io_rw { /* NOTE: kiocb has the file as the first member, so don't do it here */ struct kiocb kiocb; u64 addr; - u64 len; + u32 len; + u32 flags; }; =20 struct io_connect { @@ -2984,50 +2985,11 @@ static inline bool io_file_supports_nowa =20 static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe) { - struct io_ring_ctx *ctx =3D req->ctx; struct kiocb *kiocb =3D &req->rw.kiocb; - struct file *file =3D req->file; unsigned ioprio; int ret; =20 - if (!io_req_ffs_set(req)) - req->flags |=3D io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT; - kiocb->ki_pos =3D READ_ONCE(sqe->off); - if (kiocb->ki_pos =3D=3D -1) { - if (!(file->f_mode & FMODE_STREAM)) { - req->flags |=3D REQ_F_CUR_POS; - kiocb->ki_pos =3D file->f_pos; - } else { - kiocb->ki_pos =3D 0; - } - } - kiocb->ki_flags =3D iocb_flags(file); - ret =3D kiocb_set_rw_flags(kiocb, READ_ONCE(sqe->rw_flags)); - if (unlikely(ret)) - return ret; - - /* - * If the file is marked O_NONBLOCK, still allow retry for it if it - * supports async. Otherwise it's impossible to use O_NONBLOCK files - * reliably. If not, or it IOCB_NOWAIT is set, don't retry. - */ - if ((kiocb->ki_flags & IOCB_NOWAIT) || - ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req))) - req->flags |=3D REQ_F_NOWAIT; - - if (ctx->flags & IORING_SETUP_IOPOLL) { - if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll) - return -EOPNOTSUPP; - - kiocb->ki_flags |=3D IOCB_HIPRI | IOCB_ALLOC_CACHE; - kiocb->ki_complete =3D io_complete_rw_iopoll; - req->iopoll_completed =3D 0; - } else { - if (kiocb->ki_flags & IOCB_HIPRI) - return -EINVAL; - kiocb->ki_complete =3D io_complete_rw; - } =20 ioprio =3D READ_ONCE(sqe->ioprio); if (ioprio) { @@ -3043,6 +3005,7 @@ static int io_prep_rw(struct io_kiocb *r req->imu =3D NULL; req->rw.addr =3D READ_ONCE(sqe->addr); req->rw.len =3D READ_ONCE(sqe->len); + req->rw.flags =3D READ_ONCE(sqe->rw_flags); req->buf_index =3D READ_ONCE(sqe->buf_index); return 0; } @@ -3523,13 +3486,6 @@ static inline int io_rw_prep_async(struc return 0; } =20 -static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *s= qe) -{ - if (unlikely(!(req->file->f_mode & FMODE_READ))) - return -EBADF; - return io_prep_rw(req, sqe); -} - /* * This is our waitqueue callback handler, registered through __folio_lock= _async() * when we initially tried to do the IO with the iocb armed our waitqueue. @@ -3617,6 +3573,58 @@ static bool need_read_all(struct io_kioc S_ISBLK(file_inode(req->file)->i_mode); } =20 +static int io_rw_init_file(struct io_kiocb *req, fmode_t mode) +{ + struct kiocb *kiocb =3D &req->rw.kiocb; + struct io_ring_ctx *ctx =3D req->ctx; + struct file *file =3D req->file; + int ret; + + if (unlikely(!file || !(file->f_mode & mode))) + return -EBADF; + + if (!io_req_ffs_set(req)) + req->flags |=3D io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT; + + if (kiocb->ki_pos =3D=3D -1) { + if (!(file->f_mode & FMODE_STREAM)) { + req->flags |=3D REQ_F_CUR_POS; + kiocb->ki_pos =3D file->f_pos; + } else { + kiocb->ki_pos =3D 0; + } + } + + kiocb->ki_flags =3D iocb_flags(file); + ret =3D kiocb_set_rw_flags(kiocb, req->rw.flags); + if (unlikely(ret)) + return ret; + + /* + * If the file is marked O_NONBLOCK, still allow retry for it if it + * supports async. Otherwise it's impossible to use O_NONBLOCK files + * reliably. If not, or it IOCB_NOWAIT is set, don't retry. + */ + if ((kiocb->ki_flags & IOCB_NOWAIT) || + ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req))) + req->flags |=3D REQ_F_NOWAIT; + + if (ctx->flags & IORING_SETUP_IOPOLL) { + if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll) + return -EOPNOTSUPP; + + kiocb->ki_flags |=3D IOCB_HIPRI | IOCB_ALLOC_CACHE; + kiocb->ki_complete =3D io_complete_rw_iopoll; + req->iopoll_completed =3D 0; + } else { + if (kiocb->ki_flags & IOCB_HIPRI) + return -EINVAL; + kiocb->ki_complete =3D io_complete_rw; + } + + return 0; +} + static int io_read(struct io_kiocb *req, unsigned int issue_flags) { struct io_rw_state __s, *s =3D &__s; @@ -3641,6 +3649,9 @@ static int io_read(struct io_kiocb *req, iov_iter_restore(&s->iter, &s->iter_state); iovec =3D NULL; } + ret =3D io_rw_init_file(req, FMODE_READ); + if (unlikely(ret)) + return ret; req->result =3D iov_iter_count(&s->iter); =20 if (force_nonblock) { @@ -3739,14 +3750,6 @@ out_free: return 0; } =20 -static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *= sqe) -{ - if (unlikely(!(req->file->f_mode & FMODE_WRITE))) - return -EBADF; - req->rw.kiocb.ki_hint =3D ki_hint_validate(file_write_hint(req->file)); - return io_prep_rw(req, sqe); -} - static int io_write(struct io_kiocb *req, unsigned int issue_flags) { struct io_rw_state __s, *s =3D &__s; @@ -3766,6 +3769,9 @@ static int io_write(struct io_kiocb *req iov_iter_restore(&s->iter, &s->iter_state); iovec =3D NULL; } + ret =3D io_rw_init_file(req, FMODE_WRITE); + if (unlikely(ret)) + return ret; req->result =3D iov_iter_count(&s->iter); =20 if (force_nonblock) { @@ -6501,11 +6507,10 @@ static int io_req_prep(struct io_kiocb * case IORING_OP_READV: case IORING_OP_READ_FIXED: case IORING_OP_READ: - return io_read_prep(req, sqe); case IORING_OP_WRITEV: case IORING_OP_WRITE_FIXED: case IORING_OP_WRITE: - return io_write_prep(req, sqe); + return io_prep_rw(req, sqe); case IORING_OP_POLL_ADD: return io_poll_add_prep(req, sqe); case IORING_OP_POLL_REMOVE: From nobody Thu May 14 08:08:21 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 CB566C47080 for ; Tue, 12 Apr 2022 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386207AbiDLIym (ORCPT ); Tue, 12 Apr 2022 04:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359404AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -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 E8AA42CE0C; Tue, 12 Apr 2022 00:22: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 812FA6153F; Tue, 12 Apr 2022 07:22:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88393C385A1; Tue, 12 Apr 2022 07:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748160; bh=kdGn1ftJHGVxeTLH7mFW4Oz3PjRaZe085GNp5mTVpXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1pNPmALh01m8N7B/hfXWhYmxGCxDfadT8XhwNa+8DkiAEw7DkUocFumAgrl8C5fSJ 0c3SNfd2o5X36nmo+vtDa+OAHtH/eZvBZO/SBpg9q0z0+IpVHM3lJao2tuaQePXX97 GRQPCtT1Yw5+9V8b1AZJCgwCmXVM6hBu4AQmGpyA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.17 341/343] io_uring: propagate issue_flags state down to file assignment Date: Tue, 12 Apr 2022 08:32:39 +0200 Message-Id: <20220412063001.158157154@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit 5106dd6e74ab6c94daac1c357094f11e6934b36f upstream. We'll need this in a future patch, when we could be assigning the file after the prep stage. While at it, get rid of the io_file_get() helper, it just makes the code harder to read. Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 82 +++++++++++++++++++++++++++++++++--------------------= ----- 1 file changed, 47 insertions(+), 35 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1128,8 +1128,9 @@ static int __io_register_rsrc_update(str struct io_uring_rsrc_update2 *up, unsigned nr_args); static void io_clean_op(struct io_kiocb *req); -static struct file *io_file_get(struct io_ring_ctx *ctx, - struct io_kiocb *req, int fd, bool fixed); +static inline struct file *io_file_get_fixed(struct io_kiocb *req, int fd, + unsigned issue_flags); +static inline struct file *io_file_get_normal(struct io_kiocb *req, int fd= ); static void __io_queue_sqe(struct io_kiocb *req); static void io_rsrc_put_work(struct work_struct *work); =20 @@ -1258,13 +1259,20 @@ static void io_rsrc_refs_refill(struct i } =20 static inline void io_req_set_rsrc_node(struct io_kiocb *req, - struct io_ring_ctx *ctx) + struct io_ring_ctx *ctx, + unsigned int issue_flags) { if (!req->fixed_rsrc_refs) { req->fixed_rsrc_refs =3D &ctx->rsrc_node->refs; - ctx->rsrc_cached_refs--; - if (unlikely(ctx->rsrc_cached_refs < 0)) - io_rsrc_refs_refill(ctx); + + if (!(issue_flags & IO_URING_F_UNLOCKED)) { + lockdep_assert_held(&ctx->uring_lock); + ctx->rsrc_cached_refs--; + if (unlikely(ctx->rsrc_cached_refs < 0)) + io_rsrc_refs_refill(ctx); + } else { + percpu_ref_get(req->fixed_rsrc_refs); + } } } =20 @@ -3122,7 +3130,8 @@ static int __io_import_fixed(struct io_k return 0; } =20 -static int io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *= iter) +static int io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *= iter, + unsigned int issue_flags) { struct io_mapped_ubuf *imu =3D req->imu; u16 index, buf_index =3D req->buf_index; @@ -3132,7 +3141,7 @@ static int io_import_fixed(struct io_kio =20 if (unlikely(buf_index >=3D ctx->nr_user_bufs)) return -EFAULT; - io_req_set_rsrc_node(req, ctx); + io_req_set_rsrc_node(req, ctx, issue_flags); index =3D array_index_nospec(buf_index, ctx->nr_user_bufs); imu =3D READ_ONCE(ctx->user_bufs[index]); req->imu =3D imu; @@ -3288,7 +3297,7 @@ static struct iovec *__io_import_iovec(i ssize_t ret; =20 if (opcode =3D=3D IORING_OP_READ_FIXED || opcode =3D=3D IORING_OP_WRITE_F= IXED) { - ret =3D io_import_fixed(req, rw, iter); + ret =3D io_import_fixed(req, rw, iter, issue_flags); if (ret) return ERR_PTR(ret); return NULL; @@ -4167,8 +4176,10 @@ static int io_tee(struct io_kiocb *req, if (issue_flags & IO_URING_F_NONBLOCK) return -EAGAIN; =20 - in =3D io_file_get(req->ctx, req, sp->splice_fd_in, - (sp->flags & SPLICE_F_FD_IN_FIXED)); + if (sp->flags & SPLICE_F_FD_IN_FIXED) + in =3D io_file_get_fixed(req, sp->splice_fd_in, IO_URING_F_UNLOCKED); + else + in =3D io_file_get_normal(req, sp->splice_fd_in); if (!in) { ret =3D -EBADF; goto done; @@ -4207,8 +4218,10 @@ static int io_splice(struct io_kiocb *re if (issue_flags & IO_URING_F_NONBLOCK) return -EAGAIN; =20 - in =3D io_file_get(req->ctx, req, sp->splice_fd_in, - (sp->flags & SPLICE_F_FD_IN_FIXED)); + if (sp->flags & SPLICE_F_FD_IN_FIXED) + in =3D io_file_get_fixed(req, sp->splice_fd_in, IO_URING_F_UNLOCKED); + else + in =3D io_file_get_normal(req, sp->splice_fd_in); if (!in) { ret =3D -EBADF; goto done; @@ -5513,7 +5526,7 @@ static void io_poll_remove_entries(struc * either spurious wakeup or multishot CQE is served. 0 when it's done with * the request, then the mask is stored in req->result. */ -static int io_poll_check_events(struct io_kiocb *req) +static int io_poll_check_events(struct io_kiocb *req, bool locked) { struct io_ring_ctx *ctx =3D req->ctx; struct io_poll_iocb *poll =3D io_poll_get_single(req); @@ -5569,7 +5582,7 @@ static void io_poll_task_func(struct io_ struct io_ring_ctx *ctx =3D req->ctx; int ret; =20 - ret =3D io_poll_check_events(req); + ret =3D io_poll_check_events(req, *locked); if (ret > 0) return; =20 @@ -5594,7 +5607,7 @@ static void io_apoll_task_func(struct io struct io_ring_ctx *ctx =3D req->ctx; int ret; =20 - ret =3D io_poll_check_events(req); + ret =3D io_poll_check_events(req, *locked); if (ret > 0) return; =20 @@ -6962,30 +6975,36 @@ static void io_fixed_file_set(struct io_ file_slot->file_ptr =3D file_ptr; } =20 -static inline struct file *io_file_get_fixed(struct io_ring_ctx *ctx, - struct io_kiocb *req, int fd) +static inline struct file *io_file_get_fixed(struct io_kiocb *req, int fd, + unsigned int issue_flags) { - struct file *file; + struct io_ring_ctx *ctx =3D req->ctx; + struct file *file =3D NULL; unsigned long file_ptr; =20 + if (issue_flags & IO_URING_F_UNLOCKED) + mutex_lock(&ctx->uring_lock); + if (unlikely((unsigned int)fd >=3D ctx->nr_user_files)) - return NULL; + goto out; fd =3D array_index_nospec(fd, ctx->nr_user_files); file_ptr =3D io_fixed_file_slot(&ctx->file_table, fd)->file_ptr; file =3D (struct file *) (file_ptr & FFS_MASK); file_ptr &=3D ~FFS_MASK; /* mask in overlapping REQ_F and FFS bits */ req->flags |=3D (file_ptr << REQ_F_SUPPORT_NOWAIT_BIT); - io_req_set_rsrc_node(req, ctx); + io_req_set_rsrc_node(req, ctx, 0); +out: + if (issue_flags & IO_URING_F_UNLOCKED) + mutex_unlock(&ctx->uring_lock); return file; } =20 -static struct file *io_file_get_normal(struct io_ring_ctx *ctx, - struct io_kiocb *req, int fd) +static struct file *io_file_get_normal(struct io_kiocb *req, int fd) { struct file *file =3D fget(fd); =20 - trace_io_uring_file_get(ctx, fd); + trace_io_uring_file_get(req->ctx, fd); =20 /* we don't allow fixed io_uring files */ if (file && unlikely(file->f_op =3D=3D &io_uring_fops)) @@ -6993,15 +7012,6 @@ static struct file *io_file_get_normal(s return file; } =20 -static inline struct file *io_file_get(struct io_ring_ctx *ctx, - struct io_kiocb *req, int fd, bool fixed) -{ - if (fixed) - return io_file_get_fixed(ctx, req, fd); - else - return io_file_get_normal(ctx, req, fd); -} - static void io_req_task_link_timeout(struct io_kiocb *req, bool *locked) { struct io_kiocb *prev =3D req->timeout.prev; @@ -7249,8 +7259,10 @@ static int io_init_req(struct io_ring_ct blk_start_plug_nr_ios(&state->plug, state->submit_nr); } =20 - req->file =3D io_file_get(ctx, req, READ_ONCE(sqe->fd), - (sqe_flags & IOSQE_FIXED_FILE)); + if (req->flags & REQ_F_FIXED_FILE) + req->file =3D io_file_get_fixed(req, READ_ONCE(sqe->fd), 0); + else + req->file =3D io_file_get_normal(req, READ_ONCE(sqe->fd)); if (unlikely(!req->file)) return -EBADF; } From nobody Thu May 14 08:08:21 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 3218CC4167E for ; Tue, 12 Apr 2022 09:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386841AbiDLJEb (ORCPT ); Tue, 12 Apr 2022 05:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359407AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43: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 3C1602CE0E; Tue, 12 Apr 2022 00:22: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 ams.source.kernel.org (Postfix) with ESMTPS id EBF25B81B60; Tue, 12 Apr 2022 07:22:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60863C385A1; Tue, 12 Apr 2022 07:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748163; bh=Qylrq82K99+XKXRELwVPYJ9RsHk08S1/WZzK/wRPeEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dB5/vjq21MwTDHBIqwomgo/HBOTB3Vf4nInJrVx5UzDjvw0OS3hkzd+DOBy4Ej0dJ PbJ5xrd6SQTxdEH9eH3uVRlzO3f0QgqhYiHGhqlgktUSW37zZQfVXZrX9ErrjlDJGG eXJr+QX/UNfOdCnW6J9oeXpmI1PaZIyIx6ELJhmY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.17 342/343] io_uring: defer file assignment Date: Tue, 12 Apr 2022 08:32:40 +0200 Message-Id: <20220412063001.185808860@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit 6bf9c47a398911e0ab920e362115153596c80432 upstream. If an application uses direct open or accept, it knows in advance what direct descriptor value it will get as it picks it itself. This allows combined requests such as: sqe =3D io_uring_get_sqe(ring); io_uring_prep_openat_direct(sqe, ..., file_slot); sqe->flags |=3D IOSQE_IO_LINK | IOSQE_CQE_SKIP_SUCCESS; sqe =3D io_uring_get_sqe(ring); io_uring_prep_read(sqe,file_slot, buf, buf_size, 0); sqe->flags |=3D IOSQE_FIXED_FILE; io_uring_submit(ring); where we prepare both a file open and read, and only get a completion event for the read when both have completed successfully. Currently links are fully prepared before the head is issued, but that fails if the dependent link needs a file assigned that isn't valid until the head has completed. Conversely, if the same chain is performed but the fixed file slot is already valid, then we would be unexpectedly returning data from the old file slot rather than the newly opened one. Make sure we're consistent here. Allow deferral of file setup, which makes this documented case work. Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io-wq.h | 1 + fs/io_uring.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) --- a/fs/io-wq.h +++ b/fs/io-wq.h @@ -155,6 +155,7 @@ struct io_wq_work_node *wq_stack_extract struct io_wq_work { struct io_wq_work_node list; unsigned flags; + int fd; }; =20 static inline struct io_wq_work *wq_next_work(struct io_wq_work *work) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6745,6 +6745,23 @@ static void io_clean_op(struct io_kiocb req->flags &=3D ~IO_REQ_CLEAN_FLAGS; } =20 +static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags) +{ + if (req->file || !io_op_defs[req->opcode].needs_file) + return true; + + if (req->flags & REQ_F_FIXED_FILE) + req->file =3D io_file_get_fixed(req, req->work.fd, issue_flags); + else + req->file =3D io_file_get_normal(req, req->work.fd); + if (req->file) + return true; + + req_set_fail(req); + req->result =3D -EBADF; + return false; +} + static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) { const struct cred *creds =3D NULL; @@ -6755,6 +6772,8 @@ static int io_issue_sqe(struct io_kiocb =20 if (!io_op_defs[req->opcode].audit_skip) audit_uring_entry(req->opcode); + if (unlikely(!io_assign_file(req, issue_flags))) + return -EBADF; =20 switch (req->opcode) { case IORING_OP_NOP: @@ -6896,10 +6915,11 @@ static struct io_wq_work *io_wq_free_wor static void io_wq_submit_work(struct io_wq_work *work) { struct io_kiocb *req =3D container_of(work, struct io_kiocb, work); + const struct io_op_def *def =3D &io_op_defs[req->opcode]; unsigned int issue_flags =3D IO_URING_F_UNLOCKED; bool needs_poll =3D false; struct io_kiocb *timeout; - int ret =3D 0; + int ret =3D 0, err =3D -ECANCELED; =20 /* one will be dropped by ->io_free_work() after returning to io-wq */ if (!(req->flags & REQ_F_REFCOUNT)) @@ -6911,14 +6931,18 @@ static void io_wq_submit_work(struct io_ if (timeout) io_queue_linked_timeout(timeout); =20 + if (!io_assign_file(req, issue_flags)) { + err =3D -EBADF; + work->flags |=3D IO_WQ_WORK_CANCEL; + } + /* either cancelled or io-wq is dying, so don't touch tctx->iowq */ if (work->flags & IO_WQ_WORK_CANCEL) { - io_req_task_queue_fail(req, -ECANCELED); + io_req_task_queue_fail(req, err); return; } =20 if (req->flags & REQ_F_FORCE_ASYNC) { - const struct io_op_def *def =3D &io_op_defs[req->opcode]; bool opcode_poll =3D def->pollin || def->pollout; =20 if (opcode_poll && file_can_poll(req->file)) { @@ -7249,6 +7273,8 @@ static int io_init_req(struct io_ring_ct if (io_op_defs[opcode].needs_file) { struct io_submit_state *state =3D &ctx->submit_state; =20 + req->work.fd =3D READ_ONCE(sqe->fd); + /* * Plug now if we have more than 2 IO left after this, and the * target is potentially a read/write to block based storage. @@ -7258,13 +7284,6 @@ static int io_init_req(struct io_ring_ct state->need_plug =3D false; blk_start_plug_nr_ios(&state->plug, state->submit_nr); } - - if (req->flags & REQ_F_FIXED_FILE) - req->file =3D io_file_get_fixed(req, READ_ONCE(sqe->fd), 0); - else - req->file =3D io_file_get_normal(req, READ_ONCE(sqe->fd)); - if (unlikely(!req->file)) - return -EBADF; } =20 personality =3D READ_ONCE(sqe->personality); From nobody Thu May 14 08:08:21 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 ED4D4C352B6 for ; Tue, 12 Apr 2022 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386234AbiDLIyq (ORCPT ); Tue, 12 Apr 2022 04:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359408AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A8B2CE0F; Tue, 12 Apr 2022 00:22: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 B1201B81B33; Tue, 12 Apr 2022 07:22:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29C65C385A1; Tue, 12 Apr 2022 07:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748166; bh=/ugomh2UJ0kcIyTrlE75uZzcMyiXZtPHR1TsJtdHc30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rngQ6hL9SrzdfY3jkjg3qgME/T1ETsy1Dw5AB9xq5TkFqcEZnva07jWnarKrPRKhm GMynoc2DMzXHbXEOaYBG8D+Aj/iU6YfKp5GdUApk1kRkONm2w9dcbruRHhwhya/wCc 6NsxksT/g2JB63/8OvmSY9C64OOiqiH/mui3r6H0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+c4b9303500a21750b250@syzkaller.appspotmail.com, Jens Axboe Subject: [PATCH 5.17 343/343] io_uring: drop the old style inflight file tracking Date: Tue, 12 Apr 2022 08:32:41 +0200 Message-Id: <20220412063001.214326019@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@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: Jens Axboe commit d5361233e9ab920e135819f73dd8466355f1fddd upstream. io_uring tracks requests that are referencing an io_uring descriptor to be able to cancel without worrying about loops in the references. Since we now assign the file at execution time, the easier approach is to drop a potentially problematic reference before we punt the request. This eliminates the need to special case these types of files beyond just marking them as such, and simplifies cancelation quite a bit. This also fixes a recent issue where an async punted tee operation would with the io_uring descriptor as the output file would crash when attempting to get a reference to the file from the io-wq worker. We could have worked around that, but this is the much cleaner fix. Fixes: 6bf9c47a3989 ("io_uring: defer file assignment") Reported-by: syzbot+c4b9303500a21750b250@syzkaller.appspotmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Fox Chen 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: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Zan Aziz --- fs/io_uring.c | 85 ++++++++++++++++++-----------------------------------= ----- 1 file changed, 27 insertions(+), 58 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -112,8 +112,7 @@ IOSQE_IO_DRAIN | IOSQE_CQE_SKIP_SUCCESS) =20 #define IO_REQ_CLEAN_FLAGS (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP | \ - REQ_F_POLLED | REQ_F_INFLIGHT | REQ_F_CREDS | \ - REQ_F_ASYNC_DATA) + REQ_F_POLLED | REQ_F_CREDS | REQ_F_ASYNC_DATA) =20 #define IO_TCTX_REFS_CACHE_NR (1U << 10) =20 @@ -469,7 +468,6 @@ struct io_uring_task { const struct io_ring_ctx *last; struct io_wq *io_wq; struct percpu_counter inflight; - atomic_t inflight_tracked; atomic_t in_idle; =20 spinlock_t task_lock; @@ -1131,6 +1129,8 @@ static void io_clean_op(struct io_kiocb static inline struct file *io_file_get_fixed(struct io_kiocb *req, int fd, unsigned issue_flags); static inline struct file *io_file_get_normal(struct io_kiocb *req, int fd= ); +static void io_drop_inflight_file(struct io_kiocb *req); +static bool io_assign_file(struct io_kiocb *req, unsigned int issue_flags); static void __io_queue_sqe(struct io_kiocb *req); static void io_rsrc_put_work(struct work_struct *work); =20 @@ -1312,29 +1312,9 @@ static bool io_match_task(struct io_kioc bool cancel_all) __must_hold(&req->ctx->timeout_lock) { - struct io_kiocb *req; - if (task && head->task !=3D task) return false; - if (cancel_all) - return true; - - io_for_each_link(req, head) { - if (req->flags & REQ_F_INFLIGHT) - return true; - } - return false; -} - -static bool io_match_linked(struct io_kiocb *head) -{ - struct io_kiocb *req; - - io_for_each_link(req, head) { - if (req->flags & REQ_F_INFLIGHT) - return true; - } - return false; + return cancel_all; } =20 /* @@ -1344,24 +1324,9 @@ static bool io_match_linked(struct io_ki static bool io_match_task_safe(struct io_kiocb *head, struct task_struct *= task, bool cancel_all) { - bool matched; - if (task && head->task !=3D task) return false; - if (cancel_all) - return true; - - if (head->flags & REQ_F_LINK_TIMEOUT) { - struct io_ring_ctx *ctx =3D head->ctx; - - /* protect against races with linked timeouts */ - spin_lock_irq(&ctx->timeout_lock); - matched =3D io_match_linked(head); - spin_unlock_irq(&ctx->timeout_lock); - } else { - matched =3D io_match_linked(head); - } - return matched; + return cancel_all; } =20 static inline bool req_has_async_data(struct io_kiocb *req) @@ -1509,14 +1474,6 @@ static inline bool io_req_ffs_set(struct return req->flags & REQ_F_FIXED_FILE; } =20 -static inline void io_req_track_inflight(struct io_kiocb *req) -{ - if (!(req->flags & REQ_F_INFLIGHT)) { - req->flags |=3D REQ_F_INFLIGHT; - atomic_inc(¤t->io_uring->inflight_tracked); - } -} - static struct io_kiocb *__io_prep_linked_timeout(struct io_kiocb *req) { if (WARN_ON_ONCE(!req->link)) @@ -2380,6 +2337,8 @@ static void io_req_task_work_add(struct =20 WARN_ON_ONCE(!tctx); =20 + io_drop_inflight_file(req); + spin_lock_irqsave(&tctx->task_lock, flags); if (priority) wq_list_add_tail(&req->io_task_work.node, &tctx->prior_task_list); @@ -5548,7 +5507,10 @@ static int io_poll_check_events(struct i if (!req->result) { struct poll_table_struct pt =3D { ._key =3D poll->events }; =20 - req->result =3D vfs_poll(req->file, &pt) & poll->events; + if (unlikely(!io_assign_file(req, IO_URING_F_UNLOCKED))) + req->result =3D -EBADF; + else + req->result =3D vfs_poll(req->file, &pt) & poll->events; } =20 /* multishot, just fill an CQE and proceed */ @@ -6731,11 +6693,6 @@ static void io_clean_op(struct io_kiocb kfree(req->apoll); req->apoll =3D NULL; } - if (req->flags & REQ_F_INFLIGHT) { - struct io_uring_task *tctx =3D req->task->io_uring; - - atomic_dec(&tctx->inflight_tracked); - } if (req->flags & REQ_F_CREDS) put_cred(req->creds); if (req->flags & REQ_F_ASYNC_DATA) { @@ -7024,6 +6981,19 @@ out: return file; } =20 +/* + * Drop the file for requeue operations. Only used of req->file is the + * io_uring descriptor itself. + */ +static void io_drop_inflight_file(struct io_kiocb *req) +{ + if (unlikely(req->flags & REQ_F_INFLIGHT)) { + fput(req->file); + req->file =3D NULL; + req->flags &=3D ~REQ_F_INFLIGHT; + } +} + static struct file *io_file_get_normal(struct io_kiocb *req, int fd) { struct file *file =3D fget(fd); @@ -7031,8 +7001,8 @@ static struct file *io_file_get_normal(s trace_io_uring_file_get(req->ctx, fd); =20 /* we don't allow fixed io_uring files */ - if (file && unlikely(file->f_op =3D=3D &io_uring_fops)) - io_req_track_inflight(req); + if (file && file->f_op =3D=3D &io_uring_fops) + req->flags |=3D REQ_F_INFLIGHT; return file; } =20 @@ -8804,7 +8774,6 @@ static __cold int io_uring_alloc_task_co xa_init(&tctx->xa); init_waitqueue_head(&tctx->wait); atomic_set(&tctx->in_idle, 0); - atomic_set(&tctx->inflight_tracked, 0); task->io_uring =3D tctx; spin_lock_init(&tctx->task_lock); INIT_WQ_LIST(&tctx->task_list); @@ -9942,7 +9911,7 @@ static __cold void io_uring_clean_tctx(s static s64 tctx_inflight(struct io_uring_task *tctx, bool tracked) { if (tracked) - return atomic_read(&tctx->inflight_tracked); + return 0; return percpu_counter_sum(&tctx->inflight); }