All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Rong Tao <rtoax@foxmail.com>
Cc: daniel@iogearbox.net, andrii@kernel.org, ast@kernel.org,
	bpf@vger.kernel.org, david.laight@aculab.com, haoluo@google.com,
	john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	martin.lau@linux.dev, mykolal@fb.com, rongtao@cestc.cn,
	sdf@google.com, shuah@kernel.org, song@kernel.org, yhs@fb.com
Subject: Re: [PATCH bpf-next] selftests/bpf: cgroup_helpers.c: Fix strncpy() fortify warning
Date: Thu, 3 Nov 2022 11:45:55 -0700	[thread overview]
Message-ID: <CAEf4BzYAcGgM93r5YfF2ZQWjAnc4k=aN5C3in-bZ-6n+Jrn1vw@mail.gmail.com> (raw)
In-Reply-To: <tencent_B91CA31B889B06CF4292592F97892A53AF08@qq.com>

On Wed, Nov 2, 2022 at 5:59 AM Rong Tao <rtoax@foxmail.com> wrote:
>
> From: Rong Tao <rongtao@cestc.cn>
>
> Move libbpf_strlcpy() to libbpf_common.h, and replace strncpy() with
> libbpf_strlcpy(), fix compile warning.
>
> We can't use libbpf_internal.h directly, because it introduces a lot of
> header dependency issues. So move libbpf_strlcpy() into libbpf_common.h,
> and if you need to use the libbpf_strlcpy() function, you need to include
> the header file libbpf.h

well, no, we should make libbpf_strlcpy as a public API, it's internal
helper. libbpf_common.h is part of libbpf's UAPI.

So don't touch libbpf, please. Name the function as _strlcpy or
something like that, put it into bpf_util.h and use that from
selftests.

>
> How to reproduce this compilation warning:
>
> $ make -C samples/bpf
> cgroup_helpers.c: In function ‘__enable_controllers’:
> cgroup_helpers.c:80:17: warning: ‘strncpy’ specified bound 4097 equals destination size [-Wstringop-truncation]
>    80 |                 strncpy(enable, controllers, sizeof(enable));
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Rong Tao <rongtao@cestc.cn>
> ---
>  tools/lib/bpf/libbpf_common.h                | 19 +++++++++++++++++++
>  tools/lib/bpf/libbpf_internal.h              | 19 -------------------
>  tools/testing/selftests/bpf/cgroup_helpers.c |  3 ++-
>  tools/testing/selftests/bpf/xsk.c            | 19 -------------------
>  4 files changed, 21 insertions(+), 39 deletions(-)
>

[...]

  reply	other threads:[~2022-11-03 18:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 11:33 [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning Rong Tao
2022-10-27 20:09 ` Andrii Nakryiko
2022-10-28  0:26   ` Re: [PATCH] " Rong Tao
2022-10-28 17:08     ` Andrii Nakryiko
2022-10-29  2:59       ` [PATCH bpf-next] " Rong Tao
2022-10-29 12:23         ` David Laight
2022-11-01  9:25           ` Rong Tao
2022-11-01  9:27             ` David Laight
2022-11-01 12:21               ` Rong Tao
2022-11-01 13:56                 ` Daniel Borkmann
2022-11-01 14:23                   ` Rong Tao
2022-11-01 15:46                     ` Daniel Borkmann
2022-11-02 12:59                       ` [PATCH bpf-next] selftests/bpf: cgroup_helpers.c: " Rong Tao
2022-11-03 18:45                         ` Andrii Nakryiko [this message]
2022-11-04  1:27                           ` Rong Tao
2022-11-04 22:50                             ` patchwork-bot+netdevbpf
2022-10-29  3:07       ` [RESEND PATCH bpf-next] selftests/bpf: " Rong Tao

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='CAEf4BzYAcGgM93r5YfF2ZQWjAnc4k=aN5C3in-bZ-6n+Jrn1vw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=david.laight@aculab.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=rongtao@cestc.cn \
    --cc=rtoax@foxmail.com \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /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.