• Kees Cook's avatar
    pstore/ram: Run without kernel crash dump region · 08ae2e88
    Kees Cook authored
    commit 8880fa32c557600f5f624084152668ed3c2ea51e upstream.
    
    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 89d328f637b9
    ("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: 's avatarYaro Slav <yaro330@gmail.com>
    Fixes: 89d328f637b9 ("pstore/ram: Correctly calculate usable PRZ bytes")
    Cc: stable@vger.kernel.org
    Signed-off-by: 's avatarKees Cook <keescook@chromium.org>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    08ae2e88
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
ftrace.c Loading commit data...
inode.c Loading commit data...
internal.h Loading commit data...
platform.c Loading commit data...
pmsg.c Loading commit data...
ram.c Loading commit data...
ram_core.c Loading commit data...