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]
Message-ID: <CAEf4BzYOhiddakWzVGe1CYt2GZ+a57kT4EyujhoiTQN6Mc6uLg@mail.gmail.com>
Date: Fri, 5 Dec 2025 15:51:44 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Mikhail Gavrilov <mikhail.v.gavrilov@...il.com>
Cc: bpf@...r.kernel.org, andrii@...nel.org, ast@...nel.org, 
	daniel@...earbox.net, netdev@...r.kernel.org, fweimer@...hat.com
Subject: Re: [PATCH v2 bpf-next] tools/lib/bpf: fix -Wdiscarded-qualifiers
 under C23

On Fri, Nov 28, 2025 at 6:59 AM Mikhail Gavrilov
<mikhail.v.gavrilov@...il.com> wrote:
>
> glibc ≥ 2.42 (GCC 15) defaults to -std=gnu23, which promotes
> -Wdiscarded-qualifiers to an error in the default hardening flags
> of Fedora Rawhide, Arch Linux, openSUSE Tumbleweed, Gentoo, etc.
>
> In C23, strstr() and strchr() return "const char *" in most cases,
> making previous implicit casts invalid.
>
> This breaks the build of tools/bpf/resolve_btfids on pristine
> upstream kernel when using GCC 15 + glibc 2.42+.
>
> Fix the three remaining instances with explicit casts.
>
> No functional changes.
>
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2417601
> Suggested-by: Florian Weimer <fweimer@...hat.com>
> Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@...il.com>
>
> ---
> v2:
> - Declare `res` as `const char *` — never modified.
> - Keep `sym_sfx` as `char *` and cast — it is advanced in the loop.
> - Cast `next_path` — declared as `char *` earlier in the function.
>   Changing it to const would require refactoring the whole function,
>   which is not justified for a tools/ file.
> ---
>  tools/lib/bpf/libbpf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index dd3b2f57082d..22ccd50e9978 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -8245,7 +8245,7 @@ static int kallsyms_cb(unsigned long long sym_addr, char sym_type,
>         struct bpf_object *obj = ctx;
>         const struct btf_type *t;
>         struct extern_desc *ext;
> -       char *res;
> +       const char *res;
>
>         res = strstr(sym_name, ".llvm.");
>         if (sym_type == 'd' && res)
> @@ -11576,7 +11576,7 @@ static int avail_kallsyms_cb(unsigned long long sym_addr, char sym_type,
>                  */
>                 char sym_trim[256], *psym_trim = sym_trim, *sym_sfx;

const char *sym_sfx; instead of unnecessary cast

>
> -               if (!(sym_sfx = strstr(sym_name, ".llvm.")))
> +               if (!(sym_sfx = (char *)strstr(sym_name, ".llvm.")))  /* needs mutation */
>                         return 0;
>
>                 /* psym_trim vs sym_trim dance is done to avoid pointer vs array
> @@ -12164,7 +12164,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
>
>                         if (s[0] == ':')
>                                 s++;
> -                       next_path = strchr(s, ':');
> +                       next_path = (char *)strchr(s, ':');   /* declared as char * above */

same here, next_path should be const char *

pw-bot: cr


>                         seg_len = next_path ? next_path - s : strlen(s);
>                         if (!seg_len)
>                                 continue;
> --
> 2.52.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ