please ignore the email sent from [email protected] and reply to this post
if you will.
thanks.
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.
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.
Signed-off-by: Wengang Wang <[email protected]>
--
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
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.
What's the Create Mode in this case? EXCLUSIVE or UNCHECKED?
What's the error the server is returning without this patch - ERR_NOTSUPP?
I tested this on 2.6.27.7 with a small program which does this:
fd = open("file", O_CREAT, 0000);
The file creation succeeded with file size set to 0 and the subsequent
chmod too.
May be this could break EXCLUSIVE create mode semantics?
> the patch is based on 2.6.27.10.
>
> Signed-off-by: Wengang Wang <[email protected]>
> --
> 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
--
Suresh Jayaraman
Suresh Jayaraman wrote:
> 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.
>>
>
>
> What's the Create Mode in this case? EXCLUSIVE or UNCHECKED?
>
it's UNCHECKED.
> What's the error the server is returning without this patch - ERR_NOTSUPP?
>
>
permission deny, that is NFS3ERR_ACCES.
> I tested this on 2.6.27.7 with a small program which does this:
> fd = open("file", O_CREAT, 0000);
>
> The file creation succeeded with file size set to 0 and the subsequent
> chmod too.
>
>
tcpdump available for your test?
just after the creation, is the file mode 0000?
> May be this could break EXCLUSIVE create mode semantics?
>
>
>
In my case, it's UNCHECKED.
>> the patch is based on 2.6.27.10.
>>
>> Signed-off-by: Wengang Wang <[email protected]>
>> --
>> 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
>>
>
>
wengang wang wrote:
> Suresh Jayaraman wrote:
>> 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.
>>>
>>
>>
>> What's the Create Mode in this case? EXCLUSIVE or UNCHECKED?
>>
> it's UNCHECKED.
>> What's the error the server is returning without this patch -
>> ERR_NOTSUPP?
>>
>>
> permission deny, that is NFS3ERR_ACCES.
>> I tested this on 2.6.27.7 with a small program which does this:
>> fd = open("file", O_CREAT, 0000);
>>
>> The file creation succeeded with file size set to 0 and the subsequent
>> chmod too.
>>
>>
> tcpdump available for your test?
> just after the creation, is the file mode 0000?
Here are the relevant packets (both server and client are running 2.6.27.7)
<snip>
V3 LOOKUP Call (Reply In 153), DH:0x83dc449c/myfile
Frame 152 (186 bytes on wire, 186 bytes captured)
Ethernet II, Src: Foxconn_ca:9d:29 (00:15:58:ca:9d:29), Dst:
HewlettP_06:50:f9 (00:14:c2:06:50:f9)
Internet Protocol, Src: 164.99.138.53 (164.99.138.53), Dst:
164.99.138.52 (164.99.138.52)
Transmission Control Protocol, Src Port: 882 (882), Dst Port: nfs
(2049), Seq: 1, Ack: 1, Len: 120
Remote Procedure Call, Type:Call XID:0x3eb00345
Network File System, LOOKUP Call DH:0x83dc449c/myfile
[Program Version: 3]
[V3 Procedure: LOOKUP (3)]
what
dir
Name: myfile
V3 LOOKUP Reply (Call In 152) Error:NFS3ERR_NOENT
Frame 153 (186 bytes on wire, 186 bytes captured)
Ethernet II, Src: HewlettP_06:50:f9 (00:14:c2:06:50:f9), Dst:
Foxconn_ca:9d:29 (00:15:58:ca:9d:29)
Internet Protocol, Src: 164.99.138.52 (164.99.138.52), Dst:
164.99.138.53 (164.99.138.53)
Transmission Control Protocol, Src Port: nfs (2049), Dst Port: 882
(882), Seq: 1, Ack: 121, Len: 120
Remote Procedure Call, Type:Reply XID:0x3eb00345
Network File System, LOOKUP Reply Error:NFS3ERR_NOENT
[Program Version: 3]
[V3 Procedure: LOOKUP (3)]
Status: NFS3ERR_NOENT (2)
dir_attributes Directory mode:0777 uid:0 gid:0
attributes_follow: value follows (1)
attributes Directory mode:0777 uid:0 gid:0
Type: Directory (2)
mode: 040777
0... .... .... = not SUID
.0.. .... .... = not SGID
..0. .... .... = not save swapped text
...1 .... .... = Read permission for owner
.... 1... .... = Write permission for owner
.... .1.. .... = Execute permission for owner
.... ..1. .... = Read permission for group
.... ...1 .... = Write permission for group
.... .... 1... = Execute permission for group
.... .... .1.. = Read permission for others
.... .... ..1. = Write permission for others
.... .... ...1 = Execute permission for others
nlink: 2
uid: 0
gid: 0
size: 4096
used: 4096
rdev: 0,0
fsid: 0xd6aa5ceb9647d2e8
fileid: 2970241
atime: Dec 24, 2008 12:06:42.000000000
mtime: Dec 24, 2008 12:06:42.000000000
ctime: Dec 24, 2008 12:06:42.000000000
V3 CREATE Call (Reply In 156), DH:0x83dc449c/myfile Mode:UNCHECKED
Frame 155 (218 bytes on wire, 218 bytes captured)
Ethernet II, Src: Foxconn_ca:9d:29 (00:15:58:ca:9d:29), Dst:
HewlettP_06:50:f9 (00:14:c2:06:50:f9)
Internet Protocol, Src: 164.99.138.53 (164.99.138.53), Dst:
164.99.138.52 (164.99.138.52)
Transmission Control Protocol, Src Port: 882 (882), Dst Port: nfs
(2049), Seq: 121, Ack: 121, Len: 152
Remote Procedure Call, Type:Call XID:0x3fb00345
Network File System, CREATE Call DH:0x83dc449c/myfile Mode:UNCHECKED
[Program Version: 3]
[V3 Procedure: CREATE (8)]
where
dir
Name: myfile
Create Mode: UNCHECKED (0)
obj_attributes
mode: value follows
set_it: value follows (1)
mode: 00
0... .... .... = not SUID
.0.. .... .... = not SGID
..0. .... .... = not save swapped text
...0 .... .... = no Read permission for owner
.... 0... .... = no Write permission for owner
.... .0.. .... = no Execute permission for owner
.... ..0. .... = no Read permission for group
.... ...0 .... = no Write permission for group
.... .... 0... = no Execute permission for group
.... .... .0.. = no Read permission for others
.... .... ..0. = no Write permission for others
.... .... ...0 = no Execute permission for others
uid: no value
gid: no value
size: no value
atime: don't change
mtime: don't change
V3 CREATE Reply (Call In 155)
Frame 156 (346 bytes on wire, 346 bytes captured)
Ethernet II, Src: HewlettP_06:50:f9 (00:14:c2:06:50:f9), Dst:
Foxconn_ca:9d:29 (00:15:58:ca:9d:29)
Internet Protocol, Src: 164.99.138.52 (164.99.138.52), Dst:
164.99.138.53 (164.99.138.53)
Transmission Control Protocol, Src Port: nfs (2049), Dst Port: 882
(882), Seq: 121, Ack: 273, Len: 280
Remote Procedure Call, Type:Reply XID:0x3fb00345
Network File System, CREATE Reply
[Program Version: 3]
[V3 Procedure: CREATE (8)]
Status: NFS3_OK (0)
obj
obj_attributes Regular File mode:0000 uid:0 gid:0
attributes_follow: value follows (1)
attributes Regular File mode:0000 uid:0 gid:0
Type: Regular File (1)
mode: 0100000
0... .... .... = not SUID
.0.. .... .... = not SGID
..0. .... .... = not save swapped text
...0 .... .... = no Read permission for owner
.... 0... .... = no Write permission for owner
.... .0.. .... = no Execute permission for owner
.... ..0. .... = no Read permission for group
.... ...0 .... = no Write permission for group
.... .... 0... = no Execute permission for group
.... .... .0.. = no Read permission for others
.... .... ..0. = no Write permission for others
.... .... ...0 = no Execute permission for others
nlink: 1
uid: 0
gid: 0
size: 0
used: 0
rdev: 0,0
fsid: 0xd6aa5ceb9647d2e8
fileid: 1615722
atime: Dec 24, 2008 12:07:03.000000000
mtime: Dec 24, 2008 12:07:03.000000000
ctime: Dec 24, 2008 12:07:03.000000000
dir_wcc
</snip>
Thanks,
--
Suresh Jayaraman
Suresh Jayaraman wrote:
> wengang wang wrote:
>
>> Suresh Jayaraman wrote:
>>
>>> 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.
>>>>
>>>>
>>> What's the Create Mode in this case? EXCLUSIVE or UNCHECKED?
>>>
>>>
>> it's UNCHECKED.
>>
>>> What's the error the server is returning without this patch -
>>> ERR_NOTSUPP?
>>>
>>>
>>>
>> permission deny, that is NFS3ERR_ACCES.
>>
>>> I tested this on 2.6.27.7 with a small program which does this:
>>> fd = open("file", O_CREAT, 0000);
>>>
>>> The file creation succeeded with file size set to 0 and the subsequent
>>> chmod too.
>>>
>>>
>>>
>> tcpdump available for your test?
>> just after the creation, is the file mode 0000?
>>
>
> Here are the relevant packets (both server and client are running 2.6.27.7)
>
>
>
<snip>
> Network File System, CREATE Call DH:0x83dc449c/myfile Mode:UNCHECKED
> [Program Version: 3]
> [V3 Procedure: CREATE (8)]
> where
> dir
> Name: myfile
> Create Mode: UNCHECKED (0)
> obj_attributes
> mode: value follows
> set_it: value follows (1)
> mode: 00
> 0... .... .... = not SUID
> .0.. .... .... = not SGID
> ..0. .... .... = not save swapped text
> ...0 .... .... = no Read permission for owner
> .... 0... .... = no Write permission for owner
> .... .0.. .... = no Execute permission for owner
> .... ..0. .... = no Read permission for group
> .... ...0 .... = no Write permission for group
> .... .... 0... = no Execute permission for group
> .... .... .0.. = no Read permission for others
> .... .... ..0. = no Write permission for others
> .... .... ...0 = no Execute permission for others
> uid: no value
> gid: no value
> size: no value
>
Here is the difference, hpux request to set size to 0.
size: value follows
set_it: value follows (1)
size: 0
changing size(no matter the new size is equal to old size or not) needs
WRITE privilege.
For specific file systems that does permission check, such as gfs, they
fails at permission
check (in the gfs case, generic_permission()). the patch I posted is
based on "setting size
to it's original size is unnecessary".
Actually, I think the nfsd_create() should an "atomic" operation like
create_with_attr(),
in which, we don't do permission check, instead of create() and then
setattr().
but seems this needs lots of work. so I would like to take the above
trick before the
create_with_attr() is out.
thanks,
wengang.
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 <[email protected]>
> --
> 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Finally, how about this patch?
for this problem, the solution is either to fix HPUX or to fix linux.
are we going to fix linux?
any comment is appreciated.
thanks,
wengang.
wengang wang wrote:
> please ignore the email sent from [email protected] and reply to this post
> if you will.
> thanks.
>
> 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.
>
> 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.
>
> Signed-off-by: Wengang Wang <[email protected]>
> --
> 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
On Sun, Jan 04, 2009 at 09:53:12AM +0800, wengang wang wrote:
> Hi,
> Finally, how about this patch?
> for this problem, the solution is either to fix HPUX or to fix linux.
> are we going to fix linux?
>
> any comment is appreciated.
On my list, sorry, I just haven't gotten to it--bug me again if I
haven't dealt with it by the end of the week.--b.
>
> thanks,
> wengang.
>
> wengang wang wrote:
>> please ignore the email sent from [email protected] and reply to this post
>> if you will.
>> thanks.
>>
>> 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.
>>
>> 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.
>>
>> Signed-off-by: Wengang Wang <[email protected]>
>> --
>> 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 [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html