Skip to content

Commit fe2c34b

Browse files
osandovbrauner
authored andcommitted
iov_iter: fix copy_page_to_iter_nofault()
The recent conversion to inline functions made two mistakes: 1. It tries to copy the full amount requested (bytes), not just what's available in the kmap'd page (n). 2. It's not applying the offset in the first page. Note that copy_page_to_iter_nofault() is only used by /proc/kcore. This was detected by drgn's test suite. Fixes: f198274 ("iov_iter: Convert iterate*() to inline funcs") Signed-off-by: Omar Sandoval <[email protected]> Link: https://lore.kernel.org/r/c1616e06b5248013cbbb1881bb4fef85a7a69ccb.1700257019.git.osandov@fb.com Acked-by: David Howells <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 8a924db commit fe2c34b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/iov_iter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ size_t copy_page_to_iter_nofault(struct page *page, unsigned offset, size_t byte
409409
void *kaddr = kmap_local_page(page);
410410
size_t n = min(bytes, (size_t)PAGE_SIZE - offset);
411411

412-
n = iterate_and_advance(i, bytes, kaddr,
412+
n = iterate_and_advance(i, n, kaddr + offset,
413413
copy_to_user_iter_nofault,
414414
memcpy_to_iter);
415415
kunmap_local(kaddr);

0 commit comments

Comments
 (0)