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)