Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3861914rwb; Tue, 16 Aug 2022 09:58:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nP9FH1WZ7PGeKwLQFMjA+OH/vucBS6StqJmnEvgpiTWEPxE1TEuNMVI2TZu2hZX6Y+bQx X-Received: by 2002:a17:902:b70c:b0:171:407c:e1bd with SMTP id d12-20020a170902b70c00b00171407ce1bdmr22851768pls.33.1660669086473; Tue, 16 Aug 2022 09:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660669086; cv=none; d=google.com; s=arc-20160816; b=l4kCTmdI+aUBwnWtPgda6FQqtWGs3YLHhdFpB+L2UyofZxRE4rDkrBfcKGfHQdZeOI asREyVGZOdSC8v9Ws44uS+DT/3nGPiypgF4EbPYWl10YzI4rI6c44Xts7v85zmvMH9VA D9+FKwk8X/idpjd9q9XPieNRzxQMWv9QeBEu8sQyKV5AnAMsRRnYJ4fh+T71NPmebUn6 pUNwC2B24QVX49OzCz4CHu972nB/uRRaCNrh3xx6ZVGx4gUXc2ARO5eTj6XhlggNZQyk ku3dzrWI0EAouf6y4aOtUFNuuBNGypKw2jmQSycsPmxV4HlAoyFio64fTlglWIw/Pkwt 8o+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FOpQGOCCCOeHXcTTEf2Jf8cH6crBmZD9kljFNdM3FZI=; b=ksi5hpO66qMIui7POE5qLuOjU3P+qFMkoT13n9iy8IbXL/0rc667otTjJ8rDnS8RpB f2RFLpq6zEM+nt6nc91fUQ8jAU3lebHoUKgcHvADTdTI/nvF4Qo9TnGLbrvzCc6EXZ7a VqrrI+VRPl7WSaIOaTi32lSKQJ4loJlVLMG7pEKlJokFNb7VLH4pGHe3jtekM/9pmHb2 Gv54PIh6dFaFFgsEXABS4A6JAkqzS1jLMDZj3/72xMRXtSpeHQCCX7s20dwOv47pRbhN Ty/PuRAhPMZ67fvDv5JMzOXCLcolbkI+gjTB9wDi7TZpwUPvBXum5PZ2m6qXsqGVA80d 9qFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MTj13ZQO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020a635f11000000b0041bd351f349si9993193pgb.173.2022.08.16.09.57.55; Tue, 16 Aug 2022 09:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MTj13ZQO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236610AbiHPQnz (ORCPT + 99 others); Tue, 16 Aug 2022 12:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236663AbiHPQnd (ORCPT ); Tue, 16 Aug 2022 12:43:33 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97AD9B4C for ; Tue, 16 Aug 2022 09:43:24 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-32fd97c199fso141372377b3.6 for ; Tue, 16 Aug 2022 09:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=FOpQGOCCCOeHXcTTEf2Jf8cH6crBmZD9kljFNdM3FZI=; b=MTj13ZQOudsv0Y/McakJDk6R1ExbHgwbtUeK89PeymxtSWo3zoC/Q+XY5F0T9OgxhA CzABOs9R7GE90wClbCdVOrcM6GRfOKwq+0a/5wfHvjtt6DYvaF1PRFQQ3M062sfAtwI4 8UnQAo38spsmsPCYWMBFEbqgijBH+I/eJMfioC6BVTs7FJi2en4QOqZKHDlWzdImDdH+ J6IVV754BSXjX/oT6ElqiIjwORuzURt2RgAmqdA3R9RHomDzCMQf2wRPzE28XTQv2ajt bB05KJTL9nz58MGwokLqh0fOH7HYqUj+tJgv4ZQMpboYpqVIKxfZcJykgQQFCFG6VrxU vPoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=FOpQGOCCCOeHXcTTEf2Jf8cH6crBmZD9kljFNdM3FZI=; b=8KvJNnYz06zyzIIsbk9qT6i6T4E+UW1zDBtQmlZZXxTQrLa27gA3jHoHbiOvMtvfOt mDOnUMtGrOeOmjJZXxw2HvZlSCvwGlBYwOkCDGY99RdNssQl+g2ZZTEyag6vEYKhrSeP vJxcvSM786/KSIG7Ct9Lri+jDukG8Wp0AuIfyo0QX1kQAFkzuMl+l8DE5KgMofZadJN3 /0mIxkVCB2MFyHXOTL5yHuWCEIkv3RMocwNYlYLIRWg3NJiluzAT4TOXSEDm8CJC/QRB yRZwmoUI28KRtK8/hnHfob2XB5pmWXSVXA64pHunKEbcFixscuJKrAgG2QSpn9XY0z+i QGLA== X-Gm-Message-State: ACgBeo3jfLgK8zkIeTyzL29nl6vO4b3LqobiEcdYsGGRwimQ/AH2l/LU /R3ipyJqJ7S4CYuJ/15kCBF581IuCUi3YMZk1sBnfA== X-Received: by 2002:a81:500a:0:b0:333:9bcd:8a41 with SMTP id e10-20020a81500a000000b003339bcd8a41mr2849801ywb.4.1660668202873; Tue, 16 Aug 2022 09:43:22 -0700 (PDT) MIME-Version: 1.0 References: <20220816163641.2359996-1-elver@google.com> In-Reply-To: <20220816163641.2359996-1-elver@google.com> From: Marco Elver Date: Tue, 16 Aug 2022 18:42:46 +0200 Message-ID: Subject: Re: [PATCH 5.19.y] Revert "mm: kfence: apply kmemleak_ignore_phys on early allocated pool" To: elver@google.com, stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexander Potapenko , Dmitry Vyukov , Andrew Morton , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Will Deacon , Catalin Marinas , Yee Lee , Max Schulze Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 16 Aug 2022 at 18:37, Marco Elver wrote: > > This reverts commit 07313a2b29ed1079eaa7722624544b97b3ead84b. > > Commit 0c24e061196c21d5 ("mm: kmemleak: add rbtree and store physical > address for objects allocated with PA") is not yet in 5.19 (but appears > in 6.0). Without 0c24e061196c21d5, kmemleak still stores phys objects > and non-phys objects in the same tree, and ignoring (instead of freeing) > will cause insertions into the kmemleak object tree by the slab > post-alloc hook to conflict with the pool object (see comment). > > Reports such as the following would appear on boot, and effectively > disable kmemleak: > > | kmemleak: Cannot insert 0xffffff806e24f000 into the object search tree (overlaps existing) > | CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-v8-0815+ #5 > | Hardware name: Raspberry Pi Compute Module 4 Rev 1.0 (DT) > | Call trace: > | dump_backtrace.part.0+0x1dc/0x1ec > | show_stack+0x24/0x80 > | dump_stack_lvl+0x8c/0xb8 > | dump_stack+0x1c/0x38 > | create_object.isra.0+0x490/0x4b0 > | kmemleak_alloc+0x3c/0x50 > | kmem_cache_alloc+0x2f8/0x450 > | __proc_create+0x18c/0x400 > | proc_create_reg+0x54/0xd0 > | proc_create_seq_private+0x94/0x120 > | init_mm_internals+0x1d8/0x248 > | kernel_init_freeable+0x188/0x388 > | kernel_init+0x30/0x150 > | ret_from_fork+0x10/0x20 > | kmemleak: Kernel memory leak detector disabled > | kmemleak: Object 0xffffff806e24d000 (size 2097152): > | kmemleak: comm "swapper", pid 0, jiffies 4294892296 > | kmemleak: min_count = -1 > | kmemleak: count = 0 > | kmemleak: flags = 0x5 > | kmemleak: checksum = 0 > | kmemleak: backtrace: > | kmemleak_alloc_phys+0x94/0xb0 > | memblock_alloc_range_nid+0x1c0/0x20c > | memblock_alloc_internal+0x88/0x100 > | memblock_alloc_try_nid+0x148/0x1ac > | kfence_alloc_pool+0x44/0x6c > | mm_init+0x28/0x98 > | start_kernel+0x178/0x3e8 > | __primary_switched+0xc4/0xcc > > Reported-by: Max Schulze > Signed-off-by: Marco Elver The discussion is: Link: https://lore.kernel.org/all/b33b33bc-2d06-1bcd-2df7-43678962b728@online.de/ > --- > mm/kfence/core.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/mm/kfence/core.c b/mm/kfence/core.c > index 6aff49f6b79e..4b5e5a3d3a63 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -603,6 +603,14 @@ static unsigned long kfence_init_pool(void) > addr += 2 * PAGE_SIZE; > } > > + /* > + * The pool is live and will never be deallocated from this point on. > + * Remove the pool object from the kmemleak object tree, as it would > + * otherwise overlap with allocations returned by kfence_alloc(), which > + * are registered with kmemleak through the slab post-alloc hook. > + */ > + kmemleak_free(__kfence_pool); > + > return 0; > } > > @@ -615,16 +623,8 @@ static bool __init kfence_init_pool_early(void) > > addr = kfence_init_pool(); > > - if (!addr) { > - /* > - * The pool is live and will never be deallocated from this point on. > - * Ignore the pool object from the kmemleak phys object tree, as it would > - * otherwise overlap with allocations returned by kfence_alloc(), which > - * are registered with kmemleak through the slab post-alloc hook. > - */ > - kmemleak_ignore_phys(__pa(__kfence_pool)); > + if (!addr) > return true; > - } > > /* > * Only release unprotected pages, and do not try to go back and change > -- > 2.37.1.595.g718a3a8f04-goog >