From nobody Sun Feb 8 07:07:47 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 79AD03376B0 for ; Mon, 15 Dec 2025 18:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765822168; cv=none; b=nYZTwOwWJ68qEfSLCUEuRXUGwgjDFgT/JuPCE3v8R6ihdAs6uqiOe1FQfBftHqtr/HMQxehm8LGj9zLehhJhjWkRjRNPsGnugMSX8L4MTJgPHHZHoXK7sJoGJPsin4y9kpWbHQMZS8Nu2mWokYYjXs+Li/T3n2/M/P9o5M2e7TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765822168; c=relaxed/simple; bh=AY0TkiefWWJxabFgVI1H9Em9SIdHO9Ae7VODUrXYkn4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pwAocBvuJy3hoEj7yqm8wD0lSFB14rjV8/7+EzAu09nw/hY9bQ3xNqgL+EL42jPZgofuVeW0K4Y3hvhtJi0Gso7VMBGMpcnEfl3MErxDwQggYXW0c+zOx46HN4c/wt/hh+HjbWHH8bpU3Yr8UluHuvFA+ZdG2zNnitu2UdFI85k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jy8sho09; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jy8sho09" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7aa2170adf9so2995425b3a.0 for ; Mon, 15 Dec 2025 10:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765822165; x=1766426965; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kKn5YS5dI6hedLIYw2DaM/TDp6sjQOBZVfOejLbhZto=; b=jy8sho09cDND/7sYU3u/Mu4hLyi/eOlNTTbMw4NenurAqbSZx8TtIEdLH8n31hV7u7 XGmSfvXGXpnsMmQNArPXHh1fkpOk1QaBJRWSFpNS/Uej1sz9J1GvB+0b3pCTAwUo4ehq KNDs4Jc+X+IEHDXrNMXHcljfKgsZnv2uGU9Eeqi9z9DbYdDUmRyBzFduwUJaYwRVHLA/ ADKYimfBhVlbbSEOBICVOfqYW3qgLZuEWzEmMN6cgixqvBrTISAVKQuHdXl3PYwanJl3 DGOMu4z1AjruhNCKSUo62AFksV+VG9DZDgtoaCpZIyHESIG7xfDA+SB4ktgo1Ck95X34 QrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765822165; x=1766426965; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kKn5YS5dI6hedLIYw2DaM/TDp6sjQOBZVfOejLbhZto=; b=Vu16HOSATGXkf9Pe/CYhzFkTa4MkcnC/tTflkhBdM6Qjpj37FFilxoO2vzLkIVeLKl gM07y0+XFDo62ZwRrdYtXsPzrQ72DnZl2U5R+MbPMZQghKQOYDutPkFfPpZIKKlaWTS1 4zZhslA0Y/5QAVhWDT1onsaHUHlZWiy177jAQwHW4STRtS0wRq47LM3G+GutH87Dlxz6 VW9JdL9V3WfgEQsOCtS5tjzOPlkW0VH6C1rLbDJJZaVRkDXnrODNpZ+ztcp1uC+zScjk HskRDW3VOB0m1rZka7FXsMMZnRg2zRTVaxwumqVDEFWH/6o28HExkUbafSTjPVk2HmH9 Ihgg== X-Forwarded-Encrypted: i=1; AJvYcCXnaqgj50+eHKF6KZOFbkFO4Z0jQwfh82IZq2go9yosVuBbY6MIf9PJFp0ZiVabC9kc8LxwKBShva4oMZQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9v/wu6Kckyr+7KxwQEPPHhYJ4znczOu3THzQ9G1x5eTRazSOH +wUkY1Sr0bnA3zHDa7TUInG1TJojdMqsqNw2r6fCHUH1TMaK0jG3UTw2iQBK0i3PXIMrng== X-Gm-Gg: AY/fxX6v9OWFndb6aqd8B76CGddZhPsCHdwVXqtOU5jpStTHZYrkHKGWFI9vzetijEj TFbZmeS9BHURBVRVYa2Fn1F0ZEAp3wGNfWMStyuYBN6FMNCo7VaYz/2M4yRIiOliE/NYHXvnk2F LViOrRG76U2IDS5TeRydkxzdBf6Zw+oPXIb0M+6/F2Ekj5GFyg1/EuEYzdcIAOUoPA9yeXaxFI/ OBCkslV3zbScqVnXVbESajuc/cmsbEy2A3WW4dpIF4yNxbuAbl+A9uMsAJQ29nP2qv/H2gjd/gy 6cBiR4SHHz3Q/LJ821bfM7OylxfdF8ejYgW0yv1Q9HBGa3cgzuyofVt05drpvznn3e+1c4sUZMq bb5Ic8231xVD/2VpXmQQDp3y3GRUiXgHrdnWnc5b1pxVQfbwixzAIYHwf2UBMmZPBOYl1Fq/ZVT e8RPwa3ToTruHM0iWsXfJ3G7/eGb6v77E2glbOsB4kZmH9pqIxuw== X-Google-Smtp-Source: AGHT+IEdIn7/Xx2gZxK7oHVQGuBMB5XT5BC/9BQW5pH0KKPL02QkjBMaOLjCbrdxGlRAY3qDNRZF3g== X-Received: by 2002:a05:6a20:3d8a:b0:366:55c4:c5a8 with SMTP id adf61e73a8af0-369adad45a1mr11687148637.25.1765822164871; Mon, 15 Dec 2025 10:09:24 -0800 (PST) Received: from SLSGDTSWING002.tail0ac356.ts.net ([129.126.109.177]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c2ae4e346sm13138947a12.23.2025.12.15.10.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 10:09:24 -0800 (PST) From: Weiming Shi To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xmei5@asu.edu, "Weiming Shi" Subject: [PATCH v2] net: skbuff: add usercopy region to skbuff_fclone_cache Date: Tue, 16 Dec 2025 02:09:04 +0800 Message-ID: <20251215180903.954968-2-bestswngs@gmail.com> X-Mailer: git-send-email 2.43.0 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 Content-Type: text/plain; charset="utf-8" From: "Weiming Shi" skbuff_fclone_cache was created without defining a usercopy region, [1] unlike skbuff_head_cache which properly whitelists the cb[] field. [2] This causes a usercopy BUG() when CONFIG_HARDENED_USERCOPY is enabled and the kernel attempts to copy sk_buff.cb data to userspace via sock_recv_errqueue() -> put_cmsg(). The crash occurs when: 1. TCP allocates an skb using alloc_skb_fclone() (from skbuff_fclone_cache)= [1] 2. The skb is cloned via skb_clone() using the pre-allocated fclone [3] 3. The cloned skb is queued to sk_error_queue for timestamp reporting 4. Userspace reads the error queue via recvmsg(MSG_ERRQUEUE) 5. sock_recv_errqueue() calls put_cmsg() to copy serr->ee from skb->cb [4] 6. __check_heap_object() fails because skbuff_fclone_cache has no usercopy whitelist [5] When cloned skbs allocated from skbuff_fclone_cache are used in the socket error queue, accessing the sock_exterr_skb structure in skb->cb via put_cmsg() triggers a usercopy hardening violation: [ 5.379589] usercopy: Kernel memory exposure attempt detected from SLUB = object 'skbuff_fclone_cache' (offset 296, size 16)! [ 5.382796] kernel BUG at mm/usercopy.c:102! [ 5.383923] Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI [ 5.384903] CPU: 1 UID: 0 PID: 138 Comm: poc_put_cmsg Not tainted 6.12.5= 7 #7 [ 5.384903] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS = rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 [ 5.384903] RIP: 0010:usercopy_abort+0x6c/0x80 [ 5.384903] Code: 1a 86 51 48 c7 c2 40 15 1a 86 41 52 48 c7 c7 c0 15 1a = 86 48 0f 45 d6 48 c7 c6 80 15 1a 86 48 89 c1 49 0f 45 f3 e8 84 27 88 ff <0f= > 0b 490 [ 5.384903] RSP: 0018:ffffc900006f77a8 EFLAGS: 00010246 [ 5.384903] RAX: 000000000000006f RBX: ffff88800f0ad2a8 RCX: 1ffffffff0f= 72e74 [ 5.384903] RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffffff87b= 973a0 [ 5.384903] RBP: 0000000000000010 R08: 0000000000000000 R09: fffffbfff0f= 72e74 [ 5.384903] R10: 0000000000000003 R11: 79706f6372657375 R12: 00000000000= 00001 [ 5.384903] R13: ffff88800f0ad2b8 R14: ffffea00003c2b40 R15: ffffea00003= c2b00 [ 5.384903] FS: 0000000011bc4380(0000) GS:ffff8880bf100000(0000) knlGS:= 0000000000000000 [ 5.384903] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 5.384903] CR2: 000056aa3b8e5fe4 CR3: 000000000ea26004 CR4: 00000000007= 70ef0 [ 5.384903] PKRU: 55555554 [ 5.384903] Call Trace: [ 5.384903] [ 5.384903] __check_heap_object+0x9a/0xd0 [ 5.384903] __check_object_size+0x46c/0x690 [ 5.384903] put_cmsg+0x129/0x5e0 [ 5.384903] sock_recv_errqueue+0x22f/0x380 [ 5.384903] tls_sw_recvmsg+0x7ed/0x1960 [ 5.384903] ? srso_alias_return_thunk+0x5/0xfbef5 [ 5.384903] ? schedule+0x6d/0x270 [ 5.384903] ? srso_alias_return_thunk+0x5/0xfbef5 [ 5.384903] ? mutex_unlock+0x81/0xd0 [ 5.384903] ? __pfx_mutex_unlock+0x10/0x10 [ 5.384903] ? __pfx_tls_sw_recvmsg+0x10/0x10 [ 5.384903] ? _raw_spin_lock_irqsave+0x8f/0xf0 [ 5.384903] ? _raw_read_unlock_irqrestore+0x20/0x40 [ 5.384903] ? srso_alias_return_thunk+0x5/0xfbef5 In our patch, we referenced net: Whitelist the `skb_head_cache` "cb" field.= [5] Fix by using kmem_cache_create_usercopy() with the same cb[] region whitelist as skbuff_head_cache. [1] https://elixir.bootlin.com/linux/v6.12.62/source/net/ipv4/tcp.c#L885 [2] https://elixir.bootlin.com/linux/v6.12.62/source/net/core/skbuff.c#L5104 [3] https://elixir.bootlin.com/linux/v6.12.62/source/net/core/skbuff.c#L5566 [4] https://elixir.bootlin.com/linux/v6.12.62/source/net/core/skbuff.c#L5491 [5] https://elixir.bootlin.com/linux/v6.12.62/source/mm/slub.c#L5719 [6] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit= /?id=3D79a8a642bf05c Fixes: 6d07d1cd300f ("usercopy: Restrict non-usercopy caches to size 0") Signed-off-by: Weiming Shi Reported-by: Xiang Mei --- v2: Fix the Commit Message net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index c52e955dd3a0..89c98ce6106a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5157,7 +5157,7 @@ void __init skb_init(void) NULL); skbuff_cache_size =3D kmem_cache_size(net_hotdata.skbuff_cache); =20 - net_hotdata.skbuff_fclone_cache =3D kmem_cache_create("skbuff_fclone_cach= e", + net_hotdata.skbuff_fclone_cache =3D kmem_cache_create_usercopy("skbuff_fc= lone_cache", sizeof(struct sk_buff_fclones), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, --=20 2.43.0