linux/fs/pstore
Norbert Manthey 5e9a2ce6d3 pstore: Fix double-free in pstore_mkfile() failure path
[ Upstream commit 4c6d80e114 ]

The pstore_mkfile() function is passed a pointer to a struct
pstore_record. On success it consumes this 'record' pointer and
references it from the created inode.

On failure, however, it may or may not free the record. There are even
two different code paths which return -ENOMEM -- one of which does and
the other doesn't free the record.

Make the behaviour deterministic by never consuming and freeing the
record when returning failure, allowing the caller to do the cleanup
consistently.

Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
Link: https://lore.kernel.org/r/1562331960-26198-1-git-send-email-nmanthey@amazon.de
Fixes: 83f70f0769 ("pstore: Do not duplicate record metadata")
Fixes: 1dfff7dd67 ("pstore: Pass record contents instead of copying")
Cc: stable@vger.kernel.org
[kees: also move "private" allocation location, rename inode cleanup label]
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-09-16 08:22:20 +02:00
..
ftrace.c pstore: Remove write_buf() callback 2017-03-07 14:01:02 -08:00
inode.c pstore: Fix double-free in pstore_mkfile() failure path 2019-09-16 08:22:20 +02:00
internal.h pstore: Centralize init/exit routines 2019-05-22 07:37:45 +02:00
Kconfig pstore: add zstd compression support 2018-08-03 18:12:18 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
platform.c pstore/ram: Run without kernel crash dump region 2019-06-11 12:20:52 +02:00
pmsg.c pstore: Create common record initializer 2017-05-31 10:13:44 -07:00
ram_core.c pstore/ram: Do not treat empty buffers as valid 2019-01-26 09:32:37 +01:00
ram.c pstore/ram: Run without kernel crash dump region 2019-06-11 12:20:52 +02:00