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: <f38e4782-1959-d1f3-e8d7-f60e199514e3@amd.com>
Date:   Thu, 31 Mar 2022 10:44:40 -0400
From:   Felix Kuehling <felix.kuehling@....com>
To:     Lee Jones <lee.jones@...aro.org>
Cc:     linux-kernel@...r.kernel.org,
        Alex Deucher <alexander.deucher@....com>,
        Christian König <christian.koenig@....com>,
        "Pan, Xinhui" <Xinhui.Pan@....com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>, amd-gfx@...ts.freedesktop.org,
        dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v2 1/1] drm/amdkfd: Create file descriptor after client is
 added to smi_clients list


Am 2022-03-31 um 08:21 schrieb Lee Jones:
> This ensures userspace cannot prematurely clean-up the client before
> it is fully initialised which has been proven to cause issues in the
> past.
>
> Cc: Felix Kuehling <Felix.Kuehling@....com>
> Cc: Alex Deucher <alexander.deucher@....com>
> Cc: "Christian König" <christian.koenig@....com>
> Cc: "Pan, Xinhui" <Xinhui.Pan@....com>
> Cc: David Airlie <airlied@...ux.ie>
> Cc: Daniel Vetter <daniel@...ll.ch>
> Cc: amd-gfx@...ts.freedesktop.org
> Cc: dri-devel@...ts.freedesktop.org
> Signed-off-by: Lee Jones <lee.jones@...aro.org>

Reviewed-by: Felix Kuehling <Felix.Kuehling@....com>

I will apply to patch to amd-staging-drm-next.

> ---
>
> CAVEAT: This patch is completely untested
>          I can't seem to find a configuration strategy to compile test this
>          allyesconfig and allmodconfig do not appear sufficient

That's very strange. It should get compiled if CONFIG_HSA_AMD is 
enabled. I will at least compile-test it before I submit.

Regards,
   Felix


>
> v2: Also remove Client from RCU list in error path
>
>   drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 24 +++++++++++++--------
>   1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
> index e4beebb1c80a2..f2e1d506ba211 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
> @@ -247,15 +247,6 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
>   		return ret;
>   	}
>   
> -	ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
> -			       O_RDWR);
> -	if (ret < 0) {
> -		kfifo_free(&client->fifo);
> -		kfree(client);
> -		return ret;
> -	}
> -	*fd = ret;
> -
>   	init_waitqueue_head(&client->wait_queue);
>   	spin_lock_init(&client->lock);
>   	client->events = 0;
> @@ -265,5 +256,20 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd)
>   	list_add_rcu(&client->list, &dev->smi_clients);
>   	spin_unlock(&dev->smi_lock);
>   
> +	ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client,
> +			       O_RDWR);
> +	if (ret < 0) {
> +		spin_lock(&dev->smi_lock);
> +		list_del_rcu(&client->list);
> +		spin_unlock(&dev->smi_lock);
> +
> +		synchronize_rcu();
> +
> +		kfifo_free(&client->fifo);
> +		kfree(client);
> +		return ret;
> +	}
> +	*fd = ret;
> +
>   	return 0;
>   }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ