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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250530123852.2574030-28-sashal@kernel.org>
Date: Fri, 30 May 2025 08:38:50 -0400
From: Sasha Levin <sashal@...nel.org>
To: patches@...ts.linux.dev,
	stable@...r.kernel.org
Cc: Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
	Willy Tarreau <w@....eu>,
	Sasha Levin <sashal@...nel.org>,
	paul.walmsley@...ive.com,
	palmer@...belt.com,
	aou@...s.berkeley.edu,
	linux-kernel@...r.kernel.org,
	linux-riscv@...ts.infradead.org
Subject: [PATCH AUTOSEL 6.15 28/30] tools/nolibc: use pselect6_time64 if available

From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>

[ Upstream commit 248ddc80b145515286bfb75d08034ad4c0fdb08e ]

riscv32 does not have any of the older select systemcalls.
Use pselect6_time64 instead.
poll() is also used to implement sleep().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Acked-by: Willy Tarreau <w@....eu>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---

**YES** This commit should be backported to stable kernel trees. Here's
my detailed analysis: ## Code Analysis The commit adds support for
`pselect6_time64` syscall as a fallback option in the `sys_select()`
function in `tools/include/nolibc/sys.h`. The change adds 8 lines of
code that implement an additional fallback case: ```c #elif
defined(__NR_pselect6_time64) struct __kernel_timespec t; if (timeout) {
t.tv_sec = timeout->tv_sec; t.tv_nsec = timeout->tv_usec 0001-Fix-
Clippy-warnings.patch 0002-Enhance-inference-prompt-to-utilize-
CVEKERNELDIR-whe.patch 0003-Update-to-latest-version-of-clap.patch
Cargo.lock Cargo.toml LICENSE README.md analyze_merge_commit.sh
io_uring_analysis.txt ksmbd_analysis.txt merge_commit_analysis.txt model
prompt src target test_gpio_cleanup.txt test_patch.txt 1000; } return
my_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, timeout ? &t :
NULL, NULL); ``` This follows the exact same pattern as the existing
`__NR_pselect6` fallback, but uses `__kernel_timespec` instead of
`timespec`. ## Why This Should Be Backported **1. Fixes a Real Bug**:
RISC-V 32-bit systems that don't provide legacy select syscalls
(`__NR_select`, `__NR__newselect`) would fall back to `__NR_pselect6`,
but newer systems may only provide `__NR_pselect6_time64`. Without this
patch, `select()` calls would fail with `ENOSYS` on such systems. **2.
Low Risk**: This is a minimal, targeted fix that: - Only affects systems
that lack both legacy select syscalls AND regular pselect6 - Uses an
identical code pattern to existing fallbacks - Doesn't modify any
existing working code paths - Is self-contained with no dependencies
**3. Consistent with Similar Commits**: Looking at the historical
reference commits, this follows the same pattern as commit #1 (Status:
YES) which added pselect6 support for RISCV, and is much simpler than
commits #2-5 (Status: NO) which involved more complex architectural
changes. **4. Addresses Platform Compatibility**: The commit message
specifically mentions that "riscv32 does not have any of the older
select systemcalls" and this provides necessary compatibility for newer
RISC-V 32-bit platforms. **5. Minimal Scope**: The change only adds one
additional fallback case before the final `ENOSYS` return, making it
extremely safe. **6. Essential for Functionality**: Without this fix,
basic I/O operations using select() would be broken on affected RISC-V
32-bit systems, making tools/nolibc unusable for such platforms. The
commit meets all criteria for stable backporting: it's a clear bugfix,
has minimal risk, doesn't introduce new features, and fixes
functionality that users depend on.

 tools/include/nolibc/sys.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 08c1c074bec89..a5decdba40223 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -1023,6 +1023,14 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
 		t.tv_nsec = timeout->tv_usec * 1000;
 	}
 	return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
+#elif defined(__NR_pselect6_time64)
+	struct __kernel_timespec t;
+
+	if (timeout) {
+		t.tv_sec  = timeout->tv_sec;
+		t.tv_nsec = timeout->tv_usec * 1000;
+	}
+	return my_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
 #else
 	return __nolibc_enosys(__func__, nfds, rfds, wfds, efds, timeout);
 #endif
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ