ext2: fix potential use after free
authorPan Bian <bianpan2016@163.com>
Sun, 25 Nov 2018 00:58:02 +0000 (08:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Dec 2018 18:32:11 +0000 (19:32 +0100)
commitffaaaf68be1e3c6f3a8ff5285e7b52543c1c2885
tree392bc69724bdd6b5baf2538e6e5481e3cf5406cc
parent1666cf8c492d7a9b8b83e26eb139961a4c137b80
ext2: fix potential use after free

commit ecebf55d27a11538ea84aee0be643dd953f830d5 upstream.

The function ext2_xattr_set calls brelse(bh) to drop the reference count
of bh. After that, bh may be freed. However, following brelse(bh),
it reads bh->b_data via macro HDR(bh). This may result in a
use-after-free bug. This patch moves brelse(bh) after reading field.

CC: stable@vger.kernel.org
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext2/xattr.c