Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "songliubraving@fb.com" <songliubraving@fb.com>,
	"hawk@kernel.org" <hawk@kernel.org>,
	"kafai@fb.com" <kafai@fb.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kpsingh@chromium.org" <kpsingh@chromium.org>,
	"john.fastabend@gmail.com" <john.fastabend@gmail.com>,
	"leon@kernel.org" <leon@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"ast@kernel.org" <ast@kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"xiongx18@fudan.edu.cn" <xiongx18@fudan.edu.cn>,
	"yhs@fb.com" <yhs@fb.com>, "andriin@fb.com" <andriin@fb.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "xiyuyang19@fudan.edu.cn" <xiyuyang19@fudan.edu.cn>,
	"tanxin.ctf@gmail.com" <tanxin.ctf@gmail.com>,
	"yuanxzhang@fudan.edu.cn" <yuanxzhang@fudan.edu.cn>
Subject: Re: [PATCH] net/mlx5e: fix bpf_prog refcnt leaks in mlx5e_alloc_rq
Date: Wed, 29 Jul 2020 19:02:15 +0000
Message-ID: <613fe5f56cb60982937c826ed915ada2de5e93a2.camel@mellanox.com> (raw)
In-Reply-To: <20200729123334.GA6766@xin-virtual-machine>

On Wed, 2020-07-29 at 20:33 +0800, Xin Xiong wrote:
> The function invokes bpf_prog_inc(), which increases the refcount of
> a
> bpf_prog object "rq->xdp_prog" if the object isn't NULL.
> 
> The refcount leak issues take place in two error handling paths. When
> mlx5_wq_ll_create() or mlx5_wq_cyc_create() fails, the function
> simply
> returns the error code and forgets to drop the refcount increased
> earlier, causing a refcount leak of "rq->xdp_prog".
> 
> Fix this issue by jumping to the error handling path
> err_rq_wq_destroy
> when either function fails.
> 

Fixes: 422d4c401edd ("net/mlx5e: RX, Split WQ objects for different RQ
types")

> 
> Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index a836a02a2116..8e1b1ab416d8 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -419,7 +419,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel
> *c,
>  		err = mlx5_wq_ll_create(mdev, &rqp->wq, rqc_wq, &rq-
> >mpwqe.wq,
>  					&rq->wq_ctrl);
>  		if (err)
> -			return err;
> +			goto err_rq_wq_destroy;
>  
>  		rq->mpwqe.wq.db = &rq->mpwqe.wq.db[MLX5_RCV_DBR];
>  
> @@ -470,7 +470,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel
> *c,
>  		err = mlx5_wq_cyc_create(mdev, &rqp->wq, rqc_wq, &rq-
> >wqe.wq,
>  					 &rq->wq_ctrl);
>  		if (err)
> -			return err;
> +			goto err_rq_wq_destroy;
>  
>  		rq->wqe.wq.db = &rq->wqe.wq.db[MLX5_RCV_DBR];
>  

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 12:33 Xin Xiong
2020-07-29 19:02 ` Saeed Mahameed [this message]
2020-07-29 20:28   ` David Miller
2020-07-29 20:51     ` Saeed Mahameed

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=613fe5f56cb60982937c826ed915ada2de5e93a2.camel@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=tanxin.ctf@gmail.com \
    --cc=xiongx18@fudan.edu.cn \
    --cc=xiyuyang19@fudan.edu.cn \
    --cc=yhs@fb.com \
    --cc=yuanxzhang@fudan.edu.cn \
    /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

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git