From patchwork Mon Sep 21 13:26:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11789865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86F63139A for ; Mon, 21 Sep 2020 13:27:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 45B4F2145D for ; Mon, 21 Sep 2020 13:27:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="AwQ3SH4R" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45B4F2145D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 65D32900064; Mon, 21 Sep 2020 09:26:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5E65F900059; Mon, 21 Sep 2020 09:26:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40F14900064; Mon, 21 Sep 2020 09:26:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1EBDE900059 for ; Mon, 21 Sep 2020 09:26:58 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D97371EE6 for ; Mon, 21 Sep 2020 13:26:57 +0000 (UTC) X-FDA: 77287144074.22.scale77_020c29027145 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id B7BE818038E67 for ; Mon, 21 Sep 2020 13:26:57 +0000 (UTC) X-Spam-Summary: 1,0,0,3266f790f20e5569,d41d8cd98f00b204,3ikpoxwukcbk3ak3g5dd5a3.1dba7cjm-bb9kz19.dg5@flex--elver.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2904:3138:3139:3140:3141:3142:3152:3352:3870:3871:3872:3874:3876:4250:4321:4385:5007:6261:6653:6742:6743:9969:10004:10400:11026:11473:11658:11914:12043:12297:12438:12555:12895:13069:13161:13229:13311:13357:13972:14096:14097:14181:14394:14659:14721:21080:21444:21451:21627:21990:30054:30076:30090,0,RBL:209.85.222.202:@flex--elver.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yrkmssq6qkn93i1o1a1fr41gjm4ypcpfhsqj146m9u4hekys3gofpkybf56rw.xn153tsfo1t8phq36qejjzufdyp66ogprp9bwkhuieg7w3mbufnfnsdmtohgs4m.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,L Ftime:23 X-HE-Tag: scale77_020c29027145 X-Filterd-Recvd-Size: 4863 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 13:26:57 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id q131so10814339qke.22 for ; Mon, 21 Sep 2020 06:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=+R3FkgLg/uUxAfttfYVSjxdiI+HJZltSBRxJWgKHPWI=; b=AwQ3SH4RPdmBRFAyoSOJHU//nXO51R9eb6z2HWBBP/5KLsyCveVvAjoS/15dev1nHk C1V6mTtovAY3Pzkn8XqqyXRcPtoZVTxMDg8Lp1weN8lPN8YN3uLOinjVacYCllLMgok5 f8ha/FnRT9SaJb+NLdV7pTTsSpCC3hub0bb12gt3j8skHWk/JUktSY1U4lt6/xjuVoYP Y8nZ69cULu3nVdjxXK3zwVHwE7HMrbUr9dFp35w3c6SkDDqYTt2E/6153FiTwMQdZRnX Q2lU7puug9u1gp2aen8hAYYse1dBtG4FTtkn9TLUxm7/9W/TmRC5Poh9NfcYqpi2wrIH RplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+R3FkgLg/uUxAfttfYVSjxdiI+HJZltSBRxJWgKHPWI=; b=kBPYMaD2kP74js5iCGaz/deEwv1gRsI+IE6A6ffLat7wLy99LLSDzlvHmIN2YpAWgS R4j0S+I0VCNokP6UNMojs3Cf2ma3MbxYg3x7XdAt3nWxe4bfQEyfEBlu867lEP8Q8nL9 Rr8qX27hWX/YNC2ndYExLAWbhTspbPkB+fneh1/sdplnUkT30mmGPkR3/kI1sxtsoLal oypvTEsA2+nw9ofvccPsz44qDNk0Fsz6tR418U1P/gm6njypNqWRPJcZB/BIVoJEN3sC 5Nt5XYFBrnN8ACfe9d0l3SomEdT/US44uKy4sAbfoE96YmBCvFyTLTRncqSyt1EShrbT G1vA== X-Gm-Message-State: AOAM533xqDKd+BnSBV94rvHKkSWpLDz6aWYcTb2Vf4v3X8Ax6bDdRHfz 9nYATjcW9fcajkF5NLf0tnGTWOV8nw== X-Google-Smtp-Source: ABdhPJzdcj1vXa9IRzgIJT+0KIMH13pc+xxOpm4AAO5fmze8y5104JWt6jdjS+3w6lHF/NGj6w+Ksxvu5Q== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a0c:c709:: with SMTP id w9mr46105935qvi.26.1600694816482; Mon, 21 Sep 2020 06:26:56 -0700 (PDT) Date: Mon, 21 Sep 2020 15:26:09 +0200 In-Reply-To: <20200921132611.1700350-1-elver@google.com> Message-Id: <20200921132611.1700350-9-elver@google.com> Mime-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 08/10] kfence, lockdep: make KFENCE compatible with lockdep From: Marco Elver To: elver@google.com, akpm@linux-foundation.org, glider@google.com Cc: hpa@zytor.com, paulmck@kernel.org, andreyknvl@google.com, aryabinin@virtuozzo.com, luto@kernel.org, bp@alien8.de, catalin.marinas@arm.com, cl@linux.com, dave.hansen@linux.intel.com, rientjes@google.com, dvyukov@google.com, edumazet@google.com, gregkh@linuxfoundation.org, hdanton@sina.com, mingo@redhat.com, jannh@google.com, Jonathan.Cameron@huawei.com, corbet@lwn.net, iamjoonsoo.kim@lge.com, keescook@chromium.org, mark.rutland@arm.com, penberg@kernel.org, peterz@infradead.org, sjpark@amazon.com, tglx@linutronix.de, vbabka@suse.cz, will@kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org 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: Lockdep checks that dynamic key registration is only performed on keys that are not static objects. With KFENCE, it is possible that such a dynamically allocated key is a KFENCE object which may, however, be allocated from a static memory pool (if HAVE_ARCH_KFENCE_STATIC_POOL). Therefore, ignore KFENCE-allocated objects in static_obj(). Reviewed-by: Dmitry Vyukov Co-developed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- kernel/locking/lockdep.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 54b74fabf40c..0cf5d5ecbd31 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -755,6 +756,13 @@ static int static_obj(const void *obj) if (arch_is_kernel_initmem_freed(addr)) return 0; + /* + * KFENCE objects may be allocated from a static memory pool, but are + * not actually static objects. + */ + if (is_kfence_address(obj)) + return 0; + /* * static variable? */