From patchwork Tue Sep 15 13:20:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 11776607 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 2C7DF746 for ; Tue, 15 Sep 2020 13:21:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DED8C206F4 for ; Tue, 15 Sep 2020 13:21:40 +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="iMvsBbNh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DED8C206F4 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 4F3CA90005C; Tue, 15 Sep 2020 09:21:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A23090004C; Tue, 15 Sep 2020 09:21:20 -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 3B82390005C; Tue, 15 Sep 2020 09:21:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org 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 26ACD90004C for ; Tue, 15 Sep 2020 09:21:20 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CA0A61DEF for ; Tue, 15 Sep 2020 13:21:19 +0000 (UTC) X-FDA: 77265357078.18.kick08_230a0ba27111 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 67010100EC684 for ; Tue, 15 Sep 2020 13:21:19 +0000 (UTC) X-Spam-Summary: 1,0,0,0e0da5a7a222d0e4,d41d8cd98f00b204,3zb9gxwukcna07h0d2aa270.ya8749gj-886hwy6.ad2@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.221.73:@flex--elver.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yfhgmda8muwxyak54uydefkox8kopcpfhsqj1493m31zchib3gofpkybf4c45.nogqdj5xcswhcoyxy1soiud1p8io8knwerjcuts3cimow3f7nou9jd4zeqfkq4r.c-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,LF time:24, X-HE-Tag: kick08_230a0ba27111 X-Filterd-Recvd-Size: 4778 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 13:21:18 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id d9so1213578wrv.16 for ; Tue, 15 Sep 2020 06:21:18 -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=a8meNz/QEeXxbn8b6t9gmGleu286u2hc+BNFU326RBY=; b=iMvsBbNhgXGxnHuHOkBUVAAM2qOoY48Cj/hlej2s6y2vnL8IvcLin4Y20xBeyU/km1 5wsT+5syuztJ23L+OnZf6qPvh9KPK+uSriT1U9BNQyQVzqYYdX2+ph3t1DP2YDYfN4sf Dmro65jUXU2/e4ZFwym3N1STOvAQhGuQCVkjmJQ2g8aebKIZT9ffsKffbOtCn1attREE RsxBD7Uir7r4B7jU3FXDIJ+jVSByU3ErwYkkcn/iqxIhKM5YFs/dkTnflfODfPePIiq9 TDbx9M/7RJ6YOPJgIKKAisxFttdU10HweoylvSuu5uNY5vU97BDTQYyFyoITjaDvUh3H 5+dg== 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=a8meNz/QEeXxbn8b6t9gmGleu286u2hc+BNFU326RBY=; b=kP/gN5nUuEyZnP0FaQiDWuvg7A4bBhTkEDFXzmwba91ibglXeEJRb9pSg11k1WCLr0 sfCdW9i1FOpzN46iKSdBJ4is7g2+acqKqxXosIOqN+hjcSCpN1JeGuOWE2PVVCy1uzcb flC4EQ9mUD8kY42Mk6gNackVRAVZvACGlXo2jj88BZS7lM6Ctz2mJPLzEtDOxS9mEsL4 Qi4ARKW/WnQgkSY9WpMb2RsyQmYOgVjC9KtNvFfkOD5DHqOH7hRPRRUfsiITpYuHs/Jo W7tj9Ou196Lru8eQg+luZVLKpBTd5J3WHZsKBCQiuOWedwRlsxayZz8kuiaLYbEcszKY raeg== X-Gm-Message-State: AOAM53098aMR4Lptu6gXJIOvkAow0Iu3Z+FHdVVIHPdBemrzKgZFv4MN /fSymHoAXtFomgg+Hv/khuI9NELEig== X-Google-Smtp-Source: ABdhPJxc+SFUorzyuHDnGAmMdmAFnOXbAdljVi+RbRH5QtpV+KA/ekb7T2afDQiufl+mm1oPBfvLzn0Tjw== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:2449]) (user=elver job=sendgmr) by 2002:a7b:c749:: with SMTP id w9mr4491690wmk.29.1600176077770; Tue, 15 Sep 2020 06:21:17 -0700 (PDT) Date: Tue, 15 Sep 2020 15:20:44 +0200 In-Reply-To: <20200915132046.3332537-1-elver@google.com> Message-Id: <20200915132046.3332537-9-elver@google.com> Mime-Version: 1.0 References: <20200915132046.3332537-1-elver@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v2 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, 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, cai@lca.pw, 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-Rspamd-Queue-Id: 67010100EC684 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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(). 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? */