All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: XueBing Chen <chenxuebing@jari.cn>
Cc: gustavo@padovan.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, christian.koenig@amd.com,
	linaro-mm-sig@lists.linaro.org, sumit.semwal@linaro.org,
	linux-media@vger.kernel.org
Subject: Re: [Linaro-mm-sig] [PATCH] dma-buf/sync_file: use strscpy to replace strlcpy
Date: Wed, 10 Aug 2022 13:51:20 +0200	[thread overview]
Message-ID: <YvObuLevnEWEITnS@phenom.ffwll.local> (raw)
In-Reply-To: <6aad3bff.d1a.181b982d1b1.Coremail.chenxuebing@jari.cn>

On Fri, Jul 01, 2022 at 07:26:07PM +0800, XueBing Chen wrote:
> 
> The strlcpy should not be used because it doesn't limit the source
> length. Preferred is strscpy.
> 
> Signed-off-by: XueBing Chen <chenxuebing@jari.cn>

I don't think there's an impact here since we don't check the error return
value, but also doesn't hurt.

Thanks for your patch, applied to drm-misc-next.
-Daniel

> ---
>  drivers/dma-buf/sync_file.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index 3ebec19a8e02..af57799c86ce 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -132,7 +132,7 @@ EXPORT_SYMBOL(sync_file_get_fence);
>  char *sync_file_get_name(struct sync_file *sync_file, char *buf, int len)
>  {
>  	if (sync_file->user_name[0]) {
> -		strlcpy(buf, sync_file->user_name, len);
> +		strscpy(buf, sync_file->user_name, len);
>  	} else {
>  		struct dma_fence *fence = sync_file->fence;
>  
> @@ -172,7 +172,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
>  		return NULL;
>  	}
>  	sync_file->fence = fence;
> -	strlcpy(sync_file->user_name, name, sizeof(sync_file->user_name));
> +	strscpy(sync_file->user_name, name, sizeof(sync_file->user_name));
>  	return sync_file;
>  }
>  
> @@ -262,9 +262,9 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
>  static int sync_fill_fence_info(struct dma_fence *fence,
>  				 struct sync_fence_info *info)
>  {
> -	strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
> +	strscpy(info->obj_name, fence->ops->get_timeline_name(fence),
>  		sizeof(info->obj_name));
> -	strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
> +	strscpy(info->driver_name, fence->ops->get_driver_name(fence),
>  		sizeof(info->driver_name));
>  
>  	info->status = dma_fence_get_status(fence);
> -- 
> 2.25.1
> _______________________________________________
> Linaro-mm-sig mailing list -- linaro-mm-sig@lists.linaro.org
> To unsubscribe send an email to linaro-mm-sig-leave@lists.linaro.org

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: XueBing Chen <chenxuebing@jari.cn>
Cc: sumit.semwal@linaro.org, christian.koenig@amd.com,
	gustavo@padovan.org, linux-media@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
	linux-kernel@vger.kernel.org
Subject: Re: [Linaro-mm-sig] [PATCH] dma-buf/sync_file: use strscpy to replace strlcpy
Date: Wed, 10 Aug 2022 13:51:20 +0200	[thread overview]
Message-ID: <YvObuLevnEWEITnS@phenom.ffwll.local> (raw)
In-Reply-To: <6aad3bff.d1a.181b982d1b1.Coremail.chenxuebing@jari.cn>

On Fri, Jul 01, 2022 at 07:26:07PM +0800, XueBing Chen wrote:
> 
> The strlcpy should not be used because it doesn't limit the source
> length. Preferred is strscpy.
> 
> Signed-off-by: XueBing Chen <chenxuebing@jari.cn>

I don't think there's an impact here since we don't check the error return
value, but also doesn't hurt.

Thanks for your patch, applied to drm-misc-next.
-Daniel

> ---
>  drivers/dma-buf/sync_file.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index 3ebec19a8e02..af57799c86ce 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -132,7 +132,7 @@ EXPORT_SYMBOL(sync_file_get_fence);
>  char *sync_file_get_name(struct sync_file *sync_file, char *buf, int len)
>  {
>  	if (sync_file->user_name[0]) {
> -		strlcpy(buf, sync_file->user_name, len);
> +		strscpy(buf, sync_file->user_name, len);
>  	} else {
>  		struct dma_fence *fence = sync_file->fence;
>  
> @@ -172,7 +172,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
>  		return NULL;
>  	}
>  	sync_file->fence = fence;
> -	strlcpy(sync_file->user_name, name, sizeof(sync_file->user_name));
> +	strscpy(sync_file->user_name, name, sizeof(sync_file->user_name));
>  	return sync_file;
>  }
>  
> @@ -262,9 +262,9 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
>  static int sync_fill_fence_info(struct dma_fence *fence,
>  				 struct sync_fence_info *info)
>  {
> -	strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
> +	strscpy(info->obj_name, fence->ops->get_timeline_name(fence),
>  		sizeof(info->obj_name));
> -	strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
> +	strscpy(info->driver_name, fence->ops->get_driver_name(fence),
>  		sizeof(info->driver_name));
>  
>  	info->status = dma_fence_get_status(fence);
> -- 
> 2.25.1
> _______________________________________________
> Linaro-mm-sig mailing list -- linaro-mm-sig@lists.linaro.org
> To unsubscribe send an email to linaro-mm-sig-leave@lists.linaro.org

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2022-08-10 11:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01 11:26 [PATCH] dma-buf/sync_file: use strscpy to replace strlcpy XueBing Chen
2022-08-10 11:51 ` Daniel Vetter [this message]
2022-08-10 11:51   ` [Linaro-mm-sig] " Daniel Vetter

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=YvObuLevnEWEITnS@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chenxuebing@jari.cn \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@padovan.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sumit.semwal@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.