From: Yasuaki Torimaru <yasuakitorimaru@gmail.com>
To: netdev@vger.kernel.org
Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, stable@vger.kernel.org,
Yasuaki Torimaru <yasuakitorimaru@gmail.com>
Subject: [PATCH v2] xfrm: clear trailing padding in build_polexpire()
Date: Tue, 24 Mar 2026 10:37:42 +0900 [thread overview]
Message-ID: <20260324013742.939533-1-yasuakitorimaru@gmail.com> (raw)
In-Reply-To: <20260321210421.2504711-1-yasuakitorimaru@gmail.com>
build_expire() clears the trailing padding bytes of struct
xfrm_user_expire after setting the hard field via memset_after(),
but the analogous function build_polexpire() does not do this for
struct xfrm_user_polexpire.
The padding bytes after the __u8 hard field are left
uninitialized from the heap allocation, and are then sent to
userspace via netlink multicast to XFRMNLGRP_EXPIRE listeners,
leaking kernel heap memory contents.
Add the missing memset_after() call, matching build_expire().
Fixes: e3e5fc1698ae ("xfrm_user: fix info leak in build_expire()")
Cc: stable@vger.kernel.org
Signed-off-by: Yasuaki Torimaru <yasuakitorimaru@gmail.com>
---
Verified with pahole (struct xfrm_user_polexpire):
- x86_64: sizeof=176, padding=7
- i386: sizeof=168, padding=3
- aarch64: sizeof=176, padding=7
- armv7l (hf): sizeof=176, padding=7
net/xfrm/xfrm_user.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 403b5ecac2c5..ee31ef482be4 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -3948,6 +3948,8 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp,
return err;
}
upe->hard = !!hard;
+ /* clear the padding bytes */
+ memset_after(upe, 0, hard);
nlmsg_end(skb, nlh);
return 0;
--
2.50.1
next prev parent reply other threads:[~2026-03-24 1:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 21:04 [PATCH] xfrm: clear trailing padding in build_polexpire() Yasuaki Torimaru
2026-03-23 12:21 ` Steffen Klassert
2026-03-24 1:37 ` Yasuaki Torimaru [this message]
2026-03-25 17:15 ` [PATCH v2] " Simon Horman
2026-03-26 5:55 ` Yasuaki Torimaru
2026-03-26 5:57 ` Yasuaki Torimaru
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=20260324013742.939533-1-yasuakitorimaru@gmail.com \
--to=yasuakitorimaru@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=steffen.klassert@secunet.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