From patchwork Thu Sep 2 00:01:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12470573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C83FC4320A for ; Thu, 2 Sep 2021 00:02:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFB706108E for ; Thu, 2 Sep 2021 00:02:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DFB706108E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6FDC98D0001; Wed, 1 Sep 2021 20:02:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 679CB8D0005; Wed, 1 Sep 2021 20:02:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B9D68D0003; Wed, 1 Sep 2021 20:02:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0029.hostedemail.com [216.40.44.29]) by kanga.kvack.org (Postfix) with ESMTP id 2D45C8D0001 for ; Wed, 1 Sep 2021 20:02:17 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DE542182B1DE6 for ; Thu, 2 Sep 2021 00:02:16 +0000 (UTC) X-FDA: 78540681072.15.2321DDC Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf23.hostedemail.com (Postfix) with ESMTP id 71AD09000093 for ; Thu, 2 Sep 2021 00:02:16 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 181M53aK027790; Thu, 2 Sep 2021 00:02:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=lqnUUbmRDtDRUEQgPqfI+GRnc7Q8MIezD7vOgcm6jjI=; b=HJ3vMvf/SiHHC5/85w9ZyuvHEi0AlRmNO5WYq2KpcYjcwanvhu/My5ML8m4r33jBrgpW Wgumc2A3dZz5n2WEbAhMJdeMlQ0W7vFpP2s2+t2Rg/tiM7jMNYCESzvWVSQypwHTOD0b EKD6ZL0EFXYBCnKk/fnk1B+g7Hn89JlVKLADIUJWHwKEXyLgqSB7y6ekb57OMfGSiBfA QNYqEnDs9iLoVJ+keO6bFMn0hNerdtKwLAjqhk9nB5uvhzkuC3yc56OALnIjy3X4gBVy vBlAMqW4Ps5IhM++famaJEpLIscD2vH/nhWORnEUlXCUaKDqCALc6InxpZ7P72WG55Ip 5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=lqnUUbmRDtDRUEQgPqfI+GRnc7Q8MIezD7vOgcm6jjI=; b=tvpdwZkxkZlzz5rMXg0FxQ5KQVykrHCvdvhENWm5hWmszseI5aUfxDhUCUjEz0TRSfDG F5EtuyNWVEmaHVFnmuUkP0x8aVoyEASLJXKMC/6XSgElu6xYQrMQUkRLoH5gnUeEr1// nT8jER3ZGy/7hcmhpPhtn6K/Rfll2Ly7OpvM5bXjW7AeiB4Pu+93m1F6iD7nP1GfjNPx e7hl8rQiz6pvDr/DStZRGr5xUaPM1+PxaJzGHB+WxnwcvXqwTR9J+Dy4jJAjWEB+L8/l 8V6OtZHNfkAHdZ+WLol5FB6bF00FenYBM6aDWS+HAUyNPTwaLj0TtlMEsEY10G0YXYKx cg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3atdw00w50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Sep 2021 00:02:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18201p6t155792; Thu, 2 Sep 2021 00:02:13 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by aserp3030.oracle.com with ESMTP id 3atdyw5pgk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Sep 2021 00:02:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oz4u6oK6uLBMR8M4WDIjxUGXXb6Resa1WxwBS6Exw8JXdiPcj0OHt3brgzMBmajG0zN+hCk/bl+E2DLHUGimvdaFv0TA6r0OAHRs/xRDUt/Hko2FV0lP4fptKROurtuQ4xRU9y1DecMiiSZvPGk5As22npQ7CgUCGcgybInvFlpoOw+hI9T7w7oLBpyhf+ZNWLM2Iet3Qvsd2+vtjAlD/Vw48cTXgXShz9o8RpNbJ4oXblP3c7nQ6JAE7QYZdr+RbGH3JEQgEWMLqhAtUeWLiKROYk0VTg55zU73szQNvgrerlThcLhkBFoLqC9jfAUzeFH8pe0RNkeZUSR+/RzqDg== 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-SenderADCheck; bh=lqnUUbmRDtDRUEQgPqfI+GRnc7Q8MIezD7vOgcm6jjI=; b=c2aU5yCh79tGOOqtT4vUqoWeqyF+3CWOkC6j2swC1dturpkyiDdAOCyzzk5vZ18E/nlsiqSnkqM0HqJB5d3Mb5BfmzkK4QeGG97KEzHr7MERNDCK0FqVPHImR6mOKAVDEXef78ABEXyZ4tXpRLLzKBiediiYswRDlhcMw9vZXsiumskSkbQbIHt8i12O/Qil1JwidiHnkKoofXETNn1llix8ABlogywsmfzR3tVd6I6Qd3N9v02qBi5zvSrT9KYRhv3syME1SFjS3zxi1GrQWIjlg9XgYOfoz/Mi3ermhmsj54Jbqd44XGoQ6yE2v8YNiocFlpFG87asXLNSqbveGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lqnUUbmRDtDRUEQgPqfI+GRnc7Q8MIezD7vOgcm6jjI=; b=R+mky19r/H7M3LLAesLEwo8kWvfiYA5owPNjpLuSlVLEv98yylMPyowZdsXqrLmQPpM/Cq0bBXv2f8Ebe2hVryrTSdkTCItLkdeOIY1G0VVwcoWUqgyc9MiH+8nPfoqJKMKcluIb5XAB/eFt660xSHd4exX1MeJhxBR2+xu2GdE= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by MWHPR10MB1999.namprd10.prod.outlook.com (2603:10b6:300:10a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Thu, 2 Sep 2021 00:02:12 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::e1f7:a0f4:46c5:3df]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::e1f7:a0f4:46c5:3df%6]) with mapi id 15.20.4478.019; Thu, 2 Sep 2021 00:02:12 +0000 From: Imran Khan To: vbabka@suse.cz, geert@linux-m68k.org, akpm@linux-foundation.org, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 1/2] lib, stackdepot: check stackdepot handle before accessing slabs. Date: Thu, 2 Sep 2021 10:01:53 +1000 Message-Id: <20210902000154.1096484-2-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210902000154.1096484-1-imran.f.khan@oracle.com> References: <20210902000154.1096484-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SY6PR01CA0009.ausprd01.prod.outlook.com (2603:10c6:10:e8::14) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SY6PR01CA0009.ausprd01.prod.outlook.com (2603:10c6:10:e8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Thu, 2 Sep 2021 00:02:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6f8d4cb-7161-4682-2be9-08d96da4e9f8 X-MS-TrafficTypeDiagnostic: MWHPR10MB1999: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iIDP7UmYmHEVvk72Xjxhfj95UJgiyG4SFx/Hz3tGjxfcflHXNxxoKqX8f54B6qAatZ19tKy1rzFKjHZKe0rRYnLIBuss7EZ4O4Bdu3LdUCXcmqSEsPJi+2iRc/fhcnOaAgS9Mz0hZprc7jXz0gpbPsbWfyHkKqbkqBDY+w2S0+CV33F4tR02NTgAuM4BbY4gIkeoI7u9j42wc9iDmesKW1aAB014xe9X8lIHeBiCzidpXts/ZOl3BAkS2l2RgN/Znb/kzNSmgcxwWzNx0PIgcSl7KaY4GhxEDIVzzKK2+8FKOUxFMf2gIkZ8TkCe01tS/hEsX3/3ti7IxAxdt98qcQs+qmt6LWuroliVg2L4xdzyM4nHAU+UQ9JbI2efGSkuy6yFZwrAKsgZlkuMMnj88VNY3i4/gL8hvNDpTMMp+PfqGBXPM+zpL3KGtFUceWa3D+CPZc6zpGmZqRyWwIWly9VjcNzh3pz96KctbaC7A6ZxzUxoQh0ym5l6VLOek3a/DL2oxm3oJw7XZBaG95hE9oj0X2M0Tz4d2bOjGVQGvoS8F8ZzxDVOTLZ0/H3k2vh95ab1syNBVSA/i6ulel68Wl2IphXNIkzo7VLI7oI20ofpw3BawxghXuEiY0nN+A58qCOPCqKv/ZQDY+hMo/WJ2zIufXLkE+K/iaw0DJe8MfTBUr+t67Zn64//IlLaKAxUCP1dXvHa8H4xFfZ1ues6rw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4468.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(376002)(346002)(39860400002)(136003)(66476007)(66556008)(36756003)(1076003)(5660300002)(8936002)(52116002)(6506007)(8676002)(316002)(2906002)(478600001)(6666004)(6512007)(956004)(103116003)(2616005)(186003)(86362001)(6486002)(38100700002)(38350700002)(66946007)(26005)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Ch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ldDXc1HkQT3mxBCmcD+3I6ahKpNdSoBIKUyLTBwCW9bJXQC03i9PdS5VV0ZoBrEiYi+6wvaS/MKyius4B3QNS3+8db1Fuxsi5vJIBwmsC+hUoEDk4E57+SmkGVLteWrDB0KGMd8wqaFOofsglhpBgtCKXTrKheac7ighhpeHrAupWIZPbmXljw60AE31iT8M/RO7Fsl8g9EYYnvgppxWkq8V3UGZIgrL8gLvTdHI8JuhYxxKY0rlU/tUVZvYEDvS4jmhuGXpN3II6AKeMinO1ba0AGhS/IZGDBlib9cAP4RCpJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6f8d4cb-7161-4682-2be9-08d96da4e9f8 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2021 00:02:12.2153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 22FzBX8wqsqSFx0+E4kzObcjg8o951D/g28NDkdq91uo0y4Yt/IqyBbYXGlREnTPaJc5sLtzi0w+YPgHdJfcVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1999 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10094 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=961 spamscore=0 phishscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2108310000 definitions=main-2109010142 X-Proofpoint-GUID: KIQAn8PNIMQbP2KwYLHXjWEaPucXewF8 X-Proofpoint-ORIG-GUID: KIQAn8PNIMQbP2KwYLHXjWEaPucXewF8 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b="HJ3vMvf/"; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=tvpdwZkx; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=R+mky19r; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf23.hostedemail.com: domain of imran.f.khan@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=imran.f.khan@oracle.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 71AD09000093 X-Stat-Signature: xroerhqezcgu66qh5zy4x77r8tt9j45o X-HE-Tag: 1630540936-222734 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: stack_depot_save allocates slabs that will be used for storing objects in future.If this slab allocation fails we may get to a situation where space allocation for a new stack_record fails, causing stack_depot_save to return 0 as handle. If user of this handle ends up invoking stack_depot_fetch with this handle value, current implementation of stack_depot_fetch will end up using slab from wrong index. To avoid this check handle value at the beginning. Signed-off-by: Imran Khan Suggested-by: Vlastimil Babka Acked-by: Vlastimil Babka --- lib/stackdepot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 0a2e417f83cb..67439c082490 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -232,6 +232,9 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle, struct stack_record *stack; *entries = NULL; + if (!handle) + return 0; + if (parts.slabindex > depot_index) { WARN(1, "slab index %d out of bounds (%d) for stack id %08x\n", parts.slabindex, depot_index, handle); From patchwork Thu Sep 2 00:01:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12470575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8103CC4320E for ; Thu, 2 Sep 2021 00:02:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 18F19610A2 for ; Thu, 2 Sep 2021 00:02:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 18F19610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B38A58D0005; Wed, 1 Sep 2021 20:02:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABF788D0003; Wed, 1 Sep 2021 20:02:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9391B8D0005; Wed, 1 Sep 2021 20:02:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 829548D0003 for ; Wed, 1 Sep 2021 20:02:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 46F9229DE0 for ; Thu, 2 Sep 2021 00:02:25 +0000 (UTC) X-FDA: 78540681450.02.B5CED5E Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf02.hostedemail.com (Postfix) with ESMTP id BFD717001A23 for ; Thu, 2 Sep 2021 00:02:24 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 181M8Lj8018844; Thu, 2 Sep 2021 00:02:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=PcB4KxgkbWGkMzpop9hfst2VcB1Zg8grq9XHeeW1XR4=; b=Invzd6NOz14/asdbs4euQK58sBgAP8Xu7PonZY7TuFJ1KgnXLwsOFg318Z8kSzNIKoP8 QcJGShutydaKwUOkYmmNFUwpvNXhqxI0juIeHqKQW6SBEg9lI+rMjFYWJPTOIIHvyUgt 4skYGlDItbhT6Fjsr2wiELTMMxUmGgwEWbfgxKWXUCCe+eiLtjtWpP1k3gdHEV7WyLzq YfxnIDFgc59wx3Vim2AZRMszyRVL6COATJEbjXFYZZdY3n/rpcaO+PeHQTjhaYAa8FMT q9k7HMiffUymp+KHD4NjnttfamrV5J4G3wMtzbgwxEGRHEJITQdlBYnD/p1wrrnTtj7h RQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=PcB4KxgkbWGkMzpop9hfst2VcB1Zg8grq9XHeeW1XR4=; b=Cl2GgtNFC25wW5ID6uMGJM6J4rQpK77mWcXjczGGc1F97eSid4zM8m88RsevlBNUDn/V FJXVJH4s9/XDcxxA/mBwBq5KLKr1qtRdHfinDnQk8QGixYQoGag0XUAcT57vVZOUKfgV 4qM73Iy2AhFyzR39d28mYxTNvNEIm6FXjXMFMFGrSRJB9riO4uMaRFA2zKPX+VtM5JuW 4N01eBNoQmZe/g9lmjNdOubCkJUPprocH32Gimn3dJSS//dOVTMPD3bK30cPTaQunUXi XeHABp9ElNxkxsmXZdgAnE4X+44BBo46aEKyYcs50wTU5kplqBld0ahj6zvxu4Oja3Ei YQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3atdvygwcv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Sep 2021 00:02:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 181Nxtmq098749; Thu, 2 Sep 2021 00:02:19 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by userp3020.oracle.com with ESMTP id 3atdyxxxnt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Sep 2021 00:02:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gs27f7zkw5yZhm9MKusZEnU6P4/eWNs8FzKJdnGSsA8+pOsloIYQJP/p6r0DIcwSgSf3isQ3gDbIc5xQqm0GxokzJ2wQhyAN7BCsNKHUZgN6FIsqxaqZGN7FAlMZVHXUC2A4gdbztvfG2z58Z8vzDnP1rj/Wcr7/YpRqak/tFHBWmLmAZlGLhwi5Kqsng5LsFMQccux1XMrgY16K7Y6uQWBvl+CC9EsYDTJYoa72cY1+A9qbcHhitEA5lBu/HT2XyKwsi8PnxeGONRDkwA4aMXu7vV/ECGhYl9VcAeLTO7dwVZhTfmpffrGFkL5rzir3vE9QDqu4MwTIp2n7FIZoSg== 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-SenderADCheck; bh=PcB4KxgkbWGkMzpop9hfst2VcB1Zg8grq9XHeeW1XR4=; b=P72ImoMzAw/IGqU1K68rCbVC16lJb/0qyI4UQkH9M29/yfpGlxgQMLjCEEmzbNUxW4LLlt8eKEaaTCr/2aozuwD+0MeFeHAMdNWcq1TTAd7b1urobwfK+cTdFYf5RApOMf9gAY3bRcSrSLEUjMktIuhkc9O6EyC59aeJyKgC+r7mhc9N8lKEQZNbG76wSg1h6cEnUjdW9ljSTgnvlGDLM//one2gzN/YfBQmIVvIrjaZ2tv/vQ4LXx9dWVRSz/Zch8CnYi7OmxGpOM6PuPFg6ylc5D8KNcok9R6gNSarrRah4gULT7kyfx4eiCb0tw/7zKqqV4CoDOyGepZt7jg+VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PcB4KxgkbWGkMzpop9hfst2VcB1Zg8grq9XHeeW1XR4=; b=F36T4vyTWZyxON513UIx/K8zwVLD348fkk/xGV9XH0rEqr5HIctVz9lc7vPybguqwpMXfaknES3Ais8t7JpHhQMyAWZtMxcTDoTGmiz4U7oAIqClMIDBs93udSGXffx7zwkwKrKkbQ7bfPkgkUth51K83pfYXv0OOde5bqO9oYo= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by MWHPR10MB1999.namprd10.prod.outlook.com (2603:10b6:300:10a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Thu, 2 Sep 2021 00:02:15 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::e1f7:a0f4:46c5:3df]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::e1f7:a0f4:46c5:3df%6]) with mapi id 15.20.4478.019; Thu, 2 Sep 2021 00:02:15 +0000 From: Imran Khan To: vbabka@suse.cz, geert@linux-m68k.org, akpm@linux-foundation.org, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 2/2] lib, stackdepot: Add helper to print stack entries. Date: Thu, 2 Sep 2021 10:01:54 +1000 Message-Id: <20210902000154.1096484-3-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210902000154.1096484-1-imran.f.khan@oracle.com> References: <20210902000154.1096484-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SY6PR01CA0009.ausprd01.prod.outlook.com (2603:10c6:10:e8::14) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SY6PR01CA0009.ausprd01.prod.outlook.com (2603:10c6:10:e8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Thu, 2 Sep 2021 00:02:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9fd33a3-71bb-4146-4ae2-08d96da4ebec X-MS-TrafficTypeDiagnostic: MWHPR10MB1999: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:147; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UeRr9NQSwbrzJuM6PAafV5VVly41lhH/frSK7psQgeqyDkxwohKx3uKwpXWp4q+rbSYfse8lY/eijnFKy3wsee90y5kApKmTFPbu7JHeIze/fBQbXSs3LFdM/zZnvqy21+mp2mzOP93Ti0TLOaTjn8ascVrg0mnGHuAzDYT6HpnS14TS/Y0yI/okZyt55sKTm6i5iUJdOsFVdrz/Jamq3lmciCs9SquofKvMzUvTSxaQIE6Nyd/YWxTRZtI0ALTSPuzQZ3WF5Rw0xcaqEU6Dq6OBmq+41U1yFZZY+IkXkkf0Ad+bu7utyaRpNiwxadjTvblOSPltQZSfnGJArzKfZvRgXm6zV9KuHmP28uPycAp+9HQhZ5A1N6CVlENjMrpicF8nLZ9j+fMyKcZUDF1OG7bNqekB465DrDrWu54/hwZNMe+1wSEQDvZ4gAHz40s37WfK/pe+sB5YdUVdnuNbuCON2zLrx194jp1Vu9031OngW4ElsULk9QxT/2tm+TJMs71OG3ZTdx3/5j5w75ph9GkNsKHtD6mrCxbS8mED4vVpdbqYcGSw4d4I5YuFSh3eKW9M00xco9sWKIWRoQPXLyZwg38La/xuAnWrTyx0ZLpwLk/J25w6OraF17OlPmwXQKmXwAMTggcxSEC4+cKRz/D+Nn2bNfPRtuhQ0nN8vfuy43xsg+sM0lTf5bzQvumPVd3eS3IEDwBkMCiyGHQRwA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4468.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(376002)(346002)(39860400002)(136003)(66476007)(66556008)(83380400001)(36756003)(1076003)(5660300002)(8936002)(52116002)(6506007)(8676002)(316002)(2906002)(478600001)(6666004)(6512007)(956004)(103116003)(2616005)(186003)(86362001)(6486002)(38100700002)(38350700002)(66946007)(26005)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GYyqh2bimr8qwer62JjyEQuhkKYK8ERz6tzINjK5MLs1Ek2r8m9qr1gpwUGY73b/S5V0qxwvDguxaoiVYQAUb32XqyciuGlV+QjYE6jfB0XiYLG3an5uoD4dVCoFGIOtQriB3HHjnZxyWj3uKRmGbLs9w/8Sdv+jUMU2HkIwEEbL4WBOmJmV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BFHh1P+AY63FMmetTdD//FMbBy200H0QLkqVMtNguZMlqjdJbTNDZ2/jDZWbYnK1r2sXJoysZg X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9fd33a3-71bb-4146-4ae2-08d96da4ebec X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2021 00:02:15.0797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PKFQcDcErdncgJ8r73OnPM/RUk7gpK3VcJ0AVfq0BTQvNa9BSTzu2C8pLAgcjSV2Q3b8JGZAakbaeO7wVFbWLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1999 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10094 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2108310000 definitions=main-2109010142 X-Proofpoint-GUID: rQsZl1CEoPs-Yff_08Ibe7i9Dq7tP4Te X-Proofpoint-ORIG-GUID: rQsZl1CEoPs-Yff_08Ibe7i9Dq7tP4Te Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=Invzd6NO; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=Cl2GgtNF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=F36T4vyT; spf=none (imf02.hostedemail.com: domain of imran.f.khan@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=imran.f.khan@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: BFD717001A23 X-Stat-Signature: nm71j759k4dc1jnrq31tshf8mdfimriw X-HE-Tag: 1630540944-793695 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To print a stack entries, users of stackdepot, first use stack_depot_fetch to get a list of stack entries and then use stack_trace_print to print this list. Provide a helper in stackdepot to print stack entries based on stackdepot handle. Also change above mentioned users to use this helper. Signed-off-by: Imran Khan Suggested-by: Vlastimil Babka Acked-by: Vlastimil Babka Reviewed-by: Alexander Potapenko --- include/linux/stackdepot.h | 2 ++ lib/stackdepot.c | 17 +++++++++++++++++ mm/kasan/report.c | 15 +++------------ mm/page_owner.c | 13 ++++--------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 6bb4bc1a5f54..d77a30543dd4 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -19,6 +19,8 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); +void stack_depot_print(depot_stack_handle_t stack); + unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); #ifdef CONFIG_STACKDEPOT diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 67439c082490..873aeb152f52 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -214,6 +214,23 @@ static inline struct stack_record *find_stack(struct stack_record *bucket, return NULL; } +/** + * stack_depot_print - print stack entries from a depot + * + * @handle: Stack depot handle which was returned from + * stack_depot_save(). + * + */ +void stack_depot_print(depot_stack_handle_t stack) +{ + unsigned long *entries; + unsigned int nr_entries; + + nr_entries = stack_depot_fetch(stack, &entries); + stack_trace_print(entries, nr_entries, 0); +} +EXPORT_SYMBOL_GPL(stack_depot_print); + /** * stack_depot_fetch - Fetch stack entries from a depot * diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 884a950c7026..3239fd8f8747 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -132,20 +132,11 @@ static void end_report(unsigned long *flags, unsigned long addr) kasan_enable_current(); } -static void print_stack(depot_stack_handle_t stack) -{ - unsigned long *entries; - unsigned int nr_entries; - - nr_entries = stack_depot_fetch(stack, &entries); - stack_trace_print(entries, nr_entries, 0); -} - static void print_track(struct kasan_track *track, const char *prefix) { pr_err("%s by task %u:\n", prefix, track->pid); if (track->stack) { - print_stack(track->stack); + stack_depot_print(track->stack); } else { pr_err("(stack is not available)\n"); } @@ -214,12 +205,12 @@ static void describe_object_stacks(struct kmem_cache *cache, void *object, return; if (alloc_meta->aux_stack[0]) { pr_err("Last potentially related work creation:\n"); - print_stack(alloc_meta->aux_stack[0]); + stack_depot_print(alloc_meta->aux_stack[0]); pr_err("\n"); } if (alloc_meta->aux_stack[1]) { pr_err("Second to last potentially related work creation:\n"); - print_stack(alloc_meta->aux_stack[1]); + stack_depot_print(alloc_meta->aux_stack[1]); pr_err("\n"); } #endif diff --git a/mm/page_owner.c b/mm/page_owner.c index d24ed221357c..7918770c2b2b 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -394,8 +394,6 @@ void __dump_page_owner(const struct page *page) struct page_ext *page_ext = lookup_page_ext(page); struct page_owner *page_owner; depot_stack_handle_t handle; - unsigned long *entries; - unsigned int nr_entries; gfp_t gfp_mask; int mt; @@ -423,20 +421,17 @@ void __dump_page_owner(const struct page *page) page_owner->pid, page_owner->ts_nsec, page_owner->free_ts_nsec); handle = READ_ONCE(page_owner->handle); - if (!handle) { + if (!handle) pr_alert("page_owner allocation stack trace missing\n"); - } else { - nr_entries = stack_depot_fetch(handle, &entries); - stack_trace_print(entries, nr_entries, 0); - } + else + stack_depot_print(handle); handle = READ_ONCE(page_owner->free_handle); if (!handle) { pr_alert("page_owner free stack trace missing\n"); } else { - nr_entries = stack_depot_fetch(handle, &entries); pr_alert("page last free stack trace:\n"); - stack_trace_print(entries, nr_entries, 0); + stack_depot_print(handle); } if (page_owner->last_migrate_reason != -1)