From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417881; cv=none; d=zohomail.com; s=zohoarc; b=JUntt4zw+gOml1/CIDzt1ejp++zgUzm0bvZ2cS/6c0QtwfJ4XFXll+2BaA7NXI6eoZYHP+udBFh6wXafu116N8bq3aE9OaH4lJcVTrpTTObVk469JLLsx1p+mwgPPcrsq9jssIMJPhVeEFvAI3UU/0WNt5aMDhcT9cIwJS36FRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417881; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qblwx7bbNy5k368b4HO2T3MytVs1L8oRqcYO8Zy3rtU=; b=fpXJazBcf2o28c3TxSgI0PAItNH5pE4S+uGoVOorvUnRALxr+vwWaXdO7hjPZsG1FbVhPwsalc+/AvCMCN+BKcBduCHDDA5BQA+IdFezp638sEIkWiaDObe699QoKD+Lwu0LkLAj7TW9p+FZHZZopbt2fmdThbi7cbyp4riKylQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417881502731.6647375729647; Mon, 19 Oct 2026 06:51:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454376.1667941 (Exim 4.92) (envelope-from ) id 1xInlX-0006fb-4T; Mon, 19 Oct 2026 13:51:03 +0000 Received: by outflank-mailman (output) from mailman id 1454376.1667941; Mon, 19 Oct 2026 13:51:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlX-0006fU-17; Mon, 19 Oct 2026 13:51:03 +0000 Received: by outflank-mailman (input) for mailman id 1454376; Mon, 19 Oct 2026 13:51:01 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlV-0006el-3t for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlU-001dLL-8m for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:00 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62028-e002-0a2a0a5209dd-0a2a450a9e52-40 for ; Mon, 19 Oct 2026 15:51:00 +0200 Received: from [209.85.219.41] (helo=mail-qv1-f41.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62041-f2d2-0a2a450a0019-d155db29e5b0-3 for ; Mon, 19 Oct 2026 15:50:58 +0200 Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-91791ec1b83so18174546d6.1 for ; Mon, 19 Oct 2026 06:50:57 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.241]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bcbaae645sm99626496d6.21.2026.10.19.06.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:50:55 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417857; x=1793022657; darn=lists.xenproject.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=qblwx7bbNy5k368b4HO2T3MytVs1L8oRqcYO8Zy3rtU=; b=Klwj52t/L04ZNTrbvz+c9fMFBZSiGuSEcmxJkDr3UJ9J/QSxZXiveqWv0ZEgO87vti 0K+HKN/OI9oETyiB/g/uhko0+ujsiaJ3q9HJEmQ0725USvMdLH41Yl+XrFUCAYDEJo0N RV27bt4EGXsfGQEjrx60sPiYbDGDSdo5raEXEoij1zLF5ureKaLznIRvtb2FN705CMuh wEpura8d241lmCHFnryrvwgQ0vXfaNBSrDLEz54iV+8Td9Jf5JMmzquhc9jvPM0sIU39 Wyoot6ZGkr3nNlDSY4+69XsIeQlF6117N7VIx5roEnHqiOQ/660vhcpxVWh36TIG8Mrc 2BJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417857; x=1793022657; 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=qblwx7bbNy5k368b4HO2T3MytVs1L8oRqcYO8Zy3rtU=; b=nYVdbW1qPLaPBTixzr9Co1tfAw8kO5sIqi5ZaXtT63yOYL6Cp3zZs2GFJNuHbCfSgc JUSG9o5dkKoCxHON4T1f6k+6qUXsuAIYm+8JNC5fjFNqxWyw8NNL7ZlJwk6aNdxucPT0 oXv5wbyb/7mZD+An8zq3QWYShPWpjPbhrGWksBrKiVZqKo0uSThuhuJ7WhrZEGbEOyae duJJkMrXfXTVwg1k+iJcpR8C5kcUKoM5YHUPlcIw7//LpfbqPwx3jtug0Nw+QFmKnO9+ wPWI25xtmpeFVWxgEHMrMBQZVnukC7sCKgIcGEdEIi+c7AX02LZKFkW7wD96y46oyjyv QBhg== X-Forwarded-Encrypted: i=1; AKwUvBxRWC4bzImFwYstkJM7acnd4hUH/mMT3ZLUO7Io0v6O2DT756Rp/4cRCht3YKvgkNvNcBgc1ej+eCk=@lists.xenproject.org X-Gm-Message-State: AFq9FYIJMClVo3iJe7WlmQb/GrMvUZ+O+j02amb9IX/uF1UpwB8WrukE +3jVACWPOpIX2kp3g7atVc7IfnsUwtVH1qW+KnGThvg5MMgNRYLNku7NOATyc1uFjqI= X-Gm-Gg: AYBFou3XEFWD9UpDp2CZtj7XAOFKNyVz4IsjKyG1MkGt+C6UfdfuWL8Bzk1pJIgFjjX 2dccPdp0paaZE5OU+8+3MFBsnku8AuVYLA9MUpaUSIaq+uQthyEs7pZbJpig0OzF95pMaLgzu8M LsvM5Zvh56k/3fxdaOk7l1u9zzhWkvZdISRWqm0bWtgoWS1P3FB3sdxE+F3WF1cJDxFPhD5v5D7 5wnUHJPyduTA91vmjmUkihO4/ZsTCTuIuci/GqZipAu9PJU/kGkDH4pLJXNSnT3U/T/Vz6K560H 0wcDGePtdYEVHH3IyEoPtC0aI2m6ApzsI/Br/DGRrdpAOSD/VysJc4Xj5kwL5QvThbj1uUw0s0t 2kkLjuEgmzF4VeDRuR8Quwo5PvPppzc1tQe+jutHN66vUC20y6AFhcrIl0tqRebpzXEa0z6vHMj DM+qQKTiIxtq6jpcC+AwZG1yEyuUMuJy8tibpxHcO/CgqEv8OeMnopzy0KG3bpOu5r0vIizJ61c ExOXAl3c3nyJFcQEiUY6kZhzAdCvMyeNm7zR0/2fh5sUzbO6zUfwwxOdXV8NUbAT1mpskzQ X-Received: by 2002:a05:6214:44a0:b0:917:a4d9:1373 with SMTP id 6a1803df08f44-91bdf127eaemr121313976d6.23.1792417856134; Mon, 19 Oct 2026 06:50:56 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:35 +0000 Subject: [PATCH net-next 01/15] net: skbuff: make skb_copy_and_csum_bits() report unreadable frags MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-1-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417848; l=13888; i=josef@toxicpanda.com; h=from:subject:message-id; bh=dL3q9YRxfCrEbWcizXq9oznfRWHecZyPcn5ovtK2fxY=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QDmxDJSAVza1wipmMQxYPi6qoFImua7iVjrYNs1kkIjpC41hXs6QTatTN021+n+ilY/mobmNNiA 3jVRJaLK4rw0= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-4011c0/1792417858-4B6D6CFC-906E07B3/0/0 X-purgate-type: clean X-purgate-size: 13890 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417883206158500 skb_copy_and_csum_bits() has no way to fail. When it reaches unreadable frags it zero-fills the rest of the buffer and returns 0, and since commit ab9414ed70bd ("net: skbuff: don't leave stale bytes in skb_copy_and_csum_bits()") that 0 is the correct checksum for what's in the buffer. Its callers can't tell the copy didn't happen. That matters in the !sg && !csum branch of skb_segment(). A devmem TCP skb keeps its whole payload in unreadable frags, so every segment ends up with a payload of zeroes, tcp_gso_segment() writes a valid TCP checksum over it, and the peer accepts the zeroes as stream data. This is reachable when both SG and TX checksum offload are turned off on a device used for devmem TX: sk_setup_caps() still gives TCP SG and HW_CSUM, so the dmabuf send is accepted, validate_xmit_unreadable_skb() lets the skb through for a NETMEM_TX_NO_DMA device or a matching binding, and software GSO segments it with neither feature. Before that commit the segments carried uninitialized memory with a checksum that almost never matched. This was reproduced with a test module rather than on devmem hardware: skb_segment() on a TCPv4 GSO skb with 3000 bytes of payload in a page frag marked unreadable, with features =3D=3D 0, returns 3 segments whose payloads are all zeroes, each with a checksum of 0, which is correct for zeroes. There's no warning or error; the data is silently replaced. With this patch skb_segment() returns -EFAULT. Make skb_copy_and_csum_bits() return 0 or -EFAULT and hand the checksum back through a pointer, and make it __must_check so a new caller can't ignore the failure. Running out of skb before @len returns -EFAULT too; commit 417261779eab ("net: skbuff: don't BUG() on leftover length in skb_copy_and_csum_bits()") made that a zero-fill and a checksum of 0. Each caller takes the error path it already has for a failed copy: - skb_segment() fails the segmentation, as the csum branch already does when skb_copy_bits() fails. - icmp_glue_bits() and icmpv6_getfrag() return the error, so the ICMP error isn't sent. - __ip_append_data() and __ip6_append_data() drop the new skb and return -EFAULT, as they do when getfrag fails. - vnet_skb_shape() fails the same way it does when its skb_copy_bits() call fails. - xdr_skb_read_bits() returns 0 without consuming anything, as it does when skb_copy_bits() fails, so desc.count stays non-zero and csum_partial_copy_to_xdr() fails. csum_partial_copy_to_xdr() used to checksum the bytes it hadn't copied before checking desc.count. desc.offset and desc.count always add up to skb->len, so that only ran when it was about to fail anyway, and on an unreadable skb skb_checksum() would WARN. Drop it. - skb_copy_and_csum_dev() can't return an error, so it leaves the checksum alone and the frame goes out with a bad one. Its callers are drivers that never see unreadable skbs anyway. The zero-fill stays, so a caller that does send the buffer still doesn't leak anything. This was found by the Sashiko AI review of that commit, and Mina suggested reporting the error from the helper rather than checking for unreadable frags in skb_segment(). Link: https://lore.kernel.org/all/179148235783.434549.14322374227477832817@= kernel.org/ Suggested-by: Mina Almasry Reviewed-by: Mina Almasry Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- drivers/net/ethernet/sun/sunvnet_common.c | 10 +++-- include/linux/skbuff.h | 4 +- net/core/skbuff.c | 63 +++++++++++++++++++++------= ---- net/ipv4/icmp.c | 9 +++-- net/ipv4/ip_output.c | 11 ++++-- net/ipv6/icmp.c | 7 +++- net/ipv6/ip6_output.c | 11 ++++-- net/sunrpc/socklib.c | 9 ++--- 8 files changed, 83 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/sun/sunvnet_common.c b/drivers/net/ethern= et/sun/sunvnet_common.c index 5cca95869052..4f229fcecc32 100644 --- a/drivers/net/ethernet/sun/sunvnet_common.c +++ b/drivers/net/ethernet/sun/sunvnet_common.c @@ -1167,9 +1167,13 @@ static inline struct sk_buff *vnet_skb_shape(struct = sk_buff *skb, int ncookies) =20 /* copy the rest, with csum calculation */ *(__sum16 *)(skb->data + offset) =3D 0; - csum =3D skb_copy_and_csum_bits(skb, start, - nskb->data + start, - skb->len - start); + if (skb_copy_and_csum_bits(skb, start, + nskb->data + start, + skb->len - start, &csum)) { + dev_kfree_skb(nskb); + dev_kfree_skb(skb); + return NULL; + } =20 /* add in the header checksums */ if (skb->protocol =3D=3D htons(ETH_P_IP)) { diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index af1cbc2799b7..09db32f70b53 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4277,8 +4277,8 @@ void skb_free_datagram(struct sock *sk, struct sk_buf= f *skb); int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int f= lags); int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len= ); int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int = len); -__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *t= o, - int len); +int __must_check skb_copy_and_csum_bits(const struct sk_buff *skb, int off= set, + u8 *to, int len, __wsum *csum); int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int off= set, struct pipe_inode_info *pipe, unsigned int len, unsigned int flags); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 93c2f440b9ec..a2b52a5a61a9 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3630,14 +3630,27 @@ EXPORT_SYMBOL(skb_checksum); =20 /* Both of above in one bottle. */ =20 -__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, - u8 *to, int len) +/** + * skb_copy_and_csum_bits - copy data out of an skb and checksum it + * @skb: source buffer + * @offset: offset in @skb to start copying from + * @to: destination buffer + * @len: number of bytes to copy + * @csump: where to store the checksum of the copied bytes + * + * Return: 0 on success, or -EFAULT if @skb has unreadable frags or runs + * out before @len does. On failure *@csump is not set and the part of + * @to that couldn't be filled is zeroed. + */ +int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, + u8 *to, int len, __wsum *csump) { int start =3D skb_headlen(skb); int i, copy =3D start - offset; struct sk_buff *frag_iter; int pos =3D 0; __wsum csum =3D 0; + int err; =20 /* Copy header. */ if (copy > 0) { @@ -3646,7 +3659,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *s= kb, int offset, csum =3D csum_partial_copy_nocheck(skb->data + offset, to, copy); if ((len -=3D copy) =3D=3D 0) - return csum; + goto out; offset +=3D copy; to +=3D copy; pos =3D copy; @@ -3656,7 +3669,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *s= kb, int offset, /* Don't hand the caller a buffer with stale bytes in it. */ if (len > 0) memset(to, 0, len); - return 0; + return -EFAULT; } =20 for (i =3D 0; i < skb_shinfo(skb)->nr_frags; i++) { @@ -3688,7 +3701,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *s= kb, int offset, } =20 if (!(len -=3D copy)) - return csum; + goto out; offset +=3D copy; to +=3D copy; } @@ -3705,12 +3718,16 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff = *skb, int offset, if ((copy =3D end - offset) > 0) { if (copy > len) copy =3D len; - csum2 =3D skb_copy_and_csum_bits(frag_iter, - offset - start, - to, copy); + err =3D skb_copy_and_csum_bits(frag_iter, offset - start, + to, copy, &csum2); + if (err) { + /* The child zeroed its part; zero the rest. */ + memset(to + copy, 0, len - copy); + return err; + } csum =3D csum_block_add(csum, csum2, pos); if ((len -=3D copy) =3D=3D 0) - return csum; + goto out; offset +=3D copy; to +=3D copy; pos +=3D copy; @@ -3722,9 +3739,11 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *= skb, int offset, /* Don't hand the caller a buffer with stale bytes in it. */ if (len > 0) memset(to, 0, len); - return 0; + return -EFAULT; } - return csum; +out: + *csump =3D csum; + return 0; } EXPORT_SYMBOL(skb_copy_and_csum_bits); =20 @@ -4006,9 +4025,13 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb= , u8 *to) skb_copy_from_linear_data(skb, to, csstart); =20 csum =3D 0; - if (csstart !=3D skb->len) - csum =3D skb_copy_and_csum_bits(skb, csstart, to + csstart, - skb->len - csstart); + /* On failure the rest of @to is zeroed; leave the checksum alone so + * the frame goes out with a bad one. + */ + if (csstart !=3D skb->len && + skb_copy_and_csum_bits(skb, csstart, to + csstart, + skb->len - csstart, &csum)) + return; =20 if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { long csstuff =3D csstart + skb->csum_offset; @@ -5057,11 +5080,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_sk= b, if (!csum) { if (!nskb->remcsum_offload) nskb->ip_summed =3D CHECKSUM_NONE; - SKB_GSO_CB(nskb)->csum =3D - skb_copy_and_csum_bits(head_skb, offset, - skb_put(nskb, - len), - len); + if (skb_copy_and_csum_bits(head_skb, offset, + skb_put(nskb, len), + len, + &SKB_GSO_CB(nskb)->csum)) { + err =3D -EFAULT; + goto err; + } SKB_GSO_CB(nskb)->csum_start =3D skb_headroom(nskb) + doffset; } else { diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 90c0e22c29be..35008785e3d2 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -364,12 +364,15 @@ static int icmp_glue_bits(void *from, char *to, int o= ffset, int len, int odd, DEFINE_RAW_FLEX(struct icmp_bxm, icmp_param, replyopts.opt.__data, IP_OPTIONS_DATA_FIXED_SIZE); __wsum csum; + int err; =20 icmp_param =3D from; =20 - csum =3D skb_copy_and_csum_bits(icmp_param->skb, - icmp_param->offset + offset, - to, len); + err =3D skb_copy_and_csum_bits(icmp_param->skb, + icmp_param->offset + offset, + to, len, &csum); + if (err) + return err; =20 skb->csum =3D csum_block_add(skb->csum, csum, odd); if (icmp_param->data.icmph.type <=3D NR_ICMP_TYPES && diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 3396f177a18d..f7da4538d05b 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1162,9 +1162,14 @@ static int __ip_append_data(struct sock *sk, data +=3D fragheaderlen + exthdrlen; =20 if (fraggap) { - skb->csum =3D skb_copy_and_csum_bits( - skb_prev, maxfraglen, - data + transhdrlen, fraggap); + if (skb_copy_and_csum_bits(skb_prev, maxfraglen, + data + transhdrlen, + fraggap, + &skb->csum)) { + err =3D -EFAULT; + kfree_skb(skb); + goto error; + } skb_prev->csum =3D csum_sub(skb_prev->csum, skb->csum); data +=3D fraggap; diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index a95b0351824f..31ca3da80b1f 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -322,9 +322,12 @@ static int icmpv6_getfrag(void *from, char *to, int of= fset, int len, int odd, st struct icmpv6_msg *msg =3D (struct icmpv6_msg *) from; struct sk_buff *org_skb =3D msg->skb; __wsum csum; + int err; =20 - csum =3D skb_copy_and_csum_bits(org_skb, msg->offset + offset, - to, len); + err =3D skb_copy_and_csum_bits(org_skb, msg->offset + offset, + to, len, &csum); + if (err) + return err; skb->csum =3D csum_block_add(skb->csum, csum, odd); if (!(msg->type & ICMPV6_INFOMSG_MASK)) nf_ct_attach(skb, org_skb); diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 25fe0ba98b1a..d259e7dca8ba 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1724,9 +1724,14 @@ static int __ip6_append_data(struct sock *sk, skb->transport_header =3D (skb->network_header + fragheaderlen); if (fraggap) { - skb->csum =3D skb_copy_and_csum_bits( - skb_prev, maxfraglen, - data + transhdrlen, fraggap); + if (skb_copy_and_csum_bits(skb_prev, maxfraglen, + data + transhdrlen, + fraggap, + &skb->csum)) { + err =3D -EFAULT; + kfree_skb(skb); + goto error; + } skb_prev->csum =3D csum_sub(skb_prev->csum, skb->csum); data +=3D fraggap; diff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c index d8d8842c7de5..5d780ad4ae3a 100644 --- a/net/sunrpc/socklib.c +++ b/net/sunrpc/socklib.c @@ -49,7 +49,9 @@ xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, = size_t len) if (desc->need_checksum) { __wsum csum; =20 - csum =3D skb_copy_and_csum_bits(desc->skb, desc->offset, to, len); + if (unlikely(skb_copy_and_csum_bits(desc->skb, desc->offset, + to, len, &csum))) + return 0; desc->csum =3D csum_block_add(desc->csum, csum, desc->offset); } else { if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len))) @@ -142,11 +144,6 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, stru= ct sk_buff *skb) desc.csum =3D csum_partial(skb->data, desc.offset, skb->csum); if (xdr_partial_copy_from_skb(xdr, &desc) < 0) return -1; - if (desc.offset !=3D skb->len) { - __wsum csum2; - csum2 =3D skb_checksum(skb, desc.offset, skb->len - desc.offset, 0); - desc.csum =3D csum_block_add(desc.csum, csum2, desc.offset); - } if (desc.count) return -1; if (csum_fold(desc.csum)) --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417881; cv=none; d=zohomail.com; s=zohoarc; b=kJlOvKKvVGeHefKSOOH0fW/U2QNSupsTJlvmdEmdv7reLSCgMMGulmcFXSDWYMKWTT48VxGxxK4gSoE0MxvlW6fRCIj8HN3gWZkYvxlMYVeBQkHz3p599z/8ixoQxsZLqRl6sundPh9nlL01mE0FCLuc//nuW+R0h5eXzjpMYC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417881; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j9xcHh2wY++h6+R9ioq32anwJ7T1kqXqVTQttxnVock=; b=Jr8N8Aaxy0vuDl6CTZaFCQp23dTQw8ymDpqTjsA37aBGtFmQx7c0EgLpH69WjNAIX+gcKSLkBM/7Jhb/B70L/fH8u5QWJGF3qes4R55cBwRxENp2TroI8bPfSPksgh1X+S6+lor6M90jX0b/NW/BlqeWBbEJl2XYuBYBUN+A6Wg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417881348605.833485215091; Mon, 19 Oct 2026 06:51:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454377.1667946 (Exim 4.92) (envelope-from ) id 1xInlX-0006i5-BF; Mon, 19 Oct 2026 13:51:03 +0000 Received: by outflank-mailman (output) from mailman id 1454377.1667946; Mon, 19 Oct 2026 13:51:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlX-0006hw-7Y; Mon, 19 Oct 2026 13:51:03 +0000 Received: by outflank-mailman (input) for mailman id 1454377; Mon, 19 Oct 2026 13:51:01 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlV-0006er-Dd for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlU-009usr-Qc for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:00 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62044-8faa-0a2a0a5109dd-0a2a4509944e-0 for ; Mon, 19 Oct 2026 15:51:00 +0200 Received: from [209.85.222.177] (helo=mail-qk1-f177.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62042-be1a-0a2a45090019-d155deb1cc65-3 for ; Mon, 19 Oct 2026 15:50:59 +0200 Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-93f1cf92c9eso224759485a.0 for ; Mon, 19 Oct 2026 06:50:59 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bcba3d5a1sm97403096d6.8.2026.10.19.06.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:50:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417858; x=1793022658; darn=lists.xenproject.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=j9xcHh2wY++h6+R9ioq32anwJ7T1kqXqVTQttxnVock=; b=OD1qlKc8Rmz9yga4pK6YrfCksB6tZAO81b0koN4FZ87rN8nWx3R97knMtmIkVKn8tu G3JMySp2QqPhEAGUow7MKeNxo5A5ekZGade0hi27owWVrTA06foh8crkgfJgCWpQXuzO er1MIjOt4aFcS07jZna3TN+bXUiVB/wGne663U/D0/vYCxT1sV2/rRdmwpjtctR16/VN o3CPdAWgesyg42sCEdxWuOBOTFEgXUyhqmKauzZSsAgyw+SGa0jmsQe4ktZcX4G7Xf13 asXRUD0g1zjKNJ8VK/HFFFmNfEjYQCHiXFTyCVMcDlZKysyZfGmR8y1HDllGBlfElLAB FESg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417858; x=1793022658; 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=j9xcHh2wY++h6+R9ioq32anwJ7T1kqXqVTQttxnVock=; b=XBounGFZ00ZQaKDsk2F2qdtfGCTD5iBiZ4KfwSY6c7LRWtjZb25p6AbDAPCpf5B9VP 7Jav5pPqycJxJznxLZdQ77L4j6+SgO63eHwTGe+eBDL102YCPH5GUX3MwbzzR8312Rqo YS++mhsovkZUkVk5Ar0zPFuVA0Gvgb2gffkRt0v4VRlMZuteaWRpc4ZnHBA49qaxHD4c rJoR5+Bj25KdoIcz601Vuxn+HTcQB6RKImX2ki8tS9tZ4KqFuvceLSBs0U3CPRIGawOa 2eoYwnd6Wdd2blzCO5Wd3BNZgtD3xWbHH6V21GIw9N1C8+2IHXAGx64Sn8gu5suhicPC kYUw== X-Forwarded-Encrypted: i=1; AKwUvBxMLKpMZ/NWZ9RBwE1rsLuO7rXm/iLpLXkq64/w7MdVNdYsg09jtla0PqLjYyO1Qlvk6wEpWcbqFCU=@lists.xenproject.org X-Gm-Message-State: AFq9FYIx6scxYq2W/H/dna+lIecvS6JDmomqAJLpDKjCgDRgjTkzCrBo xkC97zm2BIpI7k6YYrRr+1hWRU71YseFMayBp0K6/JnuohfcMrtY7odLWKuIhYXoogk= X-Gm-Gg: AYBFou3mwqSRQyEsU6JJY2BC2fhK3jedZXnPK+YZrtCZIBAXBySSsYI5SQDcDTuD70f oibc3Irm37E2gco6ZibrW51e9SgpmpvFW6V4d85eDbTjbEylwU3bsape6fF7XGqnXcDX+rcn8hQ rnU4SkVTiDJPk8EUzmk1CbT0iE4/G/XBdsBX5b+lkOd6MB61CpLjNuhXuXgpkunuNHVXHBcVYo1 X5wOWlLSxd0s0VeRpQg31WP4lkkfcxVB05G96FFC+rcwwwaWnWD3Ne3rreMKIOYLiDEHyJTe5YT NbGFWB3/YlKdtwsP1Vba4NRKZ/T/ayhsSylJ91GeU92yhqvvSL80+7t6hAo+Qu0nxGbNRW3KNOV 9EsGnMdt7QGjNoZDv84fkTbaZlJIa4zlDP0mr4yINplBvLuPFlBQPg80n9Om/rcg8RhF7Otrmjj Rug5IwSYrL292M9/pyNvJcYkkheRmZoDbApmtSK5LEfcw60TvRH6ocm+QhAT3FHWK+X0038cJ6f TA31byTlCKRxsi6 X-Received: by 2002:a05:620a:4095:b0:93e:6b9e:6167 with SMTP id af79cd13be357-93f29cee007mr1347508785a.16.1792417858142; Mon, 19 Oct 2026 06:50:58 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:36 +0000 Subject: [PATCH net-next 02/15] net: skbuff: add skb_checksum_full() that reports failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-2-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417848; l=5325; i=josef@toxicpanda.com; h=from:subject:message-id; bh=ZlvWwY4Y8lGqu2UhxWxy8P8g8HVcQXW7x438vujwS94=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QNFaoaSkHTQ/kJoHxBw9tZmbGdrEQBXIlSmcmhx2hYL/udLBNhUXEeeONY2pepSid3GD1qdel1E VD02yM/ZF5Ao= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-bad1c0/1792417859-FCE14034-D3B0E2FC/0/0 X-purgate-type: clean X-purgate-size: 5327 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417883161158500 skb_checksum() can't fail. When the range runs into unreadable frags or past the end of the skb it returns 0, which is also a valid checksum, so its callers can't tell the sum from a failure. For the receive-side validation helpers that means a packet whose payload was never checksummed can pass, and commit 20ddd0fd2fcd ("net: skbuff: don't BUG() on leftover length in skb_checksum() and friends") made the past-the-end case one of those instead of a BUG(). Add skb_checksum_full(), which adds the range's sum to *@csump and returns 0, or returns -EFAULT for unreadable frags or a range past the end of the skb, and -EINVAL for a negative length, leaving *@csump alone. It's __must_check so a caller can't ignore the failure, and it recurses into frag_list members through itself so a failure there isn't lost either. skb_checksum() becomes a wrapper around it that behaves as before for the callers that haven't been converted: it returns 0 on failure and warns once if that was because of unreadable frags. The following patches convert the core users, and the rest will follow per subsystem. Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- include/linux/skbuff.h | 2 ++ net/core/skbuff.c | 56 +++++++++++++++++++++++++++++++++++++++++-----= ---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 09db32f70b53..969b1c3269ec 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4279,6 +4279,8 @@ int skb_copy_bits(const struct sk_buff *skb, int offs= et, void *to, int len); int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int = len); int __must_check skb_copy_and_csum_bits(const struct sk_buff *skb, int off= set, u8 *to, int len, __wsum *csum); +int __must_check skb_checksum_full(const struct sk_buff *skb, int offset, + int len, __wsum *csump); int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int off= set, struct pipe_inode_info *pipe, unsigned int len, unsigned int flags); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index a2b52a5a61a9..061c61422a38 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3545,12 +3545,31 @@ int skb_store_bits(struct sk_buff *skb, int offset,= const void *from, int len) EXPORT_SYMBOL(skb_store_bits); =20 /* Checksum skb data. */ -__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum= csum) +/** + * skb_checksum_full - checksum a range of an skb + * @skb: buffer to checksum + * @offset: offset in @skb to start at + * @len: number of bytes to checksum + * @csump: the sum to add to; on success the range's sum is added to it + * + * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb + * has unreadable frags in the range or runs out before @len does. On + * failure *@csump is not changed. + */ +int skb_checksum_full(const struct sk_buff *skb, int offset, int len, + __wsum *csump) { int start =3D skb_headlen(skb); int i, copy =3D start - offset; struct sk_buff *frag_iter; + __wsum csum =3D *csump; int pos =3D 0; + int err; + + if (unlikely(len < 0)) { + DEBUG_NET_WARN_ON_ONCE(1); + return -EINVAL; + } =20 /* Checksum header. */ if (copy > 0) { @@ -3558,13 +3577,13 @@ __wsum skb_checksum(const struct sk_buff *skb, int = offset, int len, __wsum csum) copy =3D len; csum =3D csum_partial(skb->data + offset, copy, csum); if ((len -=3D copy) =3D=3D 0) - return csum; + goto out; offset +=3D copy; pos =3D copy; } =20 - if (WARN_ON_ONCE(!skb_frags_readable(skb))) - return 0; + if (!skb_frags_readable(skb)) + return -EFAULT; =20 for (i =3D 0; i < skb_shinfo(skb)->nr_frags; i++) { int end; @@ -3593,7 +3612,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int of= fset, int len, __wsum csum) } =20 if (!(len -=3D copy)) - return csum; + goto out; offset +=3D copy; } start =3D end; @@ -3606,14 +3625,17 @@ __wsum skb_checksum(const struct sk_buff *skb, int = offset, int len, __wsum csum) =20 end =3D start + frag_iter->len; if ((copy =3D end - offset) > 0) { - __wsum csum2; + __wsum csum2 =3D 0; + if (copy > len) copy =3D len; - csum2 =3D skb_checksum(frag_iter, offset - start, copy, - 0); + err =3D skb_checksum_full(frag_iter, offset - start, copy, + &csum2); + if (err) + return err; csum =3D csum_block_add(csum, csum2, pos); if ((len -=3D copy) =3D=3D 0) - return csum; + goto out; offset +=3D copy; pos +=3D copy; } @@ -3621,9 +3643,23 @@ __wsum skb_checksum(const struct sk_buff *skb, int o= ffset, int len, __wsum csum) } if (unlikely(len)) { DEBUG_NET_WARN_ON_ONCE(1); - return 0; + return -EFAULT; } +out: + *csump =3D csum; + return 0; +} +EXPORT_SYMBOL(skb_checksum_full); =20 +/* skb_checksum() has no way to report failure, so it returns 0, which is a + * valid checksum. Use skb_checksum_full() in new code. + */ +__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum= csum) +{ + if (unlikely(skb_checksum_full(skb, offset, len, &csum))) { + WARN_ON_ONCE(!skb_frags_readable(skb)); + return 0; + } return csum; } EXPORT_SYMBOL(skb_checksum); --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417877; cv=none; d=zohomail.com; s=zohoarc; b=Ft14o+HVBPnDBVehUxPtwKd0Gtwk1Umo2fLBHCJGNwrPywAEi/YMdhbIPT1gskYSV9/g99lmekOAvoXYDDhhEZlbsE3m+6DhH92EXk1USK7IJ1uyGGsbxENuyTocorYQkMGPP7IKf1GYCg22h2NWEmLOOsujvXCR/5mbQzQ1VBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417877; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DPzcetTQubRCe4lOTpMna5FIDyGXRIDSoyAwtL9E3zo=; b=Nv0L7CpgHNJeZWa8VBO1NQBYDKJiLS33q0sKXmVRGIYn7uO9qEeVAf8iFSAm/ye6R0Huxd6ivqZm3sxhjh5lfcUj4bkJ2LaTulVTMKeDQhtuSTpLDfQxGmHM/7wkcTvXBaXAiyj5PE8QIhA2n0U95oc2lCXI8tzBiJ2NI21aHu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417877480917.2354260046595; Mon, 19 Oct 2026 06:51:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454378.1667953 (Exim 4.92) (envelope-from ) id 1xInlX-0006rD-Pt; Mon, 19 Oct 2026 13:51:03 +0000 Received: by outflank-mailman (output) from mailman id 1454378.1667953; Mon, 19 Oct 2026 13:51:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlX-0006p5-Ka; Mon, 19 Oct 2026 13:51:03 +0000 Received: by outflank-mailman (input) for mailman id 1454378; Mon, 19 Oct 2026 13:51:02 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlW-0006f9-95 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlV-00EZHA-MJ for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:01 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62035-bab6-0a2a0a5309dd-0a2a45039eb4-30 for ; Mon, 19 Oct 2026 15:51:01 +0200 Received: from [209.85.160.174] (helo=mail-qt1-f174.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62044-fae8-0a2a45030019-d155a0aed1fc-3 for ; Mon, 19 Oct 2026 15:51:01 +0200 Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-5363316fa0cso28487541cf.3 for ; Mon, 19 Oct 2026 06:51:01 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.240]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bcbb27839sm98396566d6.35.2026.10.19.06.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:50:59 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417860; x=1793022660; darn=lists.xenproject.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=DPzcetTQubRCe4lOTpMna5FIDyGXRIDSoyAwtL9E3zo=; b=XsSTGl1K4GYN+PDY3oQjjdJsMv3LQN11FpIdqnYLLdsat1sBjBdmM7c7tChEWyHzTL dA4Wi3ZS2ytcIVnTokQvZGhh0N4nT8y2uA3Xg3r8psqAdp2TT3rfAANFVhBwLTVAAu6s 0mqJlNumQBsOL+eiCpRM//X/PuYb0ycdQoedzAZSbRA8TGuBlDmG93VmLqfoQZY5K5+M yLYLN96WRezVqHmFq+/8X6tlBDCIArlD0RbUxsY7mzhEF9T/V7xT+lUzfrfRgCx0lh9B UNXtIvyCmpD7qYLgBYXCQ9y1WBCcmwcAtYtFo67xNmjN1HgsUpKCmm5/S8utyDDQJCMo dFlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417860; x=1793022660; 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=DPzcetTQubRCe4lOTpMna5FIDyGXRIDSoyAwtL9E3zo=; b=yE8Ig18QOmHvLn7JDwL0I9RvgEz4nevdzF715+kufVRPmU23XYBmRGh/XKxR/uG+IV mMB/Nmd9G5L1ugBCJ89R8Ow46xEXizrhotimunOU+zxUmdvxTVxpEK/aR1VjrY7w0PSD EW4nMkaITQxKHt1jH36MlKOAzXrAwPCt5FLoBh3pATc1pX9j0MLHdy1N31gzXffv7817 qyzKKPakeSvuJiU1SQYvgL4OqUehBrMCkqG/qScrwVERd77h6CNK6CZZNn5mrM2QtnyC F7+6odwic58GWnazkNftSNtUmNOo10UsImSGebq3w12in/cbNTOjFYU8bUBmhPbiYkkw oQkg== X-Forwarded-Encrypted: i=1; AKwUvBwGStJf3RtJsg0+HdYHVvCbwoVNMxCqqUtxZEfvWwY265atHjZfBn1JU1OLqKoIf8d7I37pSaQgMCE=@lists.xenproject.org X-Gm-Message-State: AFq9FYIfkyvCMDIEJ/7bOmdN9mowdxeqkJHFw3UA007YeJlkSqNSuWUJ 3ZCIQ6XwCmxmPRkXrlKA5e3Ht5N3uhkbbk/vAggRLQgT+S2A4w6dbehyUaFnHBKhy7w= X-Gm-Gg: AYBFou31hXo0+9wxnswpEoOL84hzAZ4fMhcsrB3zzD2sDiZ8fAId86QxAbEzn+v42Cv Qgyp/UaY/VKOiDUCSFCUfNwtBtqANCwORp5WABRGc8aM7G0KH7L7cYaXiWtfLyHxP+rqvHXaKyr cgY83QCCPdZARobt3nLKZBDZWIowIDpvWLvsPz8uVBBgbWSJ5uKpI1T0ndwLjF0AJPheoOjoHcs 0Hb96HQZKhrOjH1tqGOm5kEvh9ddgOXuUKTN/4jAFpvYdmHVSnmiG7+vf6UyhyZi37BSqBKpsvY q4O9D7Gbycq7+I/ebQF0Tj7/+1UGM9pq/l3A3Gi5N5MiSCZnJTgJ/tZuUFYqjWGZ8lSlLGSY+kr T2+HCxPkMfud6MYIoBIfOetIkfLODF99ccgpdMnHvCjgBwU+B59XQTOrBtIKD3HaLr9ahLK2Bzn mds05kHLJ4dpFH6eQvcRL+RAfbVAFB1++3Fr2xj/vgr9Hl5bdSDciepmUFUyvHPVOE5b4nlaW8L bjtEhfidh7DWi4= X-Received: by 2002:ac8:5745:0:b0:532:abc9:8f4f with SMTP id d75a77b69052e-53645ff0043mr114359591cf.37.1792417860150; Mon, 19 Oct 2026 06:51:00 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:37 +0000 Subject: [PATCH net-next 03/15] net: skbuff: fail checksum validation when the skb can't be checksummed MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-3-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417848; l=2860; i=josef@toxicpanda.com; h=from:subject:message-id; bh=prj+BQU7C60dBsXDxJX9jL8mklYfFucWwKvpS5MOuJ4=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QORYeqwwHo+WYErVqZ8QYEvyduUuJE0wPwwChX6fbXgz7Urjug8C88v1GDgpgDsaWL42fgGzxt7 mVAv6CTaYGQk= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-33051d/1792417861-6F8C54E9-700B187B/0/0 X-purgate-type: clean X-purgate-size: 2862 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417879082158500 __skb_checksum_complete() verifies a received packet with skb_checksum(), which returns 0 when the range runs into unreadable frags or past the end of the skb. 0 is a valid sum, so it's treated as one: it adds skb->csum, the pseudo-header sum, and folds the result. With a sum of 0 that's csum_fold(skb->csum), which is 0 whenever the pseudo-header sum folds to 0xffff, so a packet whose payload was never checksummed is accepted, marked csum_valid, and left with a wrong CHECKSUM_COMPLETE value in skb->csum. __skb_checksum_complete_head() passes skb->csum in as the seed, so a failure there folds 0 and the packet fails validation, but only because skb_checksum() happened to drop the seed. Use skb_checksum_full() in both, and report a packet that can't be checksummed as having a bad checksum, so callers drop it the way they drop any other bad checksum. Clear csum_valid, and leave skb->csum and ip_summed alone, since there's no full packet checksum to store. Found by the Sashiko AI review of the series that made skb_checksum() return 0 for a range past the end of the skb. Fixes: 20ddd0fd2fcd ("net: skbuff: don't BUG() on leftover length in skb_ch= ecksum() and friends") Link: https://lore.kernel.org/all/20261007-b4-skbuff-bug-on-v2-0-b9a5f73289= 5b@toxicpanda.com/ Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 061c61422a38..40d2dd20d47d 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3860,9 +3860,17 @@ EXPORT_SYMBOL(skb_crc32c); =20 __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len) { + __wsum csum =3D skb->csum; __sum16 sum; =20 - sum =3D csum_fold(skb_checksum(skb, 0, len, skb->csum)); + /* If the data can't be checksummed it can't be valid either. */ + if (skb_checksum_full(skb, 0, len, &csum)) { + if (!skb_shared(skb)) + skb->csum_valid =3D 0; + return (__force __sum16)1; + } + + sum =3D csum_fold(csum); /* See comments in __skb_checksum_complete(). */ if (likely(!sum)) { if (unlikely(skb->ip_summed =3D=3D CHECKSUM_COMPLETE) && @@ -3886,10 +3894,17 @@ EXPORT_SYMBOL(__skb_checksum_complete_head); */ __sum16 __skb_checksum_complete(struct sk_buff *skb) { - __wsum csum; + __wsum csum =3D 0; __sum16 sum; =20 - csum =3D skb_checksum(skb, 0, skb->len, 0); + /* If the data can't be checksummed it can't be valid either. Leave + * skb->csum alone, it's not a full packet checksum. + */ + if (skb_checksum_full(skb, 0, skb->len, &csum)) { + if (!skb_shared(skb)) + skb->csum_valid =3D 0; + return (__force __sum16)1; + } =20 sum =3D csum_fold(csum_add(skb->csum, csum)); /* This check is inverted, because we already knew the hardware --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417891; cv=none; d=zohomail.com; s=zohoarc; b=Q3blMo4nk/7JWwHW0538G7IYbWX/nf0pTX8G3+H58lxBOGFEeP+lXfl0ZLrfZ5rq6G1U6LFYYnDeFZXbJeah4pk2t9ykzuLxEZWC4CxqZTh++aBdcVwhdARQYZ4uYa6Y/S0s7bX/pHBhoQROzuw2a8eHJ6vfoHhcy5r5/ynxOiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417891; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2aRCuku2oKEDF0Op1/pBMZnZUn6snlu290Nklz94qvM=; b=adkjWSZot6wn++Q2/VTF+xkZxkVTqO5sTywgjRzvvZM8XSDF5a+tqm8dxwad2OQPDeHmQd6qovrNKi9eNefDuQ7SrxP2/bmZbrbbn0pM5IDiD4yTKbSCpif5odWQDLluf6rBUBP2Sux5H6XalY8DHrz74eyk3x/xjAZQPEvo7aA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417891521784.5350327046249; Mon, 19 Oct 2026 06:51:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454381.1667967 (Exim 4.92) (envelope-from ) id 1xInlj-0007WU-VY; Mon, 19 Oct 2026 13:51:15 +0000 Received: by outflank-mailman (output) from mailman id 1454381.1667967; Mon, 19 Oct 2026 13:51:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlj-0007WL-Se; Mon, 19 Oct 2026 13:51:15 +0000 Received: by outflank-mailman (input) for mailman id 1454381; Mon, 19 Oct 2026 13:51:14 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInli-0007Tu-P5 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInli-009uw8-5s for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:14 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6203e-8faa-0a2a0a5109dd-0a2a4504d8e6-38 for ; Mon, 19 Oct 2026 15:51:14 +0200 Received: from [209.85.222.174] (helo=mail-qk1-f174.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62050-b57f-0a2a45040019-d155deaea41d-3 for ; Mon, 19 Oct 2026 15:51:13 +0200 Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-93f2ed2541aso165362485a.0 for ; Mon, 19 Oct 2026 06:51:13 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.247]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93f332739d7sm575249785a.28.2026.10.19.06.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:01 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417872; x=1793022672; darn=lists.xenproject.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=2aRCuku2oKEDF0Op1/pBMZnZUn6snlu290Nklz94qvM=; b=nFQDfc98Zx0rxPble0Rr2HynSduZ4Q339uVr5Dq45zQOQuHCE8/NWakmwX/ZG7VqWZ ViP2DrZUjjLnB2OD/ZmLJptzf7HJXo9P+diG27+6uD/yjAOtwbsz/Yh/gBxlb+QfKqgV l34+XKHH08HdfxbjWeAQz+/ZY5YFTraKUbvM4VsWXgap312Vjl2EOKCD1EeJ1zBSeZMn FCAFt4e5ujH+s98L8Xk5tROXVzs1qWcj+ek18MMs8d8/iRyx8NzxFiDDJIptEaUVqXNd 5qMMmzIk1UaDNlUdvqj9sC0aoBYCIZoUM7mhBRwi7g3vnbsz9nfNmyZZunAYkPG+nJSb Hv+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417872; x=1793022672; 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=2aRCuku2oKEDF0Op1/pBMZnZUn6snlu290Nklz94qvM=; b=zuj7cfDXlwexzRbsth3rxh6PaECzVT9LP0LY3yDsy7Yo7ym2CuSzCJdZYOEAkbf/WK FreC82M3DFFynD6gule/9Pv1ambgs7EV72hd3HfvZgh7iKsaqrr4biNQrXbYXS6q0ikj /Ex74270op4qLPfkAz+rEvW5SmaLQn5VrwYzxTiceJMEkLasZyoS4tAfUpTyY2nKkss+ 1GoMZiu1OZtA+PsO5pyym+wjUoZRjR3mLdQ1qP2iBiBAACTQg7gaTRQ97m1YtEwN8Xi5 3lOi6dl22/zeaD4AFSTlbL1aemObV6J9y0d7wLZ4UhZSutSgK33aN+W3ZfXxNM4pQo92 lgDw== X-Forwarded-Encrypted: i=1; AKwUvBz4/DaYn4RXONjEHAnCBH5FDxMQvCaMKsRu8EojLE9MXmD/h3r3RfcjTk04sDErgrdmmvXbBbJ/jPQ=@lists.xenproject.org X-Gm-Message-State: AFq9FYLsrkO7bbdAWjuLRdJXUyFyNfPv4/j3pIq851fSYUSeKjwDUMkR VMDjo4hsdHjY3RgGP/G+GDOZE0q84CNTw5i+CvoeRArO3++eCo/Y9WgbFPtTXJKDAjg= X-Gm-Gg: AYBFou0MieoM9mrP0qgJbLNPnesLSkl30CI8YcfjM9/0tONJJxyuEEoxGrzj9oldg8T +UZdM3wxH2Dtk1REq9LodknoFu82XvrwcBNAJSFYHx0Op6n/iz4HL6yJwTL2NUyhnRi5M3Zix0+ SQ4RHs1ImR7zlHzxezw8HlUJIT2GXvJ/3+6IMy5BDyQnLeJssm7ypy1D55XrkGxMbpOULAajh91 CGxVhrm/eke4hdZ2BMDGrjRU368lFSoUL+YKA8kZN4YhwxFXvU663EhlmQUDOOXU8NeJ+/MkH3x PbglixYdmnq62UANi9/+7zuO2NjT/PmhswxicCwFklS+t1vT9gFunesseOQD5Vd3zj64pGrBvO1 2tte3R67Ur4GyVWthKl/E+AMm1yKXhc/GozuThjObheMWw47KWCbjVpw/9jO21Vfq3Ktce71ZY1 uMWsQ8Y4d7JGYP1QVi/V3yAUJ5uppvyfihnXQ3wO2REL8p52tL2cNcvNAUD1tvsHdBffqu/mt7k xxHVNRQV+7OqAw= X-Received: by 2002:a05:620a:4608:b0:93e:fcac:a91f with SMTP id af79cd13be357-93f17f9f371mr1747377785a.37.1792417872286; Mon, 19 Oct 2026 06:51:12 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:38 +0000 Subject: [PATCH net-next 04/15] net: skbuff: fail segmentation when a segment can't be checksummed MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-4-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417848; l=1895; i=josef@toxicpanda.com; h=from:subject:message-id; bh=wii8wzXlG4ePvSd6K5rd8H498XoB8iUyEaQEAS7r5bk=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QFNR28egIht/ZoRyU32fPc4iNKinzI14ufAnhDAIIBXEpJO58NOkbKAc331mB1ZlQKPGaXOwjPS ler9rEAlgTAU= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-ebf023/1792417873-C30CDB50-9953B032/0/0 X-purgate-type: clean X-purgate-size: 1897 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417893270158501 When the device can't checksum the protocol, skb_segment() computes each segment's checksum in software with skb_checksum(). With SG on, the segments share the original frags, and a devmem TCP skb keeps its whole payload in unreadable frags. The devmem MSG_ZEROCOPY path never sets SKBFL_SHARED_FRAG, so the __skb_linearize() fallback is skipped too. skb_checksum() then warns and returns 0, and tcp_gso_segment() writes a TCP checksum that doesn't cover the payload that goes out. That's reachable with tx-checksumming off and SG on: sk_setup_caps() still gives TCP SG and HW_CSUM, so the dmabuf send is accepted, and harmonize_features() strips the checksum features but keeps SG. Use skb_checksum_full() and fail the segmentation with -EFAULT when it can't checksum a segment, as skb_segment() already does when it can't copy one. Found by the Sashiko AI review of an earlier fix for the same path with SG off. Link: https://lore.kernel.org/all/20261009-b4-skb-segment-nosg-unreadable-v= 1-1-7e2334a55fe8@toxicpanda.com/ Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the Reviewed-by: Mina Almasry --- net/core/skbuff.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 40d2dd20d47d..88ed2dd99dc0 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5239,9 +5239,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, =20 if (!nskb->remcsum_offload) nskb->ip_summed =3D CHECKSUM_NONE; - SKB_GSO_CB(nskb)->csum =3D - skb_checksum(nskb, doffset, - nskb->len - doffset, 0); + SKB_GSO_CB(nskb)->csum =3D 0; + if (skb_checksum_full(nskb, doffset, + nskb->len - doffset, + &SKB_GSO_CB(nskb)->csum)) { + err =3D -EFAULT; + goto err; + } SKB_GSO_CB(nskb)->csum_start =3D skb_headroom(nskb) + doffset; } --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417895; cv=none; d=zohomail.com; s=zohoarc; b=YcqzO1f10xbYudcrYVTsUvnJORdViWQ4rW3d5sZi1y69xV54/6P9BrbzfmX4Ah3VteVqVJw24LrJ9AhwT/wJJS+KpWpU7thRGuABcJ4gSQmB9Gr1dVzqY+ZA1hlyGgAZNT/Ud7jo0YZB0vXlunG3jCJZf68PNeye64BXcN6D9DY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417895; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t5hhezvrkrPsILbBbBLRGuH3wT+463IdJ8u+tbtUXF4=; b=fG1hC9NHJSzzatoeCQunGAkNIfdI/nn4imjqG9Qt7gKVY4tSVbUkHif07aqQ4bpM0Jfiyh/CtsiIk3rhoA+xPtHjAfFqgjXvgEbMd0Bbb5+j1jTs+RyY0kdYWKfgMRhwDC0YjXUe+xtf670EW4mZJZbRDMZ1qicWgi1B1AIfGRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417895961214.7202459836634; Mon, 19 Oct 2026 06:51:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454384.1667977 (Exim 4.92) (envelope-from ) id 1xInln-0007o8-6g; Mon, 19 Oct 2026 13:51:19 +0000 Received: by outflank-mailman (output) from mailman id 1454384.1667977; Mon, 19 Oct 2026 13:51:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInln-0007o1-40; Mon, 19 Oct 2026 13:51:19 +0000 Received: by outflank-mailman (input) for mailman id 1454384; Mon, 19 Oct 2026 13:51:18 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlm-0007lx-1l for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:18 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInll-00A1LW-Ek for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:17 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62054-bab6-0a2a0a5309dd-0a2a4504c640-6 for ; Mon, 19 Oct 2026 15:51:17 +0200 Received: from [209.85.160.182] (helo=mail-qt1-f182.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62054-b57f-0a2a45040019-d155a0b6a969-3 for ; Mon, 19 Oct 2026 15:51:17 +0200 Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-53394bffe0fso36178551cf.1 for ; Mon, 19 Oct 2026 06:51:17 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.241]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bccc721a8sm97777206d6.12.2026.10.19.06.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:14 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417876; x=1793022676; darn=lists.xenproject.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=t5hhezvrkrPsILbBbBLRGuH3wT+463IdJ8u+tbtUXF4=; b=JTaaRUObGkbZOT2pl26Or9PtEENCK0/INMTY03Fn/TBOv8zjyRrLSBxVofouwX0T/z MItaZtFk9xyT5VPO2eYtpfMGd/3XyEv49/1oeOL2+aS4+cRukHymmgeFJ5WNt4bHtxD1 uqfBXgTgs5WiXv2kwT+cRAcoO1CBXuydiCf9SAbZDNM8wgEyGaJEEl+pZAYWAL237pxU OjY8FzMOO+DIe3+n7Ht+0vLgl7J8HB31JIlK1v2m3pLfyC6c9EL4LuGyGMDjhwGThKGz FV395XTsmVBRF9HiJ6DYbvsD5ZTqwP1QOrz4FLbViw0HnPQk6k5BSsLvNBjLAAuQYhIS jC6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417876; x=1793022676; 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=t5hhezvrkrPsILbBbBLRGuH3wT+463IdJ8u+tbtUXF4=; b=fL+BmL0eOCs68fZxyrRtSUUHTgtmzNChHQtyVr0tN2s0GTZT8EeOxakrh9pZncUUBr y4qoKSwCBfbWGr7g/QwXXHBxu9ZXYeBv5+TSXLa0hdar+58yp/2LvQl6pl4Q6Ss7ffG0 DmLDqEkkb9vOEreWAAiZX360G9HMW3Mbu+u6So61dNucwJs/EG2oF+7eobkmE3yIAW/t mEIIGUwmff1mz24Td6LiN2dY1Nk5hrHSAymbOZtFjMCIhor1xA0yPLmw4t4NaiwkPkbT vag+f/UcIyzd8BuUiWAovD/TjSP5FwJeLsGmokMfbE57qbo3v6VYexGQ9UoozLKsuvA8 eCVA== X-Forwarded-Encrypted: i=1; AKwUvBwyT1D/owRZAKgNLMeiXWKCD2TU/GETI0fzZQUxRw52K/TPnPppWo3XTdUY7WOPkA6yY90ZmegEHOE=@lists.xenproject.org X-Gm-Message-State: AFq9FYJPlL2V2nLTD4M7ern94GSdJM8DFOFpe2+qPnV90eh/EKoKGnjN GAWyG7DDeNXOAVhhQx8IDi333RsFyWVRgtrrV+A34WZEPiggd1C9aBvsoHFDn1rUdNc= X-Gm-Gg: AYBFou0eQsDBk1peO29jXVAuL+ZKXwyMYO7gI/CMAHP5AtUIN75nKTSVSHllRSeVKDU RC3YeILOorG7GpkD+oJL2UOy1iJ3MPaXjkuQExQB1nL5ZRGDQcp5/yFKkE6uH2JmJJJIwh89y8F cc6iin9JyW+/u1EixH6LCcErm2NjShAoEBsW+DVDavJ6il17FZBvH11QsU/ZsgkS26OOkWmuuUZ JavM6xGjhP5Wo+RWYLwhtDyzVmUvdbCKboU6OfxidD2TcCmQOozmxi5pGujNpLzMM5rSatxqGJN +kaqqw09cUpCb0OTZrI3wL3h/h2vt/4/cm7QHoHZzDmCc1L02z93pUitFYaHqneYgr3psiCqDUg 0/NnJvcur59/0+F12HylBM6jT5TVBIkeNsKK0egWy2d2gbd61XN9DdtPP96n0pSRxpNdsqlXg66 lseNR0gPpflr8yz6RnqdH0Mw3rQYr1PCxo+C7qQakkx8P4uVuJgRO2J8mpx5cnh6We7r25kJ5C1 vt/mLWotjelW3I= X-Received: by 2002:a05:620a:a0c6:10b0:93f:2571:c30a with SMTP id af79cd13be357-93f2571d926mr888761185a.30.1792417875823; Mon, 19 Oct 2026 06:51:15 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:39 +0000 Subject: [PATCH net-next 05/15] net: skbuff: fail pskb_trim_rcsum() when it can't checksum the tail MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-5-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417848; l=1264; i=josef@toxicpanda.com; h=from:subject:message-id; bh=+TWKmcN/9YISrCDdUhnWQSTAcvPk81OG628CQR0a1S8=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QPX/xL5smxia3f6ZS9PJYHyB/T8o2gs9Ov0UWXx8FV1o98bw8LukMOYZJRi8edA9qG013xP3J8r M73yrz78D0wI= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-ebf023/1792417877-516D2B50-6B464BE5/0/0 X-purgate-type: clean X-purgate-size: 1266 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417897299158500 For a CHECKSUM_COMPLETE skb, pskb_trim_rcsum() subtracts the checksum of the bytes it trims from skb->csum. It gets that checksum from skb_checksum(), so if the trimmed range runs into unreadable frags in a frag_list member, or past the end of the skb, it subtracts 0 and leaves skb->csum covering bytes that are no longer in the packet. pskb_trim_rcsum() can already fail, and its callers drop the packet when it does. Use skb_checksum_full() and return its error. Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 88ed2dd99dc0..de433d452939 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2829,9 +2829,13 @@ static int pskb_trim_rcsum_complete(struct sk_buff *= skb, unsigned int len) int delta =3D skb->len - len; =20 if (skb_frags_readable(skb)) { - skb->csum =3D csum_block_sub(skb->csum, - skb_checksum(skb, len, delta, 0), - len); + __wsum csum =3D 0; + int err; + + err =3D skb_checksum_full(skb, len, delta, &csum); + if (err) + return err; + skb->csum =3D csum_block_sub(skb->csum, csum, len); return 0; } =20 --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417903; cv=none; d=zohomail.com; s=zohoarc; b=MP+bU7nmA3I4XqKbBIpDHaZ7qVO0wpaSfV8P1SJlVMF7MsKMnDBUmaZMy8upp3lXOawVv1K1hqQoyuQ2qu1WZT3+9/hLPaPsyLoqM6gUfv7i31tJfkBqduJAIitlvnxPok9GXsJVprNFuiFgxpVLbQWKXx/rjwnsMOe9Sh6oN+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417903; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ydoWrUsryFQCXy0qk0+H+VOsHqxoYPyCdAWJE4iSCqQ=; b=TgvoU0lzWY9YtRknufcgPpJrwpIlZ6a9ucMraxE1KUP4FlxVNtiITMPQE3Oa0QH/Kr735c00W7E02KHBdyCzq2A9RIG67aHMSxDlSoymWRTBGGN3mTnmCzNA7hefc3wVT29Zkwr8S5+LJPiBvp6/DeB5KSnTKANugMBsO4SNEFU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417902913425.7329480202328; Mon, 19 Oct 2026 06:51:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454385.1667986 (Exim 4.92) (envelope-from ) id 1xInlq-00087t-Jl; Mon, 19 Oct 2026 13:51:22 +0000 Received: by outflank-mailman (output) from mailman id 1454385.1667986; Mon, 19 Oct 2026 13:51:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlq-00087Z-FH; Mon, 19 Oct 2026 13:51:22 +0000 Received: by outflank-mailman (input) for mailman id 1454385; Mon, 19 Oct 2026 13:51:21 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlo-00083x-Ub for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:21 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlo-00EegS-3f for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:20 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62052-2eae-0a2a0a5409dd-0a2a4509bbaa-10 for ; Mon, 19 Oct 2026 15:51:20 +0200 Received: from [209.85.222.176] (helo=mail-qk1-f176.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62057-be1a-0a2a45090019-d155deb0cd5f-3 for ; Mon, 19 Oct 2026 15:51:19 +0200 Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-93e503815adso194261685a.1 for ; Mon, 19 Oct 2026 06:51:19 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.247]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93f23eb7ba5sm842774385a.27.2026.10.19.06.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417878; x=1793022678; darn=lists.xenproject.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=ydoWrUsryFQCXy0qk0+H+VOsHqxoYPyCdAWJE4iSCqQ=; b=Lz27IJ4+i6Lb/GcZKjHjW8bh8IiJ6ctkSRMZhGRHtGpXFYXKAwJYKoDpv4roQnPsC4 Qq8UxyQrFXr874GXuXgV+ci/brwGaO3PC4HyAFztrxwq4O5MmmVq0dPnCX5BABWN1ZSv VBqGWIB8C8VBLYyCl8SKEPSH+G3t8dWSfXtZAC41dIdz83bcag2Gvd1k3vbF5dFLUbV9 84rdH4FroNKHsD6TZxIP5QHtZw/0+4ifKaNEiN4gNBRn5BotTeGHvRTiR8DYUTc/ySCp 4To5/POC4geZ8bSadjZ1iiouQdYpSkkcvaAxA/CZfp3LlpIkukYQ/cyiaaF5NNfosqgq ymrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417878; x=1793022678; 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=ydoWrUsryFQCXy0qk0+H+VOsHqxoYPyCdAWJE4iSCqQ=; b=C0p34dWBuGVXQuGyz4XIaVH7gmrRWVBd3aTa7kNeUBWz+WfzEpiJyMpSbicY29pkS0 R8v+019ETCA0nCP0J9cOh3ejtG/dHvXOwkYIv1dUPb9HdlWWwexZT2B06OkclbRMuQyK HxtI8dw4E8VxfniagcXllaoThhhgWiRf5DfGXcchwVBfm9magTTFzxJ7fR2ZKQCD0Wir GTYE8AIXq8rdoVQNHVZhbyHMOEihxRfOXdvIe4K1iviyiC68HmEpW7GKab9mg2xwbESH nm6V62wvKU+OPk9NqS3zeRYiK55vV39sBA0s3xzR87vfIiH/TSZnxsf93hSm7zLTJWFX /N4g== X-Forwarded-Encrypted: i=1; AKwUvBx1FuO5HAcbgk5Gaif+utjC3pslrb0+zyG7S979IA57SmAVqSzphbmEXWaADxQSgA+OIj9DP0s8E0k=@lists.xenproject.org X-Gm-Message-State: AFq9FYLgDkkCkg76dx+R4sdyqb9ObzhPE4bSlOksp1EkbGglbM9Jx6RR IhRLVrTn6pfS1sO9/h02ed0lp9fbCneIMPiBPbbe9eG9ssjf5CmumG/0ijsR2MKoGcM= X-Gm-Gg: AYBFou1zbKQqOFyMS4rcGCOudO/AGr7OQj2R+w6nrX+4DlSrbRSRAO0WWx0f7oCoOzX LTQwdHMnO1aY/7V5xxehSwtU/U6YLCg0CYQgEiygTHIm9RaJZyTW9gQSCg7o66zETdW5mJT/2Gr q66yHi9qFS5oBnU0ZxJRQ0Nyb2PsLjDf16l2N1lkADGzC56OXyBq3SjnSkByEiS6iEadAZelfxb jqgIdptP8Ri7VRnwEqM4zwhAA4rWIBcTekwxfRpeGGT/lnuY6mcmPJr/y0U4C2ny20F1eMHK1nB hDFjV9lwTCDAJG2l7XQfL2OC691V9mVimkO4jaGjF8hMVavB3ON/lCmAi5eEiqEUZeCtwFuauVA 9n9gIKCZ+y3Hw3BKZhjBSUk2nvWm6iGnZLgGDEWS1n1mlm/IUrJhmv2VuUFRpLz90aeLN9vcypW A98CVvn6NULu3xTZnhvneLxYeo3ngU0NVxxJw8CJ0zVTK7FxL5c8maQ+4YD90NcrdOglWPwQ5RR wUoWHwsvioT/bk= X-Received: by 2002:a05:620a:31a8:b0:93f:2957:39e with SMTP id af79cd13be357-93f29df1566mr1298617785a.71.1792417878389; Mon, 19 Oct 2026 06:51:18 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:40 +0000 Subject: [PATCH net-next 06/15] net: skbuff: add skb_crc32c_full() that reports failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-6-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417848; l=5122; i=josef@toxicpanda.com; h=from:subject:message-id; bh=4gDL1d1n3xZ9vhvHuHh+fxzaWH1kti0hEf02jn3aBlw=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QNQsoPXudgIBCQ4amU4Ot8wGr4uN4l6ll3DjM3OCKkakLx6NEe8pB0UhGAzuQHiV90XwzqMDHE4 OA5x0AeiNWQI= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-bad1c0/1792417880-FCA16034-FA3C0552/0/0 X-purgate-type: clean X-purgate-size: 5124 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417903509158500 skb_crc32c() has the same problem as skb_checksum(): when the range runs into unreadable frags or past the end of the skb it returns 0, which is also a valid CRC. sctp_compute_cksum() complements it, so a failed walk looks like a checksum of 0xffffffff whatever the packet contains, and the packet is accepted whenever its checksum field holds that. Add skb_crc32c_full(), which updates *@crcp and returns 0, or returns -EFAULT or -EINVAL and leaves *@crcp alone, like skb_checksum_full(). skb_crc32c() becomes a wrapper that behaves as before for the callers that haven't been converted. Convert skb_crc32c_csum_help(), which already returns an error when it can't fill in the CRC, so a transmitted SCTP packet that can't be checksummed is dropped instead of going out with a CRC of 0xffffffff. The SCTP and other callers will follow with the skb_checksum() callers. Fixes: 20ddd0fd2fcd ("net: skbuff: don't BUG() on leftover length in skb_ch= ecksum() and friends") Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- include/linux/skbuff.h | 2 ++ net/core/dev.c | 7 +++++-- net/core/skbuff.c | 51 ++++++++++++++++++++++++++++++++++++++++++----= ---- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 969b1c3269ec..327a01a5d6d0 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4329,6 +4329,8 @@ static inline int memcpy_to_msg(struct msghdr *msg, v= oid *data, int len) =20 __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum); +int __must_check skb_crc32c_full(const struct sk_buff *skb, int offset, + int len, u32 *crcp); u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc); =20 static inline void * __must_check diff --git a/net/core/dev.c b/net/core/dev.c index 8eb9bf1ff9eb..1d34fa4544a2 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3738,8 +3738,11 @@ int skb_crc32c_csum_help(struct sk_buff *skb) if (ret) goto out; =20 - crc =3D ~skb_crc32c(skb, start, skb->len - start, ~0); - *(__le32 *)(skb->data + offset) =3D cpu_to_le32(crc); + crc =3D ~0; + ret =3D skb_crc32c_full(skb, start, skb->len - start, &crc); + if (ret) + goto out; + *(__le32 *)(skb->data + offset) =3D cpu_to_le32(~crc); skb_reset_csum_not_inet(skb); out: return ret; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index de433d452939..3b2a3747f009 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3788,23 +3788,41 @@ int skb_copy_and_csum_bits(const struct sk_buff *sk= b, int offset, EXPORT_SYMBOL(skb_copy_and_csum_bits); =20 #ifdef CONFIG_NET_CRC32C -u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc) +/** + * skb_crc32c_full - CRC32C a range of an skb + * @skb: buffer to read + * @offset: offset in @skb to start at + * @len: number of bytes to include + * @crcp: the CRC to continue from; on success, updated with the range + * + * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb + * has unreadable frags in the range or runs out before @len does. On + * failure *@crcp is not changed. + */ +int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *c= rcp) { int start =3D skb_headlen(skb); int i, copy =3D start - offset; struct sk_buff *frag_iter; + u32 crc =3D *crcp; + int err; + + if (unlikely(len < 0)) { + DEBUG_NET_WARN_ON_ONCE(1); + return -EINVAL; + } =20 if (copy > 0) { copy =3D min(copy, len); crc =3D crc32c(crc, skb->data + offset, copy); len -=3D copy; if (len =3D=3D 0) - return crc; + goto out; offset +=3D copy; } =20 - if (WARN_ON_ONCE(!skb_frags_readable(skb))) - return 0; + if (!skb_frags_readable(skb)) + return -EFAULT; =20 for (i =3D 0; i < skb_shinfo(skb)->nr_frags; i++) { int end; @@ -3829,7 +3847,7 @@ u32 skb_crc32c(const struct sk_buff *skb, int offset,= int len, u32 crc) } len -=3D copy; if (len =3D=3D 0) - return crc; + goto out; offset +=3D copy; } start =3D end; @@ -3844,19 +3862,36 @@ u32 skb_crc32c(const struct sk_buff *skb, int offse= t, int len, u32 crc) copy =3D end - offset; if (copy > 0) { copy =3D min(copy, len); - crc =3D skb_crc32c(frag_iter, offset - start, copy, crc); + err =3D skb_crc32c_full(frag_iter, offset - start, copy, + &crc); + if (err) + return err; len -=3D copy; if (len =3D=3D 0) - return crc; + goto out; offset +=3D copy; } start =3D end; } if (unlikely(len)) { DEBUG_NET_WARN_ON_ONCE(1); - return 0; + return -EFAULT; } +out: + *crcp =3D crc; + return 0; +} +EXPORT_SYMBOL(skb_crc32c_full); =20 +/* skb_crc32c() has no way to report failure, so it returns 0, which is a + * valid CRC. Use skb_crc32c_full() in new code. + */ +u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc) +{ + if (unlikely(skb_crc32c_full(skb, offset, len, &crc))) { + WARN_ON_ONCE(!skb_frags_readable(skb)); + return 0; + } return crc; } EXPORT_SYMBOL(skb_crc32c); --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417903; cv=none; d=zohomail.com; s=zohoarc; b=jUlq+Eq7YCyJEYcKHHQVF2UmpzCZOCxhqaWpgzaqGjHwtbt4MF20/qS8KgRZ+qHb4nKmKQXruEe47YdEXW4cdyMQ2AMoH2miFqCgV37cFqCZVdKlzztR3Dhl2/sfJk9C8o3nZ6KZdjRG4/OvB9Oh3tEr2Vk0bL/RqTtcoBVFzns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417903; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YbXvQLGgZpsimSrfs+W8d8Jbr4mc/fISMihOBkAlu6E=; b=daoAGM02nxH17IcFhyYv9AbkhrVW6PcDR/muDTIGjfLl81V4RFX8X2/NU/4CYxWLR6gnq1iW6R44amVGSHTT0GBIkknUxDFJxr4gZkVedK5LbfXxHww7AlwE2A7WnZd0JSuXqoLMjEesixb00owmZsXND8lLBWycj3ndU8wUsmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417903742705.2856643640986; Mon, 19 Oct 2026 06:51:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454389.1667995 (Exim 4.92) (envelope-from ) id 1xInlt-0008UR-Sn; Mon, 19 Oct 2026 13:51:25 +0000 Received: by outflank-mailman (output) from mailman id 1454389.1667995; Mon, 19 Oct 2026 13:51:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlt-0008UH-OO; Mon, 19 Oct 2026 13:51:25 +0000 Received: by outflank-mailman (input) for mailman id 1454389; Mon, 19 Oct 2026 13:51:25 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlt-0008S1-13 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInls-00BvIM-71 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:24 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6204a-e002-0a2a0a5209dd-0a2a450bbf54-38 for ; Mon, 19 Oct 2026 15:51:24 +0200 Received: from [209.85.219.42] (helo=mail-qv1-f42.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad6205a-b7e8-0a2a450b0019-d155db2ac8ac-3 for ; Mon, 19 Oct 2026 15:51:23 +0200 Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-91b52ba422cso27720986d6.2 for ; Mon, 19 Oct 2026 06:51:23 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.248]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bd276eec4sm88112796d6.2.2026.10.19.06.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:19 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417882; x=1793022682; darn=lists.xenproject.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=YbXvQLGgZpsimSrfs+W8d8Jbr4mc/fISMihOBkAlu6E=; b=gNh0THi6i4S63sSBnXbJ+WIRxqTSmav0JyG7nia4l+GpvNsMDERIkJ4arHXIep1kG0 5ktnBvG4whYaAfhoUXUWN7W+5XiHU6WbFMqwj1q5gBMXAth6/43VUgA4CP3t/39EBZt9 VVtvrLVxOkrXhDeBvFIIB2sTsmg3ugnUo/6YSJwvr8kHI/ywQLUFihkfPXo6uHMazAj5 ENo5XIvGpupr5CYfyO0og2+/ls5ZpkC6JNkmqSPk12qi1elfmQY54lM039dJDijGdh8O k4LGEIF5433NjfEGMb7WfP0SrLgwMHrb67u5g7U2OXHjoNV1EzefnTOAwicm1gpy3iCF UpjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417882; x=1793022682; 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=YbXvQLGgZpsimSrfs+W8d8Jbr4mc/fISMihOBkAlu6E=; b=TNFdd1Vlgx9657eBxpaUx1do82jd68x22jSv0EWvhL/uxLqaBa4jSuhRaN2K6vDTWU 2NhPM70ClFs7YjeiJNijHPvQ+eTEYAf/R6M2p+fnNwfy6sTY8sjq7OQdsUQAdmOLn8Se eAXHHVL5J4+VbVu/MTP3QTS7xm0ie4VOdw9jcoOIBmwLvi6AMfq4Q53l2V/+/z1x6m0X 8jRGbEEsDlrgPBZOZwyaASlS+kGdYyLc6suukvFD8egH/x8lTun6GuBHshyg8uq7CydF Nt4uomV5jbeO+6QzpeD+W0+9KPdsMsCuuhU58rXXpj6tpsTjlPlEHjCI30YI/pgPd/X6 cMjw== X-Forwarded-Encrypted: i=1; AKwUvBzrpLonaSEbpb09AgWM+T+iowp3p8Bl5IoZRJxwYlY/G0q9lHw4hBO4nctqxCMx+8txn7p0KAFFtOY=@lists.xenproject.org X-Gm-Message-State: AFq9FYL7vN7A/D9kSUBCi9Y2+OugxbZlNT4oUeUS/MmiPvnw527Lb4yi eJTMrtv4dFngYbeOdAbR3cGffiFe3vgbMVyFJB0ecqygNFDTSv2c7LabLPgM8HvFqHY= X-Gm-Gg: AYBFou1pZnDqVcnMyjhtaVpKenvJyNjsP0bno4NW82kXSoIsgM5BGr4X7AHcbnXF6ia NKJii0DqnkM+21MMYyqN01Ayfc8hLVac2b4h/RLXeh131ZOBnq1Ahc0d8DPGrUt0LvXTwETyGXB f+YIrcYFEo26x+43v+aDxyUQ0bjw2ZwrZ0GtAJujZLzj3OQE27ZiUaKOeTlS9+LkPDPue0Mytwj BhbB00dGMGnbhFPuX0Ue792C8SgSEyraZkTftZWmPk8TWZ+l+vMszJkisRSw5GbrCRIwi9GBDSR Y2Lo6faBBvE/cAUy06JXCRRI4U33r/UlDOEesky0a8v4R0WG0uAmoyM9MVYDLYcBYUd4hf3Rwbg /x8JraHNDHEb6ghpVUN4VWzDoBTQw0lO5bJ+hEiFfO0mAoJU0Fn03YlU95dvYfT915pqkwB1N6I cJ2FOAaJ2kGLp4zWasQjQo1Zs/9RhM/BsCQupozty0cyO8rxHB5ebx4/sCKbCDJMCRAaSUG4B4c X8iPMFLTbc9hds9QXo4J9vlzcjxdGEfPCNVtxuRabs93dXrfLoQa06p2dK25qVIFFEkkHLsEuov 4QZ2iJrTdtwgAfYl0g== X-Received: by 2002:a05:6214:29e1:b0:91b:5d39:e145 with SMTP id 6a1803df08f44-91bdf63bb40mr141562036d6.58.1792417880639; Mon, 19 Oct 2026 06:51:20 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:41 +0000 Subject: [PATCH net-next 07/15] net: skbuff: let skb_zerocopy() copy a short skb without head_frag MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-7-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=3126; i=josef@toxicpanda.com; h=from:subject:message-id; bh=p1EJ3Mjc5nJGteUiFCelu7Pkg91i/fkjkkkh/ts8Tfs=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QB3VQkhmVt4VPOky68kfBhcPE1aOMyFJILHR1dQhl/DSlceDdzD2F0Osxoak/AkI08GCT1eWZyg KcJIYQOtx0wY= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-42698a/1792417883-A88C99EA-F91AD503/0/0 X-purgate-type: clean X-purgate-size: 3128 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417905490158500 Commit 433380f5ab8f ("net: skbuff: don't BUG() on a missing head_frag in skb_zerocopy()") turned the BUG_ON(!from->head_frag && !hlen) into an -EFAULT return, but left it ahead of the small-payload path. That path copies everything with skb_copy_bits() and never references the head as a page, so the check doesn't apply to it. Open vSwitch gets there with an ordinary request. OVS_PACKET_CMD_EXECUTE allocates the packet with __dev_alloc_skb(..., GFP_KERNEL), which gives it a kmalloc'd head without head_frag. A POP_ETH action on a 14 byte frame leaves it empty, and a USERSPACE action then queues it with queue_userspace_packet(), which calls skb_zerocopy(user_skb, skb, 0, 0). That used to BUG(), and now the upcall fails and the packet is counted as lost, with a WARN on CONFIG_DEBUG_NET kernels. OVS_PACKET_CMD_EXECUTE only needs CAP_NET_ADMIN in the user namespace that owns the network namespace, so with the openvswitch module loaded any user can do this from their own namespace. Move the check below the small-payload path, so a zero-length copy succeeds the same way it does for an skb with a head_frag, and document the -EFAULT case. Found by the Sashiko AI review of v2 of the series that made the change. Fixes: 433380f5ab8f ("net: skbuff: don't BUG() on a missing head_frag in sk= b_zerocopy()") Link: https://lore.kernel.org/all/179173804997.434549.4450793967361922984@k= ernel.org/ Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 3b2a3747f009..735dd25213bb 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4014,8 +4014,9 @@ EXPORT_SYMBOL_GPL(skb_zerocopy_headlen); * Return value: * 0: everything is OK * -ENOMEM: couldn't orphan frags of @from due to lack of memory - * -EFAULT: skb_copy_bits() found some problem with skb geometry, or reada= ble head - * payload would be mixed with unreadable frags. + * -EFAULT: skb_copy_bits() found some problem with skb geometry, @from has + * no head_frag and @hlen is 0 while @len doesn't fit in @to's tailroom, + * or readable head payload would be mixed with unreadable frags. */ int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen) @@ -4026,15 +4027,18 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *fr= om, int len, int hlen) struct page *page; unsigned int offset; =20 + /* dont bother with small payloads */ + if (len <=3D skb_tailroom(to)) + return skb_copy_bits(from, 0, skb_put(to, len), len); + + /* Without a head_frag the head can't be referenced as a page, so the + * caller has to ask for it to be copied. + */ if (unlikely(!from->head_frag && !hlen)) { DEBUG_NET_WARN_ON_ONCE(1); return -EFAULT; } =20 - /* dont bother with small payloads */ - if (len <=3D skb_tailroom(to)) - return skb_copy_bits(from, 0, skb_put(to, len), len); - if (hlen) { ret =3D skb_copy_bits(from, 0, skb_put(to, hlen), hlen); if (unlikely(ret)) --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417908; cv=none; d=zohomail.com; s=zohoarc; b=Uur6wTu/dgElwSej32mIDIcD4HjkB/brc7VKI2n5Itzp54hE7NQ2KMvGeR1FJLujmFchOxJfyPlOVr0/IEGfwm2PI5Q7TGxhaskBNlBZjoPChikk2d9zVj4pQkctA+VbLxeoVUvXQHTlgQ07S2+ZwYIMarYvI/VpLiG8sTvep1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417908; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8wxt1Epm3k3rT9QE881oEaKsrBbXJoueUEmgjTPk70U=; b=RQpkhCWAyYih+KteBQuXoqCNjwzqk8bkPROJEE3rLdIque7Y5AfCto6chkKe8g/LCV4Vix3xn6ESUfs8TPh338OqOyO7MJXPUmORY/XKBMdp2u1hIs4iSpbvJPlIFqdiER/RO1aT5qw8e0mcvX1sZmRu6h+Zz7QVndNLFlepD7k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417908736226.2355938068224; Mon, 19 Oct 2026 06:51:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454391.1668004 (Exim 4.92) (envelope-from ) id 1xInlw-0000OC-3r; Mon, 19 Oct 2026 13:51:28 +0000 Received: by outflank-mailman (output) from mailman id 1454391.1668004; Mon, 19 Oct 2026 13:51:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlw-0000O3-0R; Mon, 19 Oct 2026 13:51:28 +0000 Received: by outflank-mailman (input) for mailman id 1454391; Mon, 19 Oct 2026 13:51:26 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlu-0000Ej-Qz for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlu-00A1LW-70 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:26 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62054-bab6-0a2a0a5309dd-0a2a4504c640-40 for ; Mon, 19 Oct 2026 15:51:26 +0200 Received: from [209.85.219.46] (helo=mail-qv1-f46.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad6205d-b57f-0a2a45040019-d155db2ecdb0-3 for ; Mon, 19 Oct 2026 15:51:25 +0200 Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-917866225aaso19646276d6.1 for ; Mon, 19 Oct 2026 06:51:25 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.247]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91be8f89b54sm60221436d6.7.2026.10.19.06.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:23 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417884; x=1793022684; darn=lists.xenproject.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=8wxt1Epm3k3rT9QE881oEaKsrBbXJoueUEmgjTPk70U=; b=DWDFzEeAqUHzKs3T5WdGItjZ2R9poP75fwZRob4g67B5JYSsbf0P+Y6UGcsRPwFVqP 6nLRe7UOxSdNG4ecght6CtVbY7a6bFFwQdfWr02JOO0S9qK+ietx0R5TdNxc7C3uUZ91 NQ5AVPw1TDVMDvdjPiW9UIlAvAWQtGo94adiMkLXqcuJxbcxiwcwa3PBvQanxZGtb4TB glX6IY2BZlKdLqXrTlMf/zqRi28WHAbbo75Feo4nngiyec5vQWw3JDxWNJMj/RLyGvoL iwZpU34R4PMk03HEBkrMdkU8t+K6f9R0/Yl95L8h157pN9WH77x2ertFLcSVTpDtdnsi w8Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417884; x=1793022684; 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=8wxt1Epm3k3rT9QE881oEaKsrBbXJoueUEmgjTPk70U=; b=KEZfUDgTT8j0EHJtweZ5XW65UI1uRJJAsu8dENPmTG9Al9mTg9yjbpatcBXEFT1yNa jeSTtxuvmD6+/x/nH4De4CfYBn4Glxi45qYlv6VqJ6wGHGljNDNMpo9Jsp0krgj1KvFZ XQyi1SnXfrVJ53oJ8gQ7H10BVPtErRsxYhd6u5CHdy+5BtnxkxRZlKRFp6cNdrMDMGpZ f3+zckBlFeOpYcWhMIYm1NCDwuLpwSQFHeOoLglklaxUCrKwQLDa7J0WmtSPGBhHgTk1 b+zOvarUXvW4IktRRUhflNbcTLgxOMG1X2kM++ahdxsFXUvVrLTPUiQgM6kOWH/UUzfT lZDA== X-Forwarded-Encrypted: i=1; AKwUvBwNp5FdFAtaaFdX/R3BgYSCr5jyIrBr5Zq72dwfQdVZyq3OXfW24/rmAmYJ9wLHO5yhpv/DFy4565Q=@lists.xenproject.org X-Gm-Message-State: AFq9FYITjSbc5qJR1n51RQiiGRFSD3+OAObDFdizmMwWbFjIRrhXjpos AymbB7hlEfqYcZbMgfOgSVfAZkAQcXNd4g0RxhGWDqXu8k2eC3SLhq6gwzm9ebzJ9sk= X-Gm-Gg: AYBFou2lhbWlfaeEhdLXMcoaMLkNdUvFSc+7yGKyenzUJwmWN9vxn6CYadfe6Tv1/8u dw+V8ZGxxANe49ZuZx2MiB0a/aHKmHhpp7ARn1B/1QWvw5HFUrHyBeeGa4oHPozk3bSg9nDANjH Nb1NHrFeN7PTl6Fm3lJI+UcJFGq2ZYlwZ3JzOmC+6u+nPwlwVuy32pyxm9t+H/CT+tf39K/I57s oTiikpB6tGOUEJBRh1yQj+X8QcsJG0Tn00Al7m1xoPlv4CWyw898LSZJ2tqNUlRHdt6XlVC92Y+ ++dTJGw1fGjSR16OrblA1Yr8EsiUSNfDhGF4FvxQapilRISLAAsYlmPvGWpV4VIAW94M92/c5Ll rS9N6C6QVKpemBOBh0Do2xnG+s2lZf6hMhMTK02a339oob+CW3inxjakiKHZl9go1KbNFpZPePC yYg5htdJ9vXG3TbAVYtFbe9q3zIZtzbBkx1WzekXsHAZXVZxNX4c34EDFQ+jDncoygJblvpUspT 6vZjS+zfoulH4w= X-Received: by 2002:a05:6214:2022:b0:917:a5f1:1d45 with SMTP id 6a1803df08f44-91bdf165a4amr140313536d6.32.1792417884537; Mon, 19 Oct 2026 06:51:24 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:42 +0000 Subject: [PATCH net-next 08/15] net: skbuff: make skb_try_coalesce()'s len unsigned MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-8-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=2184; i=josef@toxicpanda.com; h=from:subject:message-id; bh=GLGsUKpELPU6q+dQsnPVRh/KHoYno5QlglXwcqwsDWs=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QNC9Sgvy7Z40iKvcRhA58lXebwfW6QGNAPE2IPZxOaOYraxtzaaXcB+Os+4BjcCqUxdgTwJlErN lVW88RefeTAY= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-ebf023/1792417886-C2ECEB50-00852B0E/0/0 X-purgate-type: clean X-purgate-size: 2186 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417909561158500 skb_try_coalesce() keeps from->len, which is unsigned, in an int. A corrupt from->len above INT_MAX turns negative and gets past the len <=3D skb_tailroom(to) check. Commit 279877d86c82 ("net: skbuff: don't BUG() when skb_copy_bits() fails in copy helpers") moved the copy into the tailroom ahead of skb_put(), so that check is now the only thing left in the way: skb_copy_bits() clamps its copy to the negative length, and memcpy() takes it as an unsigned int, so it becomes a ~2GB write past the end of @to. Before that commit skb_put() ran first, and its overflow check caught such a length before anything was copied. Keep len unsigned, like from->len. skb_tailroom() is never negative, so the tailroom check then refuses such a length, and every other use of len already takes an unsigned value. The truesize sanity check compares the int delta against len; spell out its delta < 0 case so a negative delta still warns now that the comparison is unsigned. Found by the Sashiko AI review of v2 of the series that made the change. Fixes: 279877d86c82 ("net: skbuff: don't BUG() when skb_copy_bits() fails i= n copy helpers") Link: https://lore.kernel.org/all/20261007-b4-skbuff-bug-on-v2-0-b9a5f73289= 5b@toxicpanda.com/ Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 735dd25213bb..5c89c463f234 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6392,7 +6392,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_b= uff *from, bool *fragstolen, int *delta_truesize) { struct skb_shared_info *to_shinfo, *from_shinfo; - int i, delta, len =3D from->len; + unsigned int len =3D from->len; + int i, delta; =20 *fragstolen =3D false; =20 @@ -6463,7 +6464,7 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_b= uff *from, delta =3D from->truesize - SKB_TRUESIZE(skb_end_offset(from)); } =20 - WARN_ON_ONCE(delta < len); + WARN_ON_ONCE(delta < 0 || delta < len); =20 memcpy(to_shinfo->frags + to_shinfo->nr_frags, from_shinfo->frags, --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417905; cv=none; d=zohomail.com; s=zohoarc; b=TnZxs0YF9ElKMAplAa+eTYaF72hqrcBXenztyNUyvYuwKHShPqvQXfv05yFvM7jFI+EtJarv+A0N1b2ajmIsMYdynFuzxh4ZGlJZUuH0epQlK9JHOHhbp5OLt37fSuxUyp1R5SERkg5QF9HiqEWTVgY4X2mAJoBpSsuh+Bv4Byw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417905; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i59cwFpnwV4ZWelO27hAghlfIgiy6O8zXnZ0ftvy/nk=; b=Mx55ah/gGmuj5r4CBAh0QCbWXhUjWfiiotZkn/1DrYx1Lw77L1/FPfH2TD1a3yJBya1GCC4V5Sz2YhGXzrieTEgyy1zVJISTQJuYBNY4/ByhU0m5igF8LEcR/nChdGvmQNISUHOjbkN4n93dL3O/Szo6rgy6eZr80YEioJGEcU0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417905005674.4058699977842; Mon, 19 Oct 2026 06:51:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454398.1668013 (Exim 4.92) (envelope-from ) id 1xInlz-0000o3-DG; Mon, 19 Oct 2026 13:51:31 +0000 Received: by outflank-mailman (output) from mailman id 1454398.1668013; Mon, 19 Oct 2026 13:51:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInlz-0000np-8m; Mon, 19 Oct 2026 13:51:31 +0000 Received: by outflank-mailman (input) for mailman id 1454398; Mon, 19 Oct 2026 13:51:30 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInly-0000lk-D8 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlx-00Eeji-Q4 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:29 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6205c-2eae-0a2a0a5409dd-0a2a45019992-6 for ; Mon, 19 Oct 2026 15:51:29 +0200 Received: from [209.85.222.179] (helo=mail-qk1-f179.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62060-5984-0a2a45010019-d155deb3f1d9-3 for ; Mon, 19 Oct 2026 15:51:29 +0200 Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-93f079a63b8so201007185a.3 for ; Mon, 19 Oct 2026 06:51:28 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.247]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93f3cb855a0sm338770685a.4.2026.10.19.06.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:26 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417888; x=1793022688; darn=lists.xenproject.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=i59cwFpnwV4ZWelO27hAghlfIgiy6O8zXnZ0ftvy/nk=; b=ZNzA/lhi3PNJOevdLe0ROC/XpYzghL8wZKBpiXXKkEin3qfvL/AAVf/KcTqs2U60ra 0j+SwOLvafgojm1ZMIH0fik6Fvmu6LtUPUTW+nNPLgZnskLo3d95LvFfMXwJTpuaedeP CHzkL7TyMHcdz20uEfFXz+chO6QkNwCpswe/POHWLUQ7uyN7sJNwsNyo0tLQfHlNh02s G+GgH8tS0LwaBXfcOSyQkeWkYmovxAt22NYGdW9/plUB7VDk49aRN4cmDCsRhT4JFHAl pqnKXpBxO0gPoySIpOgOA8IE7la1RA9yLCMtPn4SEBjr6AR8CJs6b5r8sCkChF9DKm4L eeUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417888; x=1793022688; 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=i59cwFpnwV4ZWelO27hAghlfIgiy6O8zXnZ0ftvy/nk=; b=U/CpioDGYttjIK1Aun/GdJCfS/5L1JRK3/A4AJQ/uvLl4QAjUvXSGEW17+hOm+cPIh 6uLRTuwp7cN1aK8Hu8SQsb6v+KFJSNoQVKnUcBdPulY/jKpWz6JDdupK7fTpiehBbV/9 JYXxpE7QQ5ax3bXkwRy2IrdTqITpdJSjPEWiI7ppU1JlMpUpjkvTYPLVmoq++4V94imA F9Sd8s16PobNRFhrrw9WrutXactXJgv+sIdYmD+eMP7nene79LsjNaQOycXwGMjWHrju dfI4yElI6EvL0O3KQNDS8mVhiSCGorRS1TjbCGms1h3EAdQecRFAiuQ8NHwokalYqrBr 3DWA== X-Forwarded-Encrypted: i=1; AKwUvBwAihHDI2PAtQdEmmWauNkeV8ZIjW4TfXyiA26J9ntDFfhXs86pqn0y52lYQvdXZPpn4Zm/G7X4C/k=@lists.xenproject.org X-Gm-Message-State: AFq9FYIwzJ52ddP9uVt8rula/jpa+sh36DqETvtibDAbVf8j1nOGwN+5 UgOV52rZfeK1DRcdeA0uLqlgNzuyV7JvhPByiDUiNBsV+ExzZp5V75Mz9tV49odWb+Kh09akyv2 NFkbO X-Gm-Gg: AYBFou2Rg+/3NVGyhW7eTA6i+9PVisbDHMKtqLS9BL+2ugF6EJN7kVj+QBIjU3pGSYn PlWg3ebETeEB7X6zacMBU8Ljm0PnEV9E1cHv6IO1GreX1znWMmt/StPvFD7SPnW1dj6lMHXu6ly KFW9/7a883JUIeZi3fo6/EoEkf8Qlz2GHAoffjvVT2l9MyxuNSENNwrQoNT5hwD6aGZj/DwQTGm DRe+BGaH0e3ii4pBhPSOOlnAkTi/RmaWWwKmm0qMvLW7boWIXZipEPKf+eD0nq1gLEqU1QKH9Bq fXsQ2yhWjpttwzB8FVqqFt3x8Kf5LHmIP8hwpQ0pwcxMDKg1K4WQAkAtP6+LSSWS+QX9YDIUXzi 3OVR61a5XFjEUrUv/AHsP5Q6pTogh8TRxwqJkfnaK7F+4+ZqPcDK20JbLnULLvr/6GVekFhnkkx IfHXgYGWJyjN7bgjE37M1inXbjdAMP5Z7vrNN7LstF5oHW6k7mdbXFvfG0y/UpkahgUAx1VHyeB FBB4ml8c88o2dE= X-Received: by 2002:a05:620a:7309:10b0:93f:322b:2209 with SMTP id af79cd13be357-93f322b2321mr606237085a.28.1792417887551; Mon, 19 Oct 2026 06:51:27 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:43 +0000 Subject: [PATCH net-next 09/15] net: skbuff: check csum_start against len in skb_copy_and_csum_dev() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-9-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=1647; i=josef@toxicpanda.com; h=from:subject:message-id; bh=sxMOxEm7hnqJ4JHjLlLYqgrWX5cOQpVgaNwl3bOsGCc=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QLHbIa3sdMEeDl3ey/+03pKmEjvdf6OVqCc90eTylLEjn32s0tlhlr2FYQHUU3Yl4h7USrA20K9 UzEGPZt5vtgo= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-d62444/1792417889-1F66C757-BEAEB250/0/0 X-purgate-type: clean X-purgate-size: 1649 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417905464158500 Commit 56453199d28f ("net: skbuff: don't BUG() on a bad csum_start in skb_copy_and_csum_dev()") checks the checksum start against both ends of the linear area before copying up to it. For an skb that isn't CHECKSUM_PARTIAL, though, the checksum start is skb_headlen() itself, so the check compares it to itself and can't fail. If data_len is bigger than len, skb_headlen() underflows to about 4GB, and that becomes the length skb_copy_from_linear_data() copies into the driver's bounce buffer. The old BUG_ON() had the same blind spot. Also check the checksum start against skb->len, so such an skb takes the existing fallback, which copies at most skb->len bytes without filling in the checksum. Found by LLM review after the series that made the change was applied. Fixes: 56453199d28f ("net: skbuff: don't BUG() on a bad csum_start in skb_c= opy_and_csum_dev()") Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 5c89c463f234..782a6bacd568 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4103,7 +4103,11 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb= , u8 *to) else csstart =3D skb_headlen(skb); =20 + /* skb_headlen() underflows if data_len is bigger than len, so check + * csstart against len as well. + */ if (unlikely(csstart < 0 || csstart > skb_headlen(skb) || + csstart > skb->len || (skb->ip_summed =3D=3D CHECKSUM_PARTIAL && csstart + skb->csum_offset + sizeof(__sum16) > skb->len))) { --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417919; cv=none; d=zohomail.com; s=zohoarc; b=Of2vLlWhZ+so3WiewP53oNdFyGvy8ol9fr82LAf/q00o3WYqgjcWhF68aE89BZuSlr/bgycSZA7JgeH3ZuLFI58Z4i0/e0yb0NUP4siuKIhZb8mZtrtTZQuKDITivIG5kN0/xZ/XNAiIB+XOJ6h9zITy/oMRADip8LOHW50EuFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417919; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NueD3KcSYkb8JdZSOJlKL8CiOB7BO395X3cXr1iZapo=; b=iAxnl/9uh8bMDbjggnX4DBigFYzI17/ufjCgr8sjgfp9xigIvjWTYCki1ZlZE0+bLT3grHHt8/xw9vY26JMUOkQrji3BjHuOt3HWeROKd2cgnUf5pXatTQcPOAL6FY3HiXjMWBo/vlqmyYwF9JW3rOU3TjhSeiKBFcqjcZR7wuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417919202364.563123907996; Mon, 19 Oct 2026 06:51:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454400.1668022 (Exim 4.92) (envelope-from ) id 1xInm1-0001CF-Ou; Mon, 19 Oct 2026 13:51:33 +0000 Received: by outflank-mailman (output) from mailman id 1454400.1668022; Mon, 19 Oct 2026 13:51:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm1-0001Bw-KY; Mon, 19 Oct 2026 13:51:33 +0000 Received: by outflank-mailman (input) for mailman id 1454400; Mon, 19 Oct 2026 13:51:32 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm0-0000xs-70 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInlz-00Eeji-JC for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:31 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6205c-2eae-0a2a0a5409dd-0a2a45019992-14 for ; Mon, 19 Oct 2026 15:51:31 +0200 Received: from [209.85.160.173] (helo=mail-qt1-f173.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62062-5984-0a2a45010019-d155a0ada50f-3 for ; Mon, 19 Oct 2026 15:51:31 +0200 Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-5351d76e1baso27243231cf.1 for ; Mon, 19 Oct 2026 06:51:30 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.249]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5367c3a016asm8422981cf.25.2026.10.19.06.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:28 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417889; x=1793022689; darn=lists.xenproject.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=NueD3KcSYkb8JdZSOJlKL8CiOB7BO395X3cXr1iZapo=; b=EVqfCMiXD1sTuugn6xQ4dcs9RsIkXJ3Gn9XIvA31AXkjEoyJu/rxk33oP78JkA1xok E/CoWh+06LF8BjNhw3fM5Ap1aGYdcV/Eq4tBaXRvcTufzKYMRuPrwZU6zBW9ee65hRGf 8kfT3gpqi9ChRFAh387WXtktn/Q3ueS1Ji1wISERG8F6A1CPEgx2auG4Fsk9PVm61v52 GDP61YlZcB6vEnjDb9/nXd5y1Apy09xPr9dhUlZKXugaJUDOZKAKNFlKtmTUrvHQKMsW QPX8cGJfZkiBJVbWNIBrSDh47/dX/z12beXRX4QC2LKCJ8XvzyRtG1ySSjAoI+nKqK6T q83Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417889; x=1793022689; 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=NueD3KcSYkb8JdZSOJlKL8CiOB7BO395X3cXr1iZapo=; b=tgISfSOvgLVGtROqAjxXW43F1YL/OFV26hbSq8t5rluqyNKe7hBhuv2T3F1Mnx0rMA 2yGHADPMRs3ZrjikFf5TbuzFpiU3o29sR291sCx0sdH7bKFIEB5s8TXpwwYK8WeHS+Qy vO8brAcnXwjVZEO4glK/sBN/dctXJ4XZ/lryWBLIUHTrfLni2vnMgqDvCzbdR2kh8UhW PtFtT3smNx+FeM+zdzB7c6cEK0RBMss596bJND8/H0Jfs9/+eMxLUXSxpLZmKDO8r95X +fF5+ylR66GdZz99V40ayzi4l8O2O1hDLofMebnnWe9ms6lHPoKaZx8oI8BW5O4AYAQO bagQ== X-Forwarded-Encrypted: i=1; AKwUvByJOriKkpZbxWgZLvfcxy1d1Fhb/KO/WK89OcfhjzEPtMD7kkBPYgL71WnzGrrjN9qdxb6vVewr4Rs=@lists.xenproject.org X-Gm-Message-State: AFq9FYKLA1/VQQX/NuCcZEs39jCp54PizJioCn9eqDLHY0zk7X+v/GPy pL/Bjv1Xt2eQ+QXab17XvdqIhkn8nfRSRIUviDWYqVD8uH1jZNbBsirsLwXKaA64Lsw= X-Gm-Gg: AYBFou0sjRxu1Wv/mFBjsPbWe4+56bAwsVbgoVJKl/6aQ8ddxvskG3qXkbtPciU1G3j JyyVw+iWxod4e1vTn+X84R5Ii+7nI+Ue3wfTLkF9n2oAkv1nGJh2q4rdC+h8Oxq8Ua850BtfVdP 4fpeJyEfYK3yl4itkIsL+0uswAs5xjYd06joHvUhCzg+xFXjTwYDyvMwGZ5QbceyyMDkYyxWATN KZmhJPy7ZJDUJZfv/7cIQ0vnUo32hf6umPkK52ha/NYSKhe2DA0JkHCXuZAJ6C/JiYisSeS5PIb 9aPWz/eqz4yLDVALnVsdlt6NFLzeOZblXXdZ8GMEkvcOlCie6iF1iJmC7rFVLv/9rwPRCY9qHnD H7GB+WZYl+IRSsV7Oum2HDhGqxE+G3hHhhyeALvlzTXKJCorvdjySqI8L2fCUuwPn6Atzcz60fF Lh8Xi9d/O9gshW7jehulcX1INOgFP6GqaRMfkLJnMnwYHGGVfM15bxp3gz4iWw3rZ5OADcWtZ9y rwg9q7GSYl7npQ= X-Received: by 2002:a05:622a:120f:b0:535:1d5b:a7fa with SMTP id d75a77b69052e-53645fcfd95mr105600221cf.14.1792417889532; Mon, 19 Oct 2026 06:51:29 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:44 +0000 Subject: [PATCH net-next 10/15] net: skbuff: reject a negative length in skb_copy_and_csum_bits() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-10-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=2599; i=josef@toxicpanda.com; h=from:subject:message-id; bh=II/CP7Oe6pPmnThcZPqfbajOFeQVtnEAdIjZymwWmTI=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QLT77d+wO2aZJcnSaM7dE9IczO8S8pXOJ39O2d4Dqx9woYqiJPcR/OP7dZYvy9TOeJvXuBMsRjF HbZ69mG6gdAs= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-d62444/1792417891-1DC79757-C005D083/0/0 X-purgate-type: clean X-purgate-size: 2601 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417919716158500 Commit 417261779eab ("net: skbuff: don't BUG() on leftover length in skb_copy_and_csum_bits()") guards its zero-fill against a negative @len from a broken caller, but such a @len never gets that far. The head, frag and frag_list copies all clamp their length to @len, so a negative one has already turned into a huge copy, or an endless frag walk, by then. Reject a negative @len on entry with -EINVAL, with a DEBUG_NET_WARN_ON_ONCE() for debug kernels, and drop the guard on the zero-fill that can no longer be reached with one. Every caller already handles an error from skb_copy_and_csum_bits(). Found by the Sashiko AI review of v2 of the series that made the change. Fixes: 417261779eab ("net: skbuff: don't BUG() on leftover length in skb_co= py_and_csum_bits()") Link: https://lore.kernel.org/all/20261007-b4-skbuff-bug-on-v2-0-b9a5f73289= 5b@toxicpanda.com/ Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 782a6bacd568..56cec58bccb7 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3678,9 +3678,10 @@ EXPORT_SYMBOL(skb_checksum); * @len: number of bytes to copy * @csump: where to store the checksum of the copied bytes * - * Return: 0 on success, or -EFAULT if @skb has unreadable frags or runs - * out before @len does. On failure *@csump is not set and the part of - * @to that couldn't be filled is zeroed. + * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb + * has unreadable frags or runs out before @len does. On failure *@csump + * is not set, and on -EFAULT the part of @to that couldn't be filled is + * zeroed. */ int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, int len, __wsum *csump) @@ -3692,6 +3693,14 @@ int skb_copy_and_csum_bits(const struct sk_buff *skb= , int offset, __wsum csum =3D 0; int err; =20 + /* Everything below clamps copies to @len, so a negative one would + * turn into a huge copy. + */ + if (unlikely(len < 0)) { + DEBUG_NET_WARN_ON_ONCE(1); + return -EINVAL; + } + /* Copy header. */ if (copy > 0) { if (copy > len) @@ -3777,8 +3786,7 @@ int skb_copy_and_csum_bits(const struct sk_buff *skb,= int offset, if (unlikely(len)) { DEBUG_NET_WARN_ON_ONCE(1); /* Don't hand the caller a buffer with stale bytes in it. */ - if (len > 0) - memset(to, 0, len); + memset(to, 0, len); return -EFAULT; } out: --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417909; cv=none; d=zohomail.com; s=zohoarc; b=iHxZcnelLmndd2MRmFTAld44aPMyjnzUEY8ZVsSgubr5Rlwh63Pctw/zfEbbwjD1YkHLBhV3OsPSLCHp006N7OR5hiUek1+BqI7TxctFlFg84HKtazjB+Zr99jSmUbP4FR4w7VL7zryfUYOdE5kSEd4rj8EC5NP4n0drVoROs+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417909; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nH4MPLjNHd0ezQ30G0wFNIQg5eWAqIll/99R00Ry+f8=; b=mHxcb1isRgxt2qWlVOTXw9JKP58PGI7EFRabyGYSLSrMM8WaHbH9DQEFLLYSF4AZ2ue4vPGbMWPSBLHjHqmBo4IRX6D1okjNJydqiCaaBwjkrlA3uCVhbEoqsxIB5Dn8eSQiDFrKLBFiEnfK1jkRUwJKPCRQLOAlTJzH4IheM2A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417909338359.46410920168694; Mon, 19 Oct 2026 06:51:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454405.1668031 (Exim 4.92) (envelope-from ) id 1xInm5-0001Xl-48; Mon, 19 Oct 2026 13:51:37 +0000 Received: by outflank-mailman (output) from mailman id 1454405.1668031; Mon, 19 Oct 2026 13:51:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm4-0001XH-Vv; Mon, 19 Oct 2026 13:51:36 +0000 Received: by outflank-mailman (input) for mailman id 1454405; Mon, 19 Oct 2026 13:51:35 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm3-0001UC-Pe for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInm3-00BvLk-62 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:35 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6204f-e002-0a2a0a5209dd-0a2a4508eb24-44 for ; Mon, 19 Oct 2026 15:51:35 +0200 Received: from [209.85.222.172] (helo=mail-qk1-f172.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62065-f659-0a2a45080019-d155deacec3b-3 for ; Mon, 19 Oct 2026 15:51:34 +0200 Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-93f30660e69so119154585a.0 for ; Mon, 19 Oct 2026 06:51:34 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.240]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93f1a19ce5asm982035485a.32.2026.10.19.06.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:32 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417893; x=1793022693; darn=lists.xenproject.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=nH4MPLjNHd0ezQ30G0wFNIQg5eWAqIll/99R00Ry+f8=; b=HJycgKfVpopbg+81JhnS99qSjXtN/UGTeqRRH6F218Bor7xkxPEVJMAiLSDKMIGSP0 SkpU0v/2nOtHzo9tcBrJTicOg+bhjHDFcmaoyfQaV3FarKnvbAQkVjq+84sIkI07wMew feEXDLS5fJky7a4Eegy25XMMLUXb+jGu9Ks5skcl5tQgpnQgsm3rwm+GwaVwAyuNxCWN 7REm36IRThC3GA11QR8Vu/dmII/3s8FwL1OLVr5qeFF/mSI2swOE2c6DyKY+jwi6aI8N 4SlccIc1+BBqprmthvM8EmhWGdFINgDpVv/zNniKBXXxjHZgTxTKb71yVpJFBCHZZFqj rxwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417893; x=1793022693; 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=nH4MPLjNHd0ezQ30G0wFNIQg5eWAqIll/99R00Ry+f8=; b=W4TPIfmI8P9ISQ+aaktvuYY3FDvoqN3dE3WZSOAURi3Kya3o+0O6t5GAa1d6QFEnVa W2YsUkVCGxWGwWUd3urCx7OmrbSuXU8BM9rRg3Mn4wycDX2AV7puCPUKUtsvAJp3Nsly WgaNOg39mNlrtNApRJCCTTc396caVezMUhGX8/PbkjjLNS1F6givwhJQ+CCo0k4jTXY9 TZUoWx3CJ2sBcfjNpFJ8fD/D8yvfQeoocTSsREIWVyrgoN+HI1+XA01rnizCvl6zP37L iQCBHSFxxF30p3u6BEDX1ZkdmQHUYZ1scOcpzxKHLCQmFiTg2ha+cmLNdb0s6JUiiknh qI8w== X-Forwarded-Encrypted: i=1; AKwUvBwSDHA/2zLWn39w2cnUH9f+c66ktYw8Z6vgjpR9fNeZfR5V5M4HAuqcSYarnggldVVZBoDcWJ7B1XY=@lists.xenproject.org X-Gm-Message-State: AFq9FYIMacVqxJi4r9vsqYJ/Ct/9MO3hDGORSw+6lwFupYxEVEQZhvIP Sy9ems5MpYvao9rn5fyFs1sDawnob2aAZIaJFE763iWpJOxOmgvLjV3iLPR145GYOio= X-Gm-Gg: AYBFou24+F1U311dQoS8GQk5s1qKMfL7MiD9Lzk6pitX4/rTV1RautOVHCnD716eYTW f368782dl51rZHlwZJ4tHRS4gZH3Vwr0qTCH4Giz389ciIcaAdrnpRiWiFEgeUyrQpCCGDYvdMy GBWgcWz0OAs8tqt0HNk+7gjFQLyMnqwP4ztcjTE1D4oKPoQJjmXIrYyvuRQFu6+TtSIP/Z4TNJn IlOTR4Pfv0RKfqZLmPHpxpypszTkqYvZBg/Y1G9iJMzWxxZzvbk/w5L2XjU3PS+a+U8PoLqcbrH CTKWxcPSNb3AkbgP0vEUG/vcWuEcm8B2IBavc7pYz4q8wy5ivyGRWOpZLRhisyWCfqDF6Fb2t3V d9f+fxM7IzcslcXqWsML4PU2QGFW45QPM13YCo6/AEXZk7ESNJpiKbCWHqrajQ/Q/exIUxM06i3 b0Qz8RA6vrZrSLPpjfG/vOYXsbFrolufTnpA2jV/ziuEYdf+lp1VWpMYZ4YU/K+JIz4U8t/2nhL f+GpRA/8zKq3hE= X-Received: by 2002:a05:620a:4109:b0:93f:35fc:5266 with SMTP id af79cd13be357-93f35fc586emr874742485a.44.1792417893366; Mon, 19 Oct 2026 06:51:33 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:45 +0000 Subject: [PATCH net-next 11/15] net: skbuff: refuse to segment a nested frag_list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-11-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=2113; i=josef@toxicpanda.com; h=from:subject:message-id; bh=6Z8CiNviIyVdg98sCBaRoAUJsHn+RV3Sx5RlE56aqBo=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QPevlwc09v/MSkDiCKh5chGO+Z/rqVC5uo+IAjB+VXJ5WH8Ns5cSB+345mYyBpXOXcO+Ul5ANjw NRhLiDZ+GoA4= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-c1860d/1792417894-CC77387B-E55E12C1/0/0 X-purgate-type: clean X-purgate-size: 2115 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417909560158500 skb_segment() walks head_skb's frag_list, but for each member it only looks at the linear part and frags[], never at the member's own frag_list. head_skb->len still counts those bytes, so with a nested frag_list the walk runs out of members while it still owes data, sets list_skb to NULL, and dereferences it on the next pass, before any of the layout checks get a chance to catch it. Nothing in the tree is known to build such an skb; GRO flushes instead of chaining an skb that already has a frag_list. Check for it up front and fail the segmentation with -EINVAL, with a DEBUG_NET_WARN_ON_ONCE() for debug kernels, like the other frag_list layout checks. Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/skbuff.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 56cec58bccb7..b6ada54ecc57 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4962,6 +4962,17 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb, } EXPORT_SYMBOL_GPL(skb_segment_list); =20 +/* skb_segment() only walks one level of frag_list. */ +static bool skb_segment_nested_frag_list(const struct sk_buff *head_skb) +{ + const struct sk_buff *iter; + + skb_walk_frags(head_skb, iter) + if (skb_has_frag_list(iter)) + return true; + return false; +} + /** * skb_segment - Perform protocol segmentation on skb. * @head_skb: buffer to segment @@ -5023,6 +5034,16 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, sg =3D !!(features & NETIF_F_SG); csum =3D !!can_checksum_protocol(features, proto); =20 + /* The walk below never looks inside a member's own frag_list, but + * head_skb->len counts those bytes, so it would run out of members + * and dereference a NULL list_skb. + */ + if (unlikely(list_skb && skb_segment_nested_frag_list(head_skb))) { + DEBUG_NET_WARN_ON_ONCE(1); + err =3D -EINVAL; + goto err; + } + if (sg && csum && !gso_by_frags) { if (!max_segs && !(features & NETIF_F_GSO_PARTIAL)) { struct sk_buff *iter; --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417923; cv=none; d=zohomail.com; s=zohoarc; b=bUaM4Y4vxpgZJCh3brrNyGkfcwalNNFr/eEHyUd6/gsjrqhKPSKvIhJMYs3m1YXgJFxVCEeTHsnHMjmjyWwFVzbpOVD2H+Z71OX2vL4Dozj2YXnIFfaQG/2XGNyfRVUBzboaA8aO9ve3GRV+GIiBPwh9lHdDkPq2Afy+O+EUcJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417923; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cCcET6n/yfDRwSzhWgNa5UxSYwstO6x0SjXdcG6UWRc=; b=fcHNkiIccTMnljLObzzTFZUJJz+udjefbRuweH+n8/KC6ZCaLBkTWAGb44EsqSgqvfbOQUYMwvq7XoEZrnSCfYuPetl1bkVDc6Za/LOlyv88nQeu6fUCpxTzEr0Xf6366bHL2zlUQSkJ4ht69iMmSbAYtfFrCIiuiM7Vhvz4D/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417923054298.67105715266473; Mon, 19 Oct 2026 06:52:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454407.1668040 (Exim 4.92) (envelope-from ) id 1xInm7-0001vh-FU; Mon, 19 Oct 2026 13:51:39 +0000 Received: by outflank-mailman (output) from mailman id 1454407.1668040; Mon, 19 Oct 2026 13:51:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm7-0001vW-AM; Mon, 19 Oct 2026 13:51:39 +0000 Received: by outflank-mailman (input) for mailman id 1454407; Mon, 19 Oct 2026 13:51:38 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm5-0001iN-SW for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInm5-00BvLk-94 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:37 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62067-e002-0a2a0a5209dd-0a2a4503a8e2-4 for ; Mon, 19 Oct 2026 15:51:37 +0200 Received: from [209.85.160.175] (helo=mail-qt1-f175.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad62068-fae8-0a2a45030019-d155a0afa45b-3 for ; Mon, 19 Oct 2026 15:51:37 +0200 Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-53639b8903bso30467561cf.0 for ; Mon, 19 Oct 2026 06:51:36 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.240]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5362a8e43cfsm99302081cf.5.2026.10.19.06.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:34 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417896; x=1793022696; darn=lists.xenproject.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=cCcET6n/yfDRwSzhWgNa5UxSYwstO6x0SjXdcG6UWRc=; b=Ki8JxYBcjsJryn86TTCTg+NU48IOxRBs0/TCY7mYKlDaI6wTJ1uJUJGDzp4CUh8PYy BzmNLHiXeqcn2uyYB0LiulSrg/alaKFBGxCWsAJsOQmciSEn/ZMcj9dliJH1NPj5LGak u6AcYuDkHw1apJj2mPJvOFv1rTd0j6+1wBqmclKA9SITFbQ7WWGaqCzDqW7I/L7TaBkE mlaSLJtrnoogHvhAvgbdwW/wFIgaegxRFs2J5ThlPD8bTSueOx7ZNF4mY6EAB4jrUJcO ZLSvOXRFPVu4dozViuKjcr5ZLmhZEtrd3FrcT+NUilTvBXtOFvx86yYqjCgEbF+N7ah0 WKww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417896; x=1793022696; 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=cCcET6n/yfDRwSzhWgNa5UxSYwstO6x0SjXdcG6UWRc=; b=FMIFR+1KT8GBQGn6nqLQO4GNbTlOuCLFqHRBYN17+Pqlb7hDtvRo63O6gdUVpf/5eu JOPsq13QcoE/EK3470QYwXOH2sJz5VVl/gMJYtQ/k+rfn78ReqDW6LHPGc2jqqomgLW0 TWebR2lzOBUoKt1q2O8EY9lD0bVvg7obvs3NdwE+CXhjiVJt9gf4Hyz9rcNc4jw2vKPJ ZSSFdNU7D4W/1U/zAma3e2mWj2L4lVXvNSt/Z19QZsOnuEFidsRgaa7OHepVWWuZAgLI UO6795DK8WYng/q4ucKH3e/ks1/pqQuN2l76MTclt2l6yIfUEl3Wsw4ikTEqoTWOdISZ M2QQ== X-Forwarded-Encrypted: i=1; AKwUvBy9eIksUe2ZX7DLwk3bMC+sRPjKr++WkBYTarOn4i9FzyiH1MsgammNa1p4dElgN/HjtE3qHCFzEbw=@lists.xenproject.org X-Gm-Message-State: AFq9FYKmh3Hr76odmGXOx2od97Yh7AxYxzOLHWsfVzNdlpVVMm5b+syU S9kw6K5Lsx4DtEClJpuzFHuVsHrfmgHzx2RpfA0M8e+poY5DG+qANdafXnPWZokVx2E= X-Gm-Gg: AYBFou1gutnFIV80HiafyhlRRgiXo6RIOo/S69iQxKLGuMYrIXgSkPk16ZkB4snROcK /psZr1VbEV9L+PSn8cZcABBf3OIhi/wnj6jeaAH1xRWW+FjqkWL4Hmmm+JCP1bQuqnY4D2jdXWd XLUTUp7Y/bDaZwTc/Oi5aUqD3NhkbTTP/FZdRrEbqPAPyB+X9CyOBveMzpmIscT/DgSQqYbeeYh A3KGTrg41ezWGYFg0pwuUYkUYJXO+jSzeTeVOpObl61d30l8X+VDM16b6WXdmvnY+upCsH3ENXW 02LAkg9AEkXoxyczp5iUc8ogRlbRB7HpSb1IjDfs3QMq1DU5k5YAMRnvvOpMBgxtpCtEGOPw1Bi EL8zTFDqRlhdnjj/6Fgjy58Z26GspV6OAQMS1d2XtsOa1kKoLwagiiSWyOHgEd3yz7lXIJcZQUr UAPjBCAoxCpr9nWl0ytwkFGjfujD8aX9ewaCVGPpWsK0dOK83GzFSu/lboq1fjBjnEtwtNd21L2 jQj6I3UDfbSWJ4= X-Received: by 2002:a05:622a:8449:20b0:535:22e8:2fd3 with SMTP id d75a77b69052e-5362725afb9mr117803081cf.10.1792417895776; Mon, 19 Oct 2026 06:51:35 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:46 +0000 Subject: [PATCH net-next 12/15] net: test the frag_list layouts skb_segment() refuses MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-12-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=3190; i=josef@toxicpanda.com; h=from:subject:message-id; bh=54YuJC4Sa4ftFWTwcdr1JHSPiV0/4B3b8lTqh1NoeIM=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QMl/CfrGUamcaF3Ng1FUVBnBIHC3kZ7QHRED94+HWu2IRKE9xF6ZECYluILceDZSaJN+2T+BFcn /RZqmOf7s7Qg= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-33051d/1792417897-6C2E04E9-2BCDB0C3/0/0 X-purgate-type: clean X-purgate-size: 3192 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417923806158500 The GSO KUnit test only checks layouts skb_segment() can segment. Add two it has to refuse with -EINVAL: the non-uniform frag_list with SG on, which used to hit the BUG_ON(i >=3D nfrags) the existing test steps around, and a frag_list member that has its own frag_list. Both warn on CONFIG_DEBUG_NET kernels, so run them with the warning backtrace suppressed. Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the Reviewed-by: Willem de Bruijn --- net/core/net_test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/net/core/net_test.c b/net/core/net_test.c index bc2ef7612e7d..12a175268a01 100644 --- a/net/core/net_test.c +++ b/net/core/net_test.c @@ -39,6 +39,8 @@ enum gso_test_nr { GSO_TEST_RESEGMENT_MULTI, GSO_TEST_RESEGMENT_TAIL, GSO_TEST_RESEGMENT_ONE_MSS, + GSO_TEST_FRAG_LIST_NON_UNIFORM_SG, + GSO_TEST_FRAG_LIST_NESTED, }; =20 struct gso_test_case { @@ -57,6 +59,9 @@ struct gso_test_case { unsigned int nr_segs; const unsigned int *segs; const unsigned int *gso_segs; + + /* skb_segment() is expected to fail with this error */ + int err; }; =20 static struct gso_test_case cases[] =3D { @@ -204,6 +209,28 @@ static struct gso_test_case cases[] =3D { }, .gso_segs =3D (const unsigned int[]) { 0, 0, 0, 0 }, }, + { + /* frag_list members that don't end on gso_size boundaries + * can't be segmented with SG + */ + .id =3D GSO_TEST_FRAG_LIST_NON_UNIFORM_SG, + .name =3D "frag_list_non_uniform_sg", + .linear_len =3D GSO_TEST_SIZE, + .nr_frag_skbs =3D 4, + .frag_skbs =3D (const unsigned int[]) { GSO_TEST_SIZE, 1, GSO_TEST_SIZE,= 2 }, + .err =3D -EINVAL, + }, + { + /* the second frag_list member hangs off the first one's + * frag_list instead of off the head's + */ + .id =3D GSO_TEST_FRAG_LIST_NESTED, + .name =3D "frag_list_nested", + .linear_len =3D GSO_TEST_SIZE, + .nr_frag_skbs =3D 2, + .frag_skbs =3D (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE }, + .err =3D -EINVAL, + }, }; =20 static void gso_test_case_to_desc(struct gso_test_case *t, char *desc) @@ -283,6 +310,15 @@ static void gso_test_func(struct kunit *test) =20 if (tcase->id =3D=3D GSO_TEST_GSO_BY_FRAGS) skb_shinfo(skb)->gso_size =3D GSO_BY_FRAGS; + + if (tcase->id =3D=3D GSO_TEST_FRAG_LIST_NESTED) { + struct sk_buff *first =3D skb_shinfo(skb)->frag_list; + + skb_shinfo(first)->frag_list =3D first->next; + first->next =3D NULL; + first->len +=3D tcase->frag_skbs[1]; + first->data_len +=3D tcase->frag_skbs[1]; + } } =20 features =3D NETIF_F_SG | NETIF_F_HW_CSUM; @@ -296,6 +332,18 @@ static void gso_test_func(struct kunit *test) features &=3D ~NETIF_F_SG; =20 SKB_GSO_CB(skb)->max_segs =3D tcase->max_segs; + + if (tcase->err) { + /* the suppression block doesn't run if it can't be set up */ + segs =3D NULL; + kunit_warning_suppress(test) + segs =3D skb_segment(skb, features); + KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(segs), tcase->err); + if (!IS_ERR_OR_NULL(segs)) + kfree_skb_list(segs); + goto free_gso_skb; + } + segs =3D skb_segment(skb, features); if (IS_ERR(segs)) { KUNIT_FAIL(test, "segs error %pe", segs); --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417915; cv=none; d=zohomail.com; s=zohoarc; b=CZLpWQjwhgLywfJykDp4M66wzumZQE+dYkIFV8Cp9oqHfvmts0btYBQqJUPUugsh59jhQqtSS3CL6OxYEfKDf7H3GzwHUv4sBEXI2OtauZBRovWhmeAZcJhd3/INOC6QF0+4fsdhkRiTm7YpfL6GQLw7hR1NRcO9JXZNr/GdNhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417915; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l2su03NSLDI+QURR7+Op6WIlpfTiC3EObk5mJFR1rWs=; b=Pp731pscQl1ZzOEC5w38+XoUQQs8h45eVs8x8Y7Kqy7DZJL1ooMpRQdmoeunnObPMBnXy8voihtjYNQzPT+OLUi/dlmI0CBTHZH/JqQbErhlO9C7Lzcr/6IVSJVqghEQ+HK6Bf/6bjqxkCcVLWzX/54fxZuL1VEg5BncKTLra4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417915076191.20291652261437; Mon, 19 Oct 2026 06:51:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454409.1668050 (Exim 4.92) (envelope-from ) id 1xInm9-0002FN-SZ; Mon, 19 Oct 2026 13:51:41 +0000 Received: by outflank-mailman (output) from mailman id 1454409.1668050; Mon, 19 Oct 2026 13:51:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm9-0002F1-Jo; Mon, 19 Oct 2026 13:51:41 +0000 Received: by outflank-mailman (input) for mailman id 1454409; Mon, 19 Oct 2026 13:51:39 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm7-0001yV-Q5 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInm7-00EenQ-6O for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:39 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6205c-2eae-0a2a0a5409dd-0a2a45019992-38 for ; Mon, 19 Oct 2026 15:51:39 +0200 Received: from [209.85.160.176] (helo=mail-qt1-f176.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad6206a-5984-0a2a45010019-d155a0b0ec31-3 for ; Mon, 19 Oct 2026 15:51:39 +0200 Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-5365d725440so11246871cf.0 for ; Mon, 19 Oct 2026 06:51:38 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.241]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5363455e7d2sm89038411cf.13.2026.10.19.06.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:37 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417898; x=1793022698; darn=lists.xenproject.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=l2su03NSLDI+QURR7+Op6WIlpfTiC3EObk5mJFR1rWs=; b=HsfCsgzQfm/3r3/QcfhDFyzF5yj30q3oaOZWVm+pGGSI2QygIV10tqs61KJrXqUfWv rgJmuXKpa9kfpdDFnYg9XO0lTx+p9AxaQvBLFUqlxll6q56EgTX5Gzu45c8evfUJEfOB hjnop1rNQ97I8cRH7jl7sUc4HkSUyg2eckwt8JrWEuOpempCsHne71YgDhb6Z4VZkwpF MgKXafAdo4vbpPt7eRt3MHZi1yuLXX6eEzkousg4gU5Xgqw/uUZGHXYHXr5B4Y0lq2L9 ZiF+b54VgFUAR5Hoqn87/hAMryWD/zAy5YDTkU1Ig4JLAPQbfiTnsCIDrvBuAIxT92cs 7CkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417898; x=1793022698; 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=l2su03NSLDI+QURR7+Op6WIlpfTiC3EObk5mJFR1rWs=; b=VjLPt6f6aqLb8lbI5SywT0mIcYX6+p5hF368Na/wdYKk9axiEhF64qxH4M6lloMPXp 67A7zq8TgKBDJ5mdZVrqE82YIKdVi2CxIsIVq6zBrgHMhpNNtrzFIQ6c3bgU7UjCFS8L ttQWPOAuJ2dD8eU2ULZxC5c2x5Sh4mi4DlnQ/+E2MspZ4oY15Ba12+h/LS6sf3LFEn3l nx9oDKUOYGApPUYys3LrTb7+QhnAn0UCJimqjifXFa7iUyyzV5YJDBFei7PcIpx7SVrF G/QwFtGvlt0iWvOq3G46DvBnsSdOhCA0+OAPAsoJMLDhQe4KIxUbIpXSg3qIn4VfOSAT x0DQ== X-Forwarded-Encrypted: i=1; AKwUvBx41moZ2nvS2Z5fWGbdAJMvjplnBNg0/vEhBVJzso0Uvu54HKI8HX7F23M1Mo9IjCcohplRX2ClheA=@lists.xenproject.org X-Gm-Message-State: AFq9FYLb1GAjlWuQRxcuTuEa/B6Ca3DqW2wQ8DbGpurm7UVrB1jdiwC5 DSaIT757/AjpFu2C+bZH4Kcvt5IIFZNxwHfQhzMyqHs0u26xvft09JL7epnpCrkjn+I= X-Gm-Gg: AYBFou20fuSuEU/pTxW7AeCQCVzTrt32NERR9mtuC6/SYaxEU9YAD/fOXUyubYJ2llE n1rb1UV46fvyaWrGiMAbnq4zJ1rf6a6YlLoTjTAP8YUaj/8DAP7lYfrw0o2sz3KGdXLVnvVZsud bAAOHpj+6QW/4v1M+wjLtuxRO0XuUAmW01zYMC0pKN01Ze7knI0CpYQgULfWQyYyirJhKfBY45O FqqqGGIQz14I++LXHenJA0l/gbbA3nLZgT1GhDCpv25uRDJs+dR/OE/yuPa1AS81LmMAmXyibMm WWxf7Cgo9r11hVJEgDqao/A2QHKslhZMOXV85Zn4s9+RdW4zaCxwYEFIAAf2hSmUv0E4aSS2Cum LFqAJKix9poBuclcZEXn/89iAgBfTrU8hBlGNyH7d0BwIZIiy/I+5hhR5UipPJb/ISMKW/led41 fjac9Mdm9vXl3FIUPTyWG+mIjsi/oVl8iQsxcRMOPwkVki1GChhFz1Ek5oMxRr4+flrqt0flxBu xBDfpiLLeDcNMI= X-Received: by 2002:a05:622a:1b87:b0:536:702c:f8ea with SMTP id d75a77b69052e-536702cfb33mr37062611cf.47.1792417897687; Mon, 19 Oct 2026 06:51:37 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:47 +0000 Subject: [PATCH net-next 13/15] xen-netfront: don't BUG() when skb_copy_bits() fails in bounce_skb() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-13-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=1219; i=josef@toxicpanda.com; h=from:subject:message-id; bh=9EvzAU9EO5dyvCGQMaA1nd2saqGuALWIDCXk9Xn6dMo=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QMKSzC4sHZmaSUvthhUD2jAMmS0Nr86UIBJrUbV6zvlVJH8olJ0s62bKQw5Ehhrzn/DanWtOPAh Q6nevl7Ie1gM= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-d62444/1792417899-BF86F757-7C49BF39/0/0 X-purgate-type: clean X-purgate-size: 1221 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417915754158500 bounce_skb() is an open-coded skb_copy() for skbs whose data isn't page-aligned, and it has the same BUG_ON(skb_copy_bits()). skb_copy_bits() only fails when the skb's lengths don't add up. bounce_skb() already frees the new skb and returns NULL when the allocation comes back misaligned, and xennet_start_xmit() drops the packet in that case. Take the same path, with a DEBUG_NET_WARN_ON_ONCE() for debug kernels. Assisted-by: LLM Signed-off-by: Josef Bacik Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- drivers/net/xen-netfront.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index fdcb91042f29..17811d81937c 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -695,7 +695,12 @@ static struct sk_buff *bounce_skb(const struct sk_buff= *skb) /* Set the tail pointer and length */ skb_put(n, skb->len); =20 - BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len)); + if (unlikely(skb_copy_bits(skb, -headerlen, n->head, + headerlen + skb->len))) { + DEBUG_NET_WARN_ON_ONCE(1); + kfree_skb(n); + return NULL; + } =20 skb_copy_header(n, skb); return n; --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417928; cv=none; d=zohomail.com; s=zohoarc; b=YdI2Wb1ZKQvuoUk6UQyeQBamqbqfiocXKvLMDfe+HJLERtjSKIRfKCXFvRaPuNlCe+1qCjCeryUlVeLMxXCQZdwnPOCAqVXBgTd2mo0zIM/Xtx152vAG2+cgGanVDblS4lDeGMeZmOm62l+BKDGIQwMnp5SstC41ZUMJ0eJ/2Cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417928; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hBRr7gTw0LaEROSfxIaRRGeZueq1UExVdpAZr5NxHXs=; b=f3CF72DeO/iuiNGLQpQRiZmgaypkVe7g0FAOeuqCoyQqs/IrExu/LA2496T1h8eP01IO3RHKz7zY5rFkHe3jXmZ0lAjo9qbb2L5KgUy5tsI7pvwEhVdx3d2Wc7a02qUHl06CybMbj5qTWD5GavFzLIBQxu+l/FLdR1PWC/QTXi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417928647326.8843979369932; Mon, 19 Oct 2026 06:52:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454411.1668057 (Exim 4.92) (envelope-from ) id 1xInmB-0002aj-Ar; Mon, 19 Oct 2026 13:51:43 +0000 Received: by outflank-mailman (output) from mailman id 1454411.1668057; Mon, 19 Oct 2026 13:51:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInmB-0002ZC-47; Mon, 19 Oct 2026 13:51:43 +0000 Received: by outflank-mailman (input) for mailman id 1454411; Mon, 19 Oct 2026 13:51:41 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInm9-0002EX-Lv for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:41 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInm9-00BvR2-2G for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:41 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad6205d-bab6-0a2a0a5309dd-0a2a4505991a-28 for ; Mon, 19 Oct 2026 15:51:41 +0200 Received: from [209.85.160.172] (helo=mail-qt1-f172.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad6206c-4cb1-0a2a45050019-d155a0acc469-3 for ; Mon, 19 Oct 2026 15:51:40 +0200 Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-5365d26ccbdso19540811cf.0 for ; Mon, 19 Oct 2026 06:51:40 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.249]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5362a9dbdb5sm99695721cf.22.2026.10.19.06.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:38 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417899; x=1793022699; darn=lists.xenproject.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=hBRr7gTw0LaEROSfxIaRRGeZueq1UExVdpAZr5NxHXs=; b=fZmjtsX3CVipSeD4msL1iBZbwG7MDQ4DbWGwwvEqELFHiUzWw5NIDeTm71iELlESRl z6lv5bSUnF4Cg6ecz62SZ9XIlhJG58pVKg/qImxaRo18yzWwGCmNMNZXMDIO1vl+8py6 BxP0wfPE2tYpB7GmA9VulKJldlNhxsEZuOvpW82dWENkcC9dMQA2DlKNsfUbjeNTvnl+ 8DpYLga1vC/rjoDS/Q8/wdXvxkTXcJ1ex3jHTuDmtkI8s8t+lTJpUY+M7oqqPM90TZKr WHcqQRwKCg6/6eebXIqWzSRKwEDEr7qVgMmGtqH/iNRgzg6zS+J3oPcONTP2RdinbSlY W+dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417899; x=1793022699; 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=hBRr7gTw0LaEROSfxIaRRGeZueq1UExVdpAZr5NxHXs=; b=Tmg6TigEA7Z17CdohTYBe/gtIH7JmOprPFVauBD1W/LgPDjMQWqsAp0p1mJCZ+nmxy GttdHFhkB/cnlFYpmIKZGcGbbb2DPTSsCmLxgGfuOQpa2N9EUJaECu7DkgWMW2wEmV54 dl0Qz7R5WngtETZzMQwikkvv56NmdAgt7/6HsDp9TwDZTLM8NTqMmNKB5jH3FtBCNXxt 2xuB5JjVm+cixCeL+iC8Jkfz73ckMlTYIZm6VKea02esqkHXKsRXuW2K3WeJWMV0QcKP pM3RJO5fFSlh8A9TCPr5hrwyDyn4RISdWb7YK+daaFQJsmUQ4Haj0ah5JmiHBTohzPQF A3wg== X-Forwarded-Encrypted: i=1; AKwUvByjDEUDSZ4Ddf1+/74MDTD7Cq1g3ykR2uK+Iv+LaBGnX0afVo94PBIJLO6zsfpZF8txbKBcXVD11d0=@lists.xenproject.org X-Gm-Message-State: AFq9FYLO68mPECVGHLWa+kAc8BK1UdyL7Lm5PUflo+zpT/Lfjwz5rLlm 12zxgUL6zS9cUYOUUBz8SfQVjiDi4cA4H6C9ZdDcn58Xvc4AYAseX1/eUEhei4zpx4E= X-Gm-Gg: AYBFou1rFcH71aJSHhu/Nu0I8dKtD3t46geBnN87S9ZwoSxccUZwu2ZPcgB2Uq3hnBI +XfEWODGY/vviP56XAfR7uKvpQRDzD2CVRbDaf+oEeaN/nP25uw0POLIEjCGkIN4M5O/fduq3jI e4Hi8KsFI4dYq2C1A2sYQnIgctg0SyeGPO3k5K+lVl54almEo+hTW4qkJZ8DOihRgl3CkM9bkdq MzGxgEGE88UuVw9gjj4OcCrwJpxVKAIJSUz5OuXvvC5B8XCZCSHhgxO6lbN1XHRE1jFECro/sNf NyBod1JBG/UB4QO2GPEsltlQ/qbR2ZmVQrssgGjV3P9ZmwhfLEH9uHhURDcvc4Ny6FHT2v4DlcE AYb49jv7W2OJ2sHZMw5jNVAMYbl339rAeCJMRK7YW/vcCbcsWJvVW3J/pcOcS6i0d3k6QjIMyAC 10wfF754Zxt0H9QULX31nW/OUY2GxYIgZRWHAYVCw8kEwmJU3lAkkfnoMiCRZn7Ft/p34xTHZfh GhDLPiwlruYl/8= X-Received: by 2002:ac8:5e0c:0:b0:530:1b1:72be with SMTP id d75a77b69052e-53646005c93mr115881901cf.40.1792417899549; Mon, 19 Oct 2026 06:51:39 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:48 +0000 Subject: [PATCH net-next 14/15] net/tls: don't BUG() on leftover length in __skb_nsg() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-14-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=1174; i=josef@toxicpanda.com; h=from:subject:message-id; bh=a5Mq1Y08mQBlSbHPsSgUKJSU0iN0kG1IRQ6Z8TBZzAw=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QAaOzcOEyDqIT7ixMNNFAojpV49DkAGaMSTgMMsV3T+Kry+T59Y4cK1hbqIN6aNryN+eDJKEsst k24iTK/yjrAM= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-c201ff/1792417901-2551A2A1-95AE5B7F/0/0 X-purgate-type: clean X-purgate-size: 1176 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417929940158500 __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. Assisted-by: LLM Signed-off-by: Josef Bacik Acked-by: Mina Almasry Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/tls/tls_sw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 312e51270f29..1c578ea47a1b 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -142,7 +142,10 @@ static int __skb_nsg(struct sk_buff *skb, int offset, = int len, start =3D end; } } - BUG_ON(len); + if (unlikely(len)) { + DEBUG_NET_WARN_ON_ONCE(1); + return -EINVAL; + } return elt; } =20 --=20 2.55.0 From nobody Mon Nov 23 22:39:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792417919; cv=none; d=zohomail.com; s=zohoarc; b=C7c2KQe8bFwz2K0DzCNMo/EBR5FU4M+orJvuycKPGU9B4iL2RxpPfKksSMRhwDIsnZvAGU+cU9OqWmU9YrTRcUB/K+BdJJyX4Lz+88KxKMO4sMg4BtGtnMoPAK8OTPrmgNbuKDJrw5zqpLP4B7w+nLYbQHxnToycbLkQAs1QySs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792417919; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Sz34K0Iw8+vtFq1WnWsYscgmIxwM3BOh5ri5FmDCCys=; b=kZiFvvyOnlTcCCMHGPPB3Q7rSErf55gc++qgFxNxGMSnFlEQ6NBVfX+m10K9hsghbQwG0amAdcxr6ogWa2s4fjX6yFCHpGVKRp/85xj1LI6WN5NtcGcDd1FlOEb0LVNIf0ELyVC2Rsel1M4AQvyN3vB57OkKVU+LM2FAiFl4BaY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792417919266567.6879093612289; Mon, 19 Oct 2026 06:51:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1454418.1668067 (Exim 4.92) (envelope-from ) id 1xInmD-00033O-LL; Mon, 19 Oct 2026 13:51:45 +0000 Received: by outflank-mailman (output) from mailman id 1454418.1668067; Mon, 19 Oct 2026 13:51:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInmD-00033F-Fx; Mon, 19 Oct 2026 13:51:45 +0000 Received: by outflank-mailman (input) for mailman id 1454418; Mon, 19 Oct 2026 13:51:44 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xInmC-0002l6-1Z for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 13:51:44 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xInmB-00EenQ-E5 for xen-devel@lists.xenproject.org; Mon, 19 Oct 2026 15:51:43 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ad62062-2eae-0a2a0a5409dd-0a2a4504afc2-46 for ; Mon, 19 Oct 2026 15:51:43 +0200 Received: from [209.85.219.43] (helo=mail-qv1-f43.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ad6206e-b57f-0a2a45040019-d155db2be519-3 for ; Mon, 19 Oct 2026 15:51:43 +0200 Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-91791ec1b83so18181286d6.1 for ; Mon, 19 Oct 2026 06:51:43 -0700 (PDT) Received: from toxicpanda.com ([153.61.196.247]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bcbb233d2sm98126806d6.32.2026.10.19.06.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 06:51:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=toxicpanda.com header.i="@toxicpanda.com" header.h="Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda.com; s=google; t=1792417902; x=1793022702; darn=lists.xenproject.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=Sz34K0Iw8+vtFq1WnWsYscgmIxwM3BOh5ri5FmDCCys=; b=a+xlEpAW2cmF5V4uu/O6jYKhOqXEf9N5lp4qPajrb1IBF4ow27Urvrv4AuR8ABDr+F +Pp9X/m6DGWFSqhRjTHOE+zCfZtayXYPMKtJOBE5cxR3h0BRdLkgDZczutT3T5blZDIp nvkPduUvPok0caxl8yAr2q2i98pSa5n2GFM+MgANPcCg/Hmkt8X+mLdt+n+a2sX+KZNY 9ofIvSpVC2fZeDXDyUClpqGnOCzjxu2C48grLuhXy/MBpvHJhyis6PPwvTb9wbFnjGKI a/7GfP2kfE3fyEmLheIEu+IsiwMVGlJh0LHbnh/wQcGwGP1E5Vy/pZZ3+DXdhttecZ9T iTzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792417902; x=1793022702; 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=Sz34K0Iw8+vtFq1WnWsYscgmIxwM3BOh5ri5FmDCCys=; b=GPiftnZyJwpNQdiP0j/5BusagI1vfJlLB500gXEooKSF/M44n7xF/+FxuxggQWl8tk wvdJG/NOfSjgBzy/vHa3F45nknDHAIudl+hTDivsy0i8I0zvuvlbkNmQNsuoW/flXs9D hqOxJ+/QgoV/VjRn69UZx6pOZKRw1E5s1l8sln4lTxRLBEf/0YAsN/zw0ZKYMgMt8Vsb WKHQdeNuVG2bqn/j7B+4YJLA7ERai6JECuNPwik+Db6L0Z67w7FbrKIl1RB1FNnRuPMD wB2vdhJQ3h6ukqqFWl8yU4cO5U6qdoi+ltlJq2eUkW7u8h1JpG6czlDW2V14TOtdU+5e r3pQ== X-Forwarded-Encrypted: i=1; AKwUvBw/LFE3B3r9db9k6km1HzrGCoZGayB+EotHzeMdGYWHFD8aoY0fdBR7DrfVkVMJi0aUzojwKCLpAiY=@lists.xenproject.org X-Gm-Message-State: AFq9FYJGEkiOSbSewNsvrQ74LK2MWaqUXAAdNVQgBnefun/KgWL5n1K3 XMtU8oLpWuin5+pM+6rrqe7dy7X2/CjXUk9TC6wmgesIVDzfwzfsVvRzZocbHd52mxk= X-Gm-Gg: AYBFou2kv6CPk22kKMKOETXyKCmsd4xLjJkBfxzjuWsv2Nli3ajH1H8JiiJQ8ZE0qX5 PJEUeAC7S5XkBj8BJYEUhG3gyU1Grs7pf9f47f1hoSUg29bSulzTME67i50zOzDx3/w5qZI2DAY oasK/AlIxlCZgcGqej4lQEGiEksLL6FMuPjeE0ZUOUSXRu0aP5cKnMYq62axJZE6Q3tSqhLdlk9 MRQb9WaCQfEUXKaS4ugbPmBfLrMt/cRoKIkhGX6nsZ+/GcM3GEzSSYhq8aaqikTsu16VROaXSvZ c8f0j+hftpHlK7fPJVm9SFGLi9Fn1ELO1sowx1SwNgt2N/gBH6/Zoo6/67TN9cDAPa14m92UYLS Kx0DONG57x0JMIQDBYRmLTFRftXE5PqiI5dcPoTFFrmjHC7MygS0127tvHFUmuYJR3EEnCUM+kj 80JZEIt7CIaYdXmWXDnsAdb7UDhKvV8CTTVVV8GD5Y1D4bW6W0Bj6j8QTaOTu0EmNa6ko4ICyMQ oeUeL3eHEe/jvY= X-Received: by 2002:a05:6214:29e2:b0:919:aba4:22e5 with SMTP id 6a1803df08f44-91bdf0aa97dmr130453586d6.18.1792417901621; Mon, 19 Oct 2026 06:51:41 -0700 (PDT) From: Josef Bacik Date: Mon, 19 Oct 2026 13:50:49 +0000 Subject: [PATCH net-next 15/15] net: update comments that still describe the skb BUG_ON()s MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261019-b4-skbuff-bug-on-followups-v1-15-41dbef50b9f7@toxicpanda.com> References: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> In-Reply-To: <20261019-b4-skbuff-bug-on-followups-v1-0-41dbef50b9f7@toxicpanda.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: Juergen Gross , Stefano Stabellini , Willem de Bruijn , Fernando Fernandez Mancera , Mina Almasry , David Laight , netdev@vger.kernel.org, xen-devel@lists.xenproject.org, Josef Bacik X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openssh-sha256; t=1792417849; l=2874; i=josef@toxicpanda.com; h=from:subject:message-id; bh=bVkQYPRV5cmZpoQgzwHTIPv/OeC1BGK6SJq4klyY24s=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgUBr36M/n0nWN0DNbnxwzIiCZez6MG JiruuNaSCI/zXsAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QGRgYXu9jiEH+o+P/X5XgMdqaIYdTCVgqXiXo+r1ZD/WK34+ps+wJnDs8hXR/0Hv/jB0pnLBW9g OlRZBGpF96AQ= X-Developer-Key: i=josef@toxicpanda.com; a=openssh; fpr=SHA256:C8kOX2QUJCMqnCX+KEeoqRAjLo9L+ELOSH2NSAJHqGA X-purgate-ID: tlsNG-ebf023/1792417903-50EDEB50-C2196414/0/0 X-purgate-type: clean X-purgate-size: 2876 X-ZohoMail-DKIM: pass (identity @toxicpanda.com) X-ZM-MESSAGEID: 1792417919729158501 The skbuff BUG_ON() conversions left a few comments behind: - bpf_skb_net_grow() says skb_segment() BUG()s on a frag_list with head_frag set at the downgraded MSS. It fails the segmentation and the packet is dropped, which is still why the skb gets linearized. - The GSO KUnit test says the non-uniform frag_list case would hit BUG_ON(i >=3D nfrags) with SG. That check now fails with -EINVAL. - The skb_to_sgvec() kernel-doc doesn't list the -EINVAL that __skb_to_sgvec() returns when @offset and @len run past the end of the skb. No functional change. Assisted-by: LLM Signed-off-by: Josef Bacik Acked-by: Mina Almasry Reviewed-by. It makes skb_copy_and_csum_bits() report failure, and the --- net/core/filter.c | 6 +++--- net/core/net_test.c | 4 ++-- net/core/skbuff.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 3ee1a093337e..f5bce0dc43fe 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3696,9 +3696,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 = off, u32 len_diff, shinfo->gso_segs =3D 0; =20 /* Due to header growth, MSS needs to be downgraded. - * There is a BUG_ON() when segmenting the frag_list with - * head_frag true, so linearize the skb after downgrading - * the MSS. + * Segmenting a frag_list with head_frag true at the new MSS + * fails and the packet gets dropped, so linearize the skb + * after downgrading the MSS. */ if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) { skb_decrease_gso_size(shinfo, len_diff); diff --git a/net/core/net_test.c b/net/core/net_test.c index 12a175268a01..d38dfeed163b 100644 --- a/net/core/net_test.c +++ b/net/core/net_test.c @@ -325,8 +325,8 @@ static void gso_test_func(struct kunit *test) if (tcase->id =3D=3D GSO_TEST_GSO_PARTIAL) features |=3D NETIF_F_GSO_PARTIAL; =20 - /* TODO: this should also work with SG, - * rather than hit BUG_ON(i >=3D nfrags) + /* TODO: this should also work with SG, rather than fail the + * i >=3D nfrags check in skb_segment() */ if (tcase->id =3D=3D GSO_TEST_FRAG_LIST_NON_UNIFORM) features &=3D ~NETIF_F_SG; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b6ada54ecc57..4822f96fc1c8 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5554,8 +5554,9 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlis= t *sg, int offset, int len, * * Fill the specified scatter-gather list with mappings/pointers into a * region of the buffer space attached to a socket buffer. Returns either - * the number of scatterlist items used, or -EMSGSIZE if the contents - * could not fit. + * the number of scatterlist items used, -EMSGSIZE if the contents + * could not fit, or -EINVAL if @offset and @len run past the end of + * the skb. */ int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, = int len) { --=20 2.55.0