Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp440284rdg; Thu, 12 Oct 2023 09:51:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3TeWMiyZcdX801U023seIvkQbYisASVEdCQUBB/oJvBazHuOhE/NuReayae/vzLRjxeru X-Received: by 2002:a05:6a00:cd4:b0:68f:c1e0:a2c4 with SMTP id b20-20020a056a000cd400b0068fc1e0a2c4mr33287077pfv.3.1697129484156; Thu, 12 Oct 2023 09:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697129484; cv=none; d=google.com; s=arc-20160816; b=0jHEyg3i88ruyu+fC47r6dQCU62Y6HsccQ/5dmIF/l4dxaT109Nspn3/1e75Qem04u l4Bj6LkyQfx83cXc4/ZxIsW2My8wKD4r1lUmSbKWOs2QhwUbSJgPViecnx8cIaKK16vR 4vtChBa8hZpe7obji9sN5mmGJDUEenPuWCSv9x0fcUQO2yeJ6TRHlQuCCvjv736/0OwN GPb2infAzhvQLo4Wd1eC+aRTtLSgGfykNq6SWyy1xJNwc1b/brAPehrSktTB8SsuRngk BMePB2RTBhCBc/rhJSGXUo0FU7AvtVlOiGSDxqSrQ5OpMNX7J9qzbmeiBvvimcgkgg5u ZnEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6y1wB+wLmbd3DnNxETvQ+qCVK9s9E8u1DdnwFwmSGKc=; fh=O+nnF2EjnDe+Hu5APcrsl7xZ84y6pz8DF4EH0MlUy7I=; b=qm3a+k2JbInt0oLEWHTjMwKTMOqFA0fA5lwpVwzz+LpdsZN+G1Y/iXG4lKy+m1p0Rb k52D9ZGgv/Lo0nRhkm+46Etf6ICFEaLI9AXILxIy/26FUFyvgcfL5GaJU93Z3XE8u0Bc wfRTO4aNhvByiKIcO/l8wU0sirZqj5GcJY9QMvQyuVZiKKIkD9Ej2m8T2De98ynkMPJs A8s+2HsuvcvHVUKH34D9BfMCTJ/BQKv7QySRR9kJNSBz7yvKRiiBt4tU3hn6liUJW/pn K3zy7MLxeilAYKZHkH23yQ+f5XW1+z4/8i1FxmnS7rYyxejz6/W3osRSzzYOM4WUGRyp VCcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=3Evlr9Ko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m187-20020a633fc4000000b0058962af84easi2501664pga.135.2023.10.12.09.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 09:51:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=3Evlr9Ko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3EC4780952C8; Thu, 12 Oct 2023 09:50:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378739AbjJLQua (ORCPT + 99 others); Thu, 12 Oct 2023 12:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235728AbjJLQu3 (ORCPT ); Thu, 12 Oct 2023 12:50:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A1ABBE; Thu, 12 Oct 2023 09:50: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=6y1wB+wLmbd3DnNxETvQ+qCVK9s9E8u1DdnwFwmSGKc=; b=3Evlr9KoSDHi22us3TUTb+Fiyd gpw+vQLph7yAIUkkXcLUqlYn6cWIAUPdtGWauTTIyuMru/9b6Fpqw2kSlok3vm+PyhsPpNckmHPl7 eYJIj5eVzmazuqs/5C1p7XZY7nBlj66Az8VFEVFwgx98zi1pBh553mqSYysImTi6L5R+8W8UTwCgp ovUGic/6YcYy833JjclTyb8KHJwHjkMiIvikmnZ067/eCewx2XLGsFU/UdrzetMW62sjIfQcsRd+9 Y/za7hzSia8NxG/hekMKqNR0ospFPvJneh96OYcuV35sOaSCB2yx73EJIfVqYzyIH78cgU6w4Ggbn FuS0O7KA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qqytH-001SdC-2n; Thu, 12 Oct 2023 16:50:27 +0000 Date: Thu, 12 Oct 2023 09:50:27 -0700 From: Luis Chamberlain To: Joey Jiao Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] module: Add CONFIG_MODULE_DISABLE_INIT_FREE option Message-ID: References: <20231012014012.9030-1-quic_jiangenj@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231012014012.9030-1-quic_jiangenj@quicinc.com> Sender: Luis Chamberlain X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 09:50:50 -0700 (PDT) On Thu, Oct 12, 2023 at 07:10:11AM +0530, Joey Jiao wrote: > To facilitate syzkaller test, it's essential for the module to retain the same > address across reboots. Why? > In userspace, the execution of modprobe commands must > occur sequentially. Why? > In the kernel, selecting the CONFIG_MODULE_DISABLE_INIT_FREE > option disables the asynchronous freeing of init sections. No it does not. > Signed-off-by: Joey Jiao > --- > kernel/module/Kconfig | 8 ++++++++ > kernel/module/main.c | 5 +++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig > index 33a2e991f608..1cdbee4c51de 100644 > --- a/kernel/module/Kconfig > +++ b/kernel/module/Kconfig > @@ -389,4 +389,12 @@ config MODULES_TREE_LOOKUP > def_bool y > depends on PERF_EVENTS || TRACING || CFI_CLANG > > +config MODULE_DISABLE_INIT_FREE > + bool "Disable freeing of init sections" > + default n > + help > + Allows users to prevent the freeing of init sections. This option is > + particularly helpful for syzkaller fuzzing, ensuring that the module > + consistently loads into the same address across reboots. > + > endif # MODULES > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 98fedfdb8db5..a5210b90c078 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -2593,8 +2593,9 @@ static noinline int do_init_module(struct module *mod) > * be cleaned up needs to sync with the queued work - ie > * rcu_barrier() > */ > - if (llist_add(&freeinit->node, &init_free_list)) > - schedule_work(&init_free_wq); > + if (llist_add(&freeinit->node, &init_free_list) && > + !IS_ENABLED(CONFIG_MODULE_DISABLE_INIT_FREE)) > + schedule_work(&init_free_wq); llist_add() returns true if the list was empty prior to adding the entry, so the functionality you are adding makes no sense with the commit log in any way shape or form. Luis