Commit a36b1725b342c8131a86a0238789d8e7bcb490dd
1 parent
063b0fb9fa
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
nfsd4: return badname, not inval, on "." or "..", or "/"
The spec requires badname, not inval, in these cases. Some callers want us to return enoent, but I can see no justification for that. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Showing 1 changed file with 12 additions and 13 deletions Side-by-side Diff
fs/nfsd/nfs4xdr.c
... | ... | @@ -65,17 +65,17 @@ |
65 | 65 | #define NFS4_REFERRAL_FSID_MINOR 0x8000000ULL |
66 | 66 | |
67 | 67 | static __be32 |
68 | -check_filename(char *str, int len, __be32 err) | |
68 | +check_filename(char *str, int len) | |
69 | 69 | { |
70 | 70 | int i; |
71 | 71 | |
72 | 72 | if (len == 0) |
73 | 73 | return nfserr_inval; |
74 | 74 | if (isdotent(str, len)) |
75 | - return err; | |
75 | + return nfserr_badname; | |
76 | 76 | for (i = 0; i < len; i++) |
77 | 77 | if (str[i] == '/') |
78 | - return err; | |
78 | + return nfserr_badname; | |
79 | 79 | return 0; |
80 | 80 | } |
81 | 81 | |
... | ... | @@ -570,7 +570,7 @@ |
570 | 570 | READ32(create->cr_namelen); |
571 | 571 | READ_BUF(create->cr_namelen); |
572 | 572 | SAVEMEM(create->cr_name, create->cr_namelen); |
573 | - if ((status = check_filename(create->cr_name, create->cr_namelen, nfserr_inval))) | |
573 | + if ((status = check_filename(create->cr_name, create->cr_namelen))) | |
574 | 574 | return status; |
575 | 575 | |
576 | 576 | status = nfsd4_decode_fattr(argp, create->cr_bmval, &create->cr_iattr, |
... | ... | @@ -602,7 +602,7 @@ |
602 | 602 | READ32(link->li_namelen); |
603 | 603 | READ_BUF(link->li_namelen); |
604 | 604 | SAVEMEM(link->li_name, link->li_namelen); |
605 | - if ((status = check_filename(link->li_name, link->li_namelen, nfserr_inval))) | |
605 | + if ((status = check_filename(link->li_name, link->li_namelen))) | |
606 | 606 | return status; |
607 | 607 | |
608 | 608 | DECODE_TAIL; |
... | ... | @@ -696,7 +696,7 @@ |
696 | 696 | READ32(lookup->lo_len); |
697 | 697 | READ_BUF(lookup->lo_len); |
698 | 698 | SAVEMEM(lookup->lo_name, lookup->lo_len); |
699 | - if ((status = check_filename(lookup->lo_name, lookup->lo_len, nfserr_noent))) | |
699 | + if ((status = check_filename(lookup->lo_name, lookup->lo_len))) | |
700 | 700 | return status; |
701 | 701 | |
702 | 702 | DECODE_TAIL; |
... | ... | @@ -860,7 +860,7 @@ |
860 | 860 | READ32(open->op_fname.len); |
861 | 861 | READ_BUF(open->op_fname.len); |
862 | 862 | SAVEMEM(open->op_fname.data, open->op_fname.len); |
863 | - if ((status = check_filename(open->op_fname.data, open->op_fname.len, nfserr_inval))) | |
863 | + if ((status = check_filename(open->op_fname.data, open->op_fname.len))) | |
864 | 864 | return status; |
865 | 865 | break; |
866 | 866 | case NFS4_OPEN_CLAIM_PREVIOUS: |
... | ... | @@ -875,7 +875,7 @@ |
875 | 875 | READ32(open->op_fname.len); |
876 | 876 | READ_BUF(open->op_fname.len); |
877 | 877 | SAVEMEM(open->op_fname.data, open->op_fname.len); |
878 | - if ((status = check_filename(open->op_fname.data, open->op_fname.len, nfserr_inval))) | |
878 | + if ((status = check_filename(open->op_fname.data, open->op_fname.len))) | |
879 | 879 | return status; |
880 | 880 | break; |
881 | 881 | case NFS4_OPEN_CLAIM_FH: |
... | ... | @@ -987,7 +987,7 @@ |
987 | 987 | READ32(remove->rm_namelen); |
988 | 988 | READ_BUF(remove->rm_namelen); |
989 | 989 | SAVEMEM(remove->rm_name, remove->rm_namelen); |
990 | - if ((status = check_filename(remove->rm_name, remove->rm_namelen, nfserr_noent))) | |
990 | + if ((status = check_filename(remove->rm_name, remove->rm_namelen))) | |
991 | 991 | return status; |
992 | 992 | |
993 | 993 | DECODE_TAIL; |
994 | 994 | |
... | ... | @@ -1005,9 +1005,9 @@ |
1005 | 1005 | READ32(rename->rn_tnamelen); |
1006 | 1006 | READ_BUF(rename->rn_tnamelen); |
1007 | 1007 | SAVEMEM(rename->rn_tname, rename->rn_tnamelen); |
1008 | - if ((status = check_filename(rename->rn_sname, rename->rn_snamelen, nfserr_noent))) | |
1008 | + if ((status = check_filename(rename->rn_sname, rename->rn_snamelen))) | |
1009 | 1009 | return status; |
1010 | - if ((status = check_filename(rename->rn_tname, rename->rn_tnamelen, nfserr_inval))) | |
1010 | + if ((status = check_filename(rename->rn_tname, rename->rn_tnamelen))) | |
1011 | 1011 | return status; |
1012 | 1012 | |
1013 | 1013 | DECODE_TAIL; |
... | ... | @@ -1034,8 +1034,7 @@ |
1034 | 1034 | READ32(secinfo->si_namelen); |
1035 | 1035 | READ_BUF(secinfo->si_namelen); |
1036 | 1036 | SAVEMEM(secinfo->si_name, secinfo->si_namelen); |
1037 | - status = check_filename(secinfo->si_name, secinfo->si_namelen, | |
1038 | - nfserr_noent); | |
1037 | + status = check_filename(secinfo->si_name, secinfo->si_namelen); | |
1039 | 1038 | if (status) |
1040 | 1039 | return status; |
1041 | 1040 | DECODE_TAIL; |