]> git.baikalelectronics.ru Git - kernel.git/commit
pstore: Fix double-free in pstore_mkfile() failure path
authorNorbert Manthey <nmanthey@amazon.de>
Fri, 5 Jul 2019 13:06:00 +0000 (15:06 +0200)
committerKees Cook <keescook@chromium.org>
Tue, 9 Jul 2019 04:04:42 +0000 (21:04 -0700)
commitebabdaab2a0dfb33f3f96ba8605d6f4ef8c7f0a6
tree5bfffd85fa86428abcd5d529f5f38f79a0c43dfd
parentaf92dd257c9cc184d3819afe8bf422217f5e41b4
pstore: Fix double-free in pstore_mkfile() failure path

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: 31076e2647acc ("pstore: Do not duplicate record metadata")
Fixes: c6c6387e94c38 ("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>
fs/pstore/inode.c