public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] alpha: correct handling of negative *rlimit() args besides -1
@ 2022-10-08  2:45 Matt Turner
  2022-10-10  0:51 ` Carlos O'Donell
  2022-10-10 18:44 ` Aurelien Jarno
  0 siblings, 2 replies; 6+ messages in thread
From: Matt Turner @ 2022-10-08  2:45 UTC (permalink / raw)
  To: libc-alpha; +Cc: Aurelien Jarno, Matt Turner

The generic version of RLIM_INFINITY in Linux is equal to (rlim_t)-1,
which is equal to ULLONG_MAX.  On alpha however it is instead defined as
0x7ffffffffffffffful.  This was special-cased in 0d0bc78 [BZ #22648] but
it specifically used an equality check.

There is a cpython test case test_prlimit_refcount which calls
setrlimit() with { -2, -2 } as arguments rather than the usual -1, it
therefore fails the equality test and is treated as a large arbitrary
positive value past the maximum of RLIM_INFINITY and fails with EPERM.
This patch changes the behavior of the *rlimit() calls to treat all
integers between 0x7ffffffffffffffful and (rlim_t)-1 as (rlim_t)-1,
i.e., RLIM_INFINITY.
---
 sysdeps/unix/sysv/linux/alpha/getrlimit64.c | 4 ++--
 sysdeps/unix/sysv/linux/alpha/setrlimit64.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/getrlimit64.c b/sysdeps/unix/sysv/linux/alpha/getrlimit64.c
index c195f5b55c..40f3e6bdff 100644
--- a/sysdeps/unix/sysv/linux/alpha/getrlimit64.c
+++ b/sysdeps/unix/sysv/linux/alpha/getrlimit64.c
@@ -38,11 +38,11 @@ __old_getrlimit64 (enum __rlimit_resource resource,
   if (__getrlimit64 (resource, &krlimits) < 0)
     return -1;
 
-  if (krlimits.rlim_cur == RLIM64_INFINITY)
+  if (krlimits.rlim_cur >= OLD_RLIM64_INFINITY)
     rlimits->rlim_cur = OLD_RLIM64_INFINITY;
   else
     rlimits->rlim_cur = krlimits.rlim_cur;
-  if (krlimits.rlim_max == RLIM64_INFINITY)
+  if (krlimits.rlim_max >= OLD_RLIM64_INFINITY)
     rlimits->rlim_max = OLD_RLIM64_INFINITY;
   else
     rlimits->rlim_max = krlimits.rlim_max;
diff --git a/sysdeps/unix/sysv/linux/alpha/setrlimit64.c b/sysdeps/unix/sysv/linux/alpha/setrlimit64.c
index 421616ed20..4e88540a48 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;
-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-09  2:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-08  2:45 [PATCH] alpha: correct handling of negative *rlimit() args besides -1 Matt Turner
2022-10-10  0:51 ` Carlos O'Donell
2022-10-10  2:18   ` Matt Turner
2022-10-10 18:44 ` Aurelien Jarno
2023-02-14 19:38   ` matoro
2023-10-09  2:01     ` matoro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).