From patchwork Sat Dec 30 18:44:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 854142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-88679-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="EcMuUd4X"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z8C7z0LT1z9s7s for ; Sun, 31 Dec 2017 05:45:34 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=cJ+1qWnCeKTZAyNKhEQSPaSKuLyA8ZO DaV2KhhTWrVwIM7lWHBccqRwr0Up8WTEcGzY5VQ1lIIbUbl/jP7ZEqgE9e9mVYrz Yu8keXAEnwsySrmxoCu3LQ4R2GVUiTP7Y7SQZUQFQd8M6bVYF6s7KSQbRDppnGim TP+IkQ41BvRM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=p14n8SkT/SPtrytV2w+k6Ombf8o=; b=EcMuU d4Xoav81VdiwwffabpOchHQrxVaGZwhCyka8XF4GAZZdWYwW+TrXZNa/EeUo10np nMlNW+lbr8kmfaf6LTZxDw73NuL+kGPEls3bDQ4zWbxl0D1i8Hv3zAqWfxzXaGVK JDrZel11GkXDzfg6XAbssYVDq3v1k1n2dTf5jA= Received: (qmail 9441 invoked by alias); 30 Dec 2017 18:44:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 9264 invoked by uid 89); 30 Dec 2017 18:44:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Richard Henderson , Aurelien Jarno Subject: [PATCH 1/4] Alpha: Add wrappers to get/setrlimit64 to fix RLIM64_INFINITY constant [BZ #22648] Date: Sat, 30 Dec 2017 19:44:38 +0100 Message-Id: <20171230184441.25392-2-aurelien@aurel32.net> In-Reply-To: <20171230184441.25392-1-aurelien@aurel32.net> References: <20171230184441.25392-1-aurelien@aurel32.net> RLIM64_INFINITY was supposed to be a glibc convention rather than anything seen by the kernel, but it ended being passed to the kernel through the prlimit64 syscall. * On the kernel side, the value is defined for the prlimit64 syscall for all architectures in include/uapi/linux/resource.h: #define RLIM64_INFINITY (~0ULL) * On the kernel side, the value is defined for getrlimit and setrlimit in arch/alpha/include/uapi/asm/resource.h #define RLIM_INFINITY 0x7ffffffffffffffful * On the GNU libc side, the value is defined in sysdeps/unix/sysv/linux/alpha/bits/resource.h: # define RLIM64_INFINITY 0x7fffffffffffffffLL This was not an issue until the getrlimit and setrlimit glibc functions have been changed in commit 045c13d185 ("Consolidate Linux setrlimit and getrlimit implementation") to use the prlimit64 syscall instead of the getrlimit and setrlimit ones. This patch fixes that by adding a wrapper to fix the value passed to or received from the kernel, before or after calling the prlimit64 syscall. Changelog: [BZ #22648] * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: New file. * sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Ditto. Reviewed-by: Adhemerval Zanella --- ChangeLog | 6 +++ sysdeps/unix/sysv/linux/alpha/getrlimit64.c | 64 +++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/alpha/setrlimit64.c | 61 +++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/alpha/getrlimit64.c create mode 100644 sysdeps/unix/sysv/linux/alpha/setrlimit64.c diff --git a/ChangeLog b/ChangeLog index 26e5f96f5d..433b10145d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-12-30 Aurelien Jarno + + [BZ #22648] + * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: New file. + * sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Ditto. + 2017-12-29 Dmitry V. Levin [BZ #22433] diff --git a/sysdeps/unix/sysv/linux/alpha/getrlimit64.c b/sysdeps/unix/sysv/linux/alpha/getrlimit64.c new file mode 100644 index 0000000000..ad398a136f --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/getrlimit64.c @@ -0,0 +1,64 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* Add this redirection so the strong_alias linking getrlimit64 to + {__}getrlimit does not throw a type error. */ +#undef getrlimit +#undef __getrlimit +#define getrlimit getrlimit_redirect +#define __getrlimit __getrlimit_redirect +#include +#undef getrlimit +#undef __getrlimit + +/* RLIM64_INFINITY was supposed to be a glibc convention rather than + anything seen by the kernel, but it ended being passed to the kernel + through the prlimit64 syscall. Given that a lot of binaries with + the wrong constant value are in the wild, provide a wrapper function + fixing the value after the syscall. */ +#define KERNEL_RLIM64_INFINITY 0xffffffffffffffffULL + +int +__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits) +{ + struct rlimit64 krlimits; + + if (INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, &krlimits) < 0) + return -1; + + if (krlimits.rlim_cur == KERNEL_RLIM64_INFINITY) + rlimits->rlim_cur = RLIM64_INFINITY; + else + rlimits->rlim_cur = krlimits.rlim_cur; + if (krlimits.rlim_max == KERNEL_RLIM64_INFINITY) + rlimits->rlim_max = RLIM64_INFINITY; + else + rlimits->rlim_max = krlimits.rlim_max; + + return 0; +} +libc_hidden_def (__getrlimit64) +strong_alias (__getrlimit64, __GI_getrlimit) +strong_alias (__getrlimit64, __GI___getrlimit) +strong_alias (__getrlimit64, __getrlimit) +weak_alias (__getrlimit64, getrlimit) + +weak_alias (__getrlimit64, getrlimit64) +libc_hidden_weak (getrlimit64) diff --git a/sysdeps/unix/sysv/linux/alpha/setrlimit64.c b/sysdeps/unix/sysv/linux/alpha/setrlimit64.c new file mode 100644 index 0000000000..a5f7907afd --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/setrlimit64.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2013-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* Add this redirection so the strong_alias linking setrlimit64 to + {__}setrlimit does not throw a type error. */ +#undef setrlimit +#undef __setrlimit +#define setrlimit setrlimit_redirect +#define __setrlimit __setrlimit_redirect +#include +#undef setrlimit +#undef __setrlimit + +/* RLIM64_INFINITY was supposed to be a glibc convention rather than + anything seen by the kernel, but it ended being passed to the kernel + through the prlimit64 syscall. Given that a lot of binaries with + the wrong constant value are in the wild, provide a wrapper function + fixing the value before the syscall. */ +#define KERNEL_RLIM64_INFINITY 0xffffffffffffffffULL + +int +__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits) +{ + struct rlimit64 krlimits; + + if (rlimits->rlim_cur == RLIM64_INFINITY) + krlimits.rlim_cur = KERNEL_RLIM64_INFINITY; + else + krlimits.rlim_cur = rlimits->rlim_cur; + if (rlimits->rlim_max == RLIM64_INFINITY) + krlimits.rlim_max = KERNEL_RLIM64_INFINITY; + else + krlimits.rlim_max = rlimits->rlim_max; + + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &krlimits, NULL); +} + +weak_alias (__setrlimit64, setrlimit64) + +strong_alias (__setrlimit64, __setrlimit) +weak_alias (__setrlimit64, setrlimit) +#ifdef SHARED +__hidden_ver1 (__setrlimit64, __GI___setrlimit, __setrlimit64); +#endif From patchwork Sat Dec 30 18:44:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 854141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-88678-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="XxRmlwYO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z8C7n1QdLz9s7s for ; Sun, 31 Dec 2017 05:45:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=TT9JYI8IEkSK+HupardQ8qx06IJ2gcd d6ftCKMiQ0dNYX8ruiNq6jSrrMqjSPw0wi6q/liF5/2HB6ys24p3qX96F1/d+PmW 8GAcmSiOr32/MPzUKrTedoxW1WO7YkuVaekiDpRKIXp2Nk3JfZuTcknhSo83A0J1 kA8EiQe1x56w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=pvXOBnK5pAELxIH4YMSSniHgfFQ=; b=XxRml wYOU1BHeoTII/IebThHSlHkUaOxM7V2X5XajSPdYSZy6sp3KtgE8/tBC1xyTxUuT lcoS2iteJQppjYoMApJJZUMbLI+DPUX8yp+qUxCzqGCihsJU6p+5eZ/0vQsqtHng n7TUYeoi0E0lYJGFhqOs22sOPRJfRHzaUBbwoI= Received: (qmail 9390 invoked by alias); 30 Dec 2017 18:44:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 9262 invoked by uid 89); 30 Dec 2017 18:44:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=RESOURCE X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Richard Henderson , Aurelien Jarno Subject: [PATCH 2/4] Alpha: Fix the RLIM_INFINITY and RLIM64_INFINITY constants Date: Sat, 30 Dec 2017 19:44:39 +0100 Message-Id: <20171230184441.25392-3-aurelien@aurel32.net> In-Reply-To: <20171230184441.25392-1-aurelien@aurel32.net> References: <20171230184441.25392-1-aurelien@aurel32.net> Fix the RLIM_INFINITY and RLIM64_INFINITY constants on alpha to match the kernel one and all other architectures. Change the getrlimit, getrlimit64, setrlimit, setrlimit64 into old compat symbols, and provide the Linux generic functions as GLIBC_2_27 version. Note that the alpha implementation does not include the generic getrlimit64.c or setrlimit64.c as they: - redefine SHLIB_COMPAT when __RLIM_T_MATCHES_RLIM64_T == 1 - redefine getrlimit or setrlimit, not allowing to rename them into __new_getrlimit or __new_setrlimit. Changelog: * sysdeps/unix/sysv/linux/alpha/bits/resource.h (RLIM_INFINITY, RLIM64_INFINITY): Fix values to match the kernel ones. * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Rename __getrlimit64 into __old_getrlimit64 and provide it as getrlimit@@GLIBC_2_0 and getrlimit64@@GLIBC_2_1. Add a __getrlimit64 function and provide it as getrlimit@@GLIBC_2_27 and getrlimit64@@GLIBC_2_27. * sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Ditto with setrlimit and setrlimit64. * sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.27): Add getrlimit, setrlimit, getrlimit64 and setrlimit64. * sysdeps/unix/sysv/linux/alpha/Versions (libc): Add getrlimit, setrlimit, getrlimit64 and setrlimit64. --- ChangeLog | 15 +++++++ sysdeps/unix/sysv/linux/alpha/Versions | 3 ++ sysdeps/unix/sysv/linux/alpha/bits/resource.h | 6 +-- sysdeps/unix/sysv/linux/alpha/getrlimit64.c | 56 +++++++++++++++++++-------- sysdeps/unix/sysv/linux/alpha/libc.abilist | 4 ++ sysdeps/unix/sysv/linux/alpha/setrlimit64.c | 52 ++++++++++++++++++------- 6 files changed, 102 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 433b10145d..1e8740530d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2017-12-30 Aurelien Jarno + + * sysdeps/unix/sysv/linux/alpha/bits/resource.h (RLIM_INFINITY, + RLIM64_INFINITY): Fix values to match the kernel ones. + * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Rename __getrlimit64 + into __old_getrlimit64 and provide it as getrlimit@@GLIBC_2_0 and + getrlimit64@@GLIBC_2_1. Add a __getrlimit64 function and provide it + as getrlimit@@GLIBC_2_27 and getrlimit64@@GLIBC_2_27. + * sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Ditto with setrlimit + and setrlimit64. + * sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.27): Add + getrlimit, setrlimit, getrlimit64 and setrlimit64. + * sysdeps/unix/sysv/linux/alpha/Versions (libc): Add getrlimit, + setrlimit, getrlimit64 and setrlimit64. + 2017-12-30 Aurelien Jarno [BZ #22648] diff --git a/sysdeps/unix/sysv/linux/alpha/Versions b/sysdeps/unix/sysv/linux/alpha/Versions index 29b82f999b..3b7971c2a3 100644 --- a/sysdeps/unix/sysv/linux/alpha/Versions +++ b/sysdeps/unix/sysv/linux/alpha/Versions @@ -85,6 +85,9 @@ libc { #errlist-compat 140 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } + GLIBC_2.27 { + getrlimit; setrlimit; getrlimit64; setrlimit64; + } GLIBC_PRIVATE { __libc_alpha_cache_shape; } diff --git a/sysdeps/unix/sysv/linux/alpha/bits/resource.h b/sysdeps/unix/sysv/linux/alpha/bits/resource.h index bd5142caa4..749703b716 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/resource.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/resource.h @@ -112,13 +112,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 ((__rlim_t) -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/sysdeps/unix/sysv/linux/alpha/getrlimit64.c b/sysdeps/unix/sysv/linux/alpha/getrlimit64.c index ad398a136f..25cf4aa555 100644 --- a/sysdeps/unix/sysv/linux/alpha/getrlimit64.c +++ b/sysdeps/unix/sysv/linux/alpha/getrlimit64.c @@ -17,9 +17,10 @@ #include #include +#include -/* Add this redirection so the strong_alias linking getrlimit64 to - {__}getrlimit does not throw a type error. */ +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T + linking getrlimit64 to {__}getrlimit does not throw a type error. */ #undef getrlimit #undef __getrlimit #define getrlimit getrlimit_redirect @@ -28,37 +29,60 @@ #undef getrlimit #undef __getrlimit + +/* Put the soft and hard limits for RESOURCE in *RLIMITS. + Returns 0 if successful, -1 if not (and sets errno). */ +int +__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits) +{ + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits); +} +libc_hidden_def (__getrlimit64) + +strong_alias (__getrlimit64, __GI_getrlimit) +strong_alias (__getrlimit64, __GI_getrlimit64) +strong_alias (__getrlimit64, __GI___getrlimit) +strong_alias (__getrlimit64, __getrlimit) + +versioned_symbol (libc, __getrlimit, getrlimit, GLIBC_2_27); +versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_27); + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27) \ + || SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_27) /* RLIM64_INFINITY was supposed to be a glibc convention rather than anything seen by the kernel, but it ended being passed to the kernel through the prlimit64 syscall. Given that a lot of binaries with the wrong constant value are in the wild, provide a wrapper function fixing the value after the syscall. */ -#define KERNEL_RLIM64_INFINITY 0xffffffffffffffffULL +# define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL int -__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits) +attribute_compat_text_section +__old_getrlimit64 (enum __rlimit_resource resource, + struct rlimit64 *rlimits) { struct rlimit64 krlimits; - if (INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, &krlimits) < 0) + if (__getrlimit64 (resource, &krlimits) < 0) return -1; - if (krlimits.rlim_cur == KERNEL_RLIM64_INFINITY) - rlimits->rlim_cur = RLIM64_INFINITY; + if (krlimits.rlim_cur == RLIM64_INFINITY) + rlimits->rlim_cur = OLD_RLIM64_INFINITY; else rlimits->rlim_cur = krlimits.rlim_cur; - if (krlimits.rlim_max == KERNEL_RLIM64_INFINITY) - rlimits->rlim_max = RLIM64_INFINITY; + if (krlimits.rlim_max == RLIM64_INFINITY) + rlimits->rlim_max = OLD_RLIM64_INFINITY; else rlimits->rlim_max = krlimits.rlim_max; return 0; } -libc_hidden_def (__getrlimit64) -strong_alias (__getrlimit64, __GI_getrlimit) -strong_alias (__getrlimit64, __GI___getrlimit) -strong_alias (__getrlimit64, __getrlimit) -weak_alias (__getrlimit64, getrlimit) -weak_alias (__getrlimit64, getrlimit64) -libc_hidden_weak (getrlimit64) +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27) +strong_alias (__old_getrlimit64, __old_getrlimit) +compat_symbol (libc, __old_getrlimit, getrlimit, GLIBC_2_0); +# endif +# if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_27) +compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1); +# endif +#endif diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index fd2d81fb68..8674a874b4 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2016,6 +2016,8 @@ GLIBC_2.26 pwritev64v2 F GLIBC_2.26 reallocarray F GLIBC_2.27 GLIBC_2.27 A GLIBC_2.27 copy_file_range F +GLIBC_2.27 getrlimit F +GLIBC_2.27 getrlimit64 F GLIBC_2.27 glob F GLIBC_2.27 glob64 F GLIBC_2.27 memfd_create F @@ -2025,6 +2027,8 @@ GLIBC_2.27 pkey_free F GLIBC_2.27 pkey_get F GLIBC_2.27 pkey_mprotect F GLIBC_2.27 pkey_set F +GLIBC_2.27 setrlimit F +GLIBC_2.27 setrlimit64 F GLIBC_2.27 strfromf128 F GLIBC_2.27 strfromf32 F GLIBC_2.27 strfromf32x F diff --git a/sysdeps/unix/sysv/linux/alpha/setrlimit64.c b/sysdeps/unix/sysv/linux/alpha/setrlimit64.c index a5f7907afd..b8074d2df6 100644 --- a/sysdeps/unix/sysv/linux/alpha/setrlimit64.c +++ b/sysdeps/unix/sysv/linux/alpha/setrlimit64.c @@ -17,9 +17,10 @@ #include #include +#include -/* Add this redirection so the strong_alias linking setrlimit64 to - {__}setrlimit does not throw a type error. */ +/* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T + linking setrlimit64 to {__}setrlimit does not throw a type error. */ #undef setrlimit #undef __setrlimit #define setrlimit setrlimit_redirect @@ -28,34 +29,55 @@ #undef setrlimit #undef __setrlimit +/* Set the soft and hard limits for RESOURCE to *RLIMITS. + Only the super-user can increase hard limits. + Return 0 if successful, -1 if not (and sets errno). */ +int +__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits) +{ + return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL); +} +strong_alias (__setrlimit64, __setrlimit) +# ifdef SHARED +__hidden_ver1 (__setrlimit64, __GI___setrlimit, __setrlimit64); +# endif + +versioned_symbol (libc, __setrlimit, setrlimit, GLIBC_2_27); +versioned_symbol (libc, __setrlimit64, setrlimit64, GLIBC_2_27); + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27) \ + || SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_27) /* RLIM64_INFINITY was supposed to be a glibc convention rather than anything seen by the kernel, but it ended being passed to the kernel through the prlimit64 syscall. Given that a lot of binaries with the wrong constant value are in the wild, provide a wrapper function fixing the value before the syscall. */ -#define KERNEL_RLIM64_INFINITY 0xffffffffffffffffULL +# define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL int -__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits) +attribute_compat_text_section +__old_setrlimit64 (enum __rlimit_resource resource, + const struct rlimit64 *rlimits) { struct rlimit64 krlimits; - if (rlimits->rlim_cur == RLIM64_INFINITY) - krlimits.rlim_cur = KERNEL_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 == RLIM64_INFINITY) - krlimits.rlim_max = KERNEL_RLIM64_INFINITY; + if (rlimits->rlim_max == OLD_RLIM64_INFINITY) + krlimits.rlim_max = RLIM64_INFINITY; else krlimits.rlim_max = rlimits->rlim_max; - return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &krlimits, NULL); + return __setrlimit64 (resource, &krlimits); } -weak_alias (__setrlimit64, setrlimit64) - -strong_alias (__setrlimit64, __setrlimit) -weak_alias (__setrlimit64, setrlimit) -#ifdef SHARED -__hidden_ver1 (__setrlimit64, __GI___setrlimit, __setrlimit64); +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27) +strong_alias (__old_setrlimit64, __old_setrlimit) +compat_symbol (libc, __old_setrlimit, setrlimit, GLIBC_2_0); +# endif +# if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_27) +compat_symbol (libc, __old_setrlimit64, setrlimit64, GLIBC_2_1); +# endif #endif From patchwork Sat Dec 30 18:44:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 854140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-88677-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="HkZ9r+kQ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z8C7W3S36z9s7s for ; Sun, 31 Dec 2017 05:45:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=SPRGN3up5pMEWsRiQca/psvPGCUKKpz qYaonwlF3OUF74opKA3BY1v5eiyv6yZSv+d36EWX7TBObb8Yhs3PCfqo6W33NdvA SRYgTBmWr8BXYkRc1TfyPlUBJ3ACDvZW5aYt7pYFtrFGWWnaiYlgvh1iTESfCEj2 XFgyX8FARZY8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=id26IQy8VnYmwvOlSfQxE/xpqvc=; b=HkZ9r +kQjmXHlWgt/Uo3WAd+UYjk2aIMrOy3K+lmjRHUvhSLS2R5UZUotZYCQoG0pHSvx o1kY/GSSMuTdlBHjIm9jFrtFatyqaZ3L5fP6dLnBitF49qPIJq+a6B20SuCjeH5i y/pV2waBRFcPpoLTIjF+9+UDgnbR9e31mGwi/k= Received: (qmail 9299 invoked by alias); 30 Dec 2017 18:44:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 9244 invoked by uid 89); 30 Dec 2017 18:44:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*Ad:U*rth X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Richard Henderson , Aurelien Jarno Subject: [PATCH 3/4] Fix typos in getrlimit64.c and setrlimit64.c Date: Sat, 30 Dec 2017 19:44:40 +0100 Message-Id: <20171230184441.25392-4-aurelien@aurel32.net> In-Reply-To: <20171230184441.25392-1-aurelien@aurel32.net> References: <20171230184441.25392-1-aurelien@aurel32.net> Changelog: * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Fix a typo in the comment. * sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Fix a typo in the comment. (settrlimit): Rename into setrlimit. (__sttrlimit): Rename into __setrlimit. Reviewed-by: Adhemerval Zanella --- ChangeLog | 9 +++++++++ sysdeps/unix/sysv/linux/getrlimit64.c | 2 +- sysdeps/unix/sysv/linux/setrlimit64.c | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e8740530d..663a9186e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2017-12-30 Aurelien Jarno + + * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Fix a typo in the + comment. + * sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Fix a typo in the + comment. + (settrlimit): Rename into setrlimit. + (__sttrlimit): Rename into __setrlimit. + 2017-12-30 Aurelien Jarno * sysdeps/unix/sysv/linux/alpha/bits/resource.h (RLIM_INFINITY, diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c index 37827e5f42..53cb4bb4d8 100644 --- a/sysdeps/unix/sysv/linux/getrlimit64.c +++ b/sysdeps/unix/sysv/linux/getrlimit64.c @@ -21,7 +21,7 @@ #include /* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T - linking getlimit64 to {__}getrlimit does not throw a type error. */ + linking getrlimit64 to {__}getrlimit does not throw a type error. */ #undef getrlimit #undef __getrlimit #define getrlimit getrlimit_redirect diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c index ff835c8733..2b1d3d172e 100644 --- a/sysdeps/unix/sysv/linux/setrlimit64.c +++ b/sysdeps/unix/sysv/linux/setrlimit64.c @@ -21,9 +21,9 @@ #include /* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T - linking setlimit64 to {__}setrlimit does not throw a type error. */ -#undef settrlimit -#undef __sttrlimit + linking setrlimit64 to {__}setrlimit does not throw a type error. */ +#undef setrlimit +#undef __setrlimit #define setrlimit setrlimit_redirect #define __setrlimit __setrlimit_redirect #include From patchwork Sat Dec 30 18:44:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 854145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-88680-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="MeLBcM83"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z8D4W5QGDz9s7s for ; Sun, 31 Dec 2017 06:27:39 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=N6P9SDDcPN2p3ZMcU33Kbk2jvbXy01O cQmGcXtDOPUD2q0e3Iuuq0dg2WpAT29LuugBV1nQSEUJf9Byh2EPhao4kNL5mWS+ DGe5OhCsJ4wji7/a5tg+OlVx/xdw72MZ4T83IjcRslUOAaeOUMB1jiosA79YdtA1 TYjRxuUKXgvM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=UzXCTwkhceHR3C2GKErjuW4lsJw=; b=MeLBc M83gr8A/zIEdsI9oji1eoNtIJiG6ycoVgx4yoCjdd2MWJAc3cOVrGHp4XylFVpNJ 1jByTlVxW7E28BCVD+ZsBFBvjjQVvUajUcQEnwnN+mS+jWJADHC9jOKidneVQCCE V3VQ+Pqj9UwhPGtdw7a42VsHFpTtv3Vq28lIqE= Received: (qmail 106018 invoked by alias); 30 Dec 2017 19:27:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 106002 invoked by uid 89); 30 Dec 2017 19:27:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=6011, H*Ad:U*rth X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Richard Henderson , Aurelien Jarno Subject: [PATCH 4/4] Simplify getrlimit64.c Date: Sat, 30 Dec 2017 19:44:41 +0100 Message-Id: <20171230184441.25392-5-aurelien@aurel32.net> In-Reply-To: <20171230184441.25392-1-aurelien@aurel32.net> References: <20171230184441.25392-1-aurelien@aurel32.net> Changelog: * sysdeps/unix/sysv/linux/alpha/getrlimit64.c (__old_getrlimit64): Drop __RLIM_T_MATCHES_RLIM64_T conditional as __old_getrlimit64 is never defined in that case. Reviewed-by: Adhemerval Zanella --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/getrlimit64.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 663a9186e4..598499fd78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-12-30 Aurelien Jarno + + * sysdeps/unix/sysv/linux/alpha/getrlimit64.c (__old_getrlimit64): + Drop __RLIM_T_MATCHES_RLIM64_T conditional as __old_getrlimit64 is + never defined in that case. + 2017-12-30 Aurelien Jarno * sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Fix a typo in the diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c index 53cb4bb4d8..1310d179d0 100644 --- a/sysdeps/unix/sysv/linux/getrlimit64.c +++ b/sysdeps/unix/sysv/linux/getrlimit64.c @@ -60,11 +60,7 @@ int attribute_compat_text_section __old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits) { -# if __RLIM_T_MATCHES_RLIM64_T -# define rlimits32 (*rlimits) -# else struct rlimit rlimits32; -# endif if (__new_getrlimit (resource, &rlimits32) < 0) return -1;