Article View: linux.kernel.netdev
Article #11357[PATCH net-next v4 14/15] net/tls: don't BUG() on leftover length in __skb_nsg()
From: Josef Bacik
Date: Wed, 04 Nov 2026 20:47
Date: Wed, 04 Nov 2026 20:47
44 lines
13416 bytes
13416 bytes
__skb_nsg() counts the scatterlist entries for a range of an skb with a
copy of the __skb_to_sgvec() walk, including its BUG_ON(len) when the
skb runs out before the range does. tls_decrypt_sg() calls it on the
same range it then passes to skb_to_sgvec(), so a bad range would BUG()
here before it got to skb_to_sgvec()'s error return.
__skb_nsg() already returns -EMSGSIZE for a frag_list nested too deep,
and tls_decrypt_sg() fails the record on any return below 1. Return
-EINVAL for the leftover length too, with a DEBUG_NET_WARN_ON_ONCE() for
debug kernels, and say so in the comment above skb_nsg().
Acked-by: Mina Almasry <almasrymina@google.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
net/tls/tls_sw.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 771e02bff519..748ae27f2b88 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -142,12 +142,16 @@ static int __skb_nsg(struct sk_buff *skb, int offset, int len,
start = end;
}
}
- BUG_ON(len);
+ if (unlikely(len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
return elt;
}
/* Return the number of scatterlist elements required to completely map the
- * skb, or -EMSGSIZE if the recursion depth is exceeded.
+ * skb, -EMSGSIZE if the recursion depth is exceeded, or -EINVAL if the skb
+ * runs out before @len does.
*/
static int skb_nsg(struct sk_buff *skb, int offset, int len)
{
--
2.55.0
Technical Details
Message-ID:
<20261104-b4-skbuff-bug-on-followups-v4-14-b7ffeb364f5d@toxicpanda.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356925-linux-kernel-netdev=dewy.ruReferences:
<20261104-b4-skbuff-bug-on-followups-v4-0-b7ffeb364f5d@toxicpanda.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356925-linux-kernel-netdev=dewy.ru
From: josef@toxicpanda.com (Josef Bacik)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v4 14/15] net/tls: don't BUG() on leftover length
in __skb_nsg()
Date: Wed, 04 Nov 2026 20:47:26 +0000
Organization: Usenet Network
Message-ID: <20261104-b4-skbuff-bug-on-followups-v4-14-b7ffeb364f5d@toxicpanda.com>
References: <20261104-b4-skbuff-bug-on-followups-v4-0-b7ffeb364f5d@toxicpanda.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="3512120"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mA74HrBYimuTSVs5302+jrNoZmQ= sha256:yyzymF1zhb6a/hsHjhgVsJyl5ycrMYmz+JvMEY6yOTo=
sha1:eJrZ/LbKilJs3/7qC4npbKzDiVg= sha256:zZYeNM+SQdvq5UiPEN3lCxDkjEv7+nhy4D6a42CipIA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 00B65112DE1; Thu, 5 Nov 2026 02:12:29 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=toxicpanda.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id DVoUhZNYOQB2;
Thu, 5 Nov 2026 02:12:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356925-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=toxicpanda.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id C9F40112DCA; Thu, 5 Nov 2026 02:12:17 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id E0BEAC289C; Wed, 4 Nov 2026 21:26:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793825289;
b=oJ8LACMJKHvTRc8FSVmNDvgcxBOb97jReDsBaT8LOcFo8y0zz2n6F5OG36vGFh7RRIL9
gPuew+XpcfNBkSCyMiDhkKUzf1bjMFvcNfnGu7Y12k7vs/YBvgD2p189FeMQ4uusg0fTG
9csMV0xMfOax2xhhQEq9of9mIvHdTSj/OL8S5+12Vl9aD+sjB+mzOVF8HBfbU9zwBqFqM
UZUjAEAiN/yFhnViPepvdtrkwct6JqHoF8XvLtyzoeMgdVoGqrNDd7ih9R2jYPVXpWzHn
iiqraV4L8pK/1KGSDjCcL9chpuna+vB1OnBb+63EKnbjjJVSKm0L9QpzMeZmf1dpRpw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793825289;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:Date:Subject:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding:
Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key;
bh=vm4X83cKQV2cViXLrBy8CdaLxj8kNgfl4SZFvLru4UA=;
b=DHQ84ghLqDYCCm7DwQYu3hyMTmV/pwl15RcnyksjpbhTXYkn5t+OLyIf/PZf6xEG8SoT
wKaLbkjLxuu7nHFKW9wHq5/Kp5dd0LUGs9dQ9UCGR7HDRpEIoXNdYZLSwCL2eb/7YtBhC
D/B/zYvB3Kk/Lacu8WBRMVb668Jo9iTOMuR7Jq3TGzWog8ijpFaxVgPSQHVOpL/+ApOhT
wrn/F8SntghkJ+i0H/EESXiXVzaGzz+5iRusm8SIYpuemfWgbR0Yst8Ge7cFgQob054Kq
+RiPHY3f0e0T5xVgmccL+eNwGBtSxjUsPDETvAxLRYDuOkDHd/UT237K95yo2Bol7qw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=toxicpanda.com header.i=@toxicpanda.com header.a=rsa-sha256 header.s=google header.b=cyY7Nnw2;
dmarc=none header.from=toxicpanda.com;
spf=pass smtp.mailfrom=toxicpanda.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id EAB3D60A6F7F;
Wed, 4 Nov 2026 20:48:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=toxicpanda.com header.i=@toxicpanda.com header.a=rsa-sha256 header.s=google header.b=cyY7Nnw2
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.175
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793825288;
b=2u09NAenMJxuosk8EaH0SLFTLvUe9ISMX874+YH6a/6JAtts5o32dc2zNHjQO34cchAY
YEpgNS7Hb/UfwKOW+fpkQiGVH1h76vBK52uordruxu89bt9wacoFAod9YBYL+qHY2bJXs
tcHarRtJg8fKqpIVlA1iUnAHJ/6uJBWgYOdWCzXCIoRNz8gpEMjwlmRehPQuPJ4FUD2Rh
b8Zfs1QqizBnI/YvnD9uWMVojPckzg399+fSD1CResu+tn7Y3nfdjNrZJ2zEj68GOtY1Z
uDFltAjCcj5QLe1SPtLYtkuvHMSNB1I6BiZOnoSwdtYWXJrkPqENH16VVYxe74lERBg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793825288;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:
Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
X-Developer-Signature:X-Developer-Key;
bh=vm4X83cKQV2cViXLrBy8CdaLxj8kNgfl4SZFvLru4UA=;
b=f45g1+CdLSCatlTmxwL2/zD6SewZf1fl1ZbTNHfN+u0DAZmdDaO6b5vGDe5Rz19nY0+7
C0e2NkjH+vvPB1zMUCXrDr2zeKz3ItCY9sVP2QMVXb5F4W5tcjSdQeWAsca6yOLKasC7g
UabWPaDdLLr0tJ6eG1TWJstdEUKHjiaNuTB1ZfvE+cABtmr0rC64j833YNKslstbi0wgo
Z+PNHCx3VLtTbqhqf54P2CSYBXm+TeJFzQmrqRwiSxZ9Qi58JVK9u2KUtCwwRor1JVQGq
Rq+11em/HHAgsNIPBhz/fdu4keuYUjnJZXP6ofPQRbUudbWnvMy/qvtSQYSUS1s2Gqw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=none header.from=toxicpanda.com;
spf=pass smtp.mailfrom=toxicpanda.com;
dkim=pass header.d=toxicpanda.com header.i=@toxicpanda.com header.a=rsa-sha256 header.s=google header.b=cyY7Nnw2;
arc=none smtp.remote-ip=209.85.222.175
X-Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id B583F609692D
for <netdev@vger.kernel.org>; Wed, 4 Nov 2026 20:48:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B583F609692D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=toxicpanda.com
X-Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-93f3c8958d5so127163385a.2
for <netdev@vger.kernel.org>; Wed, 04 Nov 2026 12:48:07 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=toxicpanda.com; s=google; t=1793825287; x=1794430087; darn=vger.kernel.org;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=vm4X83cKQV2cViXLrBy8CdaLxj8kNgfl4SZFvLru4UA=;
b=cyY7Nnw2AC5c8RU6VlTJA7JMfhNPSMa5/IfHOpHz9VxoJnJDRJyFQohct8J++mHgd8
JeVKSfc7e4f34QKH4djlgXhoslOyXTjJXCAK1bXxAm+53RSN9f4JJLLSKAPtQg439jkY
rDdCQ3fq26S9cv5JOqnjXApm3R8sJAhiXqopLNpEHECEZ46GtWoOSH82eGaENheCoEEm
odnZyjCrf7//Z2eCuWbnCP4iNJ4+rLrojDMKVFq6IgBRmQHD+CMC9i3cR3W+U6W+EoV8
W5/lM/ibmdQN+N2U2gPEEW5rrRna6L3f6f+YVb64jDUxicwSD+WnkYkhFbWeaPZ9JrMT
B4Ag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793825287; x=1794430087;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=vm4X83cKQV2cViXLrBy8CdaLxj8kNgfl4SZFvLru4UA=;
b=ZmkwjNANfoQG7abTs8erY82kldpU6S+AKAHcfe2GEMCfQRC6Cx5VuUqjr+druFu9iQ
yfQ0tGPXpSHDAWs4KhXJxd45giYXDDZPIEtv695V1yvUWTkf3sM+gQ0UeYMQJuxhE0pO
OhjlJSEjYmBhKEO6hOW8Yqrda2RCgqdr39Nbkt2Wiok7sa9qAoL60dfdeqy9OueTkkuV
G9R4uq61vto5vGN8OnzKtlu8OF38YXOb4OmeP4HjcXiaP+XIfPD484OdTfJJHIxHY4LO
4y2ik40st/M20EQjJzKSaIdQUXmCJ+uoJJJ+utx33aB09igXbG6qd80ZxiIBhoBgwgxy
nqTQ==
X-Forwarded-Encrypted: i=1; AKwUvBx0hjI78Eb3khdCTx66uSiZotQ1uN7UA6mj9i9BIVzv+sxVd1dkt0Rj6rYlpppRQ/oIDYWBCM4=@vger.kernel.org
X-Gm-Message-State: APuU4Z+KtA5G9rBvRbyVP4XpE+/Yj3FsOFCJCMi4AaxlhtEWwG3L/IHL
o6JuJUgj2QWdvdiEBCvmhf3+JtoTQkPIHloMCVaW7mWBQdmEbbSKf3vSXSfaP7kullA=
X-Gm-Gg: AYBFou09YbiyOKLXwlMZg1htjbfVOYznaAoCZJbGedSQ4G4iow0NOHbxygNA3seI5dT
SkREVFryoy/eptfhpfOc0FPR5rQGzKpL8J5VF0CYWFDm84hS0OjhlXPPN7CzM6u6gdbSSrJEonx
c4GbToG1Z0+iWkyajd77FKGq3yi8LG08PWftexQQx4jVul3rnOSt/TFgn6zWdYACPOucMYqIsul
zkqkiSuSwM/MXxhfv2EKFOrUqkdtctCIYa3Q13wOrugF8O9lMpzrV6kDQKGjVgJoyjhT5zKExk3
KbiaZ3hxR83PR3eswV6PSnhDYfeIaP8mxKWCwfTXYZKvbuaQs9JvZp6tSBKJU8+d2+E1cxQnfHx
1YGrNewY8UJH3cC+RWgq2MrO3TKPXtoTkCvDD1mFzoxQ0JAiCMivl5hemTDcDxOJOuxQpWGJOFd
q8QqnaDtduhNSrQIB214Tuc6XcGc5hc0ISN9Gd941Y+BPyuNR4ZtyVRw0lWLNiIBMAwqojNsfAj
iQTAKlTgWgOfZKkvmLn3OMw2s2mJjb04B6P35h7mvPgIx1YdTCKMJqIaVUWJaeMVh7sJArTKjzU
b5WoDgUwyJUiGWKRqFvEhPvXRrRsDYHSLbJGwQjeUNdYP5lVEOTe2nAfYTzXIYqbt7w=
X-Received: by 2002:a05:620a:4043:b0:93f:31f0:6a7f with SMTP id af79cd13be357-9442172a5c1mr3191494585a.69.1793825286622;
Wed, 04 Nov 2026 12:48:06 -0800 (PST)
X-Received: from toxicpanda.com ([153.61.196.245])
by smtp.gmail.com with ESMTPSA id af79cd13be357-945d4899dc6sm292004485a.43.2026.11.04.12.48.05
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 04 Nov 2026 12:48:06 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261104-b4-skbuff-bug-on-followups-v4-0-b7ffeb364f5d@toxicpanda.com>
X-Cc: Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Fernando Fernandez Mancera <fmancera@suse.de>,
Mina Almasry <almasrymina@google.com>,
David Laight <david.laight.linux@gmail.com>, netdev@vger.kernel.org,
xen-devel@lists.xenproject.org, Josef Bacik <josef@toxicpanda.com>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=openssh-sha256; t=1793825269; l=1573;
i=josef@toxicpanda.com; h=from:subject:message-id;
bh=jtewRftckK13p/nQalxWcrhfGpFqhqstsSARsz5AoHI=;
b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG
JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA
QDKngciEsEX8JG2Ad0fN9Mloe1uVw1/l2WZ7sISbd/Ng5VMersZpizDOJC2J3tEMBwMooCA/YD/
B+ZXmrDCaGAc=
X-Developer-Key: i=josef@toxicpanda.com; a=openssh;
fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA