]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto/krb5: Fix change to use SG miter to use offset
authorDavid Howells <dhowells@redhat.com>
Mon, 28 Apr 2025 10:22:06 +0000 (11:22 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Apr 2025 18:28:50 +0000 (11:28 -0700)
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.

Note: Nothing in linus/master uses the krb5lib, though the bug is there.
It is used by AF_RXRPC's RxGK implementation in -next, no need to backport.

Fixes: da6f9bf40ac2 ("crypto: krb5 - Use SG miter instead of doing it by hand")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Chuck Lever <chuck.lever@oracle.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://patch.msgid.link/3824017.1745835726@warthog.procyon.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
crypto/krb5/rfc3961_simplified.c

index 79180d28baa9fb7a450803267eb31745ae4feb72..e49cbdec7c404dca03eb11c22ea2e7d8b53b88f7 100644 (file)
@@ -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);