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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231220164050.GN882741@kernel.org>
Date: Wed, 20 Dec 2023 17:40:50 +0100
From: Simon Horman <horms@...nel.org>
To: David Wei <dw@...idwei.uk>
Cc: Jakub Kicinski <kuba@...nel.org>, Jiri Pirko <jiri@...nulli.us>,
	Sabrina Dubroca <sd@...asysnail.net>, netdev@...r.kernel.org,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next v4 1/5] netdevsim: maintain a list of probed
 netdevsims

On Tue, Dec 19, 2023 at 05:47:43PM -0800, David Wei wrote:
> This patch adds a linked list nsim_dev_list of probed netdevsims, added
> during nsim_drv_probe() and removed during nsim_drv_remove(). A mutex
> nsim_dev_list_lock protects the list.
> 
> Signed-off-by: David Wei <dw@...idwei.uk>
> ---
>  drivers/net/netdevsim/dev.c       | 17 +++++++++++++++++
>  drivers/net/netdevsim/netdevsim.h |  1 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
> index b4d3b9cde8bd..e30a12130e07 100644
> --- a/drivers/net/netdevsim/dev.c
> +++ b/drivers/net/netdevsim/dev.c
> @@ -35,6 +35,9 @@
>  
>  #include "netdevsim.h"
>  
> +static LIST_HEAD(nsim_dev_list);
> +static DEFINE_MUTEX(nsim_dev_list_lock);
> +
>  static unsigned int
>  nsim_dev_port_index(enum nsim_dev_port_type type, unsigned int port_index)
>  {
> @@ -1531,6 +1534,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>  				 nsim_bus_dev->initial_net, &nsim_bus_dev->dev);
>  	if (!devlink)
>  		return -ENOMEM;
> +	mutex_lock(&nsim_dev_list_lock);
>  	devl_lock(devlink);
>  	nsim_dev = devlink_priv(devlink);
>  	nsim_dev->nsim_bus_dev = nsim_bus_dev;
> @@ -1544,6 +1548,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>  	spin_lock_init(&nsim_dev->fa_cookie_lock);
>  
>  	dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
> +	list_add(&nsim_dev->list, &nsim_dev_list);
>  
>  	nsim_dev->vfconfigs = kcalloc(nsim_bus_dev->max_vfs,
>  				      sizeof(struct nsim_vf_config),
> @@ -1607,6 +1612,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>  
>  	nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY;
>  	devl_unlock(devlink);
> +	mutex_unlock(&nsim_dev_list_lock);
>  	return 0;
>  

Hi David,

I see Jiri has asked about the scope and type of this lock.
And updates to address those questions may obviate my observation.
But it is that mutex_unlock(&nsim_dev_list_lock); needs to
be added to the unwind ladder:

	...
err_devlink_unlock:
	devl_unlock(devlink);
	mutex_unlock(&nsim_dev_list_lock);
	...

...

Flagged by Smatch.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ