Linux cryptographic layer development
 help / color / mirror / Atom feed
From: "Stephan Müller" <smueller@chronox.de>
To: Harsh Jain <harshjain.prof@gmail.com>
Cc: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: BUG: drbg: Added nodes from Stack Memory in link list
Date: Wed, 03 May 2017 15:11:05 +0200	[thread overview]
Message-ID: <11088841.2SosuHvOD7@tauon.chronox.de> (raw)
In-Reply-To: <CAFXBA=kDqH_32bX8XpUes9bdPP-3Gq5KRGBxu_FXKD3jwgzVdQ@mail.gmail.com>

Am Mittwoch, 3. Mai 2017, 14:47:24 CEST schrieb Harsh Jain:

Hi Harsh,

> Hi Stephen,
> 
> In drbg driver local variable of function are added as list nodes. one
> instance is given below.
> 
> 
> static inline int __init drbg_healthcheck_sanity(void)
> 
> 
> 
> ---
> ---
> 
> max_addtllen = drbg_max_addtl(drbg);
> max_request_bytes = drbg_max_request_bytes(drbg);
> drbg_string_fill(&addtl, buf, max_addtllen + 1);
> /* overflow addtllen with additonal info string */
> len = drbg_generate(drbg, buf, OUTBUFLEN, &addtl);
> 
> ===> Added "addtllist"  to the tail. which local variable.
> 
> 
> BUG_ON(0 < len);
> /* overflow max_bits */
> len = drbg_generate(drbg, buf, (max_request_bytes + 1), NULL);
> BUG_ON(0 < len);
> 
> /* overflow max addtllen with personalization string */
> ret = drbg_seed(drbg, &addtl, false);
> 
> ====> Added "seedlist" to the tail of same list. Previous
> node(addtllist) already invalid(Out of scope when function returns)
> 
> 
> BUG_ON(0 == ret);
> /* all tests passed */
> rc = 0;
> 
> 
> 
> Is't a BUG? or I missed something.

:-) You are right that in normal processing this is a bug. But this is a 
special function which shall perform a sanity checks for the maximum length 
enforcement. Thus, addtllist or seedlist should never be filled.

To be precise: The called code is expected to return an error before the 
variables are used due to the length checks. If these errors do not appear, 
something is wrong with the DRBG which causes the BUG_ON.

The following error conditions are triggered:

        /* 9.3.1 step 2 */
        len = -EINVAL;
        if (buflen > (drbg_max_request_bytes(drbg))) {
                pr_devel("DRBG: requested random numbers too large %u\n",
                         buflen);
                goto err;
        }

        /* 9.3.1 step 4 */
        if (addtl && addtl->len > (drbg_max_addtl(drbg))) {
                pr_devel("DRBG: additional information string too long %zu\n",
                         addtl->len);
                goto err;
        }


Ciao
Stephan

  reply	other threads:[~2017-05-03 13:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 12:47 BUG: drbg: Added nodes from Stack Memory in link list Harsh Jain
2017-05-03 13:11 ` Stephan Müller [this message]
2017-05-08  6:30   ` Harsh Jain
2017-05-08  8:30     ` Stephan Müller
2017-05-08  9:21       ` Harsh Jain

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=11088841.2SosuHvOD7@tauon.chronox.de \
    --to=smueller@chronox.de \
    --cc=harshjain.prof@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /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