mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitrii Iakunin <zeil@nebius.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: NB-Core Team <NB-CoreTeam@nebius.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Willem de Bruijn <willemb@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH] net: validate checksum start before software fallback on transmit
Date: Mon, 2 Nov 2026 14:06:34 +0000	[thread overview]
Message-ID: <20261102140633.42564-1-zeil@nebius.com> (raw)

Commit 6785011f8b16 ("ipv4: validate checksum_start before completing
checksum") added checks to prevent malformed checksum metadata from
causing software checksum completion to corrupt the IPv4 header.

skb_csum_hwoffload_help() can also complete checksums in software when
the available device features cannot satisfy the checksum request.
This path was not covered by the earlier validation.

For IPv4 packets, ensure that the fixed network header is accessible
and validate the checksum start before calling skb_checksum_help().
Return -EINVAL on failure so callers discard the packet rather than
complete the checksum using invalid metadata.

Leave hardware-offloaded checksums and SCTP CRC handling unchanged.

Fixes: 6785011f8b16 ("ipv4: validate checksum_start before completing checksum")
Signed-off-by: Dmitrii Iakunin <zeil@nebius.com>
---
 net/core/dev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 3ac700d37e59..77c40e914e5f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4130,6 +4130,11 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
 	}
 
 sw_checksum:
+	if (vlan_get_protocol(skb) == htons(ETH_P_IP)) {
+		if (!pskb_network_may_pull(skb, sizeof(struct iphdr)) ||
+		    ip_check_csum_start(skb))
+			return -EINVAL;
+	}
 	return skb_checksum_help(skb);
 }
 EXPORT_SYMBOL(skb_csum_hwoffload_help);
-- 
2.52.0


             reply	other threads:[~2026-11-02 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 14:06 Dmitrii Iakunin [this message]
2026-11-02 14:10 ` netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261102140633.42564-1-zeil@nebius.com \
    --to=zeil@nebius.com \
    --cc=NB-CoreTeam@nebius.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®