Netdev List
 help / color / mirror / Atom feed
* [PATCH net] pfkey: fix kernel stack leak in pfkey_migrate()
@ 2026-11-20  5:28 Henry Martin
  2026-11-20  5:33 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Henry Martin @ 2026-11-20  5:28 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, horms
  Cc: netdev, ipsec, Henry Martin, stable

pfkey_migrate() declares struct xfrm_migrate m[XFRM_MAX_DEPTH] on the
stack without initializing it. For AF_INET endpoints
pfkey_sockaddr_extract() writes only the 4-byte a4 member, leaving
the remaining 12 bytes of each xfrm_address_t as stack residue.
xfrm_state_clone_and_setup() then memcpy()s the full 16-byte
new_daddr and new_saddr into the cloned xfrm_state, and a subsequent
XFRM_MSG_GETSA dump copies them back to userspace as-is. Each
migrated SA leaks 24 bytes of kernel stack, which can contain kernel
pointers. The same uninitialized bytes also feed the 16-byte memcmp()
in xfrm_migrate_check(), making duplicate detection unreliable.

Zero-initialize the array, as xfrm_do_migrate() in xfrm_user.c
already does.

This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: 08de61beab8a ("[PFKEYV2]: Extension for dynamic update of endpoint address(es)")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
 net/key/af_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/key/af_key.c b/net/key/af_key.c
index d215b33b7492..6d116862b20d 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2571,7 +2571,7 @@ static int pfkey_migrate(struct sock *sk, struct sk_buff *skb,
 	struct sadb_x_policy *pol;
 	struct sadb_x_ipsecrequest *rq;
 	struct xfrm_selector sel;
-	struct xfrm_migrate m[XFRM_MAX_DEPTH];
+	struct xfrm_migrate m[XFRM_MAX_DEPTH] = {};
 	struct xfrm_kmaddress k;
 	struct net *net = sock_net(sk);
 
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] pfkey: fix kernel stack leak in pfkey_migrate()
  2026-11-20  5:28 [PATCH net] pfkey: fix kernel stack leak in pfkey_migrate() Henry Martin
@ 2026-11-20  5:33 ` netdev-bot+sinfo
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-20  5:33 UTC (permalink / raw)
  To: Henry Martin
  Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, horms,
	netdev, ipsec, stable

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20  5:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  5:28 [PATCH net] pfkey: fix kernel stack leak in pfkey_migrate() Henry Martin
2026-11-20  5:33 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox