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-next>] [day] [month] [year] [list]
Message-ID: <3132727fea08e81e834104761b5a5630d337340a.1725636560.git.sam@gentoo.org>
Date: Fri,  6 Sep 2024 16:29:20 +0100
From: Sam James <sam@...too.org>
To: Masahiro Yamada <masahiroy@...nel.org>,
	Nathan Chancellor <nathan@...nel.org>,
	Nicolas Schier <nicolas@...sle.eu>
Cc: Sam James <sam@...too.org>,
	Masahiro Yamada <yamada.masahiro@...ionext.com>,
	linux-kbuild@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] fixdep: handle short reads in read_file

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
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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ