xfrm: validate protocol for XFRM_MODE_ROUTEOPTIMIZATION in verify_newsa_info()
Subsystems (3)
PATCH 1/1 xfrm: validate protocol for XFRM_MODE_ROUTEOPTIMIZATION in verify_newsa_info()
In verify_newsa_info(), XFRM_MODE_ROUTEOPTIMIZATION skips the protocol switch validation, allowing IPPROTO_ESP, IPPROTO_AH, or IPPROTO_COMP states to be created with XFRM_MODE_ROUTEOPTIMIZATION even though only IPPROTO_DSTOPTS and IPPROTO_ROUTING are valid IPv6 route optimization protocols. Enforce that XFRM_MODE_ROUTEOPTIMIZATION is only used with AF_INET6 and IPPROTO_DSTOPTS or IPPROTO_ROUTING.
---
net/xfrm/xfrm_user.c +3 -1
@@ -698,7 +705,9 @@ static int attach_auth_trunc(struct xfrm_algo_auth **algpp, u8 *props,NL_SET_ERR_MSG (extack,"Requested AUTH_TRUNC algorithm not found" );return -ENOSYS ; } -if (ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits) { +if (ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits || + (ualg->alg_trunc_len &7 ) || + (ualg->alg_trunc_len >0 && ualg->alg_trunc_len <32 )) {NL_SET_ERR_MSG (extack,"Invalid length requested for truncated ICV" );return -EINVAL ; }
Quoted 6 lines · Hui Peng
In
verify_newsa_info(),XFRM_MODE_ROUTEOPTIMIZATIONskips the protocol switch validation, allowingIPPROTO_ESP,IPPROTO_AH, orIPPROTO_COMPstates to be created withXFRM_MODE_ROUTEOPTIMIZATIONeven though onlyIPPROTO_DSTOPTSandIPPROTO_ROUTINGare valid IPv6 route optimization protocols. Enforce thatXFRM_MODE_ROUTEOPTIMIZATIONis only used withAF_INET6andIPPROTO_DSTOPTSorIPPROTO_ROUTING.
That's really not what this patch does...
Quoted 20 lines
Fixes 060f02a3bdd4 ("[XFRM] STATE: Introduce care-of address.")Assisted-by LLMSigned-off-by Hui Peng <[email protected]>---
net/xfrm/xfrm_user.c +3
-1@@ -698,7 +705,9 @@ static int attach_auth_trunc(struct xfrm_algo_auth **algpp, u8 *props,NL_SET_ERR_MSG (extack,"Requested AUTH_TRUNC algorithm not found" );return -ENOSYS ; } -if (ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits) { +if (ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits || + (ualg->alg_trunc_len &7 ) || + (ualg->alg_trunc_len >0 && ualg->alg_trunc_len <32 )) {NL_SET_ERR_MSG (extack,"Invalid length requested for truncated ICV" );return -EINVAL ; }
Signature · 1 line
Sabrina