From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 2684E3858280 for ; Mon, 10 Oct 2022 18:44:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2684E3858280 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=TGqjQJ1XatG66YOUkeIK7HfmaxPc9FthrkSzk1LkKO0=; b=DoSqqEs+9jVeILPonqUFoh9wsK zj5DkRWlja+wQ52Ri8HitMen2FFzOs+5mj0N8JnlR64GX+7Do2Ct1KiIDV6vhL7K51zUkie63x8JT zGrPY20P4wjdbgdzA0iKg8OwDqTCDx8gkT7pna74IB1bmuul2mSFZy7ckwyRPwbiHxQZT+Dsrar+v 31/v3OzI/iCzNPNWy58vDJpbGwxlzmvCxTzrpnK+504djQr54doh9LVksTI0vh26SeZRuNhDa9nHM t4FOGb+EtzmVuWDTb+BvMBzF+tlNSpIGireB0aLi+jtQgox4defwP2ESP9ooski4R/Tig+lRVzDen d32i+mGA==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ohxl8-003ZHF-V0; Mon, 10 Oct 2022 20:44:15 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.96) (envelope-from ) id 1ohxl8-00Ftvm-1m; Mon, 10 Oct 2022 20:44:14 +0200 Date: Mon, 10 Oct 2022 20:44:14 +0200 From: Aurelien Jarno To: Matt Turner Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] alpha: correct handling of negative *rlimit() args besides -1 Message-ID: Mail-Followup-To: Matt Turner , libc-alpha@sourceware.org References: <20221008024522.523048-1-mattst88@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221008024522.523048-1-mattst88@gmail.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, On 2022-10-07 22:45, Matt Turner via Libc-alpha wrote: > 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. I am not sure this commit is giving the full picture, commits around should also be checked to understand it. > 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. Basically on alpha, the glibc API is now identical to the prlimit64 API, which means there is a dead zone with invalid values from 0x8000000000000000ul to 0xfffffffffffffffeul. The kernel returns EPERM for values in this range. You suggestion is to consider values is this zone as infinity. I have mixed feeling about that. From the setrlimit() side it looks like the correct thing to do. But this breaks the assumption that calling getrlimit() after a successful setrlimit() call will return the same value. > 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; That said, I do not understand the change there. It is done on the *compat* symbol which still uses the old glibc API definition. There we want to keep doing the exact reverse operations as in the rlim_to_rlim64() kernel function. > 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; Ditto here we want to do the reverse operations as the rlim64_to_rlim() kernel function. -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net