diff options
author | Kees Cook <keescook@chromium.org> | 2018-12-03 16:39:01 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-13 08:52:24 +0100 |
commit | 6b6f6030afd29f3470a3cf2630d9afdc1ec8a241 (patch) | |
tree | 87c8d87b6f4deab2f20e84aad12da990f62a8994 /fs/pstore/ram.c | |
parent | 9c6ca33f12cd4b678676c0a9e152c0e2c4e2a277 (diff) | |
download | linux-stable-6b6f6030afd29f3470a3cf2630d9afdc1ec8a241.tar.gz linux-stable-6b6f6030afd29f3470a3cf2630d9afdc1ec8a241.tar.bz2 linux-stable-6b6f6030afd29f3470a3cf2630d9afdc1ec8a241.zip |
pstore/ram: Avoid NULL deref in ftrace merging failure path
[ Upstream commit 8665569e97dd52920713b95675409648986b5b0d ]
Given corruption in the ftrace records, it might be possible to allocate
tmp_prz without assigning prz to it, but still marking it as needing to
be freed, which would cause at least a NULL dereference.
smatch warnings:
fs/pstore/ram.c:340 ramoops_pstore_read() error: we previously assumed 'prz' could be null (see line 255)
https://lists.01.org/pipermail/kbuild-all/2018-December/055528.html
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 2fbea82bbb89 ("pstore: Merge per-CPU ftrace records into one")
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/pstore/ram.c')
-rw-r--r-- | fs/pstore/ram.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 015d74ee31a0..631ae057ab53 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -301,6 +301,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) GFP_KERNEL); if (!tmp_prz) return -ENOMEM; + prz = tmp_prz; free_prz = true; while (cxt->ftrace_read_cnt < cxt->max_ftrace_cnt) { @@ -323,7 +324,6 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) goto out; } record->id = 0; - prz = tmp_prz; } } |