mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@amd.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: alexander.deucher@amd.com, christian.koenig@amd.com,
	Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org,
	Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] drm/amdkfd: Switch over to memdup_user()
Date: Wed, 14 Jun 2023 11:11:30 -0400	[thread overview]
Message-ID: <56f6f771-8ccc-ec91-e4dc-f4841bce38c5@amd.com> (raw)
In-Reply-To: <20230614020432.44044-1-jiapeng.chong@linux.alibaba.com>


Am 2023-06-13 um 22:04 schrieb Jiapeng Chong:
> Use memdup_user() rather than duplicating its implementation. This is a
> little bit restricted to reduce false positives.
>
> ./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2813:13-20: WARNING opportunity for memdup_user.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5523
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Kernel test robot is reporting a failure with this patch, looks like you 
used PTR_ERR incorrectly. Please make sure your patch compiles without 
warnings.

I see more opportunities to use memdup_user in kfd_chardev.c, 
kfd_events.c, kfd_process_queue_manager.c and kfd_svm.c. Do you want to 
fix those, too, while you're at it?

Thanks,
   Felix


> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index d6b15493fffd..637962d4083c 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -2810,12 +2810,9 @@ static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array
>   	if (!usr_queue_id_array)
>   		return NULL;
>   
> -	queue_ids = kzalloc(array_size, GFP_KERNEL);
> -	if (!queue_ids)
> -		return ERR_PTR(-ENOMEM);
> -
> -	if (copy_from_user(queue_ids, usr_queue_id_array, array_size))
> -		return ERR_PTR(-EFAULT);
> +	queue_ids = memdup_user(usr_queue_id_array, array_size);
> +	if (IS_ERR(queue_ids))
> +		return PTR_ERR(queue_ids);
>   
>   	return queue_ids;
>   }

  parent reply	other threads:[~2023-06-14 15:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14  2:04 Jiapeng Chong
2023-06-14 12:21 ` kernel test robot
2023-06-14 15:11 ` Felix Kuehling [this message]
2023-06-15  6:32 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56f6f771-8ccc-ec91-e4dc-f4841bce38c5@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=abaci@linux.alibaba.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®