From nobody Mon Jun 8 05:25:45 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B05B3955F5 for ; Tue, 2 Jun 2026 18:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780425105; cv=none; b=kg2ZuiAxmU+H34Aq5OiqK0ko1O6rcdceSnzUUJFzk+S4N7fIjD1Y9/lSQtMuEaTyr1wUcX5rat+pwlRboM2C1cBMU8kVZaXetcTrHwxGtWQUe4ZS5LaxMFQfl0TUHvJ414gAU/RThL7OTPN5tnP41ePRBKmSOOx/flwNIGNmtpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780425105; c=relaxed/simple; bh=DgMI9uMzrQhZT6TqqtIX/rBBd9+yVcvwNE78GkdB6cs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YY1QlJcYIy1WaoHiXRS9eClxIdqyBiMrR7j7qbpC+VVzHNZbgt8NY8ReBJ7wdPV+zki2RSMwVvJgu9GM/iPX3XoYGU0iB4aAm3zhSY/FPyujZVbKFKfr5RQ76EwpzV+lq3Y2iodWACsPeq06j6Z2vQErELDpgxVM3FzyWc+AcPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BCF2366FF6; Tue, 2 Jun 2026 18:31:42 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 72292779A7; Tue, 2 Jun 2026 18:31:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id QFZMGI0hH2owXQAAD6G6ig (envelope-from ); Tue, 02 Jun 2026 18:31:41 +0000 From: Pedro Falcato To: Vlastimil Babka , Harry Yoo , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-hardening@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Simon Horman , Jason Xing , Kuniyuki Iwashima , Pedro Falcato Subject: [PATCH 1/2] mm/slab: add a node-track-caller variant for kmem buckets allocation Date: Tue, 2 Jun 2026 19:31:21 +0100 Message-ID: <20260602183122.747759-2-pfalcato@suse.de> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260602183122.747759-1-pfalcato@suse.de> References: <20260602183122.747759-1-pfalcato@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: BCF2366FF6 X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="utf-8" This is required by users that want to use kmem buckets, but still desire specifying the NUMA node. Signed-off-by: Pedro Falcato Acked-by: Harry Yoo (Oracle) Acked-by: Vlastimil Babka (SUSE) Reviewed-by: Kees Cook --- include/linux/slab.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 7b46fa499b08..685a87d8f0c5 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -1153,8 +1153,11 @@ void *kmalloc_nolock(size_t size, gfp_t gfp_flags, i= nt node); #define kmem_buckets_alloc(_b, _size, _flags) \ alloc_hooks(__kmalloc_node_noprof(PASS_KMALLOC_PARAMS(_size, _b, __kmallo= c_token(_size)), _flags, NUMA_NO_NODE)) =20 -#define kmem_buckets_alloc_track_caller(_b, _size, _flags) \ - alloc_hooks(__kmalloc_node_track_caller_noprof(PASS_KMALLOC_PARAMS(_size,= _b, __kmalloc_token(_size)), _flags, NUMA_NO_NODE, _RET_IP_)) +#define kmem_buckets_alloc_node_track_caller(_b, _size, _flags, _node) \ + alloc_hooks(__kmalloc_node_track_caller_noprof(PASS_KMALLOC_PARAMS(_size,= _b, __kmalloc_token(_size)), _flags, _node, _RET_IP_)) + +#define kmem_buckets_alloc_track_caller(_b, _size, _flags) \ + kmem_buckets_alloc_node_track_caller(_b, _size, _flags, NUMA_NO_NODE) =20 static __always_inline __alloc_size(1) void *_kmalloc_node_noprof(size_t s= ize, gfp_t flags, int node, kmalloc_token_t token) { --=20 2.54.0 From nobody Mon Jun 8 05:25:45 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E2D395AE2 for ; Tue, 2 Jun 2026 18:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780425109; cv=none; b=Non7FgnEuJAm1ZgW8/FDPBOUr43xM1J49uQNAMLnY2YdWkOQM1nPIB3tJ9N73lwlnn9g69bPTqGp6tOQ0U5flyPj92jZNPi5XYfHG9VG6ziqulwuwhpJ7UgMVdOPCfRUCspWdI7dRTkYAkUptVgR/DJ+TTPtNo9iZ9oRv5ozAX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780425109; c=relaxed/simple; bh=chQg/NkEyt4Mdb9IkUxVPMwXtdBmoW3fBYnP9aDTCsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+odkW41ZBOtHuNaQnGR0AU1yWDNqx2YOrs8GFbPmhMRgabkUaRRekitEennASgFI/neSjdYfejgOY7SRtrU9S3c8wi6P/bQ3pkHFDO6yLRhJcNamdONlcRQNkIBW5mfMo7sCSdLXj5VtpW0VlYMrFxjsGBK/cYhLPIn/p84OrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2687A6AF1B; Tue, 2 Jun 2026 18:31:44 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D666B779A7; Tue, 2 Jun 2026 18:31:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 4KvUMI4hH2owXQAAD6G6ig (envelope-from ); Tue, 02 Jun 2026 18:31:42 +0000 From: Pedro Falcato To: Vlastimil Babka , Harry Yoo , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-hardening@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Simon Horman , Jason Xing , Kuniyuki Iwashima , Pedro Falcato Subject: [PATCH 2/2] net: skb: isolate skb data area allocations into a separate bucket Date: Tue, 2 Jun 2026 19:31:22 +0100 Message-ID: <20260602183122.747759-3-pfalcato@suse.de> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260602183122.747759-1-pfalcato@suse.de> References: <20260602183122.747759-1-pfalcato@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 2687A6AF1B X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="utf-8" SKB data area allocations (as done from alloc_skb()) use kmalloc(). These allocations can be variably sized and their contents can be more or less controlled from userspace, which makes them useful for attackers that want to overwrite a use-after-free'd object from the same kmalloc slab (which often just requires the sizes to roughly match into the same kmalloc bucket). [0] is an easy example of an exploit that uses netlink skb allocation to target another similarly-sized accidentally freed object. While other mitigations like CONFIG_RANDOM_KMALLOC_CACHES exist, these are probabilistic. Use the existing kmem buckets API to further isolate these allocations in a guaranteed fashion, when CONFIG_SLAB_BUCKETS=3Dy. Link: https://github.com/google/security-research/blob/master/pocs/linux/ke= rnelctf/CVE-2023-4207_lts_cos_mitigation_2/docs/exploit.md [0] Signed-off-by: Pedro Falcato Acked-by: Jakub Kicinski Reviewed-by: Kees Cook --- net/core/skbuff.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 44a7f8401468..1f6c6b531ece 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -594,6 +594,8 @@ static void *kmalloc_pfmemalloc(size_t obj_size, gfp_t = flags, int node) return kmalloc_node_track_caller(obj_size, flags, node); } =20 +static kmem_buckets *skb_data_buckets __ro_after_init; + /* * kmalloc_reserve is a wrapper around kmalloc_node_track_caller that tells * the caller if emergency pfmemalloc reserves are being used. If it is and @@ -632,7 +634,7 @@ static void *kmalloc_reserve(unsigned int *size, gfp_t = flags, int node, * Try a regular allocation, when that fails and we're not entitled * to the reserves, fail. */ - obj =3D kmalloc_node_track_caller(obj_size, + obj =3D kmem_buckets_alloc_node_track_caller(skb_data_buckets, obj_size, flags | __GFP_NOMEMALLOC | __GFP_NOWARN, node); if (likely(obj)) @@ -5213,6 +5215,7 @@ void __init skb_init(void) 0, SKB_SMALL_HEAD_HEADROOM, NULL); + skb_data_buckets =3D kmem_buckets_create("skb_data", SLAB_PANIC, 0, INT_M= AX, NULL); skb_extensions_init(); } =20 --=20 2.54.0