From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A53723EAAD for ; Mon, 13 Apr 2026 22:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776118338; cv=none; b=haKFXPM7GtXO09hchff81UTqd6jPleggDV3vB1TXDki/9TKlT+ds7a4Vu7mCfnma1H6p8eUfkgAPSqjq3UedHOCE1Txj3b6DRzg5v2jMqKQacXCXXX5AbZ5QtFclnTPLJ0u8nSba9kM6SsXACPF6FGlHEBYg9bRHKCx/Xrfo/ug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776118338; c=relaxed/simple; bh=i83J6RHjScHiuGpWIBrdFTYkPLZJfWNhwvkmhebaYbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hVV4b0pJRU4RpTEQKSKzRySX1umJbasnrES6bR8+oj5GVzQ/XPrXqdtdA9vQs6aTHPWQkgVxJZRz17MP8+a8fVWigX6y/DGwgMUqRNQM0cU7V0fAEe1anR6kEstDeQSdfAI0ghVBMr8XSkrBIlc1Bpzyc8aESrUL7F6cciAlX8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Oxe2D+39; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Oxe2D+39" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F55C2BCAF; Mon, 13 Apr 2026 22:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776118338; bh=i83J6RHjScHiuGpWIBrdFTYkPLZJfWNhwvkmhebaYbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oxe2D+39jzwdnBFWS7a7Q6EDgmQ23l+slpXVI0VvJ4sbKUvidLpTLIMjKulWOH990 aypZKW7e+MXGn7jn5AZO0xxZRtD3oxGgAWWPfIKHm/1wLoLzeAxvwaNoQLWclar1VI /IL2RPfj5sA9CBOgTrouDba+/RPoIQei9ed6cokgh2jg3CbG5bBmk8U7bVzLvMps3B PjMk/zLMKQ29ZAmKxZE5OAPeRLDZBLwIoKoOtPGGgxoxUNXUAXHHLcFdYqThI6yzym 9FNMcfwar5hpe4nsfnpNCuHvyNp5F8ekZeNv0Ci0/M4DPv9KJKkwrC/cUuM8SeajkS WyHR5PGw6ewAA== From: Sasha Levin To: stable@vger.kernel.org Cc: Yasuaki Torimaru , Simon Horman , Breno Leitao , Steffen Klassert , Sasha Levin Subject: [PATCH 5.10.y] xfrm: clear trailing padding in build_polexpire() Date: Mon, 13 Apr 2026 18:12:15 -0400 Message-ID: <20260413221215.3744762-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026041332-delivery-deplete-1461@gregkh> References: <2026041332-delivery-deplete-1461@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yasuaki Torimaru [ Upstream commit 71a98248c63c535eaa4d4c22f099b68d902006d0 ] 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: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Yasuaki Torimaru Reviewed-by: Simon Horman Reviewed-by: Breno Leitao Signed-off-by: Steffen Klassert [ replaced `memset_after()` macro with equivalent manual `memset()` call ] Signed-off-by: Sasha Levin --- 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 480da22b7ef85..03ebea3485234 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -3290,6 +3290,8 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, return err; } upe->hard = !!hard; + /* clear the padding bytes */ + memset(&upe->hard + 1, 0, sizeof(*upe) - offsetofend(typeof(*upe), hard)); nlmsg_end(skb, nlh); return 0; -- 2.53.0