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 61C3DCDB47F for ; Wed, 11 Oct 2023 19:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233431AbjJKTUK (ORCPT ); Wed, 11 Oct 2023 15:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233159AbjJKTUJ (ORCPT ); Wed, 11 Oct 2023 15:20:09 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3053B8F; Wed, 11 Oct 2023 12:20:08 -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=lgjkqHX2tUg8J3lXvm+VQWd9+smBMxN3ogHXgE1zA9U=; b=tk93etI1BLYzTY2MpHDz3iLPJ9 5j6SbX9aun+EvVMGxaRioZG4uogoJ2Ar5WLiTMHQyFGLWR2XWHElExKqQ1tWp7IJJT9r19zzZmqGQ zu/dpFriZG0kI48Gf+gfRwZU6HU4iRBlxnUON9hvLZ1sCa7PtY+yyYgv0aWBxxtbTeZGRX5BdUrj0 DVsStSBDRlSP/BiB0SdzX2tZ8wwfPniX/5un6X1zS5vFhhR2LPe3xEa1VLZGJ9+nXrdq3bH0aa7fN kkYmJC6dVzvB2Cc6Z/cbZIbW9VVAsaeGJig4XEpxu80EclXpkVRTtmBixPg4EAGHcETbzlS9sp3gC YRJP5SLw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qqekZ-00GXV9-31; Wed, 11 Oct 2023 19:20:07 +0000 Date: Wed, 11 Oct 2023 12:20:07 -0700 From: Luis Chamberlain To: Joey Jiao Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option Message-ID: References: <20231011074438.6098-1-quic_jiangenj@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231011074438.6098-1-quic_jiangenj@quicinc.com> Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 11, 2023 at 01:14:38PM +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 | 3 ++- > 2 files changed, 13 insertions(+), 1 deletion(-) > > 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..e238a31d09eb 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -2594,7 +2594,8 @@ static noinline int do_init_module(struct module *mod) > * rcu_barrier() > */ > if (llist_add(&freeinit->node, &init_free_list)) > - schedule_work(&init_free_wq); > + if (!IS_ENABLED(CONFIG_MODULE_LOAD_IN_SEQUENCE)) { > + schedule_work(&init_free_wq); > As Christoph suggested the rationale for something like this needs to be clearly spelled out in the commit log and if so valuable it should be a default. The commit log and even the Kconfig description do little to justify any rationale for this. Luis