Commit c13f003a authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Khalid Elmously

ext4: always verify the magic number in xattr blocks

BugLink: https://bugs.launchpad.net/bugs/1801893

commit 513f86d7 upstream.

If there an inode points to a block which is also some other type of
metadata block (such as a block allocation bitmap), the
buffer_verified flag can be set when it was validated as that other
metadata block type; however, it would make a really terrible external
attribute block.  The reason why we use the verified flag is to avoid
constantly reverifying the block.  However, it doesn't take much
overhead to make sure the magic number of the xattr block is correct,
and this will avoid potential crashes.

This addresses CVE-2018-10879.

https://bugzilla.kernel.org/show_bug.cgi?id=200001Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
[Backported to 4.4: adjust context]
Signed-off-by: default avatarDaniel Rosenberg <drosen@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 3b8d3053
...@@ -215,12 +215,12 @@ ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh) ...@@ -215,12 +215,12 @@ ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh)
{ {
int error; int error;
if (buffer_verified(bh))
return 0;
if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
BHDR(bh)->h_blocks != cpu_to_le32(1)) BHDR(bh)->h_blocks != cpu_to_le32(1))
return -EFSCORRUPTED; return -EFSCORRUPTED;
if (buffer_verified(bh))
return 0;
if (!ext4_xattr_block_csum_verify(inode, bh)) if (!ext4_xattr_block_csum_verify(inode, bh))
return -EFSBADCRC; return -EFSBADCRC;
error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size, error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment