Skip to content

Commit e45428a

Browse files
committed
Merge tag 'nfsd-4.21' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields: "Thanks to Vasily Averin for fixing a use-after-free in the containerized NFSv4.2 client, and cleaning up some convoluted backchannel server code in the process. Otherwise, miscellaneous smaller bugfixes and cleanup" * tag 'nfsd-4.21' of git://linux-nfs.org/~bfields/linux: (25 commits) nfs: fixed broken compilation in nfs_callback_up_net() nfs: minor typo in nfs4_callback_up_net() sunrpc: fix debug message in svc_create_xprt() sunrpc: make visible processing error in bc_svc_process() sunrpc: remove unused xpo_prep_reply_hdr callback sunrpc: remove svc_rdma_bc_class sunrpc: remove svc_tcp_bc_class sunrpc: remove unused bc_up operation from rpc_xprt_ops sunrpc: replace svc_serv->sv_bc_xprt by boolean flag sunrpc: use-after-free in svc_process_common() sunrpc: use SVC_NET() in svcauth_gss_* functions nfsd: drop useless LIST_HEAD lockd: Show pid of lockd for remote locks NFSD remove OP_CACHEME from 4.2 op_flags nfsd: Return EPERM, not EACCES, in some SETATTR cases sunrpc: fix cache_head leak due to queued request nfsd: clean up indentation, increase indentation in switch statement svcrdma: Optimize the logic that selects the R_key to invalidate nfsd: fix a warning in __cld_pipe_upcall() nfsd4: fix crash on writing v4_end_grace before nfsd startup ...
2 parents 85f7845 + 0ad30ff commit e45428a

31 files changed

Lines changed: 192 additions & 360 deletions

‎fs/lockd/clnt4xdr.c‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,14 @@ static void encode_netobj(struct xdr_stream *xdr,
128128
static int decode_netobj(struct xdr_stream *xdr,
129129
struct xdr_netobj *obj)
130130
{
131-
u32 length;
132-
__be32 *p;
131+
ssize_t ret;
133132

134-
p = xdr_inline_decode(xdr, 4);
135-
if (unlikely(p == NULL))
136-
goto out_overflow;
137-
length = be32_to_cpup(p++);
138-
if (unlikely(length > XDR_MAX_NETOBJ))
139-
goto out_size;
140-
obj->len = length;
141-
obj->data = (u8 *)p;
133+
ret = xdr_stream_decode_opaque_inline(xdr, (void *)&obj->data,
134+
XDR_MAX_NETOBJ);
135+
if (unlikely(ret < 0))
136+
return -EIO;
137+
obj->len = ret;
142138
return 0;
143-
out_size:
144-
dprintk("NFS: returned netobj was too long: %u\n", length);
145-
return -EIO;
146-
out_overflow:
147-
print_overflow_msg(__func__, xdr);
148-
return -EIO;
149139
}
150140

151141
/*

‎fs/lockd/clntproc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl)
442442
fl->fl_start = req->a_res.lock.fl.fl_start;
443443
fl->fl_end = req->a_res.lock.fl.fl_end;
444444
fl->fl_type = req->a_res.lock.fl.fl_type;
445-
fl->fl_pid = 0;
445+
fl->fl_pid = -req->a_res.lock.fl.fl_pid;
446446
break;
447447
default:
448448
status = nlm_stat_to_errno(req->a_res.status);

‎fs/lockd/clntxdr.c‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,14 @@ static void encode_netobj(struct xdr_stream *xdr,
125125
static int decode_netobj(struct xdr_stream *xdr,
126126
struct xdr_netobj *obj)
127127
{
128-
u32 length;
129-
__be32 *p;
128+
ssize_t ret;
130129

131-
p = xdr_inline_decode(xdr, 4);
132-
if (unlikely(p == NULL))
133-
goto out_overflow;
134-
length = be32_to_cpup(p++);
135-
if (unlikely(length > XDR_MAX_NETOBJ))
136-
goto out_size;
137-
obj->len = length;
138-
obj->data = (u8 *)p;
130+
ret = xdr_stream_decode_opaque_inline(xdr, (void *)&obj->data,
131+
XDR_MAX_NETOBJ);
132+
if (unlikely(ret < 0))
133+
return -EIO;
134+
obj->len = ret;
139135
return 0;
140-
out_size:
141-
dprintk("NFS: returned netobj was too long: %u\n", length);
142-
return -EIO;
143-
out_overflow:
144-
print_overflow_msg(__func__, xdr);
145-
return -EIO;
146136
}
147137

148138
/*

‎fs/lockd/xdr.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock)
127127

128128
locks_init_lock(fl);
129129
fl->fl_owner = current->files;
130-
fl->fl_pid = (pid_t)lock->svid;
130+
fl->fl_pid = current->tgid;
131131
fl->fl_flags = FL_POSIX;
132132
fl->fl_type = F_RDLCK; /* as good as anything else */
133133
start = ntohl(*p++);
@@ -269,7 +269,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
269269
memset(lock, 0, sizeof(*lock));
270270
locks_init_lock(&lock->fl);
271271
lock->svid = ~(u32) 0;
272-
lock->fl.fl_pid = (pid_t)lock->svid;
272+
lock->fl.fl_pid = current->tgid;
273273

274274
if (!(p = nlm_decode_cookie(p, &argp->cookie))
275275
|| !(p = xdr_decode_string_inplace(p, &lock->caller,

‎fs/lockd/xdr4.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
119119

120120
locks_init_lock(fl);
121121
fl->fl_owner = current->files;
122-
fl->fl_pid = (pid_t)lock->svid;
122+
fl->fl_pid = current->tgid;
123123
fl->fl_flags = FL_POSIX;
124124
fl->fl_type = F_RDLCK; /* as good as anything else */
125125
p = xdr_decode_hyper(p, &start);
@@ -266,7 +266,7 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
266266
memset(lock, 0, sizeof(*lock));
267267
locks_init_lock(&lock->fl);
268268
lock->svid = ~(u32) 0;
269-
lock->fl.fl_pid = (pid_t)lock->svid;
269+
lock->fl.fl_pid = current->tgid;
270270

271271
if (!(p = nlm4_decode_cookie(p, &argp->cookie))
272272
|| !(p = xdr_decode_string_inplace(p, &lock->caller,

‎fs/nfs/callback.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int nfs4_callback_up_net(struct svc_serv *serv, struct net *net)
5656
nfs_callback_set_tcpport, SVC_SOCK_ANONYMOUS);
5757
if (ret > 0) {
5858
nn->nfs_callback_tcpport6 = ret;
59-
dprintk("NFS: Callback listener port = %u (af %u, net %x\n",
59+
dprintk("NFS: Callback listener port = %u (af %u, net %x)\n",
6060
nn->nfs_callback_tcpport6, PF_INET6, net->ns.inum);
6161
} else if (ret != -EAFNOSUPPORT)
6262
goto out_err;
@@ -206,11 +206,13 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
206206
goto err_bind;
207207
}
208208

209-
ret = -EPROTONOSUPPORT;
209+
ret = 0;
210210
if (!IS_ENABLED(CONFIG_NFS_V4_1) || minorversion == 0)
211211
ret = nfs4_callback_up_net(serv, net);
212-
else if (xprt->ops->bc_up)
213-
ret = xprt->ops->bc_up(serv, net);
212+
else if (xprt->ops->bc_setup)
213+
set_bc_enabled(serv);
214+
else
215+
ret = -EPROTONOSUPPORT;
214216

215217
if (ret < 0) {
216218
printk(KERN_ERR "NFS: callback service start failed\n");

‎fs/nfsd/nfs4layouts.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task)
656656
struct nfsd_net *nn;
657657
ktime_t now, cutoff;
658658
const struct nfsd4_layout_ops *ops;
659-
LIST_HEAD(reaplist);
660659

661660

662661
switch (task->tk_status) {

‎fs/nfsd/nfs4proc.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,7 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
863863
struct nfsd4_rename *rename = &u->rename;
864864
__be32 status;
865865

866-
if (opens_in_grace(SVC_NET(rqstp)) &&
867-
!(cstate->save_fh.fh_export->ex_flags & NFSEXP_NOSUBTREECHECK))
866+
if (opens_in_grace(SVC_NET(rqstp)))
868867
return nfserr_grace;
869868
status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname,
870869
rename->rn_snamelen, &cstate->current_fh,
@@ -1016,8 +1015,6 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
10161015

10171016
nvecs = svc_fill_write_vector(rqstp, write->wr_pagelist,
10181017
&write->wr_head, write->wr_buflen);
1019-
if (!nvecs)
1020-
return nfserr_io;
10211018
WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec));
10221019

10231020
status = nfsd_vfs_write(rqstp, &cstate->current_fh, filp,
@@ -1348,7 +1345,7 @@ static __be32
13481345
nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
13491346
struct nfsd4_fallocate *fallocate, int flags)
13501347
{
1351-
__be32 status = nfserr_notsupp;
1348+
__be32 status;
13521349
struct file *file;
13531350

13541351
status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh,
@@ -2682,25 +2679,25 @@ static const struct nfsd4_operation nfsd4_ops[] = {
26822679
/* NFSv4.2 operations */
26832680
[OP_ALLOCATE] = {
26842681
.op_func = nfsd4_allocate,
2685-
.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
2682+
.op_flags = OP_MODIFIES_SOMETHING,
26862683
.op_name = "OP_ALLOCATE",
26872684
.op_rsize_bop = nfsd4_only_status_rsize,
26882685
},
26892686
[OP_DEALLOCATE] = {
26902687
.op_func = nfsd4_deallocate,
2691-
.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
2688+
.op_flags = OP_MODIFIES_SOMETHING,
26922689
.op_name = "OP_DEALLOCATE",
26932690
.op_rsize_bop = nfsd4_only_status_rsize,
26942691
},
26952692
[OP_CLONE] = {
26962693
.op_func = nfsd4_clone,
2697-
.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
2694+
.op_flags = OP_MODIFIES_SOMETHING,
26982695
.op_name = "OP_CLONE",
26992696
.op_rsize_bop = nfsd4_only_status_rsize,
27002697
},
27012698
[OP_COPY] = {
27022699
.op_func = nfsd4_copy,
2703-
.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
2700+
.op_flags = OP_MODIFIES_SOMETHING,
27042701
.op_name = "OP_COPY",
27052702
.op_rsize_bop = nfsd4_copy_rsize,
27062703
},

‎fs/nfsd/nfs4recover.c‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ struct cld_net {
662662
struct cld_upcall {
663663
struct list_head cu_list;
664664
struct cld_net *cu_net;
665-
struct task_struct *cu_task;
665+
struct completion cu_done;
666666
struct cld_msg cu_msg;
667667
};
668668

@@ -671,23 +671,18 @@ __cld_pipe_upcall(struct rpc_pipe *pipe, struct cld_msg *cmsg)
671671
{
672672
int ret;
673673
struct rpc_pipe_msg msg;
674+
struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_msg);
674675

675676
memset(&msg, 0, sizeof(msg));
676677
msg.data = cmsg;
677678
msg.len = sizeof(*cmsg);
678679

679-
/*
680-
* Set task state before we queue the upcall. That prevents
681-
* wake_up_process in the downcall from racing with schedule.
682-
*/
683-
set_current_state(TASK_UNINTERRUPTIBLE);
684680
ret = rpc_queue_upcall(pipe, &msg);
685681
if (ret < 0) {
686-
set_current_state(TASK_RUNNING);
687682
goto out;
688683
}
689684

690-
schedule();
685+
wait_for_completion(&cup->cu_done);
691686

692687
if (msg.errno < 0)
693688
ret = msg.errno;
@@ -754,7 +749,7 @@ cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
754749
if (copy_from_user(&cup->cu_msg, src, mlen) != 0)
755750
return -EFAULT;
756751

757-
wake_up_process(cup->cu_task);
752+
complete(&cup->cu_done);
758753
return mlen;
759754
}
760755

@@ -769,7 +764,7 @@ cld_pipe_destroy_msg(struct rpc_pipe_msg *msg)
769764
if (msg->errno >= 0)
770765
return;
771766

772-
wake_up_process(cup->cu_task);
767+
complete(&cup->cu_done);
773768
}
774769

775770
static const struct rpc_pipe_ops cld_upcall_ops = {
@@ -900,7 +895,7 @@ alloc_cld_upcall(struct cld_net *cn)
900895
goto restart_search;
901896
}
902897
}
903-
new->cu_task = current;
898+
init_completion(&new->cu_done);
904899
new->cu_msg.cm_vers = CLD_UPCALL_VERSION;
905900
put_unaligned(cn->cn_xid++, &new->cu_msg.cm_xid);
906901
new->cu_net = cn;

‎fs/nfsd/nfs4state.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5112,7 +5112,7 @@ nfs4_find_file(struct nfs4_stid *s, int flags)
51125112
}
51135113

51145114
static __be32
5115-
nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags)
5115+
nfs4_check_olstateid(struct nfs4_ol_stateid *ols, int flags)
51165116
{
51175117
__be32 status;
51185118

@@ -5195,7 +5195,7 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
51955195
break;
51965196
case NFS4_OPEN_STID:
51975197
case NFS4_LOCK_STID:
5198-
status = nfs4_check_olstateid(fhp, openlockstateid(s), flags);
5198+
status = nfs4_check_olstateid(openlockstateid(s), flags);
51995199
break;
52005200
default:
52015201
status = nfserr_bad_stateid;
@@ -6230,15 +6230,15 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
62306230
case NFS4_READ_LT:
62316231
case NFS4_READW_LT:
62326232
file_lock->fl_type = F_RDLCK;
6233-
break;
6233+
break;
62346234
case NFS4_WRITE_LT:
62356235
case NFS4_WRITEW_LT:
62366236
file_lock->fl_type = F_WRLCK;
6237-
break;
6237+
break;
62386238
default:
62396239
dprintk("NFSD: nfs4_lockt: bad lock type!\n");
62406240
status = nfserr_inval;
6241-
goto out;
6241+
goto out;
62426242
}
62436243

62446244
lo = find_lockowner_str(cstate->clp, &lockt->lt_owner);

0 commit comments

Comments
 (0)