Commit 499ecade authored by Yu Kuai's avatar Yu Kuai Committed by Zheng Zengkai
Browse files

mm/filemap: fix that first page is not mark accessed in filemap_read()

hulk inclusion
category: bugfix
bugzilla: 186896, https://gitee.com/src-openeuler/kernel/issues/I5FRAP


CVE: NA

--------------------------------

In filemap_read(), first page will not mark accessed if previous page
is equal to the current page:

if (iocb->ki_pos >> PAGE_SHIFT != ra->prev_pos >> PAGE_SHIFT))
	folio_mark_accessed(fbatch.folios[0]);

However, 'prev_pos' is set to 'ki_pos + copied' during last read, which
means 'prev_pos' can be equal to 'ki_pos' in this read, thus previous
page can be miscaculated.

Fix the problem by setting 'prev_pos' to the start offset of last read,
so that 'prev_pos >> PAGE_SHIFT' will be previous page as expected.

Fixes: 06c04442 ("mm/filemap.c: generic_file_buffered_read() now uses find_get_pages_contig")
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 2ed9d17c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment