From: "J. Bruce Fields" <bfields@fieldses.org>
To: "Myklebust, Trond" <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org, steved@redhat.com, nfsv4@ietf.org
Subject: Re: open() of device special files
Date: Tue, 16 Aug 2011 20:52:20 -0400 [thread overview]
Message-ID: <20110817005220.GA11879@fieldses.org> (raw)
In-Reply-To: <20110815212539.GA32181@fieldses.org>
> Confirmed the fix; I'll apply.
Actually that changed NFS4ERR_INVAL's to NFS4ERR_SYMLINK's all over the
place, which I'd rather not do; the following just affects the OPEN.
--b.
commit 618459ca1f7613f0dde4f09138e9acbe02690264
Author: J. Bruce Fields <bfields@redhat.com>
Date: Mon Aug 15 16:55:02 2011 -0400
nfsd4: return nfserr_symlink on v4 OPEN of non-regular file
Without this, an attempt to open a device special file without first
stat'ing it will fail.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 9bf0a66..d784ceb 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -168,6 +168,24 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
return status;
}
+static __be32 nfsd_check_obj_isreg(struct svc_fh *fh)
+{
+ umode_t mode = fh->fh_dentry->d_inode->i_mode;
+
+ if (S_ISREG(mode))
+ return nfs_ok;
+ if (S_ISDIR(mode))
+ return nfserr_isdir;
+ /*
+ * Using err_symlink as our catch-all case may look odd; but
+ * there's no other obvious error for this case in 4.0, and we
+ * happen to know that it will cause the linux v4 client to do
+ * the right thing on attempts to open something other than a
+ * regular file.
+ */
+ return nfserr_symlink;
+}
+
static __be32
do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
{
@@ -216,6 +234,9 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
status = nfsd_lookup(rqstp, current_fh,
open->op_fname.data, open->op_fname.len, &resfh);
fh_unlock(current_fh);
+ if (status)
+ goto out;
+ status = nfsd_check_obj_isreg(&resfh);
}
if (status)
goto out;
next prev parent reply other threads:[~2011-08-17 0:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-15 15:36 open() of device special files J. Bruce Fields
2011-08-15 16:03 ` Myklebust, Trond
2011-08-15 21:25 ` J. Bruce Fields
2011-08-15 22:23 ` J. Bruce Fields
2011-08-15 22:27 ` J. Bruce Fields
2011-08-16 5:04 ` Myklebust, Trond
2011-08-16 11:03 ` J. Bruce Fields
2011-08-16 5:03 ` Myklebust, Trond
2011-08-16 10:49 ` J. Bruce Fields
2011-08-15 22:28 ` J. Bruce Fields
2011-08-15 22:30 ` [PATCH 1/5] nfsd4: clean up S_IS -> NF4 file type mapping J. Bruce Fields
2011-08-15 22:30 ` [PATCH 2/5] nfsd4: return nfserr_symlink on v4 OPEN of non-regular file J. Bruce Fields
2011-08-15 22:30 ` [PATCH 3/5] nfsd4: fix incorrect comment in nfsd4_set_nfs4_acl J. Bruce Fields
2011-08-15 22:30 ` [PATCH 4/5] nfsd: open-code special directory-hardlink check J. Bruce Fields
2011-08-15 22:30 ` [PATCH 5/5] nfsd: clean up nfsd_mode_check() J. Bruce Fields
2011-08-15 22:48 ` J. Bruce Fields
2011-08-16 11:32 ` [nfsv4] open() of device special files Steve Dickson
2011-08-17 0:52 ` J. Bruce Fields [this message]
2011-08-17 1:40 ` J. Bruce Fields
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=20110817005220.GA11879@fieldses.org \
--to=bfields@fieldses.org \
--cc=Trond.Myklebust@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=nfsv4@ietf.org \
--cc=steved@redhat.com \
/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