* [PATCH v4 1/3] SUNRPC: call_connect_status() must handle tasks that got transmitted
@ 2018-11-30 22:49 Trond Myklebust
2018-11-30 22:49 ` [PATCH v4 2/3] SUNRPC: Fix leak of krb5p encode pages Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2018-11-30 22:49 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
If a task failed to get the write lock in the call to xprt_connect(), then
it will be queued on xprt->sending. In that case, it is possible for it
to get transmitted before the call to call_connect_status(), in which
case it needs to be handled by call_transmit_status() instead.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
net/sunrpc/clnt.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index ae3b8145da35..e35d642558e7 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1915,6 +1915,13 @@ call_connect_status(struct rpc_task *task)
struct rpc_clnt *clnt = task->tk_client;
int status = task->tk_status;
+ /* Check if the task was already transmitted */
+ if (!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) {
+ xprt_end_transmit(task);
+ task->tk_action = call_transmit_status;
+ return;
+ }
+
dprint_status(task);
trace_rpc_connect_status(task);
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4 2/3] SUNRPC: Fix leak of krb5p encode pages
2018-11-30 22:49 [PATCH v4 1/3] SUNRPC: call_connect_status() must handle tasks that got transmitted Trond Myklebust
@ 2018-11-30 22:49 ` Trond Myklebust
2018-11-30 22:49 ` [PATCH v4 3/3] SUNRPC: Fix a memory leak in call_encode() Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2018-11-30 22:49 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
From: Chuck Lever <chuck.lever@oracle.com>
call_encode can be invoked more than once per RPC call. Ensure that
each call to gss_wrap_req_priv does not overwrite pointers to
previously allocated memory.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: stable@kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
net/sunrpc/auth_gss/auth_gss.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 5d3f252659f1..ba765473d1f0 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -1791,6 +1791,7 @@ priv_release_snd_buf(struct rpc_rqst *rqstp)
for (i=0; i < rqstp->rq_enc_pages_num; i++)
__free_page(rqstp->rq_enc_pages[i]);
kfree(rqstp->rq_enc_pages);
+ rqstp->rq_release_snd_buf = NULL;
}
static int
@@ -1799,6 +1800,9 @@ alloc_enc_pages(struct rpc_rqst *rqstp)
struct xdr_buf *snd_buf = &rqstp->rq_snd_buf;
int first, last, i;
+ if (rqstp->rq_release_snd_buf)
+ rqstp->rq_release_snd_buf(rqstp);
+
if (snd_buf->page_len == 0) {
rqstp->rq_enc_pages_num = 0;
return 0;
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4 3/3] SUNRPC: Fix a memory leak in call_encode()
2018-11-30 22:49 ` [PATCH v4 2/3] SUNRPC: Fix leak of krb5p encode pages Trond Myklebust
@ 2018-11-30 22:49 ` Trond Myklebust
0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2018-11-30 22:49 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
If we retransmit an RPC request, we currently end up clobbering the
value of req->rq_rcv_buf.bvec that was allocated by the initial call to
xprt_request_prepare(req).
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
include/linux/sunrpc/xdr.h | 1 -
net/sunrpc/clnt.c | 1 +
net/sunrpc/xprt.c | 2 ++
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 43106ffa6788..2ec128060239 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -72,7 +72,6 @@ xdr_buf_init(struct xdr_buf *buf, void *start, size_t len)
buf->head[0].iov_base = start;
buf->head[0].iov_len = len;
buf->tail[0].iov_len = 0;
- buf->bvec = NULL;
buf->pages = NULL;
buf->page_len = 0;
buf->flags = 0;
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index e35d642558e7..c6782aa47525 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -2309,6 +2309,7 @@ call_decode(struct rpc_task *task)
task->tk_status = 0;
/* Note: rpc_verify_header() may have freed the RPC slot */
if (task->tk_rqstp == req) {
+ xdr_free_bvec(&req->rq_rcv_buf);
req->rq_reply_bytes_recvd = req->rq_rcv_buf.len = 0;
if (task->tk_client->cl_discrtry)
xprt_conditional_disconnect(req->rq_xprt,
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 86bea4520c4d..122c91c28e7c 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1623,6 +1623,8 @@ xprt_request_init(struct rpc_task *task)
req->rq_snd_buf.buflen = 0;
req->rq_rcv_buf.len = 0;
req->rq_rcv_buf.buflen = 0;
+ req->rq_snd_buf.bvec = NULL;
+ req->rq_rcv_buf.bvec = NULL;
req->rq_release_snd_buf = NULL;
xprt_reset_majortimeo(req);
dprintk("RPC: %5u reserved req %p xid %08x\n", task->tk_pid,
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-30 22:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-30 22:49 [PATCH v4 1/3] SUNRPC: call_connect_status() must handle tasks that got transmitted Trond Myklebust
2018-11-30 22:49 ` [PATCH v4 2/3] SUNRPC: Fix leak of krb5p encode pages Trond Myklebust
2018-11-30 22:49 ` [PATCH v4 3/3] SUNRPC: Fix a memory leak in call_encode() Trond Myklebust
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox