From patchwork Sat Oct 8 02:45:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 58551 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7FF24395203D for ; Sat, 8 Oct 2022 02:45:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FF24395203D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665197159; bh=9LA9rMyoSkDzreTnZavNPiNDlDzPoyuWOwUUMBFi48I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BP4n5bm1M8adrLMf3tjvDPjz7H3/7yJF0nROuS1o6KEPV1UMlFQRLhMzfjAeIfWgj M+5owMFX22WHPNdVKy6OLri3dvD6mp8FNafRTA2034HvSBR7AR7R2yoK43io5jBdvj G6mJ4Cm/Pbdt9Hm4K7hEkfvd6uugvChCjGoYyvKE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by sourceware.org (Postfix) with ESMTPS id D70B73840C09 for ; Sat, 8 Oct 2022 02:45:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D70B73840C09 Received: by mail-qt1-x82c.google.com with SMTP id cj27so3843726qtb.7 for ; Fri, 07 Oct 2022 19:45:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9LA9rMyoSkDzreTnZavNPiNDlDzPoyuWOwUUMBFi48I=; b=JbgG+3ZZPDo3NFWn/Q2Y8jv6SSdI3Nyqgl0QpvghkiJMjQ2gXvvWcNLUayGOTreHEw qjuKKZnFWlv9H2JcRIENfoiUgWfhjZzrKkoAWY2TLAv9YGVaCTibc5p4KcZCnUGiZRxN BtMcQhh4h3Q9EEW5vAY2VM4jnNDll6IHOK9XYN9Hocydbvog/Dy1dPim2od/uhpeCRwI V6vB/W5UHvJHvh35CiPWJvsFez93nRBgIQPDklxG2b6Te0sdoVxm6NpnDQOURN0EydLJ zI1V1T4ju4vrC9JKY8Fl10CAc70R9lkWlBbzNJd0wVRXD31Xjha/dKjx1Q6gtmJV/YU9 7Kig== X-Gm-Message-State: ACrzQf2qmVCpTiB5Wg3NKWv/CBh2bsTB3qXwPg1rNswnddxCV53dT33z exDkiipxyHbrAAu2S4goChbvnlvozZw= X-Google-Smtp-Source: AMsMyM7Qc6oLTGGYQXSvfYFV7e2s8Y2/4ko1GfbHb9VHZp+GN0bi+zKN5LXqn1GkKCdlqQSQqsoPhw== X-Received: by 2002:a05:622a:1046:b0:35c:dde0:6735 with SMTP id f6-20020a05622a104600b0035cdde06735mr6682355qte.689.1665197136397; Fri, 07 Oct 2022 19:45:36 -0700 (PDT) Received: from localhost ([2601:743:4180:4ff0::5c6f]) by smtp.gmail.com with ESMTPSA id q5-20020a37f705000000b006ea67959705sm1300591qkj.61.2022.10.07.19.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 19:45:35 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] alpha: correct handling of negative *rlimit() args besides -1 Date: Fri, 7 Oct 2022 22:45:22 -0400 Message-Id: <20221008024522.523048-1-mattst88@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matt Turner via Libc-alpha From: Matt Turner Reply-To: Matt Turner Cc: Aurelien Jarno Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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;