aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRustam Kovhaev <[email protected]>2021-02-24 12:00:30 -0800
committerLinus Torvalds <[email protected]>2021-02-24 13:38:26 -0800
commit4dfe6bd94959222e18d512bdf15f6bf9edb9c27c (patch)
tree7039db856343196dec084935e66fcdca3a3aa6eb
parent6bbf29010fa90a7ff22ff14e2875b4e6dea8d576 (diff)
ntfs: check for valid standard information attribute
Mounting a corrupted filesystem with NTFS resulted in a kernel crash. We should check for valid STANDARD_INFORMATION attribute offset and length before trying to access it Link: https://lkml.kernel.org/r/[email protected] Link: https://syzkaller.appspot.com/bug?extid=c584225dabdea2f71969 Signed-off-by: Rustam Kovhaev <[email protected]> Reported-by: [email protected] Tested-by: [email protected] Acked-by: Anton Altaparmakov <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--fs/ntfs/inode.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 4435dbbc0b63..f5c058b3192c 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -629,6 +629,12 @@ static int ntfs_read_locked_inode(struct inode *vi)
}
a = ctx->attr;
/* Get the standard information attribute value. */
+ if ((u8 *)a + le16_to_cpu(a->data.resident.value_offset)
+ + le32_to_cpu(a->data.resident.value_length) >
+ (u8 *)ctx->mrec + vol->mft_record_size) {
+ ntfs_error(vi->i_sb, "Corrupt standard information attribute in inode.");
+ goto unm_err_out;
+ }
si = (STANDARD_INFORMATION*)((u8*)a +
le16_to_cpu(a->data.resident.value_offset));