]> git.baikalelectronics.ru Git - kernel.git/commit
pstore/ram: Run without kernel crash dump region
authorKees Cook <keescook@chromium.org>
Fri, 31 May 2019 06:37:29 +0000 (23:37 -0700)
committerKees Cook <keescook@chromium.org>
Fri, 31 May 2019 08:19:06 +0000 (01:19 -0700)
commit01157a71379199d3afbb4316bf2b3d05c38e3d62
tree94b3238af77f6aba43ad030947ad6b81d4174bfe
parenta326e471ad46fde2079e75245057e5402e58a13f
pstore/ram: Run without kernel crash dump region

The ram pstore backend has always had the crash dumper frontend enabled
unconditionally. However, it was possible to effectively disable it
by setting a record_size=0. All the machinery would run (storing dumps
to the temporary crash buffer), but 0 bytes would ultimately get stored
due to there being no przs allocated for dumps. Commit fecff1b50acd
("pstore/ram: Correctly calculate usable PRZ bytes"), however, assumed
that there would always be at least one allocated dprz for calculating
the size of the temporary crash buffer. This was, of course, not the
case when record_size=0, and would lead to a NULL deref trying to find
the dprz buffer size:

BUG: unable to handle kernel NULL pointer dereference at (null)
...
IP: ramoops_probe+0x285/0x37e (fs/pstore/ram.c:808)

        cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size;

Instead, we need to only enable the frontends based on the success of the
prz initialization and only take the needed actions when those zones are
available. (This also fixes a possible error in detecting if the ftrace
frontend should be enabled.)

Reported-and-tested-by: Yaro Slav <yaro330@gmail.com>
Fixes: fecff1b50acd ("pstore/ram: Correctly calculate usable PRZ bytes")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
fs/pstore/platform.c
fs/pstore/ram.c