On Mon, Nov 28, 2016 at 02:39:09PM +0100, Stephan Mueller wrote: > > @@ -1737,15 +1750,22 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, > u8 *outbuf, u32 outlen) > { > struct scatterlist sg_in; > + bool virt_addr_valid = virt_addr_valid(outbuf); > + int ret = 0; > > sg_init_one(&sg_in, inbuf, inlen); > > while (outlen) { > u32 cryptlen = min_t(u32, inlen, outlen); > struct scatterlist sg_out; > - int ret; > > - sg_init_one(&sg_out, outbuf, cryptlen); > + /* If output buffer is not valid for SGL, use scratchpad */ > + if (virt_addr_valid) > + sg_init_one(&sg_out, outbuf, cryptlen); > + else { > + cryptlen = min_t(u32, cryptlen, DRBG_OUTSCRATCHLEN); > + sg_init_one(&sg_out, drbg->outscratchpad, cryptlen); > + } I'm sorry but this is just way too ugly. Please use the scratchpad unconditionally. Thanks, -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html