All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stephan Müller" <smueller@chronox.de>
To: Dmitry Vyukov <dvyukov@google.com>
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 16:26:18 +0200	[thread overview]
Message-ID: <2186798.qrgUIDAn9S@positron.chronox.de> (raw)
In-Reply-To: <CACT4Y+bRmYMt3WuVHE7e624KgRUTXQWa36wn-pr_gm2STq80bQ@mail.gmail.com>

Hi Dimitry,

This fix prevents the kernel from crashing when injecting the fault. 
Stack traces are yet shown but I guess that is expected every time
a fault is injected.

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)?

---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

  parent reply	other threads:[~2018-04-11 14:26 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 [this message]
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                             ` [PATCH] crypto: DRBG - guard uninstantion by lock Dmitry Vyukov

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=2186798.qrgUIDAn9S@positron.chronox.de \
    --to=smueller@chronox.de \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --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=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.