linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Stephan Mueller <smueller@chronox.de>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [PATCH RESEND] crypto: CTR DRBG - prevent invalid SG mappings
Date: Tue, 29 Nov 2016 16:05:57 +0800	[thread overview]
Message-ID: <20161129080556.GA5467@gondor.apana.org.au> (raw)
In-Reply-To: <1506389.b84a3PTDCG@positron.chronox.de>

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@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2016-11-29  8:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 11:31 bug in blkcipher_walk code Stephan Mueller
2016-11-25 12:43 ` Stephan Mueller
2016-11-26  8:54   ` [PATCH] crypto: CTR DRBG - prevent invalid SG mappings Stephan Mueller
2016-11-28 13:10     ` Herbert Xu
2016-11-28 13:39       ` [PATCH RESEND] " Stephan Mueller
2016-11-29  8:05         ` Herbert Xu [this message]
2016-11-29  8:45           ` [PATCH v2] " Stephan Mueller
2016-11-30 13:18             ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161129080556.GA5467@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=smueller@chronox.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).