Skip to content

Commit cf67361

Browse files
Zihan Xigregkh
authored andcommitted
xfrm: fix xfrm_state_construct() auth-trunc leak
commit c12cbf5 upstream. attach_auth_trunc() can allocate x->aalg while leaving x->props.aalgo at zero when the selected auth algorithm has no sadb_alg_id. One real case is cmac(aes). xfrm_state_construct() then treats !x->props.aalgo as "no auth algorithm attached yet" and calls attach_auth(). That overwrites x->aalg and loses the first allocation. Any later failure or teardown only frees the replacement pointer. Check whether x->aalg is already attached instead of inferring that state from x->props.aalgo. Fixes: 4447bb3 ("xfrm: Store aalg in xfrm_state with a user specified truncation length") Cc: stable@vger.kernel.org Reported-by: Vega <vega@nebusec.ai> Assisted-by: Codex:gpt-5.4 Signed-off-by: Zihan Xi <zihanx@nebusec.ai> Signed-off-by: Ren Wei <enjou1224z@gmail.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6733ae7 commit cf67361

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/xfrm/xfrm_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
916916
if ((err = attach_auth_trunc(&x->aalg, &x->props.aalgo,
917917
attrs[XFRMA_ALG_AUTH_TRUNC], extack)))
918918
goto error;
919-
if (!x->props.aalgo) {
919+
if (!x->aalg) {
920920
if ((err = attach_auth(&x->aalg, &x->props.aalgo,
921921
attrs[XFRMA_ALG_AUTH], extack)))
922922
goto error;

0 commit comments

Comments
 (0)