Skip to content

Commit ac8db82

Browse files
committed
NFSD: Fix reads with a non-zero offset that don't end on a page boundary
This was found when virtual machines with nfs-mounted qcow2 disks failed to boot properly. Reported-by: Anders Blomdell <anders.blomdell@control.lth.se> Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2142132 Fixes: bfbfb61 ("nfsd_splice_actor(): handle compound pages") Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 5a01c80 commit ac8db82

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/nfsd/vfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,11 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
871871
struct svc_rqst *rqstp = sd->u.data;
872872
struct page *page = buf->page; // may be a compound one
873873
unsigned offset = buf->offset;
874+
struct page *last_page;
874875

875-
page += offset / PAGE_SIZE;
876-
for (int i = sd->len; i > 0; i -= PAGE_SIZE)
877-
svc_rqst_replace_page(rqstp, page++);
876+
last_page = page + (offset + sd->len - 1) / PAGE_SIZE;
877+
for (page += offset / PAGE_SIZE; page <= last_page; page++)
878+
svc_rqst_replace_page(rqstp, page);
878879
if (rqstp->rq_res.page_len == 0) // first call
879880
rqstp->rq_res.page_base = offset % PAGE_SIZE;
880881
rqstp->rq_res.page_len += sd->len;

0 commit comments

Comments
 (0)