From: Jean-Paul Sergent <jpsergent@gmail.com>
To: netdev@vger.kernel.org
Cc: Jean-Paul Sergent <jpsergent@gmail.com>,
stable@vger.kernel.org, Ilya Maximets <i.maximets@ovn.org>,
Sasha Levin <sashal@kernel.org>, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Sridhar Samudrala <sridhar.samudrala@intel.com>,
Kees Cook <kees@kernel.org>
Subject: [PATCH net v3] net: dst_metadata: fix memcmp overread in skb_metadata_dst_cmp
Date: Mon, 9 Nov 2026 00:24:10 -0800 [thread overview]
Message-ID: <20261109082410.206140-1-jpsergent@gmail.com> (raw)
Commit 3fcece12bc1b6 ("net: store port/representator id in
metadata_dst") dropped the options_len equality check when converting
skb_metadata_dst_cmp() to a type switch, so the memcmp length is taken
from skb a alone. When skb b carries fewer options than a, the
comparison reads past b's allocation.
Hit in practice with Cilium geneve GRO aggregation, comparing an skb
carrying 12 bytes of tunnel options against one carrying none:
memcmp: detected buffer overflow: 108 byte read of buffer size 96
WARNING: CPU: 0 PID: 15 at lib/string_helpers.c:1036 __fortify_report
__fortify_panic+0x9/0x10
skb_metadata_dst_cmp+0x11b/0x120
dev_gro_receive+0x303/0x620
gro_cell_poll+0x67/0xa0
Restore the check: unequal options_len means different metadata and no
aggregation; the memcmp only runs when both sides carry the same
options length.
Fixes: 3fcece12bc1b6 ("net: store port/representator id in metadata_dst")
Cc: stable@vger.kernel.org
Cc: Ilya Maximets <i.maximets@ovn.org>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Sridhar Samudrala <sridhar.samudrala@intel.com>
Cc: Kees Cook <kees@kernel.org>
Signed-off-by: Jean-Paul Sergent <jpsergent@gmail.com>
---
v3:
- Restore options_len equality check as a one-liner; drop two-stage
compare entirely (Ilya Maximets).
- Update Fixes: tag to 3fcece12bc1b instead of 69050f8d6d07
(Ilya Maximets, Sasha Levin).
- Add author Signed-off-by, drop Reported-by (Ilya Maximets).
- Drop redundant Closes: tag (Ilya Maximets).
- Add maintainer Cc list via get_maintainer.pl (Ilya Maximets).
- Remove superfluous in-code comments and trim commit log
(Ilya Maximets).
v2: https://lore.kernel.org/netdev/20261003005449.2675.3@jpsergent.gmail.com/
- Fix subject prefix to [PATCH net]; no code changes.
v1: https://lore.kernel.org/netdev/20261003005449.2675.2@jpsergent.gmail.com/
include/net/dst_metadata.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/net/dst_metadata.h b/include/net/dst_metadata.h
index f45d1e3163f0..02fffbb85099 100644
--- a/include/net/dst_metadata.h
+++ b/include/net/dst_metadata.h
@@ -116,6 +116,8 @@ static inline int skb_metadata_dst_cmp(const struct sk_buff *skb_a,
return memcmp(&a->u.port_info, &b->u.port_info,
sizeof(a->u.port_info));
case METADATA_IP_TUNNEL:
+ if (a->u.tun_info.options_len != b->u.tun_info.options_len)
+ return 1;
return memcmp(&a->u.tun_info, &b->u.tun_info,
sizeof(a->u.tun_info) +
a->u.tun_info.options_len);
--
2.56.0
reply other threads:[~2026-11-09 8:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261109082410.206140-1-jpsergent@gmail.com \
--to=jpsergent@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashal@kernel.org \
--cc=sridhar.samudrala@intel.com \
--cc=stable@vger.kernel.org \
/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