Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp11387rdg; Wed, 11 Oct 2023 18:41:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET52MW/lNa7IP1WieWzo+pZ7MYUZdwOmUqXnKqh0FMmz4dd60xs6ZsxsGN0Pwtxu3ObZOw X-Received: by 2002:a17:90b:1b4f:b0:27c:fb63:9c89 with SMTP id nv15-20020a17090b1b4f00b0027cfb639c89mr4763143pjb.0.1697074898013; Wed, 11 Oct 2023 18:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697074898; cv=none; d=google.com; s=arc-20160816; b=qaDtA62qQLMIttxsEg1HrkcLra0cwpfTZLAgcqiKToUOA/XxzFGuByIhb+xjePJkdA B0+OHvMZnKXbu7jZjayPpCFipCLCiODrNGshKUNLiylZfGK0H1VOZqb6PN0AOUxmLqJO h9lecdtv2DUAIA9CFltAvbTnpUX/buj6uB7lKUMNrZeJfB6hammArGScGsB4g4DpRqN1 5nmpsM+CD2GDvg7FN4kt9hX1N8fyxUTGrN3DzsMI+dwm9oxMnQcEE5bew9Oc98Wk4ur1 ob/eB+VQAistPsN1g9Oac73gm8Oog0Wz4I9I0iDAI0FluaOaxZMD085XicSzdrAQrX1+ mgNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UQIheOsqvn5ZbIDPMFljWaqWRk+AS+WNufhS+BGF2Ls=; fh=5YBmAF6SiFPK19yasnrFcO3VT5KcPKYZINskqAtrAh0=; b=EphlX6MSKTdBzkE1RikHtgDTNBC4M/wqIE+kQPHewU8SMbkH7qez1qyGJ9nZF7U02Z +9EC7w1WDXFlblcw17CHfBQyOyPz94iLdFas/orPkxI10EMSMPsKxyOOogUzWgRjFPrb s3Bkn9btHrXpqMblC8UGIyCaXZiODdM2FiQzKeXOyRPX3T0E69rxqZ5F8Qj0mASDtjqr lnrQedFm1BSM5tNXtc9P8UGkDSStnChJGBr+HERaEmWLo1NauzSgBOkWUfAuCc23DZDU k87TvQYHkSwra1oYpY7Tzx6KCEQHXuPu5UZt07xv6Kdl6FQ1M2BG5fk7X9WQKt+7inV0 mieQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZDePl1ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t14-20020a1709027fce00b001c9af74feaesi999084plb.215.2023.10.11.18.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 18:41:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ZDePl1ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 67007804764F; Wed, 11 Oct 2023 18:41:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234080AbjJLBlZ (ORCPT + 99 others); Wed, 11 Oct 2023 21:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234068AbjJLBlZ (ORCPT ); Wed, 11 Oct 2023 21:41:25 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF49C6; Wed, 11 Oct 2023 18:41:23 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39C1FQ3m017544; Thu, 12 Oct 2023 01:41:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=UQIheOsqvn5ZbIDPMFljWaqWRk+AS+WNufhS+BGF2Ls=; b=ZDePl1kyw2b7rxTClv1BRkiG2HuNv0wqsxevYZnPqeEdyhCoxRifjWwiI0LhzL1lPXrH tNV/7JnYtI+mnSXh+NuDOuYI0Lwco25c7uXg9nwMDmel21LBJ5OxOD966dxVfoqyVUFk 46HN3R6C6Hmu1erTrPD3nc5Z4RB0NHVrh/eqxkipCO4/2LhIHZevCwc1Xf9uRAv+dIEw lHz3FlRMi4uFEcYEcbXqhUP/1zCggfJk/Oxl1MXPQAodCa/HhdT280ZkPL/Io/Tu48NM oQJ+Ce+senWzXrOV0RTYHUzQ3JnMtwyJ7Mk0R2PnHTJWvi5h6dAgRTFwYLxeX2E07v5g 7A== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tnkwnjrd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Oct 2023 01:41:14 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39C1fElE006460 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Oct 2023 01:41:14 GMT Received: from hu-jiangenj-sha.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 11 Oct 2023 18:41:12 -0700 From: Joey Jiao To: CC: , Luis Chamberlain , Subject: [PATCH v3] module: Add CONFIG_MODULE_DISABLE_INIT_FREE option Date: Thu, 12 Oct 2023 07:10:11 +0530 Message-ID: <20231012014012.9030-1-quic_jiangenj@quicinc.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: zGy8rx1h8tt5MnbW9T97Roc3Y23dtCeu X-Proofpoint-GUID: zGy8rx1h8tt5MnbW9T97Roc3Y23dtCeu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-12_02,2023-10-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=905 lowpriorityscore=0 bulkscore=0 mlxscore=0 suspectscore=0 phishscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310120012 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 18:41:35 -0700 (PDT) X-Spam-Level: ** To facilitate syzkaller test, it's essential for the module to retain the same address across reboots. In userspace, the execution of modprobe commands must occur sequentially. In the kernel, selecting the CONFIG_MODULE_DISABLE_INIT_FREE option disables the asynchronous freeing of init sections. 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); mutex_unlock(&module_mutex); wake_up_all(&module_wq); -- 2.42.0