All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Trond Myklebust <trondmy@hammerspace.com>
Cc: "trondmy@kernel.org" <trondmy@kernel.org>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 5/8] SUNRPC: Don't truncate tail in xdr_inline_pages()
Date: Mon, 23 Nov 2020 09:52:53 -0500	[thread overview]
Message-ID: <4C120984-5A7B-4245-9B04-8E44C4370BC1@oracle.com> (raw)
In-Reply-To: <614498c69c40421f8581fd8b25633e8668959581.camel@hammerspace.com>



> On Nov 22, 2020, at 11:29 PM, Trond Myklebust <trondmy@hammerspace.com> wrote:
> 
> On Sun, 2020-11-22 at 20:24 -0500, Chuck Lever wrote:
>> 
>> 
>>> On Nov 22, 2020, at 3:52 PM, trondmy@kernel.org wrote:
>>> 
>>> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>>> 
>>> True that if the length of the pages[] array is not 4-byte aligned,
>>> then
>>> we will need to store the padding in the tail, but there is no need
>>> to
>>> truncate the total buffer length here.
>> 
>> This description confuses me. The existing code reduces the length of
>> the tail, not the "total buffer length." And what the removed logic
>> is
>> doing is taking out the length of the XDR pad for the pages array
>> when
>> it is not expected to be used.
> 
> Why are we bothering to do that? There is nothing problematic with just
> ignoring this test and leaving the tail length as it is, nor is there
> anything to be gained by applying it.

You are correct that leaving the buffer a little long is not going
to harm normal operation. After all, we lived with a wildly over-
estimated slack length for years.

The purpose of this code path is to prepare the receive buffer with
the memory resources and expected length of the Reply. The series
of patches that introduced this particular change was all about
ensuring that the estimated length of the reply message was exact.

If the reply message size is overestimated, that moves the end-of-
message sentinel that is later set by xdr_init_decode(). We then
miss subtle problems like our fixed size estimates are incorrect
or a man-in-the-middle is extending the RPC message or the server
is malfunctioning.

<scratches chin>

After moving the ->pages pad into ->pages, I'm wondering if you
should revert 02ef04e432ba ("NFS: Account for XDR pad of buf->pages") --
the maxsz macros don't need to account for the XDR pad of ->pages
any more. Then the below hunk makes sense. The patch description
still doesn't, though ;-)

And then you should confirm that we are still getting the receive
buffer size estimate right for krb5i and krb5p.


>>> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
>>> ---
>>> net/sunrpc/xdr.c | 3 ---
>>> 1 file changed, 3 deletions(-)
>>> 
>>> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
>>> index 3ce0a5daa9eb..5a450055469f 100644
>>> --- a/net/sunrpc/xdr.c
>>> +++ b/net/sunrpc/xdr.c
>>> @@ -193,9 +193,6 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned
>>> int offset,
>>> 
>>>         tail->iov_base = buf + offset;
>>>         tail->iov_len = buflen - offset;
>>> -       if ((xdr->page_len & 3) == 0)
>>> -               tail->iov_len -= sizeof(__be32);
>>> -
>>>         xdr->buflen += len;
>>> }
>>> EXPORT_SYMBOL_GPL(xdr_inline_pages);
>>> -- 
>>> 2.28.0
>>> 
>> 
>> --
>> Chuck Lever
>> 
>> 
>> 
> 
> -- 
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> trond.myklebust@hammerspace.com

--
Chuck Lever




  reply	other threads:[~2020-11-23 15:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-22 20:52 [PATCH 0/8] Fix various issues in the SUNRPC xdr code trondmy
2020-11-22 20:52 ` [PATCH 1/8] NFSv4: Fix the alignment of page data in the getdeviceinfo reply trondmy
2020-11-22 20:52   ` [PATCH 2/8] SUNRPC: Fix up typo in xdr_init_decode() trondmy
2020-11-22 20:52     ` [PATCH 3/8] SUNRPC: Clean up helpers xdr_set_iov() and xdr_set_page_base() trondmy
2020-11-22 20:52       ` [PATCH 4/8] SUNRPC: Fix up xdr_read_pages() to take arbitrary object lengths trondmy
2020-11-22 20:52         ` [PATCH 5/8] SUNRPC: Don't truncate tail in xdr_inline_pages() trondmy
2020-11-22 20:52           ` [PATCH 6/8] SUNRPC: Fix up xdr_set_page() trondmy
2020-11-22 20:52             ` [PATCH 7/8] SUNRPC: Fix open coded xdr_stream_remaining() trondmy
2020-11-22 20:52               ` [PATCH 8/8] NFSv4: " trondmy
2020-11-23  1:24           ` [PATCH 5/8] SUNRPC: Don't truncate tail in xdr_inline_pages() Chuck Lever
2020-11-23  4:29             ` Trond Myklebust
2020-11-23 14:52               ` Chuck Lever [this message]
2020-11-23 15:37                 ` Trond Myklebust
2020-11-23 15:47                   ` Chuck Lever
2020-11-23 17:24           ` Anna Schumaker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C120984-5A7B-4245-9B04-8E44C4370BC1@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@hammerspace.com \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.