]> git.baikalelectronics.ru Git - kernel.git/commit
sunrpc: fix xs_read_xdr_buf for partial pages receive
authorDan Aloni <dan@kernelim.com>
Sat, 5 Dec 2020 09:28:35 +0000 (11:28 +0200)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 14 Dec 2020 11:46:55 +0000 (06:46 -0500)
commit5deffcc9307ec0bc157dcec556b6c5d7e8c909c2
tree329787ea503dae81c144b82d0cb06c1415460d16
parente25365ce6da65704400b581561a493842cdda619
sunrpc: fix xs_read_xdr_buf for partial pages receive

When receiving pages data, return value 'ret' when positive includes
`buf->page_base`, so we should subtract that before it is used for
changing `offset` and comparing against `want`.

This was discovered on the very rare cases where the server returned a
chunk of bytes that when added to the already received amount of bytes
for the pages happened to match the current `recv.len`, for example
on this case:

     buf->page_base : 258356
     actually received from socket: 1740
     ret : 260096
     want : 260096

In this case neither of the two 'if ... goto out' trigger, and we
continue to tail parsing.

Worth to mention that the ensuing EMSGSIZE from the continued execution of
`xs_read_xdr_buf` may be observed by an application due to 4 superfluous
bytes being added to the pages data.

Fixes: ccd359b08deb ("SUNRPC: Simplify TCP receive code by switching to using iterators")
Signed-off-by: Dan Aloni <dan@kernelim.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
net/sunrpc/xprtsock.c