summaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2018-11-25 08:58:02 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-05 19:42:40 +0100
commit4e443d70a1b3aabb4c73425ea0c650c790513e58 (patch)
tree7bd4786717005a4c39b201be131a94fca6f7f971 /fs/ext2
parent9c4a8f6f627c2ade859ef71c179052890658c844 (diff)
downloadlinux-stable-4e443d70a1b3aabb4c73425ea0c650c790513e58.tar.gz
linux-stable-4e443d70a1b3aabb4c73425ea0c650c790513e58.tar.bz2
linux-stable-4e443d70a1b3aabb4c73425ea0c650c790513e58.zip
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>
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/xattr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index fbdb8f171893..babef30d440b 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -609,9 +609,9 @@ skip_replace:
}
cleanup:
- brelse(bh);
if (!(bh && header == HDR(bh)))
kfree(header);
+ brelse(bh);
up_write(&EXT2_I(inode)->xattr_sem);
return error;