Commit 459aa077 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'nfs-for-5.2-2' of git://git.linux-nfs.org/projects/anna/linux-nfs

Pull NFS client fixes from Anna Schumaker:
 "These are mostly stable bugfixes found during testing, many during the
  recent NFS bake-a-thon.

  Stable bugfixes:
   - SUNRPC: Fix regression in umount of a secure mount
   - SUNRPC: Fix a use after free when a server rejects the RPCSEC_GSS credential
   - NFSv4.1: Again fix a race where CB_NOTIFY_LOCK fails to wake a waiter
   - NFSv4.1: Fix bug only first CB_NOTIFY_LOCK is handled

  Other bugfixes:
   - xprtrdma: Use struct_size() in kzalloc()"

* tag 'nfs-for-5.2-2' of git://git.linux-nfs.org/projects/anna/linux-nfs:
  NFSv4.1: Fix bug only first CB_NOTIFY_LOCK is handled
  NFSv4.1: Again fix a race where CB_NOTIFY_LOCK fails to wake a waiter
  SUNRPC: Fix a use after free when a server rejects the RPCSEC_GSS credential
  SUNRPC fix regression in umount of a secure mount
  xprtrdma: Use struct_size() in kzalloc()
parents 44e843eb ba851a39
...@@ -6932,7 +6932,6 @@ struct nfs4_lock_waiter { ...@@ -6932,7 +6932,6 @@ struct nfs4_lock_waiter {
struct task_struct *task; struct task_struct *task;
struct inode *inode; struct inode *inode;
struct nfs_lowner *owner; struct nfs_lowner *owner;
bool notified;
}; };
static int static int
...@@ -6954,13 +6953,13 @@ nfs4_wake_lock_waiter(wait_queue_entry_t *wait, unsigned int mode, int flags, vo ...@@ -6954,13 +6953,13 @@ nfs4_wake_lock_waiter(wait_queue_entry_t *wait, unsigned int mode, int flags, vo
/* Make sure it's for the right inode */ /* Make sure it's for the right inode */
if (nfs_compare_fh(NFS_FH(waiter->inode), &cbnl->cbnl_fh)) if (nfs_compare_fh(NFS_FH(waiter->inode), &cbnl->cbnl_fh))
return 0; return 0;
waiter->notified = true;
} }
/* override "private" so we can use default_wake_function */ /* override "private" so we can use default_wake_function */
wait->private = waiter->task; wait->private = waiter->task;
ret = autoremove_wake_function(wait, mode, flags, key); ret = woken_wake_function(wait, mode, flags, key);
if (ret)
list_del_init(&wait->entry);
wait->private = waiter; wait->private = waiter;
return ret; return ret;
} }
...@@ -6969,7 +6968,6 @@ static int ...@@ -6969,7 +6968,6 @@ static int
nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
{ {
int status = -ERESTARTSYS; int status = -ERESTARTSYS;
unsigned long flags;
struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner; struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner;
struct nfs_server *server = NFS_SERVER(state->inode); struct nfs_server *server = NFS_SERVER(state->inode);
struct nfs_client *clp = server->nfs_client; struct nfs_client *clp = server->nfs_client;
...@@ -6979,8 +6977,7 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) ...@@ -6979,8 +6977,7 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
.s_dev = server->s_dev }; .s_dev = server->s_dev };
struct nfs4_lock_waiter waiter = { .task = current, struct nfs4_lock_waiter waiter = { .task = current,
.inode = state->inode, .inode = state->inode,
.owner = &owner, .owner = &owner};
.notified = false };
wait_queue_entry_t wait; wait_queue_entry_t wait;
/* Don't bother with waitqueue if we don't expect a callback */ /* Don't bother with waitqueue if we don't expect a callback */
...@@ -6990,27 +6987,22 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) ...@@ -6990,27 +6987,22 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
init_wait(&wait); init_wait(&wait);
wait.private = &waiter; wait.private = &waiter;
wait.func = nfs4_wake_lock_waiter; wait.func = nfs4_wake_lock_waiter;
add_wait_queue(q, &wait);
while(!signalled()) { while(!signalled()) {
waiter.notified = false; add_wait_queue(q, &wait);
status = nfs4_proc_setlk(state, cmd, request); status = nfs4_proc_setlk(state, cmd, request);
if ((status != -EAGAIN) || IS_SETLK(cmd)) if ((status != -EAGAIN) || IS_SETLK(cmd)) {
finish_wait(q, &wait);
break; break;
status = -ERESTARTSYS;
spin_lock_irqsave(&q->lock, flags);
if (waiter.notified) {
spin_unlock_irqrestore(&q->lock, flags);
continue;
} }
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irqrestore(&q->lock, flags);
freezable_schedule_timeout(NFS4_LOCK_MAXTIMEOUT); status = -ERESTARTSYS;
freezer_do_not_count();
wait_woken(&wait, TASK_INTERRUPTIBLE, NFS4_LOCK_MAXTIMEOUT);
freezer_count();
finish_wait(q, &wait);
} }
finish_wait(q, &wait);
return status; return status;
} }
#else /* !CONFIG_NFS_V4_1 */ #else /* !CONFIG_NFS_V4_1 */
......
...@@ -2288,13 +2288,13 @@ call_status(struct rpc_task *task) ...@@ -2288,13 +2288,13 @@ call_status(struct rpc_task *task)
case -ECONNREFUSED: case -ECONNREFUSED:
case -ECONNRESET: case -ECONNRESET:
case -ECONNABORTED: case -ECONNABORTED:
case -ENOTCONN:
rpc_force_rebind(clnt); rpc_force_rebind(clnt);
/* fall through */ /* fall through */
case -EADDRINUSE: case -EADDRINUSE:
rpc_delay(task, 3*HZ); rpc_delay(task, 3*HZ);
/* fall through */ /* fall through */
case -EPIPE: case -EPIPE:
case -ENOTCONN:
case -EAGAIN: case -EAGAIN:
break; break;
case -EIO: case -EIO:
...@@ -2426,17 +2426,21 @@ call_decode(struct rpc_task *task) ...@@ -2426,17 +2426,21 @@ call_decode(struct rpc_task *task)
return; return;
case -EAGAIN: case -EAGAIN:
task->tk_status = 0; task->tk_status = 0;
/* Note: rpc_decode_header() may have freed the RPC slot */ xdr_free_bvec(&req->rq_rcv_buf);
if (task->tk_rqstp == req) { req->rq_reply_bytes_recvd = 0;
xdr_free_bvec(&req->rq_rcv_buf); req->rq_rcv_buf.len = 0;
req->rq_reply_bytes_recvd = 0; if (task->tk_client->cl_discrtry)
req->rq_rcv_buf.len = 0; xprt_conditional_disconnect(req->rq_xprt,
if (task->tk_client->cl_discrtry) req->rq_connect_cookie);
xprt_conditional_disconnect(req->rq_xprt,
req->rq_connect_cookie);
}
task->tk_action = call_encode; task->tk_action = call_encode;
rpc_check_timeout(task); rpc_check_timeout(task);
break;
case -EKEYREJECTED:
task->tk_action = call_reserve;
rpc_check_timeout(task);
rpcauth_invalcred(task);
/* Ensure we obtain a new XID if we retry! */
xprt_release(task);
} }
} }
...@@ -2572,11 +2576,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr) ...@@ -2572,11 +2576,7 @@ rpc_decode_header(struct rpc_task *task, struct xdr_stream *xdr)
break; break;
task->tk_cred_retry--; task->tk_cred_retry--;
trace_rpc__stale_creds(task); trace_rpc__stale_creds(task);
rpcauth_invalcred(task); return -EKEYREJECTED;
/* Ensure we obtain a new XID! */
xprt_release(task);
task->tk_action = call_reserve;
return -EAGAIN;
case rpc_autherr_badcred: case rpc_autherr_badcred:
case rpc_autherr_badverf: case rpc_autherr_badverf:
/* possibly garbled cred/verf? */ /* possibly garbled cred/verf? */
......
...@@ -810,8 +810,7 @@ static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ia *ia) ...@@ -810,8 +810,7 @@ static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ia *ia)
{ {
struct rpcrdma_sendctx *sc; struct rpcrdma_sendctx *sc;
sc = kzalloc(sizeof(*sc) + sc = kzalloc(struct_size(sc, sc_sges, ia->ri_max_send_sges),
ia->ri_max_send_sges * sizeof(struct ib_sge),
GFP_KERNEL); GFP_KERNEL);
if (!sc) if (!sc)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment