Skip to content

Commit 82c94e6

Browse files
LLfamgregkh
authored andcommitted
fs/ntfs3: Validate ff offset
commit 50c4787 upstream. This adds sanity checks for ff offset. There is a check on rt->first_free at first, but walking through by ff without any check. If the second ff is a large offset. We may encounter an out-of-bound read. Signed-off-by: lei lu <llfamsec@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c114d2b commit 82c94e6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/ntfs3/fslog.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,8 @@ static bool check_rstbl(const struct RESTART_TABLE *rt, size_t bytes)
724724

725725
if (!rsize || rsize > bytes ||
726726
rsize + sizeof(struct RESTART_TABLE) > bytes || bytes < ts ||
727-
le16_to_cpu(rt->total) > ne || ff > ts || lf > ts ||
727+
le16_to_cpu(rt->total) > ne ||
728+
ff > ts - sizeof(__le32) || lf > ts - sizeof(__le32) ||
728729
(ff && ff < sizeof(struct RESTART_TABLE)) ||
729730
(lf && lf < sizeof(struct RESTART_TABLE))) {
730731
return false;
@@ -754,6 +755,9 @@ static bool check_rstbl(const struct RESTART_TABLE *rt, size_t bytes)
754755
return false;
755756

756757
off = le32_to_cpu(*(__le32 *)Add2Ptr(rt, off));
758+
759+
if (off > ts - sizeof(__le32))
760+
return false;
757761
}
758762

759763
return true;

0 commit comments

Comments
 (0)