All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Azeem Shaikh <azeemshaikh38@gmail.com>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/i2c: tda998x: Replace all non-returning strlcpy with strscpy
Date: Mon, 22 May 2023 17:04:09 +0100	[thread overview]
Message-ID: <ZGuSeZcLfXNyCqtv@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230522155350.2337029-1-azeemshaikh38@gmail.com>

On Mon, May 22, 2023 at 03:53:50PM +0000, Azeem Shaikh wrote:
> strlcpy() reads the entire source buffer first.
> This read may exceed the destination size limit.
> This is both inefficient and can lead to linear read
> overflows if a source string is not NUL-terminated [1].
> In an effort to remove strlcpy() completely [2], replace
> strlcpy() here with strscpy().
> No return values were used, so direct replacement is safe.
...
>  	memset(&cec_info, 0, sizeof(cec_info));
> -	strlcpy(cec_info.type, "tda9950", sizeof(cec_info.type));
> +	strscpy(cec_info.type, "tda9950", sizeof(cec_info.type));

Please explain how:

1) a C string can not be NUL terminated.
2) this source string could be longer than I2C_NAME_SIZE (20 bytes)
   which is unlikely to ever shrink.

I'm not saying I disagree with the patch, but the boilerplate commit
message isn't correct for this change, and is actually misleading
for what the patch actually is.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Azeem Shaikh <azeemshaikh38@gmail.com>
Cc: dri-devel@lists.freedesktop.org, linux-hardening@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/i2c: tda998x: Replace all non-returning strlcpy with strscpy
Date: Mon, 22 May 2023 17:04:09 +0100	[thread overview]
Message-ID: <ZGuSeZcLfXNyCqtv@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230522155350.2337029-1-azeemshaikh38@gmail.com>

On Mon, May 22, 2023 at 03:53:50PM +0000, Azeem Shaikh wrote:
> strlcpy() reads the entire source buffer first.
> This read may exceed the destination size limit.
> This is both inefficient and can lead to linear read
> overflows if a source string is not NUL-terminated [1].
> In an effort to remove strlcpy() completely [2], replace
> strlcpy() here with strscpy().
> No return values were used, so direct replacement is safe.
...
>  	memset(&cec_info, 0, sizeof(cec_info));
> -	strlcpy(cec_info.type, "tda9950", sizeof(cec_info.type));
> +	strscpy(cec_info.type, "tda9950", sizeof(cec_info.type));

Please explain how:

1) a C string can not be NUL terminated.
2) this source string could be longer than I2C_NAME_SIZE (20 bytes)
   which is unlikely to ever shrink.

I'm not saying I disagree with the patch, but the boilerplate commit
message isn't correct for this change, and is actually misleading
for what the patch actually is.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-05-22 16:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 15:53 [PATCH] drm/i2c: tda998x: Replace all non-returning strlcpy with strscpy Azeem Shaikh
2023-05-22 15:53 ` Azeem Shaikh
2023-05-22 16:04 ` Russell King (Oracle) [this message]
2023-05-22 16:04   ` Russell King (Oracle)
2023-05-22 17:22   ` Kees Cook
2023-05-22 17:22     ` Kees Cook
2023-05-22 20:16 ` Kees Cook
2023-05-22 20:16   ` Kees Cook
2023-05-30 23:06 ` Kees Cook
2023-05-30 23:06   ` Kees Cook

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=ZGuSeZcLfXNyCqtv@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=airlied@gmail.com \
    --cc=azeemshaikh38@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-hardening@vger.kernel.org \
    --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 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.