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] [day] [month] [year] [list]
Message-ID: <CAK7LNAST1bq=oLT9spUJ3tH+f1RKjG0N_hXh+K7juaS1XgpCRQ@mail.gmail.com>
Date:   Sat, 29 Jul 2023 15:58:37 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     James Clark <james.clark@....com>
Cc:     linux-kbuild@...r.kernel.org, miguel.ojeda.sandonis@...il.com,
        linux-kernel@...r.kernel.org, Miguel Ojeda <ojeda@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Zhen Lei <thunder.leizhen@...wei.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Arnd Bergmann <arnd@...db.de>,
        Boqun Feng <boqun.feng@...il.com>,
        Nicolas Schier <n.schier@....de>
Subject: Re: [PATCH v2] scripts/kallsyms: Fix build failure by setting errno
 before calling getline()

On Tue, Jul 25, 2023 at 7:58 PM James Clark <james.clark@....com> wrote:
>
> getline() returns -1 at EOF as well as on error. It also doesn't set
> errno to 0 on success, so initialize it to 0 before using errno to check
> for an error condition. See the paragraph here [1]:
>
>   For some system calls and library functions (e.g., getpriority(2)),
>   -1 is a valid return on success. In such cases, a successful return
>   can be distinguished from an error return by setting errno to zero
>   before the call, and then, if the call returns a status that indicates
>   that an error may have occurred, checking to see if errno has a
>   nonzero value.
>
> Bear has a bug [2] that launches processes with errno set and causes the
> following build failure:
>
>  $ bear -- make LLVM=1
>  ...
>   LD      .tmp_vmlinux.kallsyms1
>   NM      .tmp_vmlinux.kallsyms1.syms
>   KSYMS   .tmp_vmlinux.kallsyms1.S
>  read_symbol: Invalid argument
>
> [1]: https://linux.die.net/man/3/errno
> [2]: https://github.com/rizsotto/Bear/issues/469
>
> Fixes: 1c975da56a6f ("scripts/kallsyms: remove KSYM_NAME_LEN_BUFFER")
> Reviewed-by: Miguel Ojeda <ojeda@...nel.org>
> Signed-off-by: James Clark <james.clark@....com>

Applied to linux-kbuild/fixes.
Thanks.


> ---
>  scripts/kallsyms.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index 16c87938b316..653b92f6d4c8 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -129,6 +129,7 @@ static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len)
>         ssize_t readlen;
>         struct sym_entry *sym;
>
> +       errno = 0;
>         readlen = getline(buf, buf_len, in);
>         if (readlen < 0) {
>                 if (errno) {
> --
> 2.34.1
>


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ