* [PATCH] xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc()
@ 2026-09-19 21:06 Hui Peng
2026-09-21 15:34 ` Sabrina Dubroca
0 siblings, 1 reply; 3+ messages in thread
From: Hui Peng @ 2026-09-19 21:06 UTC (permalink / raw)
To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni
Cc: horms, netdev, linux-kernel
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`.
Fixes: 4447bb33f094 ("xfrm: Store aalg in xfrm_state with a user specified truncation length")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
net/xfrm/xfrm_user.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index a2587c7e796b..d56a0095113b 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -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;
}
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc()
2026-09-19 21:06 [PATCH] xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc() Hui Peng
@ 2026-09-21 15:34 ` Sabrina Dubroca
2026-09-21 22:06 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Sabrina Dubroca @ 2026-09-21 15:34 UTC (permalink / raw)
To: Hui Peng
Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, horms,
netdev, linux-kernel
I'm really confused here.
2026-09-19, 21:06:23 +0000, Hui Peng wrote:
> 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
Did your LLM make this up? My kernel sources don't have any of this.
> `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
and what problem does that pose exactly, for each of those cases?
--
Sabrina
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc()
2026-09-21 15:34 ` Sabrina Dubroca
@ 2026-09-21 22:06 ` Krzysztof Kozlowski
0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2026-09-21 22:06 UTC (permalink / raw)
To: Sabrina Dubroca, Hui Peng
Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, horms,
netdev, linux-kernel
On 21/09/2026 17:34, Sabrina Dubroca wrote:
> I'm really confused here.
>
> 2026-09-19, 21:06:23 +0000, Hui Peng wrote:
>> 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
>
> Did 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-21 22:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 21:06 [PATCH] xfrm: reject sub-32-bit or unaligned alg_trunc_len in attach_auth_trunc() Hui Peng
2026-09-21 15:34 ` Sabrina Dubroca
2026-09-21 22:06 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®