Skip to content

Commit 8313064

Browse files
committed
Merge tag 'nfsd-4.11' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields: "The nfsd update this round is mainly a lot of miscellaneous cleanups and bugfixes. A couple changes could theoretically break working setups on upgrade. I don't expect complaints in practice, but they seem worth calling out just in case: - NFS security labels are now off by default; a new security_label export flag reenables it per export. But, having them on by default is a disaster, as it generally only makes sense if all your clients and servers have similar enough selinux policies. Thanks to Jason Tibbitts for pointing this out. - NFSv4/UDP support is off. It was never really supported, and the spec explicitly forbids it. We only ever left it on out of laziness; thanks to Jeff Layton for finally fixing that" * tag 'nfsd-4.11' of git://linux-nfs.org/~bfields/linux: (34 commits) nfsd: Fix display of the version string nfsd: fix configuration of supported minor versions sunrpc: don't register UDP port with rpcbind when version needs congestion control nfs/nfsd/sunrpc: enforce transport requirements for NFSv4 sunrpc: flag transports as having congestion control sunrpc: turn bitfield flags in svc_version into bools nfsd: remove superfluous KERN_INFO nfsd: special case truncates some more nfsd: minor nfsd_setattr cleanup NFSD: Reserve adequate space for LOCKT operation NFSD: Get response size before operation for all RPCs nfsd/callback: Drop a useless data copy when comparing sessionid nfsd/callback: skip the callback tag nfsd/callback: Cleanup callback cred on shutdown nfsd/idmap: return nfserr_inval for 0-length names SUNRPC/Cache: Always treat the invalid cache as unexpired SUNRPC: Drop all entries from cache_detail when cache_purge() svcrdma: Poll CQs in "workqueue" mode svcrdma: Combine list fields in struct svc_rdma_op_ctxt svcrdma: Remove unused sc_dto_q field ...
2 parents b2deee2 + ff7d117 commit 8313064

33 files changed

+510
-431
lines changed

fs/lockd/svc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ static int lockd_inet6addr_event(struct notifier_block *this,
322322
dprintk("lockd_inet6addr_event: removed %pI6\n", &ifa->addr);
323323
sin6.sin6_family = AF_INET6;
324324
sin6.sin6_addr = ifa->addr;
325+
if (ipv6_addr_type(&sin6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
326+
sin6.sin6_scope_id = ifa->idev->dev->ifindex;
325327
svc_age_temp_xprts_now(nlmsvc_rqst->rq_server,
326328
(struct sockaddr *)&sin6);
327329
}

fs/nfs/callback_xdr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ struct svc_version nfs4_callback_version1 = {
10831083
.vs_proc = nfs4_callback_procedures1,
10841084
.vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
10851085
.vs_dispatch = NULL,
1086-
.vs_hidden = 1,
1086+
.vs_hidden = true,
1087+
.vs_need_cong_ctrl = true,
10871088
};
10881089

10891090
struct svc_version nfs4_callback_version4 = {
@@ -1092,5 +1093,6 @@ struct svc_version nfs4_callback_version4 = {
10921093
.vs_proc = nfs4_callback_procedures1,
10931094
.vs_xdrsize = NFS4_CALLBACK_XDRSIZE,
10941095
.vs_dispatch = NULL,
1095-
.vs_hidden = 1,
1096+
.vs_hidden = true,
1097+
.vs_need_cong_ctrl = true,
10961098
};

fs/nfsd/export.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ static struct flags {
11021102
{ NFSEXP_NOAUTHNLM, {"insecure_locks", ""}},
11031103
{ NFSEXP_V4ROOT, {"v4root", ""}},
11041104
{ NFSEXP_PNFS, {"pnfs", ""}},
1105+
{ NFSEXP_SECURITY_LABEL, {"security_label", ""}},
11051106
{ 0, {"", ""}}
11061107
};
11071108

fs/nfsd/nfs2acl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,5 +376,4 @@ struct svc_version nfsd_acl_version2 = {
376376
.vs_proc = nfsd_acl_procedures2,
377377
.vs_dispatch = nfsd_dispatch,
378378
.vs_xdrsize = NFS3_SVC_XDRSIZE,
379-
.vs_hidden = 0,
380379
};

fs/nfsd/nfs3acl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,5 @@ struct svc_version nfsd_acl_version3 = {
266266
.vs_proc = nfsd_acl_procedures3,
267267
.vs_dispatch = nfsd_dispatch,
268268
.vs_xdrsize = NFS3_SVC_XDRSIZE,
269-
.vs_hidden = 0,
270269
};
271270

fs/nfsd/nfs3proc.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,9 @@ nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp,
193193

194194
fh_copy(&resp->fh, &argp->fh);
195195
resp->committed = argp->stable;
196-
nfserr = nfsd_write(rqstp, &resp->fh, NULL,
197-
argp->offset,
198-
rqstp->rq_vec, argp->vlen,
199-
&cnt,
200-
&resp->committed);
196+
nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
197+
rqstp->rq_vec, argp->vlen,
198+
&cnt, resp->committed);
201199
resp->count = cnt;
202200
RETURN_STATUS(nfserr);
203201
}

fs/nfsd/nfs4callback.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ static int decode_cb_compound4res(struct xdr_stream *xdr,
303303
p = xdr_inline_decode(xdr, length + 4);
304304
if (unlikely(p == NULL))
305305
goto out_overflow;
306+
p += XDR_QUADLEN(length);
306307
hdr->nops = be32_to_cpup(p);
307308
return 0;
308309
out_overflow:
@@ -396,23 +397,19 @@ static int decode_cb_sequence4resok(struct xdr_stream *xdr,
396397
struct nfsd4_callback *cb)
397398
{
398399
struct nfsd4_session *session = cb->cb_clp->cl_cb_session;
399-
struct nfs4_sessionid id;
400-
int status;
400+
int status = -ESERVERFAULT;
401401
__be32 *p;
402402
u32 dummy;
403403

404-
status = -ESERVERFAULT;
405-
406404
/*
407405
* If the server returns different values for sessionID, slotID or
408406
* sequence number, the server is looney tunes.
409407
*/
410408
p = xdr_inline_decode(xdr, NFS4_MAX_SESSIONID_LEN + 4 + 4 + 4 + 4);
411409
if (unlikely(p == NULL))
412410
goto out_overflow;
413-
memcpy(id.data, p, NFS4_MAX_SESSIONID_LEN);
414-
if (memcmp(id.data, session->se_sessionid.data,
415-
NFS4_MAX_SESSIONID_LEN) != 0) {
411+
412+
if (memcmp(p, session->se_sessionid.data, NFS4_MAX_SESSIONID_LEN)) {
416413
dprintk("NFS: %s Invalid session id\n", __func__);
417414
goto out;
418415
}
@@ -753,6 +750,14 @@ int set_callback_cred(void)
753750
return 0;
754751
}
755752

753+
void cleanup_callback_cred(void)
754+
{
755+
if (callback_cred) {
756+
put_rpccred(callback_cred);
757+
callback_cred = NULL;
758+
}
759+
}
760+
756761
static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
757762
{
758763
if (clp->cl_minorversion == 0) {

fs/nfsd/nfs4idmap.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen,
628628
{
629629
__be32 status;
630630
u32 id = -1;
631+
632+
if (name == NULL || namelen == 0)
633+
return nfserr_inval;
634+
631635
status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id);
632636
*uid = make_kuid(&init_user_ns, id);
633637
if (!uid_valid(*uid))
@@ -641,6 +645,10 @@ nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen,
641645
{
642646
__be32 status;
643647
u32 id = -1;
648+
649+
if (name == NULL || namelen == 0)
650+
return nfserr_inval;
651+
644652
status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id);
645653
*gid = make_kgid(&init_user_ns, id);
646654
if (!gid_valid(*gid))

fs/nfsd/nfs4proc.c

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ check_attr_support(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9595
u32 *bmval, u32 *writable)
9696
{
9797
struct dentry *dentry = cstate->current_fh.fh_dentry;
98+
struct svc_export *exp = cstate->current_fh.fh_export;
9899

99100
if (!nfsd_attrs_supported(cstate->minorversion, bmval))
100101
return nfserr_attrnotsupp;
101102
if ((bmval[0] & FATTR4_WORD0_ACL) && !IS_POSIXACL(d_inode(dentry)))
102103
return nfserr_attrnotsupp;
104+
if ((bmval[2] & FATTR4_WORD2_SECURITY_LABEL) &&
105+
!(exp->ex_flags & NFSEXP_SECURITY_LABEL))
106+
return nfserr_attrnotsupp;
103107
if (writable && !bmval_is_subset(bmval, writable))
104108
return nfserr_inval;
105109
if (writable && (bmval[2] & FATTR4_WORD2_MODE_UMASK) &&
@@ -983,7 +987,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
983987

984988
status = nfsd_vfs_write(rqstp, &cstate->current_fh, filp,
985989
write->wr_offset, rqstp->rq_vec, nvecs, &cnt,
986-
&write->wr_how_written);
990+
write->wr_how_written);
987991
fput(filp);
988992

989993
write->wr_bytes_written = cnt;
@@ -1838,6 +1842,12 @@ static inline u32 nfsd4_status_stateid_rsize(struct svc_rqst *rqstp, struct nfsd
18381842
return (op_encode_hdr_size + op_encode_stateid_maxsz)* sizeof(__be32);
18391843
}
18401844

1845+
static inline u32 nfsd4_access_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1846+
{
1847+
/* ac_supported, ac_resp_access */
1848+
return (op_encode_hdr_size + 2)* sizeof(__be32);
1849+
}
1850+
18411851
static inline u32 nfsd4_commit_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
18421852
{
18431853
return (op_encode_hdr_size + op_encode_verifier_maxsz) * sizeof(__be32);
@@ -1892,6 +1902,11 @@ static inline u32 nfsd4_getattr_rsize(struct svc_rqst *rqstp,
18921902
return ret;
18931903
}
18941904

1905+
static inline u32 nfsd4_getfh_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1906+
{
1907+
return (op_encode_hdr_size + 1) * sizeof(__be32) + NFS4_FHSIZE;
1908+
}
1909+
18951910
static inline u32 nfsd4_link_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
18961911
{
18971912
return (op_encode_hdr_size + op_encode_change_info_maxsz)
@@ -1933,6 +1948,11 @@ static inline u32 nfsd4_readdir_rsize(struct svc_rqst *rqstp, struct nfsd4_op *o
19331948
XDR_QUADLEN(rlen)) * sizeof(__be32);
19341949
}
19351950

1951+
static inline u32 nfsd4_readlink_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1952+
{
1953+
return (op_encode_hdr_size + 1) * sizeof(__be32) + PAGE_SIZE;
1954+
}
1955+
19361956
static inline u32 nfsd4_remove_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
19371957
{
19381958
return (op_encode_hdr_size + op_encode_change_info_maxsz)
@@ -1952,11 +1972,23 @@ static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp,
19521972
+ XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) * sizeof(__be32);
19531973
}
19541974

1975+
static inline u32 nfsd4_test_stateid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1976+
{
1977+
return (op_encode_hdr_size + 1 + op->u.test_stateid.ts_num_ids)
1978+
* sizeof(__be32);
1979+
}
1980+
19551981
static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
19561982
{
19571983
return (op_encode_hdr_size + nfs4_fattr_bitmap_maxsz) * sizeof(__be32);
19581984
}
19591985

1986+
static inline u32 nfsd4_secinfo_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1987+
{
1988+
return (op_encode_hdr_size + RPC_AUTH_MAXFLAVOR *
1989+
(4 + XDR_QUADLEN(GSS_OID_MAX_LEN))) * sizeof(__be32);
1990+
}
1991+
19601992
static inline u32 nfsd4_setclientid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
19611993
{
19621994
return (op_encode_hdr_size + 2 + XDR_QUADLEN(NFS4_VERIFIER_SIZE)) *
@@ -2011,6 +2043,19 @@ static inline u32 nfsd4_copy_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
20112043
}
20122044

20132045
#ifdef CONFIG_NFSD_PNFS
2046+
static inline u32 nfsd4_getdeviceinfo_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
2047+
{
2048+
u32 maxcount = 0, rlen = 0;
2049+
2050+
maxcount = svc_max_payload(rqstp);
2051+
rlen = min(op->u.getdeviceinfo.gd_maxcount, maxcount);
2052+
2053+
return (op_encode_hdr_size +
2054+
1 /* gd_layout_type*/ +
2055+
XDR_QUADLEN(rlen) +
2056+
2 /* gd_notify_types */) * sizeof(__be32);
2057+
}
2058+
20142059
/*
20152060
* At this stage we don't really know what layout driver will handle the request,
20162061
* so we need to define an arbitrary upper bound here.
@@ -2040,10 +2085,17 @@ static inline u32 nfsd4_layoutreturn_rsize(struct svc_rqst *rqstp, struct nfsd4_
20402085
}
20412086
#endif /* CONFIG_NFSD_PNFS */
20422087

2088+
2089+
static inline u32 nfsd4_seek_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
2090+
{
2091+
return (op_encode_hdr_size + 3) * sizeof(__be32);
2092+
}
2093+
20432094
static struct nfsd4_operation nfsd4_ops[] = {
20442095
[OP_ACCESS] = {
20452096
.op_func = (nfsd4op_func)nfsd4_access,
20462097
.op_name = "OP_ACCESS",
2098+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_access_rsize,
20472099
},
20482100
[OP_CLOSE] = {
20492101
.op_func = (nfsd4op_func)nfsd4_close,
@@ -2081,6 +2133,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
20812133
[OP_GETFH] = {
20822134
.op_func = (nfsd4op_func)nfsd4_getfh,
20832135
.op_name = "OP_GETFH",
2136+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_getfh_rsize,
20842137
},
20852138
[OP_LINK] = {
20862139
.op_func = (nfsd4op_func)nfsd4_link,
@@ -2099,6 +2152,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
20992152
[OP_LOCKT] = {
21002153
.op_func = (nfsd4op_func)nfsd4_lockt,
21012154
.op_name = "OP_LOCKT",
2155+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_lock_rsize,
21022156
},
21032157
[OP_LOCKU] = {
21042158
.op_func = (nfsd4op_func)nfsd4_locku,
@@ -2111,15 +2165,18 @@ static struct nfsd4_operation nfsd4_ops[] = {
21112165
.op_func = (nfsd4op_func)nfsd4_lookup,
21122166
.op_flags = OP_HANDLES_WRONGSEC | OP_CLEAR_STATEID,
21132167
.op_name = "OP_LOOKUP",
2168+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize,
21142169
},
21152170
[OP_LOOKUPP] = {
21162171
.op_func = (nfsd4op_func)nfsd4_lookupp,
21172172
.op_flags = OP_HANDLES_WRONGSEC | OP_CLEAR_STATEID,
21182173
.op_name = "OP_LOOKUPP",
2174+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize,
21192175
},
21202176
[OP_NVERIFY] = {
21212177
.op_func = (nfsd4op_func)nfsd4_nverify,
21222178
.op_name = "OP_NVERIFY",
2179+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize,
21232180
},
21242181
[OP_OPEN] = {
21252182
.op_func = (nfsd4op_func)nfsd4_open,
@@ -2177,6 +2234,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
21772234
[OP_READLINK] = {
21782235
.op_func = (nfsd4op_func)nfsd4_readlink,
21792236
.op_name = "OP_READLINK",
2237+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_readlink_rsize,
21802238
},
21812239
[OP_REMOVE] = {
21822240
.op_func = (nfsd4op_func)nfsd4_remove,
@@ -2215,6 +2273,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
22152273
.op_func = (nfsd4op_func)nfsd4_secinfo,
22162274
.op_flags = OP_HANDLES_WRONGSEC,
22172275
.op_name = "OP_SECINFO",
2276+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_secinfo_rsize,
22182277
},
22192278
[OP_SETATTR] = {
22202279
.op_func = (nfsd4op_func)nfsd4_setattr,
@@ -2240,6 +2299,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
22402299
[OP_VERIFY] = {
22412300
.op_func = (nfsd4op_func)nfsd4_verify,
22422301
.op_name = "OP_VERIFY",
2302+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize,
22432303
},
22442304
[OP_WRITE] = {
22452305
.op_func = (nfsd4op_func)nfsd4_write,
@@ -2314,11 +2374,13 @@ static struct nfsd4_operation nfsd4_ops[] = {
23142374
.op_func = (nfsd4op_func)nfsd4_secinfo_no_name,
23152375
.op_flags = OP_HANDLES_WRONGSEC,
23162376
.op_name = "OP_SECINFO_NO_NAME",
2377+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_secinfo_rsize,
23172378
},
23182379
[OP_TEST_STATEID] = {
23192380
.op_func = (nfsd4op_func)nfsd4_test_stateid,
23202381
.op_flags = ALLOWED_WITHOUT_FH,
23212382
.op_name = "OP_TEST_STATEID",
2383+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_test_stateid_rsize,
23222384
},
23232385
[OP_FREE_STATEID] = {
23242386
.op_func = (nfsd4op_func)nfsd4_free_stateid,
@@ -2332,6 +2394,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
23322394
.op_func = (nfsd4op_func)nfsd4_getdeviceinfo,
23332395
.op_flags = ALLOWED_WITHOUT_FH,
23342396
.op_name = "OP_GETDEVICEINFO",
2397+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_getdeviceinfo_rsize,
23352398
},
23362399
[OP_LAYOUTGET] = {
23372400
.op_func = (nfsd4op_func)nfsd4_layoutget,
@@ -2381,6 +2444,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
23812444
[OP_SEEK] = {
23822445
.op_func = (nfsd4op_func)nfsd4_seek,
23832446
.op_name = "OP_SEEK",
2447+
.op_rsize_bop = (nfsd4op_rsize)nfsd4_seek_rsize,
23842448
},
23852449
};
23862450

@@ -2425,14 +2489,11 @@ bool nfsd4_spo_must_allow(struct svc_rqst *rqstp)
24252489

24262490
int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op)
24272491
{
2428-
struct nfsd4_operation *opdesc;
2429-
nfsd4op_rsize estimator;
2430-
24312492
if (op->opnum == OP_ILLEGAL)
24322493
return op_encode_hdr_size * sizeof(__be32);
2433-
opdesc = OPDESC(op);
2434-
estimator = opdesc->op_rsize_bop;
2435-
return estimator ? estimator(rqstp, op) : PAGE_SIZE;
2494+
2495+
BUG_ON(OPDESC(op)->op_rsize_bop == NULL);
2496+
return OPDESC(op)->op_rsize_bop(rqstp, op);
24362497
}
24372498

24382499
void warn_on_nonidempotent_op(struct nfsd4_op *op)
@@ -2476,12 +2537,13 @@ static struct svc_procedure nfsd_procedures4[2] = {
24762537
};
24772538

24782539
struct svc_version nfsd_version4 = {
2479-
.vs_vers = 4,
2480-
.vs_nproc = 2,
2481-
.vs_proc = nfsd_procedures4,
2482-
.vs_dispatch = nfsd_dispatch,
2483-
.vs_xdrsize = NFS4_SVC_XDRSIZE,
2484-
.vs_rpcb_optnl = 1,
2540+
.vs_vers = 4,
2541+
.vs_nproc = 2,
2542+
.vs_proc = nfsd_procedures4,
2543+
.vs_dispatch = nfsd_dispatch,
2544+
.vs_xdrsize = NFS4_SVC_XDRSIZE,
2545+
.vs_rpcb_optnl = true,
2546+
.vs_need_cong_ctrl = true,
24852547
};
24862548

24872549
/*

0 commit comments

Comments
 (0)