36 #include <linux/slab.h>
44 #define NFSDDBG_FACILITY NFSDDBG_PROC
46 static u32 nfsd_attrmask[] = {
47 NFSD_WRITEABLE_ATTRS_WORD0,
48 NFSD_WRITEABLE_ATTRS_WORD1,
49 NFSD_WRITEABLE_ATTRS_WORD2
52 static u32 nfsd41_ex_attrmask[] = {
53 NFSD_SUPPATTR_EXCLCREAT_WORD0,
54 NFSD_SUPPATTR_EXCLCREAT_WORD1,
55 NFSD_SUPPATTR_EXCLCREAT_WORD2
68 if ((bmval[0] & ~nfsd_suppattrs0(cstate->
minorversion)) ||
86 if ((bmval[0] & ~writable[0]) || (bmval[1] & ~writable[1]) ||
87 (bmval[2] & ~writable[2]))
95 nfsd4_check_open_attributes(
struct svc_rqst *rqstp,
103 status = check_attr_support(rqstp, cstate,
106 status = check_attr_support(rqstp, cstate,
107 open->
op_bmval, nfsd41_ex_attrmask);
132 status = nfsd4_set_nfs4_acl(rqstp, fhp, acl);
139 bmval[0] &= ~FATTR4_WORD0_ACL;
225 status = do_nfsd_create(rqstp, current_fh, open->
op_fname.data,
226 open->
op_fname.len, &open->op_iattr,
228 (
u32 *)open->op_verf.data,
242 fh_unlock(current_fh);
246 status = nfsd_check_obj_isreg(resfh);
250 if (is_create_with_attrs(open) && open->
op_acl !=
NULL)
254 fh_copy_shallow(&open->
op_openowner->oo_owner.so_replay.rp_openfh,
257 status = do_open_permission(rqstp, resfh, open,
259 set_change_info(&open->
op_cinfo, current_fh);
260 fh_dup2(current_fh, resfh);
279 fh_copy_shallow(&open->
op_openowner->oo_owner.so_replay.rp_openfh,
283 (open->op_iattr.ia_size == 0);
285 status = do_open_permission(rqstp, current_fh, open,
308 dprintk(
"NFSD: nfsd4_open filename %.*s op_openowner %p\n",
321 if (nfsd4_has_session(cstate) &&
323 &cstate->
session->se_client->cl_flags) &&
327 if (nfsd4_has_session(cstate))
338 fh_copy_shallow(&cstate->
current_fh.fh_handle,
342 dprintk(
"nfsd4_open: replay failed"
343 " restoring previous filehandle\n");
350 status = nfsd4_check_open_attributes(rqstp, cstate, open);
366 status = do_open_lookup(rqstp, &cstate->
current_fh,
378 status = do_open_fhandle(rqstp, &cstate->
current_fh,
386 dprintk(
"NFSD: unsupported OPEN claim type %d\n",
391 dprintk(
"NFSD: Invalid OPEN claim type %d\n",
452 if (!cstate->
save_fh.fh_dentry)
506 gen_boot_verifier(&commit->
co_verf);
526 status = check_attr_support(rqstp, cstate, create->
cr_bmval,
540 create->cr_linkname[create->cr_linklen] = 0;
544 create->cr_linkname, create->cr_linklen,
549 rdev =
MKDEV(create->cr_specdata1, create->cr_specdata2);
550 if (
MAJOR(rdev) != create->cr_specdata1 ||
551 MINOR(rdev) != create->cr_specdata2)
559 rdev =
MKDEV(create->cr_specdata1, create->cr_specdata2);
560 if (
MAJOR(rdev) != create->cr_specdata1 ||
561 MINOR(rdev) != create->cr_specdata2)
595 do_set_nfs4_acl(rqstp, &resfh, create->
cr_acl,
616 if (getattr->
ga_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)
633 if (!cstate->
save_fh.fh_dentry)
663 return nfsd4_do_lookupp(rqstp, &cstate->
current_fh);
692 dprintk(
"NFSD: nfsd4_read: couldn't process stateid!\n");
714 if (readdir->
rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)
721 if ((cookie == 1) || (cookie == 2) ||
748 remove->rm_name, remove->rm_namelen);
751 set_change_info(&remove->rm_cinfo, &cstate->
current_fh);
762 if (!cstate->
save_fh.fh_dentry)
793 struct dentry *dentry;
827 err = nfsd4_do_lookupp(rqstp, &cstate->
current_fh);
853 dprintk(
"NFSD: nfsd4_setattr: couldn't process stateid!\n");
862 status = check_attr_support(rqstp, cstate, setattr->
sa_bmval,
868 status = nfsd4_set_nfs4_acl(rqstp, &cstate->
current_fh,
901 dprintk(
"NFSD: nfsd4_write: couldn't process stateid!\n");
937 status = check_attr_support(rqstp, cstate, verify->
ve_bmval,
NULL);
942 || (verify->
ve_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1))
968 p = buf + 1 +
ntohl(buf[0]);
986 status = _nfsd4_verify(rqstp, cstate, verify);
996 status = _nfsd4_verify(rqstp, cstate, verify);
1004 nfsd4_proc_null(
struct svc_rqst *rqstp,
void *
argp,
void *resp)
1009 static inline void nfsd4_increment_op_stats(
u32 opnum)
1064 static const char *nfsd4_op_name(
unsigned opnum);
1087 if (args->
opcnt == 0)
1095 if (args->
opcnt != 1)
1102 return &nfsd4_ops[op->
opnum];
1110 static bool need_wrongsec_check(
struct svc_rqst *rqstp)
1119 thisd = OPDESC(
this);
1134 nextd = OPDESC(next);
1147 nfsd4_proc_compound(
struct svc_rqst *rqstp,
1159 resp->
p = rqstp->
rq_res.head[0].iov_base +
1160 rqstp->
rq_res.head[0].iov_len;
1161 resp->
tagp = resp->
p;
1163 resp->
p += 2 + XDR_QUADLEN(args->
taglen);
1168 resp->
rqstp = rqstp;
1187 status = nfs41_check_op_ordering(args);
1194 while (!status && resp->
opcnt < args->
opcnt) {
1197 dprintk(
"nfsv4 compound op #%d/%d: %d (%s)\n",
1199 nfsd4_op_name(op->
opnum));
1213 slack_bytes = (
char *)resp->
end - (
char *)resp->
p;
1214 if (slack_bytes < COMPOUND_SLACK_SPACE
1215 + COMPOUND_ERR_SLACK_SPACE) {
1216 BUG_ON(slack_bytes < COMPOUND_ERR_SLACK_SPACE);
1221 opdesc = OPDESC(op);
1228 }
else if (cstate->
current_fh.fh_export->ex_fslocs.migrated &&
1257 if (need_wrongsec_check(rqstp))
1264 dprintk(
"%s NFS4.1 replay from cache\n", __func__);
1277 dprintk(
"nfsv4 compound op %p opcnt %d #%d: %d: status %d\n",
1289 nfsd4_increment_op_stats(op->
opnum);
1299 dprintk(
"nfsv4 compound returned %d\n",
ntohl(status));
1303 #define op_encode_hdr_size (2)
1304 #define op_encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
1305 #define op_encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
1306 #define op_encode_change_info_maxsz (5)
1307 #define nfs4_fattr_bitmap_maxsz (4)
1309 #define op_encode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
1310 #define op_encode_lock_denied_maxsz (8 + op_encode_lockowner_maxsz)
1312 #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
1314 #define op_encode_ace_maxsz (3 + nfs4_owner_maxsz)
1315 #define op_encode_delegation_maxsz (1 + op_encode_stateid_maxsz + 1 + \
1316 op_encode_ace_maxsz)
1318 #define op_encode_channel_attrs_maxsz (6 + 1 + 1)
1363 u32 maxcount = 0, rlen = 0;
1366 rlen = op->
u.
read.rd_length;
1368 if (rlen > maxcount)
1425 static inline u32 nfsd4_bind_conn_to_session_rsize(
struct svc_rqst *rqstp,
struct nfsd4_op *op)
1537 .
op_name =
"OP_OPEN_DOWNGRADE",
1639 .
op_name =
"OP_SETCLIENTID_CONFIRM",
1657 .
op_name =
"OP_RELEASE_LOCKOWNER",
1673 .
op_name =
"OP_BIND_CONN_TO_SESSION",
1680 .
op_name =
"OP_CREATE_SESSION",
1687 .
op_name =
"OP_DESTROY_SESSION",
1699 .
op_name =
"OP_DESTROY_CLIENTID",
1705 .
op_name =
"OP_RECLAIM_COMPLETE",
1711 .
op_name =
"OP_SECINFO_NO_NAME",
1727 static const char *nfsd4_op_name(
unsigned opnum)
1730 return nfsd4_ops[opnum].
op_name;
1731 return "unknown_operation";
1735 #define nfsd4_voidres nfsd4_voidargs
1762 .vs_proc = nfsd_procedures4,