Message ID | a3482c41395c69baa80eb59dbb06beef213d2a14.1703024586.git.andreyknvl@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-6062-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2276414dyi; Tue, 19 Dec 2023 14:38:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4wNWFMxtFNSPR8MH2JN8BMgT6CbNzzwu/9KIISW7CbFAYxmBtpoKcmNAreZBhlHRFRxW9 X-Received: by 2002:a05:6a00:21c1:b0:6ce:56da:62d3 with SMTP id t1-20020a056a0021c100b006ce56da62d3mr20505252pfj.25.1703025532131; Tue, 19 Dec 2023 14:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703025532; cv=none; d=google.com; s=arc-20160816; b=PjljyuSoIgz9GHEAtt7CXmDVn6evab1y1ZekCCCIaHzkXBZ2/gfrRRYvZLPHfGEgRw VFS3kKQ2B+pb+XrxA1yt3/SV34bLCnwtf73SHP/sKoZ+aEF7tM8tbjSCgcEU+OQEaMze NLTt0uktu2rXcdKd/c2meeJOUAJulr6mj4jJ7+jgZi8tr5sOD8a0+f9FiotTd49dixG5 326sEM3h8lHgM1cah6tY1r7pvF0EtlthEJ+Fn9FdSDMxheOR3Mc6FmPEphhNy7sN3vDV A2hTfwHKR6K9y3bURZLnmlkUqipjgY9KrNF7Yi+fPaExeEc3vtl6z6MoOJbC7sDtey8F GMhQ== 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=e29xpsueqsta+pB4dpMwNezQWpITpFZrOcR7dgpqXnM=; fh=AIzsiqkKUtrB7QnM+XRgAblgvDINIC5pDvD0mg8EzrU=; b=rz/qLWzNrMMnQw0d3FWeWBmvPYymv5VoHta6FRJBYGtfrTClrlljGPKp/9B52HTr/R uksuydQCFePC6+G7GI3/8ASRzT9nqmdjDAhpgohtvQGFENkVzDnimU6jlT4sgTSdtsM3 +mqPnklfCNR1ZDt/LpZKfA+9WsTT1rhFCKAywxiidEYCqubg9y/BhFvaH8OMc1DpXhBN CIR0mtR8yZ+KSNWTHYn1UtusYv8Mj/A/LHXfJw5RolbNS+MPPhSA2yU5F0jdbuO6JYWE UvcZLdUopJU2nCm+K/BtToOxXCHaSzLefcf+XktEd51LK1Qfx8gGhwk6pydykZl19qcu cwog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="ljf0/KaK"; spf=pass (google.com: domain of linux-kernel+bounces-6062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y20-20020a056a00191400b0068fd7cb5864si20707719pfi.263.2023.12.19.14.38.51 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 14:38:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="ljf0/KaK"; spf=pass (google.com: domain of linux-kernel+bounces-6062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6062-ouuuleilei=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 93720B25512 for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 22:35:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11E604EB5F; Tue, 19 Dec 2023 22:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ljf0/KaK" X-Original-To: linux-kernel@vger.kernel.org Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 03BEB4CB22 for <linux-kernel@vger.kernel.org>; Tue, 19 Dec 2023 22:32:31 +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=1703025149; 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=e29xpsueqsta+pB4dpMwNezQWpITpFZrOcR7dgpqXnM=; b=ljf0/KaKFmDC2Uyj9pcq18seQDB62a/kgliZneYzRVKag4kgTWvduY54lnptev/4IOVTKg XWh9fADptQruk8bYRvzl+jF0l8p4U0RNpQ3xZT3+C7DxlLuZnVWmBR0/EtI5V5z/V058ga q4EXpOfTgh0O1XTzevXYooHK4dHrhlQ= From: andrey.konovalov@linux.dev To: Marco Elver <elver@google.com>, Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@gmail.com>, Dmitry Vyukov <dvyukov@google.com>, Andrey Ryabinin <ryabinin.a.a@gmail.com>, kasan-dev@googlegroups.com, Evgenii Stepanov <eugenis@google.com>, Breno Leitao <leitao@debian.org>, Alexander Lobakin <alobakin@pm.me>, Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov <andreyknvl@google.com> Subject: [PATCH mm 20/21] skbuff: use mempool KASAN hooks Date: Tue, 19 Dec 2023 23:29:04 +0100 Message-Id: <a3482c41395c69baa80eb59dbb06beef213d2a14.1703024586.git.andreyknvl@google.com> In-Reply-To: <cover.1703024586.git.andreyknvl@google.com> References: <cover.1703024586.git.andreyknvl@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785751700271320664 X-GMAIL-MSGID: 1785751700271320664 |
Series |
kasan: save mempool stack traces
|
|
Commit Message
andrey.konovalov@linux.dev
Dec. 19, 2023, 10:29 p.m. UTC
From: Andrey Konovalov <andreyknvl@google.com> Instead of using slab-internal KASAN hooks for poisoning and unpoisoning cached objects, use the proper mempool KASAN hooks. Also check the return value of kasan_mempool_poison_object to prevent double-free and invali-free bugs. Signed-off-by: Andrey Konovalov <andreyknvl@google.com> --- net/core/skbuff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 63bb6526399d..bb75b4272992 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -337,7 +337,7 @@ static struct sk_buff *napi_skb_cache_get(void) } skb = nc->skb_cache[--nc->skb_count]; - kasan_unpoison_new_object(skbuff_cache, skb); + kasan_mempool_unpoison_object(skb, kmem_cache_size(skbuff_cache)); return skb; } @@ -1309,13 +1309,15 @@ static void napi_skb_cache_put(struct sk_buff *skb) struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache); u32 i; - kasan_poison_new_object(skbuff_cache, skb); + if (!kasan_mempool_poison_object(skb)) + return; + nc->skb_cache[nc->skb_count++] = skb; if (unlikely(nc->skb_count == NAPI_SKB_CACHE_SIZE)) { for (i = NAPI_SKB_CACHE_HALF; i < NAPI_SKB_CACHE_SIZE; i++) - kasan_unpoison_new_object(skbuff_cache, - nc->skb_cache[i]); + kasan_mempool_unpoison_object(nc->skb_cache[i], + kmem_cache_size(skbuff_cache)); kmem_cache_free_bulk(skbuff_cache, NAPI_SKB_CACHE_HALF, nc->skb_cache + NAPI_SKB_CACHE_HALF);