All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: "Stephan Müller" <smueller@chronox.de>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	Matthew Wilcox <willy@infradead.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	David Miller <davem@davemloft.net>,
	linux-crypto@vger.kernel.org, Eric Biggers <ebiggers3@gmail.com>,
	syzbot <syzbot+75397ee3df5c70164154@syzkaller.appspotmail.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] crypto: DRBG - guard uninstantion by lock
Date: Wed, 11 Apr 2018 19:09:53 +0200	[thread overview]
Message-ID: <CACT4Y+ZxumagMiZTFwzX2e_tdd4U862BzgzHVDsiOACbMXEh_A@mail.gmail.com> (raw)
In-Reply-To: <2186798.qrgUIDAn9S@positron.chronox.de>

On Wed, Apr 11, 2018 at 4:26 PM, Stephan Müller <smueller@chronox.de> wrote:
> Hi Dimitry,
>
> This fix prevents the kernel from crashing when injecting the fault.

Good!

> Stack traces are yet shown but I guess that is expected every time
> a fault is injected.

Yes, nothing to fix here.

> As to why KASAN did not notice this one, I am not sure. Maybe it is
> because I use two buffer pointers to point to (almost) the same memory
> (one that is aligned and one pointing to the complete buffer)?

After looking at the fix, I figured out what happened with KASAN.
Filed https://bugzilla.kernel.org/show_bug.cgi?id=199359. In short,
tricky interplay between kzfree, ksize and double-free detection.
If KASAN worked as intended it would give a nice "double-free in this
stack for object allocated in this stack and previously freed in this
stack", which would probably make debugging much simpler.


> ---8<---
>
> During freeing of the internal buffers used by the DRBG, set the pointer
> to NULL. It is possible that the context with the freed buffers is
> reused. In case of an error during initialization where the pointers
> do not yet point to allocated memory, the NULL value prevents a double
> free.
>
> Signed-off-by: Stephan Mueller <smueller@chronox.de>
> Reported-by: syzbot+75397ee3df5c70164154@syzkaller.appspotmail.com
> ---
>  crypto/drbg.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/crypto/drbg.c b/crypto/drbg.c
> index 4faa2781c964..466a112a4446 100644
> --- a/crypto/drbg.c
> +++ b/crypto/drbg.c
> @@ -1134,8 +1134,10 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
>         if (!drbg)
>                 return;
>         kzfree(drbg->Vbuf);
> +       drbg->Vbuf = NULL;
>         drbg->V = NULL;
>         kzfree(drbg->Cbuf);
> +       drbg->Cbuf = NULL;
>         drbg->C = NULL;
>         kzfree(drbg->scratchpadbuf);
>         drbg->scratchpadbuf = NULL;
> --
> 2.14.3
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/2186798.qrgUIDAn9S%40positron.chronox.de.
> For more options, visit https://groups.google.com/d/optout.

      parent reply	other threads:[~2018-04-11 17:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 13:24 WARNING in kmem_cache_free syzbot
2018-04-06 13:33 ` Dmitry Vyukov
2018-04-08  3:16   ` Use struct page for filename Matthew Wilcox
2018-04-08  4:42     ` Al Viro
2018-04-08  5:59   ` WARNING in kmem_cache_free Al Viro
2018-04-08  6:01   ` Matthew Wilcox
2018-04-08 10:26     ` Dmitry Vyukov
2018-04-08 11:18       ` Dmitry Vyukov
2018-04-08 15:31         ` Stephan Müller
2018-04-08 15:41           ` Dmitry Vyukov
2018-04-08 19:07             ` [PATCH] crypto: DRBG - guard uninstantion by lock Stephan Müller
2018-04-08 22:46               ` Theodore Y. Ts'o
2018-04-08 22:46                 ` Theodore Y. Ts'o
2018-04-09  5:40                 ` Stephan Mueller
2018-04-09  7:57                   ` Dmitry Vyukov
2018-04-10 15:23                     ` Dmitry Vyukov
2018-04-10 15:35                       ` Stephan Mueller
2018-04-11 12:29                         ` Dmitry Vyukov
2018-04-11 12:59                           ` Stephan Mueller
2018-04-11 14:26                           ` Stephan Müller
2018-04-11 14:31                             ` [PATCH] crypto: drbg - set freed buffers to NULL Stephan Müller
2018-04-11 17:29                               ` Eric Biggers
2018-04-11 17:29                                 ` Eric Biggers
2018-04-12  6:40                               ` Stephan Müller
2018-04-20 16:54                                 ` Herbert Xu
2018-04-20 16:54                                   ` Herbert Xu
2018-04-11 17:09                             ` Dmitry Vyukov [this message]

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=CACT4Y+ZxumagMiZTFwzX2e_tdd4U862BzgzHVDsiOACbMXEh_A@mail.gmail.com \
    --to=dvyukov@google.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers3@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=smueller@chronox.de \
    --cc=syzbot+75397ee3df5c70164154@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.