From patchwork Tue Sep 29 13:38:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11805859 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 9852E112C for ; Tue, 29 Sep 2020 13:39:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4814621531 for ; Tue, 29 Sep 2020 13:39:09 +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="UOSBvRZB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4814621531 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 C6D0D900008; Tue, 29 Sep 2020 09:39:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BF7146B0074; Tue, 29 Sep 2020 09:39:03 -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 AE617900008; Tue, 29 Sep 2020 09:39:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 936AF6B0073 for ; Tue, 29 Sep 2020 09:39:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 55B6C5853 for ; Tue, 29 Sep 2020 13:39:03 +0000 (UTC) X-FDA: 77316204966.13.book18_3011aac2718a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 2EA5618140B67 for ; Tue, 29 Sep 2020 13:39:03 +0000 (UTC) X-Spam-Summary: 1,0,0,648de26a2d6320a4,d41d8cd98f00b204,39thzxwukcdywdnwjyggydw.ugedafmp-eecnsuc.gjy@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-62.18.0.100 66.100.201.100;04yf3hts1nt5z4x8aij7j4a8r6671opcpfhsqj146m9u4hekys3gofpkybf56rw.xn153tsfo1t8phq36qejjzufd8io8knwerjbwkhuieg7w3f7nou9jdumtohgs4m.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:24 X-HE-Tag: book18_3011aac2718a X-Filterd-Recvd-Size: 4858 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 13:39:02 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id 16so2665858qky.8 for ; Tue, 29 Sep 2020 06:39:02 -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=vVOlNt/WCejDp1JOCEsvSSdVHILjJnc43Mcb0PKSl94=; b=UOSBvRZBZKrpnksJMXA3OOhNYA+IsYKy4qy9MiaMAWv4Qmco6I0lGG/1E1y4vY58vz CZBn6KJFIpSQPzI+0qHZF+n9AKpdnR1c/FcXU2vi9d6AcLaxN+0h2+6lKxpJ+VwD/Fb0 l3hIQBgDmYX4Qqem9eqXPEynllsNkpk/ipyQ/c4kOJwGgN0Mahu/+1w7p7blTpkFPPDH eBthRpEWp+J41zyd12Z9gm0BLrS+hsDfGa9rRHXKGig2x9ktsb/VO1/Z+5uzlxgK3Imv TxFCLtBlLbW0IQrbRuWQz26NF7uEVM4FpTthHS8NRQsg6B3mcVsX1dkd9vbBMEbwjd3+ Bw5A== 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=vVOlNt/WCejDp1JOCEsvSSdVHILjJnc43Mcb0PKSl94=; b=l9LXyqBrak7Fahqah1+8YJr5jE5Wl7F8ixWXSYFv5JjrQ9JmvbtyMhV7dRqhe3RZLd n03ZQEQe1DHUqmnSVMjzqUqdoQsVW+3vTT1nIvCnjv8ovQmZ+tUvdtBzbNT6YkgrNDRl 7xLy+s9vYZR5XPQcAB9GFqYaJ4aA8qPIRb1lnyc+oI8/gV06D93SMvw+gbED4uCfFDSf G9Ny/5W0lWfpIlydC48BcjKH5UK+oaQzl4DFgrbysbHlJjS/RbtwMQmBQMltOvtGeFtN cigvz9X1QGR5abwkY0nd3vubTaI+f3uSiDEkMvwqAFWVwm9vRwvEVRxe8R6HdWVhLUGB k/6w== X-Gm-Message-State: AOAM533oJrhjZo/vZ++uInBDzytkfFXRC+qNsHNs7g1TpEZ+iywJULoq +MZPVO+xzMzrzgTW3D2uyzzS8jq6Zg== X-Google-Smtp-Source: ABdhPJxPHumSkQ+1sRW54lJFlDtPVwTgrVQLDVfUTBhLd4jdPTbPDJavbzzqCAAj2yGSJ8AXrL9sZ4EW2w== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a0c:f6c4:: with SMTP id d4mr4373033qvo.41.1601386741788; Tue, 29 Sep 2020 06:39:01 -0700 (PDT) Date: Tue, 29 Sep 2020 15:38:11 +0200 In-Reply-To: <20200929133814.2834621-1-elver@google.com> Message-Id: <20200929133814.2834621-9-elver@google.com> Mime-Version: 1.0 References: <20200929133814.2834621-1-elver@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 08/11] 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? */