Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp160777pxf; Wed, 17 Mar 2021 01:54:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI1fHvAcMvA0GZhumPb1i0GADswVueA0UmTOgix1JAojHm2tVgkWTV/bPC62GTc5Jy3PLO X-Received: by 2002:a17:906:1c98:: with SMTP id g24mr34193138ejh.51.1615971254732; Wed, 17 Mar 2021 01:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615971254; cv=none; d=google.com; s=arc-20160816; b=MTRvYnnNudXY7FaM4zBrOago10zQDQEwUjpFK8YJnKVTuSvvScV824uAPNxq3wfQIP Uxqoq+6spZmSbLFKrnZ6nrEXc7cdhiwCORThukwa1ajazpobkiecN4vw1PCksvH8gf3C 5m3ANCIw8ZkKA3yutneMaAsV1Xd0AncbaKCDgpcXs6H1NJOpZdXqPFXDF8K1WS0JJcOt b5FGnsU3NPtWliSnQRkdXFjelJFQQbn7qt2Ervwy+joFsg5mUSUWljfBZ109l6i7NuWm AdnMvmqBeNnq38hjY/9IygYunqHyBD5wQMvldX/azkG5u7/ka3MX4UrrVE5zaxI2eMY0 yTIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=/qW/VElwaqVTeHlKYyk2v3D3oBW97+vbqzwRAaAhJbI=; b=iN7PpyMSooUmjcxSFpIQki5UopLEEUV3qhpuwnVqweWvgmonAcyvAWWCWDqOe219qk ApTBO9cLDxIdNDnW+F4JfOe6foSagNR2+G2e/mm5ri9ANKZrtNrlrSt5Fz0SK/u0oD/K AbDZBCoJYbhQRfncCMrsrvCC3L6CY6PPRZRUxJ6iPOxiX/0QdLYg7TJdkRe6megvqUT8 IixwpvMq2ZxTUQQ5uY86avNcqmFfldK4pF1lAUql9A2A9Iy34GYBIffdfue+phrBsjf4 gkOGNbR3ulvx4Tj7l0NiS5LZRRn6DffgPpx3rFfIy6sprB9IJYrI8u6agNyAHAXTh88r HC5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc17si16080604ejc.480.2021.03.17.01.53.52; Wed, 17 Mar 2021 01:54:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbhCQIw4 (ORCPT + 99 others); Wed, 17 Mar 2021 04:52:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:45142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbhCQIwb (ORCPT ); Wed, 17 Mar 2021 04:52:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0ECE364E27; Wed, 17 Mar 2021 08:52:28 +0000 (UTC) Date: Wed, 17 Mar 2021 08:52:26 +0000 From: Catalin Marinas To: Marco Elver Cc: akpm@linux-foundation.org, glider@google.com, dvyukov@google.com, andreyknvl@google.com, jannh@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, Luis Henriques Subject: Re: [PATCH mm] kfence: make compatible with kmemleak Message-ID: <20210317085225.GA12269@arm.com> References: <20210317084740.3099921-1-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210317084740.3099921-1-elver@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 17, 2021 at 09:47:40AM +0100, Marco Elver wrote: > Because memblock allocations are registered with kmemleak, the KFENCE > pool was seen by kmemleak as one large object. Later allocations through > kfence_alloc() that were registered with kmemleak via > slab_post_alloc_hook() would then overlap and trigger a warning. > Therefore, once the pool is initialized, we can remove (free) it from > kmemleak again, since it should be treated as allocator-internal and be > seen as "free memory". > > The second problem is that kmemleak is passed the rounded size, and not > the originally requested size, which is also the size of KFENCE objects. > To avoid kmemleak scanning past the end of an object and trigger a > KFENCE out-of-bounds error, fix the size if it is a KFENCE object. > > For simplicity, to avoid a call to kfence_ksize() in > slab_post_alloc_hook() (and avoid new IS_ENABLED(CONFIG_DEBUG_KMEMLEAK) > guard), just call kfence_ksize() in mm/kmemleak.c:create_object(). > > Reported-by: Luis Henriques > Cc: Catalin Marinas > Signed-off-by: Marco Elver Reviewed-by: Catalin Marinas