aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2014-12-22 16:14:51 -0500
committerJ. Bruce Fields <bfields@redhat.com>2015-01-07 14:03:58 -0500
commit49a068f82a1d30eb585d7804b05948376be6cf9a (patch)
tree670d3bc2de3e9faec18f6fbc36f0a997f99a0992 /net
parent94ae1db226a5bcbb48372d81161f084c9e283fd8 (diff)
rpc: fix xdr_truncate_encode to handle buffer ending on page boundary
A struct xdr_stream at a page boundary might point to the end of one page or the beginning of the next, but xdr_truncate_encode isn't prepared to handle the former. This can cause corruption of NFSv4 READDIR replies in the case that a readdir entry that would have exceeded the client's dircount/maxcount limit would have ended exactly on a 4k page boundary. You're more likely to hit this case on large directories. Other xdr_truncate_encode callers are probably also affected. Reported-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com> Tested-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com> Fixes: 3e19ce762b53 "rpc: xdr_truncate_encode" Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/xdr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 1cb61242e55e..4439ac4c1b53 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -606,7 +606,7 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len)
606 struct kvec *head = buf->head; 606 struct kvec *head = buf->head;
607 struct kvec *tail = buf->tail; 607 struct kvec *tail = buf->tail;
608 int fraglen; 608 int fraglen;
609 int new, old; 609 int new;
610 610
611 if (len > buf->len) { 611 if (len > buf->len) {
612 WARN_ON_ONCE(1); 612 WARN_ON_ONCE(1);
@@ -629,8 +629,8 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len)
629 buf->len -= fraglen; 629 buf->len -= fraglen;
630 630
631 new = buf->page_base + buf->page_len; 631 new = buf->page_base + buf->page_len;
632 old = new + fraglen; 632
633 xdr->page_ptr -= (old >> PAGE_SHIFT) - (new >> PAGE_SHIFT); 633 xdr->page_ptr = buf->pages + (new >> PAGE_SHIFT);
634 634
635 if (buf->page_len) { 635 if (buf->page_len) {
636 xdr->p = page_address(*xdr->page_ptr); 636 xdr->p = page_address(*xdr->page_ptr);