From patchwork Fri Sep 24 12:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manjeet Pawar X-Patchwork-Id: 12515625 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,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 133ACC433EF for ; Fri, 24 Sep 2021 13:55:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8DCCF61050 for ; Fri, 24 Sep 2021 13:55:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8DCCF61050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2486B900003; Fri, 24 Sep 2021 09:55:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F85E900002; Fri, 24 Sep 2021 09:55:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C0BA900003; Fri, 24 Sep 2021 09:55:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id F0562900002 for ; Fri, 24 Sep 2021 09:55:53 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AF61F27024 for ; Fri, 24 Sep 2021 13:55:53 +0000 (UTC) X-FDA: 78622615386.03.E7A4E2F Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf17.hostedemail.com (Postfix) with ESMTP id 6DA68F000136 for ; Fri, 24 Sep 2021 13:55:52 +0000 (UTC) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210924135549epoutp02267f50b9141a2c6f1cfdf61fdb325740~nxpjDBmdA1661116611epoutp02h for ; Fri, 24 Sep 2021 13:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210924135549epoutp02267f50b9141a2c6f1cfdf61fdb325740~nxpjDBmdA1661116611epoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1632491749; bh=mNQhFy+0EiS+QFcEKoyz6Gg5CkSs9cKnhKzNpsJdN6Y=; h=From:To:Cc:Subject:Date:References:From; b=LUFa8tWWuJ3QsitRJZIkoHZ7waYbvAmvaatQPxkOKiNPxbaUi7CO7J5XOeR7kOP+V ZJRwnAZbdwD3kdlMlEh5GB97G+mQla8KI8HfUz9F9L0lkffkcj/WYJlyqsHEnbwf6C xy7FJ1VS8+2URU2+rSr+BNTJH3xRf6pKTYuY6vCE= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20210924135548epcas5p114c5dca6c0cb260a1e30d3bde0962b39~nxph5DVLr1707317073epcas5p1g; Fri, 24 Sep 2021 13:55:48 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 80.22.59762.3E8DD416; Fri, 24 Sep 2021 22:55:47 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20210924121457epcas5p39266266f9cef79177f2301a6a4f7d79a~nwRe_0fYE1848718487epcas5p3u; Fri, 24 Sep 2021 12:14:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210924121457epsmtrp21f242e919d84fda83da496006302ee51~nwRe_AMG82712327123epsmtrp2B; Fri, 24 Sep 2021 12:14:57 +0000 (GMT) X-AuditID: b6c32a49-10fff7000000e972-97-614dd8e38bdf Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AB.6D.09091.141CD416; Fri, 24 Sep 2021 21:14:57 +0900 (KST) Received: from localhost.localdomain (unknown [107.109.224.44]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210924121455epsmtip2923d25f8bf1e960d7c28e1c1f758c3bc~nwRc95v331682016820epsmtip2a; Fri, 24 Sep 2021 12:14:55 +0000 (GMT) From: Manjeet Pawar To: glider@google.com, elver@google.com, dvyukov@google.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: r.thapliyal@samsung.com, a.sahrawat@samsung.com, v.narang@samsung.com, Manjeet Pawar Subject: [PATCH] mm/kfence: Null check is added for return value of addr_to_metadata Date: Fri, 24 Sep 2021 17:44:02 +0530 Message-Id: <1632485642-20625-1-git-send-email-manjeet.p@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7bCmpu7jG76JBkt6bCwu7k61mLN+DZvF hIdt7BZtZ7azWrR/3MtsseLZfSaLy7vmsFncW/Of1eJe61o2i433si0OnZzL6MDtsWBTqcee iSfZPDZ9msTucWLGbxaPvi2rGD0+b5ILYIvisklJzcksSy3St0vgyujeeoC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H35ZVjB6fN8kFsEVx2aSk5mSWpRbp2yVwZXRvPcBe0MxWcWzvMsYG xs8sXYycHBICJhL/3nxhBLGFBHYzSjyeogsRl5ToXzcVqkZYYuW/5+wQNZ8YJba1poDYbALa Ent+tIHFRQQ2MEqseefdxcjBwSxQJtHwWQAkLCwQIjFh4XpmEJtFQFXi+KWtrCA2r4CrxLGL d9khxstJ3DzXyTyBkWcBI8MqRsnUguLc9NxiwwLDvNRyveLE3OLSvHS95PzcTYzgYNPS3MG4 fdUHvUOMTByMhxglOJiVRHg/3/BKFOJNSaysSi3Kjy8qzUktPsQozcGiJM57oetkvJBAemJJ anZqakFqEUyWiYNTqoHJbXHGqX+Jk57xvSx7/+JT1xXZm891IjdVnRCXYLVfvvby65jfs+1Z MwoDg7+mSPdnTfn1JTdpo/uUuVV3dsQocwh9uGsUWHovvcdrv4HWgVUek6+z39ZJ/W11zkLW KLnqT9+Pa1zfeSKP/Hz2vztB3DTkytG+K9m7xSuVDiza5Xeapym0O+Jq3luDiRtz8x+IPrj/ +26trXyeetpWRdP4rT8NPkXX7NH2eTCjlYXvkenLD4YWGX+O+SzY/+DJ0v9SWUmJ3o+aF/H/ 9jWUecxofPl97EtjY0v2Z/8bG3V1hJ89TCudoM94d6dup3+qbRani/CyU7v+Ja6eenJT89me hHfsC9gixdylVv1a0DZHiaU4I9FQi7moOBEAT32yLaUCAAA= X-CMS-MailID: 20210924121457epcas5p39266266f9cef79177f2301a6a4f7d79a X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20210924121457epcas5p39266266f9cef79177f2301a6a4f7d79a References: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6DA68F000136 X-Stat-Signature: 5pth41ek7ir6eaa96kba8f3fwcgczc3c Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=LUFa8tWW; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf17.hostedemail.com: domain of manjeet.p@samsung.com designates 203.254.224.25 as permitted sender) smtp.mailfrom=manjeet.p@samsung.com X-HE-Tag: 1632491752-109810 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: This patch add null check for return value of addr_to_metadata(). currently 'meta' is geting accessed without any NULL check but it is usually checked for this function. Signed-off-by: Manjeet Pawar --- mm/kfence/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 575c685aa642..9b953cfa7fee 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -802,6 +802,9 @@ void __kfence_free(void *addr) { struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr); + if (unlikely(!meta)) + return; + /* * If the objects of the cache are SLAB_TYPESAFE_BY_RCU, defer freeing * the object, as the object page may be recycled for other-typed