From patchwork Fri Nov 17 08:57:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Kozlov X-Patchwork-Id: 1864994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=pfptdkimsnps header.b=ivvCgXUn; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=hSPmIz1d; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SWrQz2s3Lz1yS6 for ; Fri, 17 Nov 2023 19:58:17 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id B4F4A3520F2C; Fri, 17 Nov 2023 09:58:07 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=pfptdkimsnps header.b=ivvCgXUn; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.a=rsa-sha256 header.s=mail header.b=hSPmIz1d; dkim-atps=neutral Received: from mx0a-00230701.pphosted.com (mx0a-00230701.pphosted.com [148.163.156.19]) by helium.openadk.org (Postfix) with ESMTPS id 46FD63520D48 for ; Fri, 17 Nov 2023 09:57:58 +0100 (CET) Received: from pps.filterd (m0098571.ppops.net [127.0.0.1]) by mx0a-00230701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AH8V9XD004173 for ; Fri, 17 Nov 2023 00:57:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synopsys.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pfptdkimsnps; bh=fALof0+hDb+IQh6MTeTeyeL6PLOjN8RrjfnvQKnY2jw=; b=ivvCgXUn84KFEJMyFtLPuYMubqfLG1uwbCnvIIrJRNI7V4Tyyjhs9xQoKBEdp+OmUvoB VMGloUINHT3GjNG+7QgNg/IxRkFLL7G+guKaMO/JFsMTmlCrHPT9T+05nDCdziVwYgly B3lLOY4KIgVMpum2hkxVpiQUOk2mJ/B/9FPAvzm9bNDwR0MoXD6IDijkwiLxJDzL2QCL 4jGtnAuyY1FGC7MTOyOwC+0ENecr0ELtBxbsMbvzU22EWNznFZtxsMbj6/ia41UqLgyJ bwVYCfSBm3PQA5YyEmahDyJOTdmGXAijRuDdAA4AblPvRUfC6vNG6CsPQiGTej/iYyKY Gw== Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.87.133]) by mx0a-00230701.pphosted.com (PPS) with ESMTPS id 3ua9gskh7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Nov 2023 00:57:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1700211473; bh=FPWuh71kXA43o3Pu7KGAazui6awVwpYtGOjd6cKszSg=; h=From:To:Cc:Subject:Date:From; b=hSPmIz1dhuWlVQIPP0WKmDIL60b28qzHMWX7PRpYw0Er06+yWZZ/DGfvThPAoxcCf agV+rJ69H2Nv6bxgGSaKoNZXUqzyH6NyUNgZkyh5jMRVb1aideswCW30QhrO9dvaeJ FvahUolCiKfZZ6+iU95nVJ8Iys+IQEzHcfIAOOSef0jf/NsfhYIGyLWk3cfpik/1dy ryOKdTBFsaE/7speoQpqOdn1HoBZGfFiaDh44heWBYO1njSEkLwcVWkMZradSrj3Bb AZewqC5z7CY5yU3nRqN3/G2E91QJmByJYsJDWVAddS/EQ9Hh2MA/F2ShHE8HjwjDqS ClmWhHujD3YAQ== Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 135A840364 for ; Fri, 17 Nov 2023 08:57:52 +0000 (UTC) Received: from SNPS-o0WHuHJU73.internal.synopsys.com (snps-o0whuhju73.internal.synopsys.com [10.116.111.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id CD306A005B; Fri, 17 Nov 2023 08:57:50 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Pavel Kozlov To: devel@uclibc-ng.org Date: Fri, 17 Nov 2023 12:57:31 +0400 Message-Id: <20231117085731.5675-1-kozlov@synopsys.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: _a8URWLaZObjPWKJsKh9ePXLnHFvr3K9 X-Proofpoint-ORIG-GUID: _a8URWLaZObjPWKJsKh9ePXLnHFvr3K9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-17_06,2023-11-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_active_cloned_notspam policy=outbound_active_cloned score=0 lowpriorityscore=0 mlxlogscore=669 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311170065 Message-ID-Hash: Z4DY4SIOYEM3JV4Z4WQES5WIMKYKZVAL X-Message-ID-Hash: Z4DY4SIOYEM3JV4Z4WQES5WIMKYKZVAL X-MailFrom: Pavel.Kozlov@synopsys.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexey Brodkin , Pavel Kozlov X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] rlimit: fix 64-bit RLIM64_INFINITY macro List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pavel Kozlov Linux kernel returns -1ULL as RLIM64_INFINITY for all cpus. Fix RLIM64_INFINTIY and 64-bit variant of RLIM_INFINITY macro for sparc, mips, alpha, as for these CPUs the library uses different value than what the kernel sets and it can cause incorrect RLIM64_INFINTY check. Because alpha is a 64-bit arch, fix the RLIM_INFINITY macro twice (the value should be the same with and without __USE_FILE_OFFSET64 definition) to match the prlimit64 syscall in the kernel. Previous implementation of setrlimit/getrlimit functions didn't use prlimit64 syscall and didn't receive RLIM64_INFINTIY from the kernel, RLIM64_INFINTY macro was used by the library itself to mimic the 64-bit rlimit in the getrlimit64/setrlimit64 functions, that allowed to have RLIM64_INFINTIY different from what the kernel sets. New implementation of setrlimit/getrlimit uses prlimit64 and checks for RLIM64_INFINITY value and must have equal RLIM64_INFINITY definition with what the kernel uses. This issue is indicated by the tst-rlim/tst-rlim64 tests on sparc/mips32/alpha, tests return 23 (UNSUPPORTED) because of incorrect RLIM_INFINTY check for available rlimit type. This patch will require rebuild of sparc/mips32/alpha binaries that explicitly use RLIM64_INFINTY or 64-bit variant of RLIM_INFINITY (if binary for 32-bit CPU was built with _FILE_OFFSET_BITS=64) to update the macro value. Signed-off-by: Pavel Kozlov --- libc/sysdeps/linux/alpha/bits/resource.h | 6 +++--- libc/sysdeps/linux/mips/bits/resource.h | 4 ++-- libc/sysdeps/linux/sparc/bits/resource.h | 4 ++-- libc/sysdeps/linux/sparc64/bits/resource.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libc/sysdeps/linux/alpha/bits/resource.h b/libc/sysdeps/linux/alpha/bits/resource.h index 38f73961e99d..dba818714d84 100644 --- a/libc/sysdeps/linux/alpha/bits/resource.h +++ b/libc/sysdeps/linux/alpha/bits/resource.h @@ -113,13 +113,13 @@ enum __rlimit_resource /* Value to indicate that there is no limit. */ #ifndef __USE_FILE_OFFSET64 -# define RLIM_INFINITY ((long int)(~0UL >> 1)) +# define RLIM_INFINITY ((unsigned long int)(~0UL)) #else -# define RLIM_INFINITY 0x7fffffffffffffffLL +# define RLIM_INFINITY 0xffffffffffffffffULL #endif #ifdef __USE_LARGEFILE64 -# define RLIM64_INFINITY 0x7fffffffffffffffLL +# define RLIM64_INFINITY 0xffffffffffffffffULL #endif /* We can represent all limits. */ diff --git a/libc/sysdeps/linux/mips/bits/resource.h b/libc/sysdeps/linux/mips/bits/resource.h index 5690527bf9a3..97487d274f21 100644 --- a/libc/sysdeps/linux/mips/bits/resource.h +++ b/libc/sysdeps/linux/mips/bits/resource.h @@ -123,10 +123,10 @@ enum __rlimit_resource # ifndef __USE_FILE_OFFSET64 # define RLIM_INFINITY ((long int)(~0UL >> 1)) # else -# define RLIM_INFINITY 0x7fffffffffffffffULL +# define RLIM_INFINITY 0xffffffffffffffffULL # endif # ifdef __USE_LARGEFILE64 -# define RLIM64_INFINITY 0x7fffffffffffffffULL +# define RLIM64_INFINITY 0xffffffffffffffffULL # endif #endif diff --git a/libc/sysdeps/linux/sparc/bits/resource.h b/libc/sysdeps/linux/sparc/bits/resource.h index a5ec31e4e677..48e1049f41a6 100644 --- a/libc/sysdeps/linux/sparc/bits/resource.h +++ b/libc/sysdeps/linux/sparc/bits/resource.h @@ -114,11 +114,11 @@ enum __rlimit_resource #ifndef __USE_FILE_OFFSET64 # define RLIM_INFINITY ((long int)(~0UL >> 1)) #else -# define RLIM_INFINITY 0x7fffffffffffffffLL +# define RLIM_INFINITY 0xffffffffffffffffULL #endif #ifdef __USE_LARGEFILE64 -# define RLIM64_INFINITY 0x7fffffffffffffffLL +# define RLIM64_INFINITY 0xffffffffffffffffULL #endif /* We can represent all limits. */ diff --git a/libc/sysdeps/linux/sparc64/bits/resource.h b/libc/sysdeps/linux/sparc64/bits/resource.h index f1e11e239602..84c76878520d 100644 --- a/libc/sysdeps/linux/sparc64/bits/resource.h +++ b/libc/sysdeps/linux/sparc64/bits/resource.h @@ -128,11 +128,11 @@ enum __rlimit_resource #ifndef __USE_FILE_OFFSET64 # define RLIM_INFINITY ((long int)(~0UL >> 1)) #else -# define RLIM_INFINITY 0x7fffffffffffffffLL +# define RLIM_INFINITY 0xffffffffffffffffULL #endif #ifdef __USE_LARGEFILE64 -# define RLIM64_INFINITY 0x7fffffffffffffffLL +# define RLIM64_INFINITY 0xffffffffffffffffULL #endif #endif