Skip to contentSkip to conversation

crypto/krb5: Fix change to use SG miter to use offset

PATCH Applied David Howells 3 participants 3 messages Apr 28, 2025 – Apr 29, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/krb5: Fix change to use SG miter to use offset

[Note: Nothing in linus/master uses the krb5lib, though the bug is there,
but it is used by AF_RXRPC's RxGK implementation in net-next, so can it go through the net-next tree rather than directly to Linus or through crypto?]

The recent patch to make the rfc3961 simplified code use sg_miter rather than manually walking the scatterlist to hash the contents of a buffer described by that scatterlist failed to take the starting offset into account.

This is indicated by the selftests reporting:

    krb5: Running aes128-cts-hmac-sha256-128 mic
    krb5: !!! TESTFAIL crypto/krb5/selftest.c:446
    krb5: MIC mismatch

Fix this by calling sg_miter_skip() before doing the loop to advance by the offset.

This only affects packet signing modes and not full encryption in RxGK because, for full encryption, the message digest is handled inside the authenc and krb5enc drivers.

Fixes da6f9bf40ac2 ("crypto: krb5 - Use SG miter instead of doing it by hand")
cc Herbert Xu <[email protected]>
cc "David S. Miller" <[email protected]>
cc Chuck Lever <[email protected]>
cc Eric Dumazet <[email protected]>
cc Jakub Kicinski <[email protected]>
cc Paolo Abeni <[email protected]>
cc Simon Horman <[email protected]>
---
 crypto/krb5/rfc3961_simplified.c |    1 +
 1 file changed, 1 insertion(+)
crypto/krb5/rfc3961_simplified.c +1 -0
index 79180d28baa9..e49cbdec7c40 100644
@@ -89,6 +89,7 @@ int crypto_shash_update_sg(struct shash_desc *desc, struct scatterlist *sg,
 
 	sg_miter_start(&miter, sg, sg_nents(sg),
 		       SG_MITER_FROM_SG | SG_MITER_LOCAL);
+	sg_miter_skip(&miter, offset);
 	for (i = 0; i < len; i += n) {
 		sg_miter_next(&miter);
 		n = min(miter.length, len - i);
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · David Howells

[Note: Nothing in linus/master uses the krb5lib, though the bug is there,
but it is used by AF_RXRPC's RxGK implementation in net-next, so can it go through the net-next tree rather than directly to Linus or through crypto?]

Sure I'm happy for this to go through net-next.

Quoted 32 lines

The recent patch to make the rfc3961 simplified code use sg_miter rather than manually walking the scatterlist to hash the contents of a buffer described by that scatterlist failed to take the starting offset into account.

This is indicated by the selftests reporting:

    krb5: Running aes128-cts-hmac-sha256-128 mic
    krb5: !!! TESTFAIL crypto/krb5/selftest.c:446
    krb5: MIC mismatch

Fix this by calling sg_miter_skip() before doing the loop to advance by the offset.

This only affects packet signing modes and not full encryption in RxGK because, for full encryption, the message digest is handled inside the authenc and krb5enc drivers.

Fixes da6f9bf40ac2 ("crypto: krb5 - Use SG miter instead of doing it by hand")
cc Herbert Xu <[email protected]>
cc "David S. Miller" <[email protected]>
cc Chuck Lever <[email protected]>
cc Eric Dumazet <[email protected]>
cc Jakub Kicinski <[email protected]>
cc Paolo Abeni <[email protected]>
cc Simon Horman <[email protected]>
Quoted 3 lines
---
 crypto/krb5/rfc3961_simplified.c |    1 +
 1 file changed, 1 insertion(+)

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
In reply to David Howells
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Mon, 28 Apr 2025 11:22:06 +0100 you wrote:

[Note: Nothing in linus/master uses the krb5lib, though the bug is there,
but it is used by AF_RXRPC's RxGK implementation in net-next, so can it go through the net-next tree rather than directly to Linus or through crypto?]

The recent patch to make the rfc3961 simplified code use sg_miter rather than manually walking the scatterlist to hash the contents of a buffer described by that scatterlist failed to take the starting offset into account.

[...]

Here is the summary with links:
- [net-next] crypto/krb5: Fix change to use SG miter to use offset

    https://git.kernel.org/netdev/net-next/c/eed848871c96

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html