lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 3 Nov 2022 11:45:55 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Rong Tao <rtoax@...mail.com>
Cc:     daniel@...earbox.net, andrii@...nel.org, ast@...nel.org,
        bpf@...r.kernel.org, david.laight@...lab.com, haoluo@...gle.com,
        john.fastabend@...il.com, jolsa@...nel.org, kpsingh@...nel.org,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        martin.lau@...ux.dev, mykolal@...com, rongtao@...tc.cn,
        sdf@...gle.com, shuah@...nel.org, song@...nel.org, yhs@...com
Subject: Re: [PATCH bpf-next] selftests/bpf: cgroup_helpers.c: Fix strncpy()
 fortify warning

On Wed, Nov 2, 2022 at 5:59 AM Rong Tao <rtoax@...mail.com> wrote:
>
> From: Rong Tao <rongtao@...tc.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@...tc.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(-)
>

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ