]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:13:08 +0000 (09:13 +0200)
commit09afa9e360259e8c797c5778df73c9bb645a0725
tree429094c4ef017390f82b3f371852da8e5ce12004
parent61c3ed42bc2e55d600bc614e8d7de8a9c4f6a1cf
pstore: Fix double-free in pstore_mkfile() failure path

commit 4c6d80e1144bdf48cae6b602ae30d41f3e5c76a9 upstream.

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: 83f70f0769ddd ("pstore: Do not duplicate record metadata")
Fixes: 1dfff7dd67d1a ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/pstore/inode.c