Skip to content

Commit 50c4787

Browse files
LLfamaalexandrovich
authored andcommitted
fs/ntfs3: Validate ff offset
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 <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent f28d086 commit 50c4787

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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)