[glibc] alpha: fix setrlimit compat symbol for negative rlim values besides -1
Adhemerval Zanella via Glibc-cvs <[email protected]> Mon, 25 May 2026 15:43:51 +0000 (GMT)
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c056561d31a29d82d89b5a374aea3147fd5a2de3 commit c056561d31a29d82d89b5a374aea3147fd5a2de3 Author: Matt Turner <[email protected]> Date: Sat May 23 12:53:05 2026 -0400 alpha: fix setrlimit compat symbol for negative rlim values besides -1 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 Reviewed-by: Adhemerval Zanella <[email protected]> Diff: --- sysdeps/unix/sysv/linux/alpha/setrlimit64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/alpha/setrlimit64.c b/sysdeps/unix/sysv/linux/alpha/setrlimit64.c index 512aaf2042..d8cb04fa5e 100644 --- a/sysdeps/unix/sysv/linux/alpha/setrlimit64.c +++ b/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;