From: "J. Bruce Fields" <bfields@fieldses.org>
To: wengang wang <wen.gang.wang@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/1] nfsd(v2/v3): fix the failure of creation from HPUX client
Date: Fri, 9 Jan 2009 16:57:57 -0500 [thread overview]
Message-ID: <20090109215757.GF5466@fieldses.org> (raw)
In-Reply-To: <200812240537.mBO5blpr005502-eiegoW5zEh26xOVM2wN62FaTQe2KTcn/@public.gmane.org>
On Wed, Dec 24, 2008 at 01:36:16PM +0800, wengang wang wrote:
> sometimes HPUX nfs client sends a create request to linux nfs server(v2/v3).
> the dump of the request is like:
> obj_attributes
> mode: value follows
> set_it: value follows (1)
> mode: 00
> uid: no value
> set_it: no value (0)
> gid: value follows
> set_it: value follows (1)
> gid: 8030
> size: value follows
> set_it: value follows (1)
> size: 0
> atime: don't change
> set_it: don't change (0)
> mtime: don't change
> set_it: don't change (0)
>
> note that mode is 00(havs no rwx privilege even for the owner) and it requires
> to set size to 0.
>
> as current nfsd(v2/v3) implementation, the server does mainly 2 steps:
> 1) creates the file in mode specified by calling vfs_create().
> 2) sets attributes for the file by calling nfsd_setattr().
>
> at step 2), it finally calls file system specific setattr() function which may
> fails when checking permission because changing size needs WRITE privilege but
> it has no since mode is 000.
Thanks for the report.
> for this case, a new file created, we may simply ignore the request of setting
> size to 0. so that the WRITE privilege is not needed and finally success.
>
> the patch is based on 2.6.27.10.
It is a bit of a weird special case, but I can't see why not to do it.
Could you find some way to avoid adding those sane 10 lines twice? How
about just doing this inside nfsd_create_setattr(), which is called from
both functions?
--b.
>
> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
> --
> vfs.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
> diff -up ./fs/nfsd/vfs.c.orig ./fs/nfsd/vfs.c
> --- ./fs/nfsd/vfs.c.orig 2008-12-23 14:11:14.000000000 +0800
> +++ ./fs/nfsd/vfs.c 2008-12-23 14:54:16.000000000 +0800
> @@ -1268,6 +1268,16 @@ nfsd_create(struct svc_rqst *rqstp, stru
> switch (type) {
> case S_IFREG:
> host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
> + /* HPUX client sometimes creates a file in mode 000, and set
> + * size to 0. setting size to 0 may fail for some spcific
> + * file systems by the permission checking which requires
> + * WRITE privilege but the mode is 000.
> + * we ignore setting size to 0 for the creation, since it's
> + * just 0 after created.
> + * */
> + if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0))
> + iap->ia_valid &= ~ATTR_SIZE;
> +
> break;
> case S_IFDIR:
> host_err = vfs_mkdir(dirp, dchild, iap->ia_mode);
> @@ -1421,6 +1431,16 @@ nfsd_create_v3(struct svc_rqst *rqstp, s
> /* setattr will sync the child (or not) */
> }
>
> + /* HPUX client sometimes creates a file in mode 000, and set size to 0.
> + * setting size to 0 may fail for some spcific file systems by the
> + * permission checking which requires WRITE privilege but the mode is
> + * 000.
> + * we ignore setting size to 0 for the creation, since it's just 0
> + * after created.
> + * */
> + if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0))
> + iap->ia_valid &= ~ATTR_SIZE;
> +
> if (createmode == NFS3_CREATE_EXCLUSIVE) {
> /* Cram the verifier into atime/mtime */
> iap->ia_valid = ATTR_MTIME|ATTR_ATIME
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-01-09 21:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-24 5:36 [PATCH 1/1] nfsd(v2/v3): fix the failure of creation from HPUX client wengang wang
[not found] ` <200812240537.mBO5blpr005502-eiegoW5zEh26xOVM2wN62FaTQe2KTcn/@public.gmane.org>
2008-12-24 7:14 ` Suresh Jayaraman
2008-12-24 8:14 ` wengang wang
2008-12-24 9:17 ` Suresh Jayaraman
2008-12-24 9:43 ` wengang wang
2009-01-04 1:53 ` wengang wang
2009-01-04 21:38 ` J. Bruce Fields
2009-01-09 21:57 ` J. Bruce Fields [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-12-24 5:18 wwg
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=20090109215757.GF5466@fieldses.org \
--to=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=wen.gang.wang@oracle.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