Linux NFS development
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "niejianglei2021@163.com" <niejianglei2021@163.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"chuck.lever@oracle.com" <chuck.lever@oracle.com>,
	"anna@kernel.org" <anna@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"jlayton@kernel.org" <jlayton@kernel.org>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] SUNRPC: Fix potential memory leak in xs_udp_send_request()
Date: Wed, 7 Sep 2022 13:30:30 +0000	[thread overview]
Message-ID: <9bb5ce3a9949b8a51fcacc52e42ff529a9f04b3f.camel@hammerspace.com> (raw)
In-Reply-To: <1e0877bc528f3e9218f0070889c7288a8aaa47ba.camel@kernel.org>

On Wed, 2022-09-07 at 06:08 -0400, Jeff Layton wrote:
> 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>

No, this patch is unnecessary and won't be applied. We already do this
for all transports in xprt_request_dequeue_transmit().

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



      reply	other threads:[~2022-09-07 13:30 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
2022-09-07 13:30   ` Trond Myklebust [this message]

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=9bb5ce3a9949b8a51fcacc52e42ff529a9f04b3f.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jlayton@kernel.org \
    --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 \
    /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