1 From ecebf55d27a11538ea84aee0be643dd953f830d5 Mon Sep 17 00:00:00 2001
2 From: Pan Bian <bianpan2016@163.com>
3 Date: Sun, 25 Nov 2018 08:58:02 +0800
4 Subject: ext2: fix potential use after free
6 From: Pan Bian <bianpan2016@163.com>
8 commit ecebf55d27a11538ea84aee0be643dd953f830d5 upstream.
10 The function ext2_xattr_set calls brelse(bh) to drop the reference count
11 of bh. After that, bh may be freed. However, following brelse(bh),
12 it reads bh->b_data via macro HDR(bh). This may result in a
13 use-after-free bug. This patch moves brelse(bh) after reading field.
15 CC: stable@vger.kernel.org
16 Signed-off-by: Pan Bian <bianpan2016@163.com>
17 Signed-off-by: Jan Kara <jack@suse.cz>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 fs/ext2/xattr.c | 2 +-
22 1 file changed, 1 insertion(+), 1 deletion(-)
26 @@ -609,9 +609,9 @@ skip_replace:
31 if (!(bh && header == HDR(bh)))
34 up_write(&EXT2_I(inode)->xattr_sem);