From: Jeff Layton <jlayton@kernel.org>
To: Jianglei Nie <niejianglei2021@163.com>,
chuck.lever@oracle.com, trond.myklebust@hammerspace.com,
anna@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] SUNRPC: Fix potential memory leak in xs_udp_send_request()
Date: Wed, 07 Sep 2022 06:08:25 -0400 [thread overview]
Message-ID: <1e0877bc528f3e9218f0070889c7288a8aaa47ba.camel@kernel.org> (raw)
In-Reply-To: <20220907071338.56969-1-niejianglei2021@163.com>
On Wed, 2022-09-07 at 15:13 +0800, Jianglei Nie wrote:
> xs_udp_send_request() allocates a memory chunk for xdr->bvec with
> xdr_alloc_bvec(). When xprt_sock_sendmsg() finishs, xdr->bvec is not
> released, which will lead to a memory leak.
>
> we should release the xdr->bvec with xdr_free_bvec() after
> xprt_sock_sendmsg() like bc_sendto() does.
>
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> ---
> net/sunrpc/xprtsock.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> index e976007f4fd0..298182a3c168 100644
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -958,6 +958,7 @@ static int xs_udp_send_request(struct rpc_rqst *req)
> return status;
> req->rq_xtime = ktime_get();
> status = xprt_sock_sendmsg(transport->sock, &msg, xdr, 0, 0, &sent);
> + xdr_free_bvec(xdr);
>
> dprintk("RPC: xs_udp_send_request(%u) = %d\n",
> xdr->len, status);
I think you're probably correct here.
I was thinking we might have a similar bug in svc_tcp_sendmsg, but it
looks like that one gets freed in svc_tcp_sendto.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2022-09-07 10:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 7:13 [PATCH] SUNRPC: Fix potential memory leak in xs_udp_send_request() Jianglei Nie
2022-09-07 10:08 ` Jeff Layton [this message]
2022-09-07 13:30 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e0877bc528f3e9218f0070889c7288a8aaa47ba.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=anna@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=niejianglei2021@163.com \
--cc=pabeni@redhat.com \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox