From patchwork Mon Jan 7 20:38:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3.5.y.z, extended, stable] Patch "nfs: don't zero out the rest of the page if we hit the EOF" has been added to staging queue X-Patchwork-Submitter: Herton Ronaldo Krzesinski X-Patchwork-Id: 210218 Message-Id: <1357591117-22304-1-git-send-email-herton.krzesinski@canonical.com> To: Jeff Layton Cc: kernel-team@lists.ubuntu.com, Trond Myklebust , Eryu Guan , Fred Isaman Date: Mon, 7 Jan 2013 18:38:37 -0200 From: Herton Ronaldo Krzesinski List-Id: Kernel team discussions This is a note to let you know that I have just added a patch titled nfs: don't zero out the rest of the page if we hit the EOF to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree which can be found at: http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 3.5.y.z tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Herton ------ >From 32a72be9dab96ff67937c977e21696a9075bb678 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 12 Dec 2012 11:38:44 -0500 Subject: [PATCH] nfs: don't zero out the rest of the page if we hit the EOF on a DIO READ commit 67fad106a219e083c91c79695bd1807dde1bf7b9 upstream. Eryu provided a test program that would segfault when attempting to read past the EOF on file that was opened O_DIRECT. The buffer given to the read() call was on the stack, and when he attempted to read past it it would scribble over the rest of the stack page. If we hit the end of the file on a DIO READ request, then we don't want to zero out the rest of the buffer. These aren't pagecache pages after all, and there's no guarantee that the buffers that were passed in represent entire pages. Cc: Fred Isaman Reported-by: Eryu Guan Signed-off-by: Jeff Layton Signed-off-by: Trond Myklebust Signed-off-by: Herton Ronaldo Krzesinski --- fs/nfs/direct.c | 8 -------- 1 file changed, 8 deletions(-) -- 1.7.9.5 diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 4825337..36b3958 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -247,14 +247,6 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) struct nfs_page *req = nfs_list_entry(hdr->pages.next); struct page *page = req->wb_page; - if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) { - if (bytes > hdr->good_bytes) - zero_user(page, 0, PAGE_SIZE); - else if (hdr->good_bytes - bytes < PAGE_SIZE) - zero_user_segment(page, - hdr->good_bytes & ~PAGE_MASK, - PAGE_SIZE); - } if (!PageCompound(page)) { if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { if (bytes < hdr->good_bytes)