Skip to content

Commit ee3c9c7

Browse files
ebiggersherbertx
authored andcommitted
crypto: powerpc/p10-aes-gcm - simplify handling of linear associated data
p10_aes_gcm_crypt() is abusing the scatter_walk API to get the virtual address for the first source scatterlist element. But this code is only built for PPC64 which is a !HIGHMEM platform, and it can read past a page boundary from the address returned by scatterwalk_map() which means it already assumes the address is from the kernel's direct map. Thus, just use sg_virt() instead to get the same result in a simpler way. Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Danny Tsen <dtsen@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Naveen N Rao <naveen@kernel.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 1742b0a commit ee3c9c7

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

arch/powerpc/crypto/aes-gcm-p10-glue.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ static int p10_aes_gcm_crypt(struct aead_request *req, u8 *riv,
214214
struct gcm_ctx *gctx = PTR_ALIGN((void *)databuf, PPC_ALIGN);
215215
u8 hashbuf[sizeof(struct Hash_ctx) + PPC_ALIGN];
216216
struct Hash_ctx *hash = PTR_ALIGN((void *)hashbuf, PPC_ALIGN);
217-
struct scatter_walk assoc_sg_walk;
218217
struct skcipher_walk walk;
219218
u8 *assocmem = NULL;
220219
u8 *assoc;
@@ -234,8 +233,7 @@ static int p10_aes_gcm_crypt(struct aead_request *req, u8 *riv,
234233

235234
/* Linearize assoc, if not already linear */
236235
if (req->src->length >= assoclen && req->src->length) {
237-
scatterwalk_start(&assoc_sg_walk, req->src);
238-
assoc = scatterwalk_map(&assoc_sg_walk);
236+
assoc = sg_virt(req->src); /* ppc64 is !HIGHMEM */
239237
} else {
240238
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
241239
GFP_KERNEL : GFP_ATOMIC;
@@ -253,10 +251,7 @@ static int p10_aes_gcm_crypt(struct aead_request *req, u8 *riv,
253251
gcmp10_init(gctx, iv, (unsigned char *) &ctx->enc_key, hash, assoc, assoclen);
254252
vsx_end();
255253

256-
if (!assocmem)
257-
scatterwalk_unmap(assoc);
258-
else
259-
kfree(assocmem);
254+
kfree(assocmem);
260255

261256
if (enc)
262257
ret = skcipher_walk_aead_encrypt(&walk, req, false);

0 commit comments

Comments
 (0)