lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6efeeada-f514-4d30-909c-39a5786764f9@stanley.mountain>
Date: Wed, 4 Dec 2024 15:04:55 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Tariq Toukan <ttoukan.linux@...il.com>
Cc: Yevgeny Kliteynik <kliteyn@...dia.com>,
	Saeed Mahameed <saeedm@...dia.com>,
	Leon Romanovsky <leon@...nel.org>, Tariq Toukan <tariqt@...dia.com>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Muhammad Sammar <muhammads@...dia.com>, netdev@...r.kernel.org,
	linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH v2 net] net/mlx5: DR, prevent potential error pointer
 dereference

On Wed, Dec 04, 2024 at 01:42:14PM +0200, Tariq Toukan wrote:
> 
> 
> On 03/12/2024 11:45, Dan Carpenter wrote:
> > The dr_domain_add_vport_cap() function generally returns NULL on error
> > but sometimes we want it to return ERR_PTR(-EBUSY) so the caller can
> > retry.  The problem here is that "ret" can be either -EBUSY or -ENOMEM
> > and if it's and -ENOMEM then the error pointer is propogated back and
> > eventually dereferenced in dr_ste_v0_build_src_gvmi_qpn_tag().
> > 
> > Fixes: 11a45def2e19 ("net/mlx5: DR, Add support for SF vports")
> > Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> > Reviewed-by: Yevgeny Kliteynik <kliteyn@...dia.com>
> > ---
> > v2: Fix a typo in the commit message.  "generally".
> > 
> >   .../net/ethernet/mellanox/mlx5/core/steering/sws/dr_domain.c    | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_domain.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_domain.c
> > index 3d74109f8230..a379e8358f82 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_domain.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_domain.c
> > @@ -297,6 +297,8 @@ dr_domain_add_vport_cap(struct mlx5dr_domain *dmn, u16 vport)
> >   	if (ret) {
> >   		mlx5dr_dbg(dmn, "Couldn't insert new vport into xarray (%d)\n", ret);
> >   		kvfree(vport_caps);
> > +		if (ret != -EBUSY)
> > +			return NULL;
> >   		return ERR_PTR(ret);
> >   	}
> 
> Thanks for your patch.
> 
> It would be clearer to the reader if you test against -EBUSY and return
> ERR_PTR(-EBUSY).
> Otherwise, return NULL.
> 
> Or at least modify ERR_PTR(ret) to be ERR_PTR(-EBUSY).
> 
> Keeping "return ERR_PTR(ret);" does not make it clear that we have only 2
> possible return values here.

Sure, that's a good point.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ