[PATCH] alpha: fix setrlimit compat symbol for negative rlim values besides -1
Matt Turner
mattst88@gmail.com
Sat May 23 16:53:05 GMT 2026
Old alpha glibc defined rlim_t as signed long, making RLIM_INFINITY
equal to LONG_MAX (0x7ffffffffffffffful). The compat symbol
__old_setrlimit64 (setrlimit@GLIBC_2.0 and setrlimit64@GLIBC_2.1) was
introduced in 0d0bc784ca [BZ #22648] to translate this old RLIM_INFINITY
to the kernel's RLIM64_INFINITY (ULONG_MAX) before the prlimit64
syscall, using an exact equality check.
Because old rlim_t was signed, any value a caller treats as negative
(e.g. -2 = 0xfffffffffffffffe unsigned) is also an "infinity or beyond"
value in the old ABI. Such values are >= OLD_RLIM64_INFINITY and
should be translated to RLIM64_INFINITY; passing them through unchanged
causes prlimit64 to treat them as large finite limits, resulting in
unexpected failures (EPERM or silent truncation).
Change the equality check to >= OLD_RLIM64_INFINITY in
__old_setrlimit64 so that all values the old signed-rlim_t ABI would
interpret as infinity-or-more are correctly mapped to RLIM64_INFINITY.
No change is made to __old_getrlimit64: prlimit64 returns only exact
RLIM64_INFINITY for unlimited resources, so the existing equality
check against RLIM64_INFINITY is correct and mirrors the kernel's own
rlim64_is_infinity() logic.
Fixes: 0d0bc784ca ("Alpha: Add wrappers to get/setrlimit64 to fix
RLIM64_INFINITY constant [BZ #22648]")
Fixes: https://sourceware.org/bugzilla/show_bug.cgi?id=30992
---
sysdeps/unix/sysv/linux/alpha/setrlimit64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git ./sysdeps/unix/sysv/linux/alpha/setrlimit64.c ./sysdeps/unix/sysv/linux/alpha/setrlimit64.c
index 512aaf2042..d8cb04fa5e 100644
--- ./sysdeps/unix/sysv/linux/alpha/setrlimit64.c
+++ ./sysdeps/unix/sysv/linux/alpha/setrlimit64.c
@@ -35,11 +35,11 @@ __old_setrlimit64 (enum __rlimit_resource resource,
{
struct rlimit64 krlimits;
- if (rlimits->rlim_cur == OLD_RLIM64_INFINITY)
+ if (rlimits->rlim_cur >= OLD_RLIM64_INFINITY)
krlimits.rlim_cur = RLIM64_INFINITY;
else
krlimits.rlim_cur = rlimits->rlim_cur;
- if (rlimits->rlim_max == OLD_RLIM64_INFINITY)
+ if (rlimits->rlim_max >= OLD_RLIM64_INFINITY)
krlimits.rlim_max = RLIM64_INFINITY;
else
krlimits.rlim_max = rlimits->rlim_max;
--
2.53.0
More information about the Libc-alpha
mailing list