From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9649CD98C0 for ; Tue, 10 Oct 2023 22:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343758AbjJJWgf (ORCPT ); Tue, 10 Oct 2023 18:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbjJJWga (ORCPT ); Tue, 10 Oct 2023 18:36:30 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00BD798; Tue, 10 Oct 2023 15:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GC2Zo8w3qa1p/gg7pwDrOZOfPLZQVYf+w0DHvJnVE8M=; b=qxcllpn94k9taiJWwKPRaifOWu Zek/PxhRD8VqWF24HxhcCh/7SU3bcsl8yxNYCoh6JUDqBhbEuhJveW1NeTwpdpAG6vtEj9ZcPSrF9 EH4Aa4xp8OzWDWdcu36xtrb4eXHHoCxzJqZG0ZMiq6YZtbg5Lxu9wiXtLoKB/m65K7VNXqasChjyz hP9akOy46HVjZpCbvMaSfF37G63fVIoljV6B5AC2R6lyTkHcNn7pop0z+Ftp66QTMOPHGfArKrUW+ FdSBnQL0Yt8/Gi0brT9OTcRkLga1T8H4Qy6W76dgASS9gA6dtpiNmKMkpuQhK/Cbe2qZrFo3jr88c UEe6Pwlw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qqLL2-00EHGM-2n; Tue, 10 Oct 2023 22:36:28 +0000 Date: Tue, 10 Oct 2023 15:36:28 -0700 From: Luis Chamberlain To: Joey Jiao Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option Message-ID: References: <20231009045636.4143-1-quic_jiangenj@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231009045636.4143-1-quic_jiangenj@quicinc.com> Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 09, 2023 at 10:26:35AM +0530, Joey Jiao wrote: > When modprobe cmds are executed one by one, the final loaded modules > are not in fixed sequence as expected. > > Add the option to make sure modules are in fixed sequence across reboot. > > Signed-off-by: Joey Jiao > --- > kernel/module/Kconfig | 11 +++++++++++ > kernel/module/main.c | 6 ++++++ > 2 files changed, 17 insertions(+) > > diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig > index 33a2e991f608..b45a45f31d6d 100644 > --- a/kernel/module/Kconfig > +++ b/kernel/module/Kconfig > @@ -389,4 +389,15 @@ config MODULES_TREE_LOOKUP > def_bool y > depends on PERF_EVENTS || TRACING || CFI_CLANG > > +config MODULE_LOAD_IN_SEQUENCE > + bool "Load module in sequence" > + default n > + help > + By default, modules are loaded in random sequence depending on when modprobe > + is executed. > + > + This option allows modules to be loaded in sequence if modprobe cmds are > + executed one by one in sequence. This option is helpful during syzkaller fuzzing > + to make sure module is loaded into fixed address across device reboot. > + > endif # MODULES > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 98fedfdb8db5..587fd84083ae 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -2593,11 +2593,17 @@ static noinline int do_init_module(struct module *mod) > * be cleaned up needs to sync with the queued work - ie > * rcu_barrier() > */ > +#ifdef CONFIG_MODULE_LOAD_IN_SEQUENCE > + llist_add(&freeinit->node, &init_free_list); > +#else > if (llist_add(&freeinit->node, &init_free_list)) > schedule_work(&init_free_wq); > +#endif How is ignoring an error ensuring ordering? > mutex_unlock(&module_mutex); > +#ifdef CONFIG_MODULE_LOAD_IN_SEQUENCE > wake_up_all(&module_wq); > +#endif Why are you making this only now be called with this new kconfig option? Luis