Message ID | 20210902000154.1096484-2-imran.f.khan@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=eNaS=NY=kvack.org=owner-linux-mm@kernel.org> 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 <linux-mm@archiver.kernel.org>; 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 <linux-mm@archiver.kernel.org>; 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 <linux-mm@kvack.org>; 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 <linux-mm@kvack.org>; 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 <linux-mm@kvack.org>; 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 <imran.f.khan@oracle.com> 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> Content-Type: text/plain 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: <MWHPR10MB1999E5FB4910A0033E9758D0B0CE9@MWHPR10MB1999.namprd10.prod.outlook.com> 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-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gjgmWO8k1vK6KLqURL/XlalxTwc1w/FE0DTOpGLE6apyR+rqxDjooo9QA4paxLvX0LbNHzBoRX2AVWYvmkNgQQTbdYlBy2Ym4LQfLR/bYYM2XatLnImO/BY67rOA7ZU459+OVqpXdmUIsRVzFVLZn6vV7XOR4hmQ+jSwDdlFfB9KeZrh7Ai0ShhJcYO1kKn2yJw80JvUdF2NMkFOcjtaC2zmDMxyaW5bUP6RITJXSp1+95dpdO/eQw8Q01ZyMiX511iXi4E40t2+J2cGjNATv/JktETm+3+jAzvoCS6AUQb5mgQR53Sjorbt0oyXSGx5H2CUpFRvWlQuhSUqGi0Dxi/QLbiM0iwgtVduobpxJL81lKxI1iqdMCEH7HlZbXqc5O3fpEAsDY0RH0cM2+do0+vsVd+Pr90+GFSdRO0ZKw1tsKQbd1aJLa0/szJYIefxjpiezxe9QtZ89jnZKLWs+nFnDWj3CB9x0CwQrwTGyU8eSiBVJgFCUBnELy8zZA3xNDC0nYr/VbEmElC8HhnVL2zBjXJSEfV4sd6hLm8J6NKwma0Fa9aqy1oRQGlujhzenRwis99yLEWXtftFt5ELL2cj984mADEzyDXYpBKrYR/euZm9SksoViyuDMwbuIfcw9Xxn/wuQpoXMpVtgBTX/cWyzPgG4RFOtEugIGLCXZO/iG8GZ4enT0W2ZjwVYYDRklbn09FPu6cvcBHHMRr83tHUyrCl+iBlmCcvUvazQEBSh+RyloTGSVpkXmzrvM0sZ7rXBeEIF/twac5K4h1C3m6Bs5ACAcYZfZ8ssCsWRe+pYNS4S1QHdcq5H7mqIladWS2SX25JKvWO9RQfVu2h8wRzSDmvrMOG09r8jea4LQeCRW9FZXg8fq6yxq93tCv7ut3xwxZvtgRlE1xv42Dyh2mF7GdWyCgnRpxAgYlzkE7vv+S5m9Ts1cnHvorGhalNYDmm+VTpVmYZUtFDoi2EZo3pLcud9ebN5e+5fVsikZezoX+WQ5wGGitApCYAQH818pYJpvQTAG8wucFNQqldDXc1HkQT3mxBCmcD+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 Content-Transfer-Encoding: quoted-printable 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: <linux-mm.kvack.org> |
Series |
lib, stackdepot: check stackdepot handle before accessing slabs
|
expand
|
On 9/2/21 02:01, Imran Khan wrote: > 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 <imran.f.khan@oracle.com> > Suggested-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Vlastimil Babka <vbabka@suse.cz> > --- > 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); >
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);
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 <imran.f.khan@oracle.com> Suggested-by: Vlastimil Babka <vbabka@suse.cz> --- lib/stackdepot.c | 3 +++ 1 file changed, 3 insertions(+)