From patchwork Thu Aug 10 07:47:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xiaolei wang X-Patchwork-Id: 133752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp261658vqi; Thu, 10 Aug 2023 01:10:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7CpCmPsFTjfamLjIF7c9DlqPn8DOLPyfwBUEG3Bpnk6IrpYzif2JQ+5Run3GHiz+JVIBQ X-Received: by 2002:a05:6512:1142:b0:4fd:ba8d:d4ed with SMTP id m2-20020a056512114200b004fdba8dd4edmr1043719lfg.24.1691655029186; Thu, 10 Aug 2023 01:10:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691655029; cv=pass; d=google.com; s=arc-20160816; b=fRXIlZztjX8hGLH7tzYYh62hUXfwVgTZ2CkhZRJK3jley5OtRWjpon06A7xOWyNMi7 hpo/NEEq/YOkJ5yrWsZ5SG2mnUyCQ27BCEq4Kg2DAuBX3aWfzlRdLXwQsae4UlYtxORg f7cXR/Itlz0fZton3RB5CWw1PhwirKLiGMuqx98dXpRfOUFbU+ko2RsTzxd+tlbCz67k oQjpMJZ3MMgjH6FHi0UPQceuPB9tbYGg/RgwlrcU74DwrY435/y8dtUbRYbtpb8iA7vD kQAs2YovMq67JM+RPCxlp8zYx4BLTOOXFH9zXN7xxEhBWxfDQQFrm4FBjAV4JUbl7Ryo n2Vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kO2unsl0pxbA2sfGTphXE1MHCO64iOliAz2mFZSmsc4=; fh=glBGht3B7KMhoGavPouAoC22VMdqX5IG52ihPt7JcDA=; b=aiiD4BBX4tVXZ5awLNFZ8mzGnmjbP+4dMagS4TPsmLaqhO2pf8mNOC9GYmmUZdCEzY BD81cB6Xf8kTKsmIBckmuVARY1KSVFstMakUVBYzVpL5SIsoXUkt8KcUuSOzimsUdiPr 2/EK1TduyzgWaBKlBnTCJQO7x8XSYUIn+AjgshQtdv8BB5N24os0d0cyLCfsC47dM37u 0153xS1FnQMxqbXPvbjNWLlKYkpRWeBBiFdjmn5987+a+G9+/ncS0/YIjVS2NYBkJoNQ 2UYyqhM7CkbPCzB9yyd0mWMLvqM1JrkZ+Z4oijE7ejEqAefv7iOn15wxuRzWpgyq/itr VlvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@windriver.com header.s=PPS06212021 header.b="Hmtw/Eve"; arc=pass (i=1 spf=pass spfdomain=windriver.com dkim=pass dkdomain=windriver.com dmarc=pass fromdomain=windriver.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=windriver.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo9-20020a0564020b2900b0052337ed4c3bsi1041260edb.151.2023.08.10.01.09.55; Thu, 10 Aug 2023 01:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@windriver.com header.s=PPS06212021 header.b="Hmtw/Eve"; arc=pass (i=1 spf=pass spfdomain=windriver.com dkim=pass dkdomain=windriver.com dmarc=pass fromdomain=windriver.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=windriver.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232289AbjHJHr4 (ORCPT + 99 others); Thu, 10 Aug 2023 03:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbjHJHrx (ORCPT ); Thu, 10 Aug 2023 03:47:53 -0400 Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD74211D for ; Thu, 10 Aug 2023 00:47:51 -0700 (PDT) Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 37A702ox014269; Thu, 10 Aug 2023 07:47:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= PPS06212021; bh=kO2unsl0pxbA2sfGTphXE1MHCO64iOliAz2mFZSmsc4=; b= Hmtw/EveHgAe+5MVMEvsozQMtUwCvVt5bmqc80EZLkynw2GdilhjXFIQpbG/QFxj wY3MlMvHfX0UvsPZjBcAvtff8DtIyypB3daNzdHsnQVZo+NTyvdega/ueZD3eshX vejFrvoMbKEm3dL4k/f0bc7C/eKzU5LmF3R/a9xWppQbMBmCVuNusMMYL1LM+Q+q H7zMDWLuD5uGD1s0y/E7JzSGbbfg5HwCATuoalKoPLo9k3AjJzdj3ejkoFoJLywG cc5RgzrVzvqf8Ee81iwapSDll98u0SxwJlseHgUwERvMS1t35GJ1Y65KuuhVk2E8 pKK0oYL3PfkmUCxf5xS+Dg== Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2049.outbound.protection.outlook.com [104.47.73.49]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3s9dd64msq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Aug 2023 07:47:27 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QszQvue1t7qm9J3IxwYscn1IY4OyTQ/8zyYqY6+CTiJj1Igf/3PHyEozJrnohNsG+flFUcuVfrxPBIeePQZSvBk4HzGKuvNgyiWZZ4VV46qZBc5CBRTd+/VvOR8gWZQ/39icTgGW+GrZeo6AVZqFjyhClTMPKQ/sDvazow8vCyTUcqJMt/Xbs3q4UC2yAFYZE+RH6l2DciJO9INLXAYS5YA3CSi2gpd5LQdWWncGSDl2oD+JiCKA6VpYxpTEvIAZd29YJ2uuSTHLiHy5dgMxxofNn/OFq1lSVTdFBHx5a1TrY2A3UcbwwZ1GxE4lsu0rbnVuvhpA76YY+bm4knbacg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kO2unsl0pxbA2sfGTphXE1MHCO64iOliAz2mFZSmsc4=; b=O/zeCeG64OMxsAdMOl5xgJRl7AD7f+9a9wypJpQNGeE0PHUcJS0/qpNNp4KGUdUBlsp8lSIGWytSPuwLsVYzQqsh5lFQPP8mus9VSrG18Px8OquaSmQTkCVZOBV9oCLHFjMlrIgUVclZiOerEpR7K733uQEfadW6Yg+YF3AK4Bkx3MKzkPz72O6kACBOZhZPdlMiLwYOhPyDoYYNX+OirOBij+LUSLWlTiaDvw9xACZn0RZjG1ieMD6BgB/nQZpJYi77ZBsBIj71QfrxpQJanRspBb+dg6mximan448h246Q02bqPNUuCM2NTWCgudoHPze8uqBPzGtCC3OHknDiYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from SJ0PR11MB5769.namprd11.prod.outlook.com (2603:10b6:a03:420::8) by PH7PR11MB7497.namprd11.prod.outlook.com (2603:10b6:510:270::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 07:47:26 +0000 Received: from SJ0PR11MB5769.namprd11.prod.outlook.com ([fe80::1b5d:f77d:a3c1:ce4c]) by SJ0PR11MB5769.namprd11.prod.outlook.com ([fe80::1b5d:f77d:a3c1:ce4c%4]) with mapi id 15.20.6652.026; Thu, 10 Aug 2023 07:47:26 +0000 From: Xiaolei Wang To: catalin.marinas@arm.com, akpm@linux-foundation.org, glider@google.com, andreyknvl@gmail.com, vbabka@suse.cz, zhaoyang.huang@unisoc.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] lib/stackdepot: Bail out in __stack_depot_save() if the stack_table is not allocated Date: Thu, 10 Aug 2023 15:47:03 +0800 Message-Id: <20230810074704.2042664-2-xiaolei.wang@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230810074704.2042664-1-xiaolei.wang@windriver.com> References: <20230810074704.2042664-1-xiaolei.wang@windriver.com> X-ClientProxiedBy: SI2PR02CA0006.apcprd02.prod.outlook.com (2603:1096:4:194::8) To SJ0PR11MB5769.namprd11.prod.outlook.com (2603:10b6:a03:420::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR11MB5769:EE_|PH7PR11MB7497:EE_ X-MS-Office365-Filtering-Correlation-Id: 204e435a-0cae-4280-0c50-08db997609fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ocYoDtvZvI2IdH4t1oJTzKBxV+B3mJkzys/E62kbmA7O7w7SBc+IJmF6+PLGdPpi0fbFYErk/hQ7zs7ZgE+bfBL96Dd63EvN04jLn2uer+e/mMQjRShjuHKFU3vfUn1c7ZfIgMTQS5Q4r1AwaqM0j3AyQnPQGJVQwTTFYVn3dd5EeHs7cw0RaJBF3kDB2r5jfidynt3rbK2SE8tAOTnMJfXh1KDCMSkaOCEA6EJ74vx+iz4l+tSQ61AQRJmuq2BsKLgvyxSUP3jXOpm6kT17hixQZ2obBFebKpGx1l52PdvIYdk2l5JVNLzaeSWyK9CfDRicqB7RVShX/Lm6TbSrQPPJV7iJzcW3nSvr+/VgO5c6Izo9kq85wj8VCZ7sVJZB8u/R4wN+I7Ovejz847BGP1I6jrQn+zo8xfjn9xTzPBf89nN+Gqqb5FnersNHTuHLGUEjE/OXZ5jWuQTpQJ7ZMBaWck8StV8xQYxZEdNCg0srs0C94dR3z3cwQJE8V3juk6W80CyycBPGG+z4GQvXdmqSIvLL6m3vCk2aMNc0gMkxeObyy6OVMrkLHCuA6H8M/mzv4jqazET+XJvzidRWv7fTlsqM0CXj2rLKu/s8kCM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR11MB5769.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(376002)(366004)(396003)(39850400004)(186006)(1800799006)(451199021)(2616005)(316002)(86362001)(478600001)(6666004)(6506007)(26005)(1076003)(36756003)(5660300002)(8936002)(8676002)(44832011)(6486002)(41300700001)(6512007)(52116002)(4326008)(2906002)(38350700002)(38100700002)(83380400001)(66476007)(66556008)(66946007)(4744005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iP3OaXL1JR7WFvIXLAnb1cnoK8BLABl86HmKV7icXHHPuSs7kvM/+oZPZchTEE3qAMJPPdJvmVnpghoxbLFqq/DjX3gh9jczg1plPamsnrclddcKsKWyyDPZKF1EcS9YJFwfNX3ymZwkB6Xsdpd0V/wzcLO2Cy6URXk/ZeGlTmD/zi73Mlsx8W4bUuV05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tc0KE08PNM4afkFzOJ4g9BxS9Un0540kkGrFrN4AYzCFRuig/+gigh4CgLoJ63bvRRxBbKfp1KpFVEQZw352ADvgE0Y4q4jXiyXy14hXoTM6l+sNoVyYwTyCsxw9U0IvCk94yursQi9AkH9qTuu9ywLgzhs2Xxs4woiLnZqOd7YysYmxfi6jnbnf22EGHXY18BzujI1nmzb1K8nlkHRl3gMXi1kFB8r/5/ZztbH4KN6YehzLtJtZqe74RmOdkYtAV9gQ5fA8IYKkT/nKGCak5ZqyOhCRAAAxWtVDrEELN5zhPKmLhe+0Fzwod6zzDMX+zudpzFAmrCTX1+pycsbK+Kr0fSXeVqMg== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 204e435a-0cae-4280-0c50-08db997609fc X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5769.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 07:47:25.9542 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CndRtmNA/YyU8Bcd65+FHXNLfmjaDsIwfNGEVoOcv7Hd4ANwPiCPhzpoP5yBz7At7xbbv//hG++hu0K4Pi9TJJX/3/nkgwh3brqHJ6GNonY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB7497 X-Proofpoint-GUID: 24tkBtBO4qCJRhzpj64h80Heo7lmGNAY X-Proofpoint-ORIG-GUID: 24tkBtBO4qCJRhzpj64h80Heo7lmGNAY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-10_07,2023-08-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 mlxlogscore=645 impostorscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2306200000 definitions=main-2308100065 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773828863887111727 X-GMAIL-MSGID: 1773828863887111727 The __stack_depot_save() may be used by some subsystems even before the stack depot is initialized. So add a check of stack_table in __stack_depot_save() to make sure no oops in this case. Fixes: 56a61617dd22 ("mm: use stack_depot for recording kmemleak's backtrace") Signed-off-by: Xiaolei Wang --- lib/stackdepot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 2f5aa851834e..a0651d013a0d 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -376,7 +376,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries, */ nr_entries = filter_irq_stacks(entries, nr_entries); - if (unlikely(nr_entries == 0) || stack_depot_disabled) + if (unlikely(nr_entries == 0) || stack_depot_disabled || unlikely(!stack_table)) goto fast_exit; hash = hash_stack(entries, nr_entries);