linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel@riscstar.com>
To: Doug Anderson <dianders@chromium.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	Jason Wessel <jason.wessel@windriver.com>,
	Daniel Thompson <danielt@kernel.org>,
	Justin Stitt <justinstitt@google.com>,
	linux-hardening@vger.kernel.org,
	kgdb-bugreport@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] kdb: Replace deprecated strcpy() with memmove() in vkdb_printf()
Date: Fri, 15 Aug 2025 15:32:29 +0100	[thread overview]
Message-ID: <aJ9E_W4Z0n7EzjUw@aspen.lan> (raw)
In-Reply-To: <CAD=FV=VnvUUG7qE_RDKfos1H-baZUT8V5vKx2QNRX14OZ0QnwA@mail.gmail.com>

On Tue, Aug 12, 2025 at 09:24:55AM -0700, Doug Anderson wrote:
> Hi,
>
> On Tue, Aug 12, 2025 at 6:27 AM Thorsten Blum <thorsten.blum@linux.dev> wrote:
> >
> > strcpy() is deprecated and its behavior is undefined when the source and
> > destination buffers overlap. Use memmove() instead to avoid any
> > undefined behavior.
> >
> > Adjust comments for clarity.
> >
> > Link: https://github.com/KSPP/linux/issues/88
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> > Changes in v2:
> > - Use memmove() because of strcpy()'s undefined behavior with
> >   overlapping buffers as suggested by Doug Anderson
> > - Compile-tested only
> > - Link to v1: https://lore.kernel.org/lkml/20250811170351.68985-1-thorsten.blum@linux.dev/
> > ---
> >  kernel/debug/kdb/kdb_io.c | 14 ++++++++------
> >  1 file changed, 8 insertions(+), 6 deletions(-)
>
> Much nicer, thank you!
>
> Given that the old code was officially relying on undefined behavior
> of strcpy() before, I'd personally even add:
>
> Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)")
>
> In any case:
>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>

LGTM... and I agree that this is bug rather than a clean up so am
waiting to hear back on the Fixes: .


Daniel


PS Feel free to roll all three kdb patches discussed recently into a
   series so I can pull in one go ;-) .

  reply	other threads:[~2025-08-15 14:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 13:26 [PATCH v2] kdb: Replace deprecated strcpy() with memmove() in vkdb_printf() Thorsten Blum
2025-08-12 16:24 ` Doug Anderson
2025-08-15 14:32   ` Daniel Thompson [this message]
2025-08-15 14:56     ` Thorsten Blum

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=aJ9E_W4Z0n7EzjUw@aspen.lan \
    --to=daniel@riscstar.com \
    --cc=danielt@kernel.org \
    --cc=dianders@chromium.org \
    --cc=jason.wessel@windriver.com \
    --cc=justinstitt@google.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).