Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp217570rdb; Tue, 19 Dec 2023 14:33:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfcGL9ZXd/QSJYBr+egjHCGwyQ8LnzZnRdi8mgPpwiMF3FBzRkUMYrKQYANnpO48O7FWGS X-Received: by 2002:a17:902:ea07:b0:1d3:c1a7:6ba1 with SMTP id s7-20020a170902ea0700b001d3c1a76ba1mr4076492plg.0.1703025226083; Tue, 19 Dec 2023 14:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703025223; cv=none; d=google.com; s=arc-20160816; b=f/x2R++qvAfxM1QNYniCkKpi5GS/c3vECOcUFYlaIg0YW0+czvDubMU9ciSPb0jji2 NNse0LBDMeBkldnnwRJ2aVlzGX9dhVZr6SIDDL7TmS8PKLYRNl+ERptzELNveOsZM/3V 4jElGkoCQZCcraSWfxCmWO+XnQong0BAvmlbbobNquBg5/5nbxPiZwa18DN9pbebzYba b3j7yaZJtuOM9dykV0404u+0qIfmsv7STBCSibEEcc7frmfW2L2sRZTRISwf0M+YjL54 0Vl/ry9/00F09CnXFAAznImqCXpy7eTaaviLQVlR98MYYukg3BZfYLoIe3MfemYtOEVX FddA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=KVsX1wYh/u3bsgXc0v6541Y+g0kgoewEBIuD2sVrVOE=; fh=AIzsiqkKUtrB7QnM+XRgAblgvDINIC5pDvD0mg8EzrU=; b=VfJhm28ei0Y3sbftijye0nZQHL16q4jUaKipBae2ou6sbOtdSAF5iN/KP2Zq0pBwBr nHHAdtwz+VpaQ7A5IlDLw239SQs9fU2rEdgGtm3lr60OiGCGEzKyxBegvXfFrRC33Zau Ud7pvaLeJe2tvab8CxLkZPdz8OeeYwGK5QLkYCQs84eKrbECQM7zpt+wxKUgeIKhldzc Pv7Eme+JU56FKRbY3Dx9r3aIZE1gFQiC/0otbgE4B28u9SoXmS6rNzHhd1vMGRumMIpj mKvw5TLZqtsYUzhxt4BKPfU9mpOzlzgQAItq19IlpjJY5V4R7lu/x8pZYVuKgg+fJPBL puZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Kt1rNfuv; spf=pass (google.com: domain of linux-kernel+bounces-6053-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6053-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id az4-20020a170902a58400b001d05ec3be0bsi20328371plb.130.2023.12.19.14.33.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 14:33:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6053-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Kt1rNfuv; spf=pass (google.com: domain of linux-kernel+bounces-6053-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6053-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 58D85B23ABF for ; Tue, 19 Dec 2023 22:32:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A80C83EA7D; Tue, 19 Dec 2023 22:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Kt1rNfuv" X-Original-To: linux-kernel@vger.kernel.org Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC21F3D0AB for ; Tue, 19 Dec 2023 22:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703025084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KVsX1wYh/u3bsgXc0v6541Y+g0kgoewEBIuD2sVrVOE=; b=Kt1rNfuvx7+wT5H8UNOgwHCeTbOEvaDygKRpZZi3u1FYmus+bD/11ubTVW79B+oIdiaNwz JlwOYJnlQA+xJy+dqmZh3LmC25rgn5CNTohHAkyMco9Blc+/P3IIuddLLDTvM6CJy8A9+O KeuWbai25yfJ/zAiqqyvZxcC5VTNrDs= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Breno Leitao , Alexander Lobakin , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 13/21] mempool: skip slub_debug poisoning when KASAN is enabled Date: Tue, 19 Dec 2023 23:28:57 +0100 Message-Id: <98a4b1617e8ceeb266ef9a46f5e8c7f67a563ad2.1703024586.git.andreyknvl@google.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Andrey Konovalov With the changes in the following patch, KASAN starts saving its metadata within freed mempool elements. Thus, skip slub_debug poisoning and checking of mempool elements when KASAN is enabled. Corruptions of freed mempool elements will be detected by KASAN anyway. Signed-off-by: Andrey Konovalov --- Changes RFC->v1: - This is a new patch. --- mm/mempool.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/mempool.c b/mm/mempool.c index 7e1c729f292b..1fd39478c85e 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -56,6 +56,10 @@ static void __check_element(mempool_t *pool, void *element, size_t size) static void check_element(mempool_t *pool, void *element) { + /* Skip checking: KASAN might save its metadata in the element. */ + if (kasan_enabled()) + return; + /* Mempools backed by slab allocator */ if (pool->free == mempool_kfree) { __check_element(pool, element, (size_t)pool->pool_data); @@ -81,6 +85,10 @@ static void __poison_element(void *element, size_t size) static void poison_element(mempool_t *pool, void *element) { + /* Skip poisoning: KASAN might save its metadata in the element. */ + if (kasan_enabled()) + return; + /* Mempools backed by slab allocator */ if (pool->alloc == mempool_kmalloc) { __poison_element(element, (size_t)pool->pool_data); -- 2.25.1