public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Suchit K <suchitkarunakaran@gmail.com>
Cc: Yonghong Song <yonghong.song@linux.dev>,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
	haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org,
	skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] libbpf: Replace strcpy() with memcpy() in bpf_object__new()
Date: Thu, 17 Jul 2025 19:09:26 +0200	[thread overview]
Message-ID: <2025071756-motor-slackness-ef0d@gregkh> (raw)
In-Reply-To: <CAO9wTFjEJOfF7krFuV=DkZFzRU3FpRXtnq93UaX8=_Y=wnwbHw@mail.gmail.com>

On Thu, Jul 17, 2025 at 10:29:50PM +0530, Suchit K wrote:
> On Thu, 17 Jul 2025 at 22:19, Yonghong Song <yonghong.song@linux.dev> wrote:
> >
> >
> >
> > On 7/17/25 4:59 AM, Suchit Karunakaran wrote:
> > > Replace the unsafe strcpy() call with memcpy() when copying the path
> > > into the bpf_object structure. Since the memory is pre-allocated to
> > > exactly strlen(path) + 1 bytes and the length is already known, memcpy()
> > > is safer than strcpy().
> >
> > I don't understand in this particular context why strcpy()
> > is less safer than memcpy(). Both of them will achieve the
> > exactly same goal.
> >
> 
> Sorry, I meant that strcpy() is generally considered unsafe because it
> doesn't perform bounds checking. Its use is deprecated and
> discouraged, as noted in Documentation/process/deprecated.rst. I made
> this change with that in mind, although I'm not entirely certain
> whether it's actually unsafe in this specific context.
> 

Your change also did not do any bounds checking at all, so how is this
now safer?

confused,

greg k-h

  reply	other threads:[~2025-07-17 17:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 11:59 [PATCH] libbpf: Replace strcpy() with memcpy() in bpf_object__new() Suchit Karunakaran
2025-07-17 16:49 ` Yonghong Song
2025-07-17 16:59   ` Suchit K
2025-07-17 17:09     ` Greg KH [this message]
2025-07-17 17:20       ` Suchit K
2025-07-17 17:19 ` Andrii Nakryiko
2025-07-17 17:25   ` Suchit K
2025-07-17 17:33   ` Suchit K
2025-07-18 15:39     ` Andrii Nakryiko
2025-07-18 16:18       ` Suchit K

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=2025071756-motor-slackness-ef0d@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=skhan@linuxfoundation.org \
    --cc=song@kernel.org \
    --cc=suchitkarunakaran@gmail.com \
    --cc=yonghong.song@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