From patchwork Thu Oct 26 20:28:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 158680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp150940vqb; Thu, 26 Oct 2023 13:28:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsvx/7FAZO3Zuyx6CD+UAwqM0USw9MkhhU0wzDZEOtiS/6oD9skA8s0ipVYdHMQH5YLGBr X-Received: by 2002:a81:4c8e:0:b0:5a5:798:4f0b with SMTP id z136-20020a814c8e000000b005a507984f0bmr445648ywa.52.1698352116185; Thu, 26 Oct 2023 13:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698352116; cv=none; d=google.com; s=arc-20160816; b=H6IRHH/Y3k7cfkJWI0WLuB5zlpCWXYzR8AZ1Tux7g4r5mJpYwX9beFujAVq9CaR5V0 XirvlmfYTePi/OBQToea/54ySQ6oAru0wuGgGX8pJiNmSUn+2sP91vpVl4ROrI3UyXwh TJAVtBHQaZKcIfIM0YrGAqk2T5Xfl3v9A4Fc2T8k2vY216JWjq+4yq9N+cvKI7MdP5Vh Cxlj3MV3BtP8WtU5v1BzWWjCMLX1BfPPLeo28pngYrCh5adcpqyAtZ9xTZq8mwuWewC5 BwAHI2CpvZImGbCO5/nnFo7Gd3ykzSGGoWibL2bRy94Pb6jiOUfUDKnaGNmexVTJMa5b BfKg== 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=kXYcCHbJg58Ieumk8Pr2f/O/cn/d7Aaxj+WCDVOiCJ4=; fh=J1Qt2dYQZwHfoASHEf8Q1j6KnDtpzzpCUlDsDM7WT0M=; b=M+FOTqplDKKnON8+IXnZ1l3MulBi9kR4apBf0WkyjkZ0yuHjqg6yzZXQK/VfVHWvVO kTCgRraw4mU8RaZqlxANZTpw73JGwHo8Xv92mebyYIvQZzUhzu8aYYENmRbUKQ9IoIk1 gOoLH90xsXl6d5CvSRUjykyL13UPcsH53LcoSLbI49tQVvm4ONhTJXdEs8KxQVhwx7Ub s8drTNKxoLSnvB72HYMWkgA/YnxVAvNzUQtY2XXVIpK4A/E32tXw/wZntqnZvzdJxU1G R4GhQziF1mc4Pt3QqgwtqT/tnCCUb4t8nGkFANZeBC34egoOkjJinT7BfjQxsW5Oqp0S a3mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=W2lYs0jB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x184-20020a814ac1000000b0059bfb110b0bsi121458ywa.278.2023.10.26.13.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 13:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=W2lYs0jB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 92F0F823CEA5; Thu, 26 Oct 2023 13:28:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbjJZU2b (ORCPT + 26 others); Thu, 26 Oct 2023 16:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjJZU2a (ORCPT ); Thu, 26 Oct 2023 16:28:30 -0400 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68F29191 for ; Thu, 26 Oct 2023 13:28:27 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698352105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=kXYcCHbJg58Ieumk8Pr2f/O/cn/d7Aaxj+WCDVOiCJ4=; b=W2lYs0jBZASwDmrGC7f3bhRJi1VgwgTxiQ3RIZjGLNNdTO8/OPBdW4X4uhHMYI5OiC8QGP ciJayvPMPDdB7OySvUkmjqVOmTGfr2FVLWNih5vlqS6+fVpQRGEEEUtyYehvMmDP6rye5y TUAua2T66HZ38KRK+FAe2C1E7oaBx5s= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 1/1] lib/stackdepot: print disabled message only if truly disabled Date: Thu, 26 Oct 2023 22:28:16 +0200 Message-Id: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 26 Oct 2023 13:28:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780851268312251329 X-GMAIL-MSGID: 1780851268312251329 From: Andrey Konovalov Currently, if stack_depot_disable=off is passed to the kernel command-line after stack_depot_disable=on, stack depot prints a message that it is disabled, while it is actually enabled. Fix this by moving printing the disabled message to stack_depot_early_init. Place it before the __stack_depot_early_init_requested check, so that the message is printed even if early stack depot init has not been requested. Also drop the stack_table = NULL assignment from disable_stack_depot, as stack_table is NULL by default. Fixes: e1fdc403349c ("lib: stackdepot: add support to disable stack depot") Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- lib/stackdepot.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 2f5aa851834e..0eeaef4f2523 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -101,14 +101,7 @@ static int next_pool_required = 1; static int __init disable_stack_depot(char *str) { - int ret; - - ret = kstrtobool(str, &stack_depot_disabled); - if (!ret && stack_depot_disabled) { - pr_info("disabled\n"); - stack_table = NULL; - } - return 0; + return kstrtobool(str, &stack_depot_disabled); } early_param("stack_depot_disable", disable_stack_depot); @@ -130,6 +123,15 @@ int __init stack_depot_early_init(void) return 0; __stack_depot_early_init_passed = true; + /* + * Print disabled message even if early init has not been requested: + * stack_depot_init() will not print one. + */ + if (stack_depot_disabled) { + pr_info("disabled\n"); + return 0; + } + /* * If KASAN is enabled, use the maximum order: KASAN is frequently used * in fuzzing scenarios, which leads to a large number of different @@ -138,7 +140,11 @@ int __init stack_depot_early_init(void) if (kasan_enabled() && !stack_bucket_number_order) stack_bucket_number_order = STACK_BUCKET_NUMBER_ORDER_MAX; - if (!__stack_depot_early_init_requested || stack_depot_disabled) + /* + * Check if early init has been requested after setting + * stack_bucket_number_order: stack_depot_init() uses its value. + */ + if (!__stack_depot_early_init_requested) return 0; /*