xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc()
Subsystems (3)
PATCH 1/1 xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc()
In attach_auth_trunc(), userspace supplies ualg->alg_trunc_len (in bits) via XFRMA_ALG_AUTH_TRUNC, and attach_auth_trunc() only checks that ualg->alg_trunc_len <= algo->uinfo.auth.icv_fullbits.
However, ESP and AH convert alg_trunc_len to bytes via esp_authsize = ALIGN(x->aalg->alg_trunc_len, 8) >> 3 or ah_authsize = x->aalg->alg_trunc_len >> 3, and pass authsize to crypto_aead_setauthsize() or ah_init_state(). If alg_trunc_len is not a multiple of 8 bits (or is between 1 and 31 bits), integer division by 8 truncates the requested bit length (for example, alg_trunc_len == 7 yields a 0-byte ICV in AH, or alg_trunc_len not divisible by 8 mismatches the ICV byte length between AH and ESP).
Reject alg_trunc_len values that are not a multiple of 8 bits (ualg->alg_trunc_len & 7) or non-zero values smaller than 32 bits (ualg->alg_trunc_len > 0 && ualg->alg_trunc_len < 32) with -EINVAL.
--- net/xfrm/xfrm_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +3 -1
@@ -698,7 +698,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
2.55.0.1082.g2b9226bbc0-goog
I'm really confused here.
Quoted 7 lines · Hui Peng
In
attach_auth_trunc(), userspace suppliesualg->alg_trunc_len(in bits) viaXFRMA_ALG_AUTH_TRUNC, andattach_auth_trunc()only checks thatualg->alg_trunc_len <= algo->uinfo.auth.icv_fullbits.However, ESP and AH convert
alg_trunc_lento bytes viaesp_authsize = ALIGN(x->aalg->alg_trunc_len, 8) >> 3orah_authsize = x->aalg->alg_trunc_len >> 3, and passauthsizeto
Did your LLM make this up? My kernel sources don't have any of this.
Quoted 4 lines
crypto_aead_setauthsize()orah_init_state(). Ifalg_trunc_lenis not a multiple of 8 bits (or is between 1 and 31 bits), integer division by 8 truncates the requested bit length (for example,alg_trunc_len == 7yields a 0-byte ICV in AH, oralg_trunc_lennot divisible by 8
and what problem does that pose exactly, for each of those cases?
Signature · 1 line
Sabrina
Quoted 7 lines · Sabrina Dubroca
I'm really confused here.
Quoted 4 lines · Hui Peng
In
attach_auth_trunc(), userspace suppliesualg->alg_trunc_len(in bits) viaXFRMA_ALG_AUTH_TRUNC, andattach_auth_trunc()only checks thatualg->alg_trunc_len <= algo->uinfo.auth.icv_fullbits.
Quoted 6 lines
Quoted 3 lines
However, ESP and AH convert
alg_trunc_lento bytes viaesp_authsize = ALIGN(x->aalg->alg_trunc_len, 8) >> 3orah_authsize = x->aalg->alg_trunc_len >> 3, and passauthsizetoDid your LLM make this up? My kernel sources don't have any of this.
Don't waste your time. This is AI slop agent posting (one of 500 more of postings where agent does not care about replies).
Best regards,
Krzysztof