From nobody Sun Apr 19 13:41:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21B70C43334 for ; Thu, 30 Jun 2022 14:11:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236878AbiF3OL5 (ORCPT ); Thu, 30 Jun 2022 10:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236784AbiF3OKy (ORCPT ); Thu, 30 Jun 2022 10:10:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D973E51B2F; Thu, 30 Jun 2022 06:55: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 37BC6620E4; Thu, 30 Jun 2022 13:55:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 453E1C3411E; Thu, 30 Jun 2022 13:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597347; bh=r9/ywhLT5CIo5UdvxEHO7yYlVGfstFnIeupe8lcgfWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDz03lkPc72fBMq3rUZkYgocyUZofkjhOc+2/YQu/3cfKQWFe4Fjd/J3fSws7Vzhf COvey3nB5MBSpCFAvspdFubzgsIYig1CslHw5RIGHVRe0NhvVcqY7hheuQjk1qPuUw nRvqYVlg4x1CK+lfZyZWEhz30ze056JOOAwRMwjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds , Masahiro Yamada , "Paul E. McKenney" , Thomas Backlund Subject: [PATCH 5.18 1/6] tick/nohz: unexport __init-annotated tick_nohz_full_setup() Date: Thu, 30 Jun 2022 15:47:27 +0200 Message-Id: <20220630133230.285309399@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@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: Masahiro Yamada commit 2390095113e98fc52fffe35c5206d30d9efe3f78 upstream. EXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic. modpost used to detect it, but it had been broken for a decade. Commit 28438794aba4 ("modpost: fix section mismatch check for exported init/exit sections") fixed it so modpost started to warn it again, then this showed up: MODPOST vmlinux.symvers WARNING: modpost: vmlinux.o(___ksymtab_gpl+tick_nohz_full_setup+0x0): Sec= tion mismatch in reference from the variable __ksymtab_tick_nohz_full_setup= to the function .init.text:tick_nohz_full_setup() The symbol tick_nohz_full_setup is exported and annotated __init Fix this by removing the __init annotation of tick_nohz_full_setup or dro= p the export. Drop the export because tick_nohz_full_setup() is only called from the built-in code in kernel/sched/isolation.c. Fixes: ae9e557b5be2 ("time: Export tick start/stop functions for rcutorture= ") Reported-by: Linus Torvalds Signed-off-by: Masahiro Yamada Tested-by: Paul E. McKenney Signed-off-by: Linus Torvalds Cc: Thomas Backlund Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- kernel/time/tick-sched.c | 1 - 1 file changed, 1 deletion(-) --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -526,7 +526,6 @@ void __init tick_nohz_full_setup(cpumask cpumask_copy(tick_nohz_full_mask, cpumask); tick_nohz_full_running =3D true; } -EXPORT_SYMBOL_GPL(tick_nohz_full_setup); =20 static int tick_nohz_cpu_down(unsigned int cpu) { From nobody Sun Apr 19 13:41:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCEF8CCA47B for ; Thu, 30 Jun 2022 14:12:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236971AbiF3OMS (ORCPT ); Thu, 30 Jun 2022 10:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236894AbiF3OLE (ORCPT ); Thu, 30 Jun 2022 10:11:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E90A58FE1; Thu, 30 Jun 2022 06:55: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 D75D56211A; Thu, 30 Jun 2022 13:55:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E60A3C3411E; Thu, 30 Jun 2022 13:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597350; bh=3wnhMYImqIC9HM39V22zzymJJlEVLwXPGIwl/VYjO54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bBcHB7iVAnFTDzJGEIgjkzHKASqhZxGr3xxzI4UfFd6JD7BUkL5JaB0TD9amX43KB JXuTBzmWvNyUzXhw8RKrFP16MT5e9+5vv361pHSRS1RDUmaUqOOEO6d2/Qn4K1FNBd 4NPTDO9Sd8XmwDWrwWNnJFrREN09PBH7fW9ISQBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Walleij , Daniel Lezcano Subject: [PATCH 5.18 2/6] clocksource/drivers/ixp4xx: Drop boardfile probe path Date: Thu, 30 Jun 2022 15:47:28 +0200 Message-Id: <20220630133230.313912598@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Linus Walleij commit 41929c9f628b9990d33a200c54bb0c919e089aa8 upstream. The boardfiles for IXP4xx have been deleted. Delete all the quirks and code dealing with that boot path and rely solely on device tree boot. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20220406205505.2332821-1-linus.walleij@lina= ro.org Signed-off-by: Daniel Lezcano Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/timer-ixp4xx.c | 25 ------------------------- include/linux/platform_data/timer-ixp4xx.h | 11 ----------- 3 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 include/linux/platform_data/timer-ixp4xx.h --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -80,7 +80,7 @@ config IXP4XX_TIMER bool "Intel XScale IXP4xx timer driver" if COMPILE_TEST depends on HAS_IOMEM select CLKSRC_MMIO - select TIMER_OF if OF + select TIMER_OF help Enables support for the Intel XScale IXP4xx SoC timer. =20 --- a/drivers/clocksource/timer-ixp4xx.c +++ b/drivers/clocksource/timer-ixp4xx.c @@ -19,8 +19,6 @@ #include #include #include -/* Goes away with OF conversion */ -#include =20 /* * Constants to make it easy to access Timer Control/Status registers @@ -263,28 +261,6 @@ static struct platform_driver ixp4xx_tim }; builtin_platform_driver(ixp4xx_timer_driver); =20 -/** - * ixp4xx_timer_setup() - Timer setup function to be called from boardfiles - * @timerbase: physical base of timer block - * @timer_irq: Linux IRQ number for the timer - * @timer_freq: Fixed frequency of the timer - */ -void __init ixp4xx_timer_setup(resource_size_t timerbase, - int timer_irq, - unsigned int timer_freq) -{ - void __iomem *base; - - base =3D ioremap(timerbase, 0x100); - if (!base) { - pr_crit("IXP4xx: can't remap timer\n"); - return; - } - ixp4xx_timer_register(base, timer_irq, timer_freq); -} -EXPORT_SYMBOL_GPL(ixp4xx_timer_setup); - -#ifdef CONFIG_OF static __init int ixp4xx_of_timer_init(struct device_node *np) { void __iomem *base; @@ -315,4 +291,3 @@ out_unmap: return ret; } TIMER_OF_DECLARE(ixp4xx, "intel,ixp4xx-timer", ixp4xx_of_timer_init); -#endif --- a/include/linux/platform_data/timer-ixp4xx.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __TIMER_IXP4XX_H -#define __TIMER_IXP4XX_H - -#include - -void __init ixp4xx_timer_setup(resource_size_t timerbase, - int timer_irq, - unsigned int timer_freq); - -#endif From nobody Sun Apr 19 13:41:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AB61C433EF for ; Thu, 30 Jun 2022 14:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236981AbiF3OMV (ORCPT ); Thu, 30 Jun 2022 10:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236903AbiF3OLF (ORCPT ); Thu, 30 Jun 2022 10:11: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 55CE95A46B; Thu, 30 Jun 2022 06:55: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 8379A6204B; Thu, 30 Jun 2022 13:55:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95B8DC3411E; Thu, 30 Jun 2022 13:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597352; bh=8TLd2Le8ME8tL6hO7wkEtHxu0MyfnSARvmpEGWLGYeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f9k+ZejMff9EOiwisEaQYNpY3OQQJyp/eRjktj1bp7nZvKlLDt/EEOYbhXZur9+5c BNF2sqpjcR3pYfxdcS09+eEEWsDqVRnNRU5cReolDEh4nMgNobUd5v8vLH9NpnpaZt e2ylUBCBx433AeyDGJSLe9D85/ohh9iyUgtnIxBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Jens Axboe Subject: [PATCH 5.18 3/6] bcache: memset on stack variables in bch_btree_check() and bch_sectors_dirty_init() Date: Thu, 30 Jun 2022 15:47:29 +0200 Message-Id: <20220630133230.342925455@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Coly Li commit 7d6b902ea0e02b2a25c480edf471cbaa4ebe6b3c upstream. The local variables check_state (in bch_btree_check()) and state (in bch_sectors_dirty_init()) should be fully filled by 0, because before allocating them on stack, they were dynamically allocated by kzalloc(). Signed-off-by: Coly Li Link: https://lore.kernel.org/r/20220527152818.27545-2-colyli@suse.de Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/md/bcache/btree.c | 1 + drivers/md/bcache/writeback.c | 1 + 2 files changed, 2 insertions(+) --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -2017,6 +2017,7 @@ int bch_btree_check(struct cache_set *c) if (c->root->level =3D=3D 0) return 0; =20 + memset(&check_state, 0, sizeof(struct btree_check_state)); check_state.c =3D c; check_state.total_threads =3D bch_btree_chkthread_nr(); check_state.key_idx =3D 0; --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -950,6 +950,7 @@ void bch_sectors_dirty_init(struct bcach return; } =20 + memset(&state, 0, sizeof(struct bch_dirty_init_state)); state.c =3D c; state.d =3D d; state.total_threads =3D bch_btre_dirty_init_thread_nr(); From nobody Sun Apr 19 13:41:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B87C433EF for ; Thu, 30 Jun 2022 14:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236914AbiF3OMY (ORCPT ); Thu, 30 Jun 2022 10:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236528AbiF3OLG (ORCPT ); Thu, 30 Jun 2022 10:11:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A8C07C1AF; Thu, 30 Jun 2022 06:55: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 CD07EB82AEE; Thu, 30 Jun 2022 13:55:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4130FC34115; Thu, 30 Jun 2022 13:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597355; bh=0Pztk4mzBqgFgfsq/p8hGIUhrVzLBaGck9BeRq7gqEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6IC1Y9er6nY8OAIsJdxyjxEd6xUB1dB4a98jULLELviemI5b/cr1p/q2XZu1huWD 7KjyEM90BZYCglP64/Z4e9w8oAhshPUp3X3hhkZFp2IkfOsRk9hnAbwyF4ruRYRSjT Z9n89b7u+jGp9dnNW3C6ckvOCji6dfQVwgGc4sA0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Desaulniers , Tom Rix , llvm@lists.linux.dev, Kees Cook , "Gustavo A. R. Silva" , Jakub Kicinski , Nathan Chancellor Subject: [PATCH 5.18 4/6] hinic: Replace memcpy() with direct assignment Date: Thu, 30 Jun 2022 15:47:30 +0200 Message-Id: <20220630133230.371942781@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kees Cook commit 1e70212e031528918066a631c9fdccda93a1ffaa upstream. Under CONFIG_FORTIFY_SOURCE=3Dy and CONFIG_UBSAN_BOUNDS=3Dy, Clang is bugged here for calculating the size of the destination buffer (0x10 instead of 0x14). This copy is a fixed size (sizeof(struct fw_section_info_st)), with the source and dest being struct fw_section_info_st, so the memcpy should be safe, assuming the index is within bounds, which is UBSAN_BOUNDS's responsibility to figure out. Avoid the whole thing and just do a direct assignment. This results in no change to the executable code. [This is a duplicate of commit 2c0ab32b73cf ("hinic: Replace memcpy() with direct assignment") which was applied to net-next.] Cc: Nick Desaulniers Cc: Tom Rix Cc: llvm@lists.linux.dev Link: https://github.com/ClangBuiltLinux/linux/issues/1592 Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Tested-by: Nathan Chancellor # build Link: https://lore.kernel.org/r/20220616052312.292861-1-keescook@chromium.o= rg Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- drivers/net/ethernet/huawei/hinic/hinic_devlink.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c @@ -43,9 +43,7 @@ static bool check_image_valid(struct hin =20 for (i =3D 0; i < fw_image->fw_info.fw_section_cnt; i++) { len +=3D fw_image->fw_section_info[i].fw_section_len; - memcpy(&host_image->image_section_info[i], - &fw_image->fw_section_info[i], - sizeof(struct fw_section_info_st)); + host_image->image_section_info[i] =3D fw_image->fw_section_info[i]; } =20 if (len !=3D fw_image->fw_len || From nobody Sun Apr 19 13:41:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F948C43334 for ; Thu, 30 Jun 2022 14:13:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236998AbiF3OM0 (ORCPT ); Thu, 30 Jun 2022 10:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236538AbiF3OLP (ORCPT ); Thu, 30 Jun 2022 10:11:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB727C1B5; Thu, 30 Jun 2022 06:55: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 0BD576204B; Thu, 30 Jun 2022 13:55:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1327FC34115; Thu, 30 Jun 2022 13:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597358; bh=OaN9Xtb+HK3G1FPwqyeCfvjC3Ef/GbvvmjKvofkkCPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjIFpEor6tc5upuCQ0N0KiI1ABj89DrqIzvDIzh/ce2Ra158fl7rC77gS2ZAjYse5 80BGi6aGRJlfcXTl2E3oKGFfaiLMW9Hf50I1vLSn9+SFHbojASwny/cUdNWMxaODxm XfPd2TI9cF7pXqmZ7nM6jkK8x+i4L0os+tpgw7C8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Naveen N. Rao" , Michael Ellerman Subject: [PATCH 5.18 5/6] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete Date: Thu, 30 Jun 2022 15:47:31 +0200 Message-Id: <20220630133230.402616375@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naveen N. Rao commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream. Stop using the ftrace trampoline for init section once kernel init is complete. Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs") Cc: stable@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n.rao@linux.= vnet.ibm.com Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- arch/powerpc/include/asm/ftrace.h | 4 +++- arch/powerpc/kernel/trace/ftrace.c | 15 ++++++++++++--- arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -86,7 +86,7 @@ static inline bool arch_syscall_match_sy #endif /* PPC64_ELF_ABI_v1 */ #endif /* CONFIG_FTRACE_SYSCALLS */ =20 -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER) #include =20 static inline void this_cpu_disable_ftrace(void) @@ -110,11 +110,13 @@ static inline u8 this_cpu_get_ftrace_ena return get_paca()->ftrace_enabled; } =20 +void ftrace_free_init_tramp(void); #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } +static inline void ftrace_free_init_tramp(void) { } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ =20 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -306,9 +306,7 @@ static int setup_mcount_compiler_tramp(u =20 /* Is this a known long jump tramp? */ for (i =3D 0; i < NUM_FTRACE_TRAMPS; i++) - if (!ftrace_tramps[i]) - break; - else if (ftrace_tramps[i] =3D=3D tramp) + if (ftrace_tramps[i] =3D=3D tramp) return 0; =20 /* Is this a known plt tramp? */ @@ -863,6 +861,17 @@ void arch_ftrace_update_code(int command =20 extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; =20 +void ftrace_free_init_tramp(void) +{ + int i; + + for (i =3D 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++) + if (ftrace_tramps[i] =3D=3D (unsigned long)ftrace_tramp_init) { + ftrace_tramps[i] =3D 0; + return; + } +} + int __init ftrace_dyn_arch_init(void) { int i; --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 #include =20 @@ -312,6 +313,7 @@ void free_initmem(void) ppc_md.progress =3D ppc_printk_progress; mark_initmem_nx(); free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } =20 /* From nobody Sun Apr 19 13:41:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A337C433EF for ; Thu, 30 Jun 2022 14:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237028AbiF3OM3 (ORCPT ); Thu, 30 Jun 2022 10:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236657AbiF3OL1 (ORCPT ); Thu, 30 Jun 2022 10:11:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFD474795; Thu, 30 Jun 2022 06:56: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 BCA486211A; Thu, 30 Jun 2022 13:56:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5147C34115; Thu, 30 Jun 2022 13:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597361; bh=+YLc4a0WbZpCVn31X/6oyULnGlfdxP35QoZV3HumIlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DdO9W/OzETwctEidDZ2qlf/PyhqITcjlebMtgi7x98CLacYlMqRfT0/fk8nBSKHVQ ZJI/EpXifSIB+wCXMK3I789NgTseHFd0P8+ydmnbFLKJuwsY9tjfgwqL1I94xXTduB IXg211ZQ/1qjke4/FbQkigPYCPdg1ah1SzLNpdjQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov Subject: [PATCH 5.18 6/6] io_uring: fix not locked access to fixed buf table Date: Thu, 30 Jun 2022 15:47:32 +0200 Message-Id: <20220630133230.432585784@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133230.239507521@linuxfoundation.org> References: <20220630133230.239507521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-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 commit 05b538c1765f8d14a71ccf5f85258dcbeaf189f7 upstream. We can look inside the fixed buffer table only while holding ->uring_lock, however in some cases we don't do the right async prep for IORING_OP_{WRITE,READ}_FIXED ending up with NULL req->imu forcing making an io-wq worker to try to resolve the fixed buffer without proper locking. Move req->imu setup into early req init paths, i.e. io_prep_rw(), which is called unconditionally for rw requests and under uring_lock. Fixes: 634d00df5e1cf ("io_uring: add full-fledged dynamic buffers support") Signed-off-by: Pavel Begunkov Signed-off-by: Greg Kroah-Hartman Tested-by: Bagas Sanjaya Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Justin M. Forbes Tested-by: Linux Kernel Functional Testing Tested-by: Ron Economos Tested-by: Rudi Heitbaum Tested-by: Shuah Khan Tested-by: Sudip Mukherjee Tested-by: Zan Aziz --- fs/io_uring.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3187,6 +3187,21 @@ static int io_prep_rw(struct io_kiocb *r int ret; =20 kiocb->ki_pos =3D READ_ONCE(sqe->off); + /* used for fixed read/write too - just read unconditionally */ + req->buf_index =3D READ_ONCE(sqe->buf_index); + req->imu =3D NULL; + + if (req->opcode =3D=3D IORING_OP_READ_FIXED || + req->opcode =3D=3D IORING_OP_WRITE_FIXED) { + struct io_ring_ctx *ctx =3D req->ctx; + u16 index; + + if (unlikely(req->buf_index >=3D ctx->nr_user_bufs)) + return -EFAULT; + index =3D array_index_nospec(req->buf_index, ctx->nr_user_bufs); + req->imu =3D ctx->user_bufs[index]; + io_req_set_rsrc_node(req, ctx, 0); + } =20 ioprio =3D READ_ONCE(sqe->ioprio); if (ioprio) { @@ -3199,11 +3214,9 @@ static int io_prep_rw(struct io_kiocb *r kiocb->ki_ioprio =3D get_current_ioprio(); } =20 - 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; } =20 @@ -3335,20 +3348,9 @@ static int __io_import_fixed(struct io_k 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; - - if (likely(!imu)) { - struct io_ring_ctx *ctx =3D req->ctx; - - if (unlikely(buf_index >=3D ctx->nr_user_bufs)) - return -EFAULT; - 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; - } - return __io_import_fixed(req, rw, iter, imu); + if (WARN_ON_ONCE(!req->imu)) + return -EFAULT; + return __io_import_fixed(req, rw, iter, req->imu); } =20 static void io_ring_submit_unlock(struct io_ring_ctx *ctx, bool needs_lock)