From: "J. Bruce Fields" <bfields@fieldses.org>
To: Ingo Oeser <ioe-lkml@rameria.de>
Cc: NeilBrown <neilb@suse.de>,
nfs@lists.sourceforge.net, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@osdl.org>
Subject: Re: [NFS] Re: [PATCH 011 of 16] knfsd: svcrpc: WARN() instead of returning an error from svc_take_page
Date: Mon, 3 Apr 2006 22:26:13 -0400 [thread overview]
Message-ID: <20060404022613.GB6365@fieldses.org> (raw)
In-Reply-To: <200604040002.22544.ioe-lkml@rameria.de>
On Tue, Apr 04, 2006 at 12:02:21AM +0200, Ingo Oeser wrote:
> On Monday, 3. April 2006 07:19, you wrote:
> > diff ./include/linux/sunrpc/svc.h~current~ ./include/linux/sunrpc/svc.h
> > --- ./include/linux/sunrpc/svc.h~current~ 2006-04-03 15:12:15.000000000 +1000
> > +++ ./include/linux/sunrpc/svc.h 2006-04-03 15:12:15.000000000 +1000
> > @@ -197,15 +197,13 @@ svc_take_res_page(struct svc_rqst *rqstp
> > return rqstp->rq_respages[rqstp->rq_resused++];
> > }
> >
> > -static inline int svc_take_page(struct svc_rqst *rqstp)
> > +static inline void svc_take_page(struct svc_rqst *rqstp)
> > {
> > - if (rqstp->rq_arghi <= rqstp->rq_argused)
> > - return -ENOMEM;
> > + WARN_ON(rqstp->rq_arghi <= rqstp->rq_argused);
> > rqstp->rq_arghi--;
> > rqstp->rq_respages[rqstp->rq_resused] =
> > rqstp->rq_argpages[rqstp->rq_arghi];
> > rqstp->rq_resused++;
> > - return 0;
> > }
>
> What will prevent underflow of ->rq_arghi and overflow of ->rq_resused here?
>
> Before that change, this code would return without
> modifying both members here on error.
>
> Now this code makes the error worse with each call.
>
> Just ignore me, if this is ok :-)
No, you're right, apologies. The results could be worse than if we'd
just BUG()'d there.
So we should probably either just bite the bullet and make that a BUG(),
or add back the return. The latter option appended in the form of a
replacement patch....
--b.
svcrpc: WARN() instead of returning an error from svc_take_page
Every caller of svc_take_page ignores its return value and assumes it
succeeded. So just WARN() instead of returning an ignored error. This
would have saved some time debugging a recent nfsd4 problem.
If there are still failure cases here, then the result is probably that we
overwrite an earlier part of the reply while xdr-encoding.
While the corrupted reply is a nasty bug, it would be worse to panic here
and create the possibility of a remote DOS; hence WARN() instead of BUG().
Thanks to Ingo Oeser for noticing a bug in an earlier version of this
patch.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
include/linux/sunrpc/svc.h | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 50cab2a..5035643 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -197,15 +197,16 @@ svc_take_res_page(struct svc_rqst *rqstp
return rqstp->rq_respages[rqstp->rq_resused++];
}
-static inline int svc_take_page(struct svc_rqst *rqstp)
+static inline void svc_take_page(struct svc_rqst *rqstp)
{
- if (rqstp->rq_arghi <= rqstp->rq_argused)
- return -ENOMEM;
+ if (rqstp->rq_arghi <= rqstp->rq_argused) {
+ WARN_ON(1);
+ return;
+ }
rqstp->rq_arghi--;
rqstp->rq_respages[rqstp->rq_resused] =
rqstp->rq_argpages[rqstp->rq_arghi];
rqstp->rq_resused++;
- return 0;
}
static inline void svc_pushback_allpages(struct svc_rqst *rqstp)
next prev parent reply other threads:[~2006-04-04 2:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-03 5:18 [PATCH 000 of 16] knfsd: Introduction NeilBrown
2006-04-03 5:18 ` [PATCH 001 of 16] knfsd: locks: flag NFSv4-owned locks NeilBrown
2006-04-03 5:18 ` [PATCH 002 of 16] knfsd: nfsd4: Wrong error handling in nfs4acl NeilBrown
2006-04-03 5:18 ` [PATCH 003 of 16] knfsd: nfsd4: better nfs4acl errors NeilBrown
2006-04-03 5:18 ` [PATCH 004 of 16] knfsd: nfsd4: fix acl xattr length return NeilBrown
2006-04-03 5:18 ` [PATCH 005 of 16] knfsd: nfsd: oops exporting nonexistent directory NeilBrown
2006-04-03 5:18 ` [PATCH 006 of 16] knfsd: nfsd: nfsd_setuser doesn't really need to modify rqstp->rq_cred NeilBrown
2006-04-03 5:18 ` [PATCH 007 of 16] knfsd: nfsd4: remove nfsd_setuser from putrootfh NeilBrown
2006-04-03 5:18 ` [PATCH 008 of 16] knfsd: nfsd4: fix corruption of returned data when using 64k pages NeilBrown
2006-04-03 5:18 ` [PATCH 009 of 16] knfsd: nfsd4: fix corruption on readdir encoding with " NeilBrown
2006-04-03 5:18 ` [PATCH 010 of 16] knfsd: svcrpc: gss: don't call svc_take_page unnecessarily NeilBrown
2006-04-03 5:19 ` [PATCH 011 of 16] knfsd: svcrpc: WARN() instead of returning an error from svc_take_page NeilBrown
2006-04-03 22:02 ` Ingo Oeser
2006-04-04 2:26 ` J. Bruce Fields [this message]
2006-04-03 5:19 ` [PATCH 012 of 16] knfsd: nfsd4: fix laundromat shutdown race NeilBrown
2006-04-03 5:19 ` [PATCH 013 of 16] knfsd: nfsd4: nfsd4_probe_callback cleanup NeilBrown
2006-04-03 5:19 ` [PATCH 014 of 16] knfsd: nfsd4: add missing rpciod_down() NeilBrown
2006-04-03 5:19 ` [PATCH 015 of 16] knfsd: nfsd4: limit number of delegations handed out NeilBrown
2006-04-03 5:19 ` [PATCH 016 of 16] knfsd: nfsd4: grant delegations more frequently NeilBrown
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=20060404022613.GB6365@fieldses.org \
--to=bfields@fieldses.org \
--cc=akpm@osdl.org \
--cc=ioe-lkml@rameria.de \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=nfs@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®