mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
fs/ntfs3: Correct function is_rst_area_valid
[ Upstream commit 1b7dd28e14c4728ae1a815605ca33ffb4ce1b309 ] Reported-by: Robert Morris <rtm@csail.mit.edu> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0d2f804b9f
commit
32a3974b26
@@ -465,7 +465,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr)
|
|||||||
{
|
{
|
||||||
const struct RESTART_AREA *ra;
|
const struct RESTART_AREA *ra;
|
||||||
u16 cl, fl, ul;
|
u16 cl, fl, ul;
|
||||||
u32 off, l_size, file_dat_bits, file_size_round;
|
u32 off, l_size, seq_bits;
|
||||||
u16 ro = le16_to_cpu(rhdr->ra_off);
|
u16 ro = le16_to_cpu(rhdr->ra_off);
|
||||||
u32 sys_page = le32_to_cpu(rhdr->sys_page_size);
|
u32 sys_page = le32_to_cpu(rhdr->sys_page_size);
|
||||||
|
|
||||||
@@ -511,13 +511,15 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr)
|
|||||||
/* Make sure the sequence number bits match the log file size. */
|
/* Make sure the sequence number bits match the log file size. */
|
||||||
l_size = le64_to_cpu(ra->l_size);
|
l_size = le64_to_cpu(ra->l_size);
|
||||||
|
|
||||||
file_dat_bits = sizeof(u64) * 8 - le32_to_cpu(ra->seq_num_bits);
|
seq_bits = sizeof(u64) * 8 + 3;
|
||||||
file_size_round = 1u << (file_dat_bits + 3);
|
while (l_size) {
|
||||||
if (file_size_round != l_size &&
|
l_size >>= 1;
|
||||||
(file_size_round < l_size || (file_size_round / 2) > l_size)) {
|
seq_bits -= 1;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (seq_bits != ra->seq_num_bits)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* The log page data offset and record header length must be quad-aligned. */
|
/* The log page data offset and record header length must be quad-aligned. */
|
||||||
if (!IS_ALIGNED(le16_to_cpu(ra->data_off), 8) ||
|
if (!IS_ALIGNED(le16_to_cpu(ra->data_off), 8) ||
|
||||||
!IS_ALIGNED(le16_to_cpu(ra->rec_hdr_len), 8))
|
!IS_ALIGNED(le16_to_cpu(ra->rec_hdr_len), 8))
|
||||||
|
|||||||
Reference in New Issue
Block a user