hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8JUUC?from=project-issue
--------------------------------
In seq_read_dirty(), the parameter passed into simple_read_from_buffer() will cause problem on a 32-bit system; The simple_read_from_buffer() function has a lot of redundancy checks inside. Replaced it with copy_to_user() and add the return value check. And the update of the "copied" character count in seq_read_dirty() is also incorrect, fixed it.
Fixes: aeb96447becc ("fs/dirty_pages: dump the number of dirty pages for each inode") Signed-off-by: Zizhi Wo wozizhi@huawei.com --- fs/dirty_pages.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/dirty_pages.c b/fs/dirty_pages.c index 21e2251b6619..0eb818b599ba 100644 --- a/fs/dirty_pages.c +++ b/fs/dirty_pages.c @@ -217,12 +217,12 @@ static ssize_t seq_read_dirty( }
n = min(m->count - m->from, size); - err = simple_read_from_buffer(buf, n, - (loff_t *) &m->from, m->buf, m->count); - if (err < 0) { + n -= copy_to_user(buf, m->buf + m->from, n); + if (unlikely(!n)) { err = -EFAULT; goto done; } + m->from += n; copied += n; done: if (!copied)
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/3022 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/3022 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5...