Message ID | 20240202033334.1784409-1-lizhi.xu@windriver.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fs/ntfs3: fix oob in mi_enum_attr | expand |
diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 53629b1f65e9..a435df98c2b1 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -243,14 +243,14 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr) off += asize; } - asize = le32_to_cpu(attr->size); - /* Can we use the first field (attr->type). */ if (off + 8 > used) { static_assert(ALIGN(sizeof(enum ATTR_TYPE), 8) == 8); return NULL; } + asize = le32_to_cpu(attr->size); + if (attr->type == ATTR_END) { /* End of enumeration. */ return NULL;
When the value of attr->size is too large, it can cause overflow when taking the next attr. Here, off is used to determine the offset first to avoid problems. Reported-and-tested-by: syzbot+a426cde6dee8c2884b0b@syzkaller.appspotmail.com Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com> --- fs/ntfs3/record.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)