Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	"dcritch@redhat.com" <dcritch@redhat.com>,
	"d.lesca@solinos.it" <d.lesca@solinos.it>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v2 2/2] sunrpc: add bounds checking to svc_rqst_replace_page
Date: Fri, 17 Mar 2023 20:55:41 +0000	[thread overview]
Message-ID: <27346F71-367D-42DF-85AB-D168012F5C41@oracle.com> (raw)
In-Reply-To: <c78fff223129f289214ceada0d82f6952e0d3a82.camel@kernel.org>



> On Mar 17, 2023, at 2:59 PM, Jeff Layton <jlayton@kernel.org> wrote:
> 
> On Fri, 2023-03-17 at 18:08 +0000, Chuck Lever III wrote:
>> 
>>> On Mar 17, 2023, at 2:04 PM, Jeff Layton <jlayton@kernel.org> wrote:
>>> 
>>> On Fri, 2023-03-17 at 17:51 +0000, Chuck Lever III wrote:
>>>>> On Mar 17, 2023, at 1:13 PM, Jeff Layton <jlayton@kernel.org> wrote:
>>>>> 
>>>>> If rq_next_page ends up pointing outside the array, then we can
>>>>> corrupt
>>>>> memory when we go to change its value. Ensure that it hasn't strayed
>>>>> outside the array, and have svc_rqst_replace_page return -EIO
>>>>> without
>>>>> changing anything if it has.
>>>>> 
>>>>> Fix up nfsd_splice_actor (the only caller) to handle this case by
>>>>> either
>>>>> returning an error or a short splice when this happens.
>>>> 
>>>> IMO it's not worth the extra complexity to return a short splice.
>>>> This is a "should never happen" scenario in a hot I/O path. Let's
>>>> keep this code as simple as possible, and use unlikely() for the
>>>> error cases in both nfsd_splice_actor and svc_rqst_replace_page().
>>>> 
>>> 
>>> Are there any issues with just returning an error even though we have
>>> successfully spliced some of the data into the buffer? I guess the
>>> caller will just see an EIO or whatever instead of the short read in
>>> that case?
>> 
>> NFSv4 READ is probably going to truncate the XDR buffer. I'm not
>> sure NFSv3 is so clever, so you should test it.
> 
> Honestly, I don't have the cycles to do that sort of fault injection
> testing for this.

nfsd_splice_actor() has never returned an error, so IMO it is
necessary to confirm that when svc_rqst_replace_page() returns
an error, it doesn't create further problems. I don't see how
we can avoid some kind of simple fault injection while developing
the fix.

Tell you what, I can take it from here if you'd like.


> If you think handling it as a short read is overblown,
> then tell me what you would like see here.

It's not the short reads that bugs me, it's the additional
code in a hot path that is worrisome.

--
Chuck Lever



  reply	other threads:[~2023-03-17 20:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 17:13 [PATCH v2 1/2] nfsd: don't replace page in rq_pages if it's a continuation of last page Jeff Layton
2023-03-17 17:13 ` [PATCH v2 2/2] sunrpc: add bounds checking to svc_rqst_replace_page Jeff Layton
2023-03-17 17:51   ` Jeff Layton
2023-03-17 17:51   ` Chuck Lever III
2023-03-17 18:04     ` Jeff Layton
2023-03-17 18:08       ` Chuck Lever III
2023-03-17 18:59         ` Jeff Layton
2023-03-17 20:55           ` Chuck Lever III [this message]
2023-03-17 22:10             ` Jeff Layton
2023-03-17 18:32   ` Chuck Lever III
2023-03-17 18:52     ` Jeff Layton
2023-03-17 17:33 ` [PATCH v2 1/2] nfsd: don't replace page in rq_pages if it's a continuation of last page Chuck Lever III

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=27346F71-367D-42DF-85AB-D168012F5C41@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=d.lesca@solinos.it \
    --cc=dcritch@redhat.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox