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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR12MB5381316B1E76612838BBB762AF769@BN9PR12MB5381.namprd12.prod.outlook.com>
Date:   Tue, 9 May 2023 09:35:51 +0000
From:   Vadim Pasternak <vadimp@...dia.com>
To:     Liming Sun <limings@...dia.com>,
        David Thompson <davthompson@...dia.com>,
        Hans de Goede <hdegoede@...hat.com>,
        Mark Gross <markgross@...nel.org>
CC:     "platform-driver-x86@...r.kernel.org" 
        <platform-driver-x86@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v1 1/1] platform/mellanox: fix potential race in
 mlxbf-tmfifo driver



> -----Original Message-----
> From: Liming Sun <limings@...dia.com>
> Sent: Wednesday, 26 April 2023 17:24
> To: Vadim Pasternak <vadimp@...dia.com>; David Thompson
> <davthompson@...dia.com>; Hans de Goede <hdegoede@...hat.com>;
> Mark Gross <markgross@...nel.org>
> Cc: Liming Sun <limings@...dia.com>; platform-driver-x86@...r.kernel.org;
> linux-kernel@...r.kernel.org
> Subject: [PATCH v1 1/1] platform/mellanox: fix potential race in mlxbf-tmfifo
> driver
> 
> This commit adds memory barrier for the 'vq' update in function
> mlxbf_tmfifo_virtio_find_vqs() to avoid potential race due to out-of-order
> memory write. It also adds barrier for the 'is_ready'
> flag to make sure the initializations are visible before this flag is checked.
> 
> Signed-off-by: Liming Sun <limings@...dia.com>

Reviewed-by: Vadim Pasternak <vadimp@...dia.com>

> ---
>  drivers/platform/mellanox/mlxbf-tmfifo.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c
> b/drivers/platform/mellanox/mlxbf-tmfifo.c
> index 91a077c35b8b..a79318e90a13 100644
> --- a/drivers/platform/mellanox/mlxbf-tmfifo.c
> +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
> @@ -784,7 +784,7 @@ static void mlxbf_tmfifo_rxtx(struct
> mlxbf_tmfifo_vring *vring, bool is_rx)
>  	fifo = vring->fifo;
> 
>  	/* Return if vdev is not ready. */
> -	if (!fifo->vdev[devid])
> +	if (!fifo || !fifo->vdev[devid])
>  		return;
> 
>  	/* Return if another vring is running. */ @@ -980,9 +980,13 @@
> static int mlxbf_tmfifo_virtio_find_vqs(struct virtio_device *vdev,
> 
>  		vq->num_max = vring->num;
> 
> +		vq->priv = vring;
> +
> +		/* Make vq update visible before using it. */
> +		virtio_mb(false);
> +
>  		vqs[i] = vq;
>  		vring->vq = vq;
> -		vq->priv = vring;
>  	}
> 
>  	return 0;
> @@ -1302,6 +1306,9 @@ static int mlxbf_tmfifo_probe(struct
> platform_device *pdev)
> 
>  	mod_timer(&fifo->timer, jiffies + MLXBF_TMFIFO_TIMER_INTERVAL);
> 
> +	/* Make all updates visible before setting the 'is_ready' flag. */
> +	virtio_mb(false);
> +
>  	fifo->is_ready = true;
>  	return 0;
> 
> --
> 2.30.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ