From: Christoph Hellwig <hch@lst.de>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 1/6] nfsd: fix the check for confirmed openowner in nfs4_preprocess_stateid_op
Date: Tue, 28 Apr 2015 15:41:15 +0200 [thread overview]
Message-ID: <1430228480-7656-2-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1430228480-7656-1-git-send-email-hch@lst.de>
If we find a non-confirmed openowner we jump to exit the function, but do
not set an error value. Fix this by factoring out a helper to do the
check and properly set the error from nfsd4_validate_stateid.
Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/nfsd/nfs4state.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 9072964..66067a2 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4498,10 +4498,17 @@ static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_s
return nfserr_old_stateid;
}
+static __be32 nfsd4_check_openowner_confirmed(struct nfs4_ol_stateid *ols)
+{
+ if (ols->st_stateowner->so_is_open_owner &&
+ !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED))
+ return nfserr_bad_stateid;
+ return nfs_ok;
+}
+
static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
{
struct nfs4_stid *s;
- struct nfs4_ol_stateid *ols;
__be32 status = nfserr_bad_stateid;
if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
@@ -4531,13 +4538,7 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
break;
case NFS4_OPEN_STID:
case NFS4_LOCK_STID:
- ols = openlockstateid(s);
- if (ols->st_stateowner->so_is_open_owner
- && !(openowner(ols->st_stateowner)->oo_flags
- & NFS4_OO_CONFIRMED))
- status = nfserr_bad_stateid;
- else
- status = nfs_ok;
+ status = nfsd4_check_openowner_confirmed(openlockstateid(s));
break;
default:
printk("unknown stateid type %x\n", s->sc_type);
@@ -4629,8 +4630,8 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
status = nfs4_check_fh(current_fh, stp);
if (status)
goto out;
- if (stp->st_stateowner->so_is_open_owner
- && !(openowner(stp->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED))
+ status = nfsd4_check_openowner_confirmed(stp);
+ if (status)
goto out;
status = nfs4_check_openmode(stp, flags);
if (status)
--
1.9.1
next prev parent reply other threads:[~2015-04-28 13:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 13:41 refactor stateid checking and file allocation Christoph Hellwig
2015-04-28 13:41 ` Christoph Hellwig [this message]
2015-04-28 19:12 ` [PATCH 1/6] nfsd: fix the check for confirmed openowner in nfs4_preprocess_stateid_op J. Bruce Fields
2015-04-28 13:41 ` [PATCH 2/6] nfsd: remove nfsd_close Christoph Hellwig
2015-04-28 13:41 ` [PATCH 3/6] nfsd: refactor nfs4_preprocess_stateid_op Christoph Hellwig
2015-04-28 13:41 ` [PATCH 4/6] nfsd: clean up raparams handling Christoph Hellwig
2015-04-28 13:41 ` [PATCH 5/6] nfsd: take struct file setup fully into nfs4_preprocess_stateid_op Christoph Hellwig
2015-04-28 20:44 ` J. Bruce Fields
2015-04-28 20:50 ` J. Bruce Fields
2015-04-29 13:11 ` Christoph Hellwig
2015-04-29 14:16 ` J. Bruce Fields
2015-04-28 13:41 ` [PATCH 6/6] nfsd: drop the file argument to nfsd_write Christoph Hellwig
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=1430228480-7656-2-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).