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: <CAK7LNATeuwaO8AvAqmz_4hyb5vjFnL-jhxbXv6_KoCTZbsS86A@mail.gmail.com>
Date: Sat, 7 Sep 2024 11:02:44 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Sam James <sam@...too.org>
Cc: Nathan Chancellor <nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>, linux-kbuild@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fixdep: handle short reads in read_file

On Sat, Sep 7, 2024 at 12:29 AM Sam James <sam@...too.org> wrote:
>
> 50% or so of kernel builds within our package manager fail for me with
> 'fixdep: read: success' because read(), for some reason - possibly ptrace,
> only read a short amount, not the full size.
>
> Unfortunately, this didn't trigger a -Wunused-result warning because
> we _are_ checking the return value, but with a bad comparison (it's completely
> fine for read() to not read the whole file in one gulp).
>
> Fixes: 01b5cbe7012fb1eeffc5c143865569835bcd405e


Fixes: 01b5cbe7012f ("fixdep: use malloc() and read() to load dep_file
to buffer")


I guess, another approach would be to use fread() instead of read().

Does the attached diff fix the issue too?





> Signed-off-by: Sam James <sam@...too.org>
> ---
>  scripts/basic/fixdep.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
> index 84b6efa849f4d..04d7742c99ac2 100644
> --- a/scripts/basic/fixdep.c
> +++ b/scripts/basic/fixdep.c
> @@ -233,9 +233,15 @@ static void *read_file(const char *filename)
>                 perror("fixdep: malloc");
>                 exit(2);
>         }
> -       if (read(fd, buf, st.st_size) != st.st_size) {
> -               perror("fixdep: read");
> -               exit(2);
> +       ssize_t bytes = 0;
> +       while (bytes < st.st_size) {
> +               ssize_t cur = read(fd, buf + bytes, st.st_size - bytes);
> +               if (cur == -1) {
> +                       perror("fixdep: read");
> +                       exit(2);
> +               } else {
> +                       bytes += cur;
> +               }
>         }
>         buf[st.st_size] = '\0';
>         close(fd);
> --
> 2.46.0
>


-- 
Best Regards
Masahiro Yamada

View attachment "use_fread.diff" of type "text/x-patch" (1213 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ