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: <9632c958-9c35-4282-9e20-ce84d10a6b20@suswa.mountain>
Date: Mon, 12 May 2025 17:58:58 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Thomas Andreatta <thomasandreatta2000@...il.com>
Cc: dpenkler@...il.com, gregkh@...uxfoundation.org,
	linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev,
	Thomas Andreatta <thomas.andreatta2000@...il.com>
Subject: Re: [PATCH] Staging: gpib: iblib: iboffline check if board is in use

On Sat, May 10, 2025 at 07:24:20PM +0200, Thomas Andreatta wrote:
> Ensures that a board cannot be taken offline while it's still in use.
> 
> Signed-off-by: Thomas Andreatta <thomas.andreatta2000@...il.com>
> ---
>  drivers/staging/gpib/common/iblib.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/gpib/common/iblib.c b/drivers/staging/gpib/common/iblib.c
> index 7a44517464ab..0ab5680457ac 100644
> --- a/drivers/staging/gpib/common/iblib.c
> +++ b/drivers/staging/gpib/common/iblib.c
> @@ -240,7 +240,6 @@ int ibonline(struct gpib_board *board)
>  	return 0;
>  }
>  
> -/* XXX need to make sure board is generally not in use (grab board lock?) */
>  int iboffline(struct gpib_board *board)
>  {
>  	int retval;
> @@ -250,6 +249,15 @@ int iboffline(struct gpib_board *board)
>  	if (!board->interface)
>  		return -ENODEV;
>  
> +	/* Ensure board is not in use */
> +	if (mutex_lock_interruptible(&board->user_mutex))
> +		return -ERESTARTSYS;
> +
> +	if (board->use_count > 0) {

We're not holding this mutex in ibopen() and not necessarily
in ibclose() either so this doesn't work.  It's racy.

You'd have to change the ioctl as well.

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ