From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 739A13986408 for ; Fri, 13 May 2022 20:14:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 739A13986408 Received: by mail-oi1-x229.google.com with SMTP id v66so11458683oib.3 for ; Fri, 13 May 2022 13:14:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=coF7kO3WCvnjiN/C72mYEIuyyZjl4c2Y90qepVIO1gw=; b=hB4nEzl9EagMVQWoSm55ZpMW8qvTtc3dWLqo6WkrHNUTufwJT4l5IqJ75PDOV0nb2P oujJyxlFww9dWkPl4T4iD5BEQg09Cq5+q04RSJjUHfsgFrOiUUAIrdocerF5MZtgzVMX 2pxkGwoO+VNDE7XH1SOVg+yGHwY5x28811EMkKEZ6VXNI2DDuNMw+7OqxNeaZQaog0Fd upImGYLcNDK1DNdQVXXY/KOdvLWcSBHndvZsocrYsAFAVquoA2Khf+JGETDczPhZ/ecu UuccKWFrlKXr/fT9i2h/BrFq6xpEFWTQDb0x6amT2Gs1BJtzQQmfC0iaPuhrL8XusJSx Ar5g== X-Gm-Message-State: AOAM532zFjKda/PGxDMThG6gI+vLwQbpzQ0tVHDxPhKFv04l9hqUl4ua 3O+mBWItm8ysJsQstcutDFQ60w== X-Google-Smtp-Source: ABdhPJxX4t7xI7+WMnlbe7GxOSiiCa6UU6NgFlcJ6TxTywLzxcbUkzxqh0u4yBkDBptyn82WJFxxZA== X-Received: by 2002:a05:6808:120d:b0:2d9:a01a:4895 with SMTP id a13-20020a056808120d00b002d9a01a4895mr8788479oil.224.1652472888630; Fri, 13 May 2022 13:14:48 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:5fbd:b7af:daa5:1bf0:c543? ([2804:431:c7ca:5fbd:b7af:daa5:1bf0:c543]) by smtp.gmail.com with ESMTPSA id u7-20020a056871058700b000e686d13876sm1446795oan.16.2022.05.13.13.14.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 May 2022 13:14:48 -0700 (PDT) Message-ID: Date: Fri, 13 May 2022 17:14:45 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v6 2/4] rtld: Remove DL_ARGV_NOT_RELRO and make _dl_skip_args const Content-Language: en-US To: Szabolcs Nagy , libc-alpha@sourceware.org Cc: Florian Weimer References: <94c82dda28369de49a68e25ac606b828a2e4fd02.1651757640.git.szabolcs.nagy@arm.com> From: Adhemerval Zanella In-Reply-To: <94c82dda28369de49a68e25ac606b828a2e4fd02.1651757640.git.szabolcs.nagy@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Fri, 13 May 2022 20:14:52 -0000 On 05/05/2022 10:58, Szabolcs Nagy via Libc-alpha wrote: > _dl_skip_args is always 0, so the target specific code that modifies > argv after relro protection is applied is no longer used. > > After the patch relro protection is applied to _dl_argv consistently > on all targets. > > --- > v6: > - const _dl_skip_args. > v4: > - New patch. > Reviewed-by: Florian Weimer > Tested-by: Florian Weimer LGTM to me as well. Reviewed-by: Adhemerval Zanella > --- > elf/rtld.c | 10 ++-------- > sysdeps/aarch64/dl-sysdep.h | 4 ---- > sysdeps/alpha/dl-sysdep.h | 23 ----------------------- > sysdeps/arc/dl-sysdep.h | 4 ---- > sysdeps/arm/dl-sysdep.h | 4 ---- > sysdeps/csky/dl-sysdep.h | 23 ----------------------- > sysdeps/generic/ldsodefs.h | 13 +++---------- > sysdeps/ia64/dl-sysdep.h | 23 ----------------------- > sysdeps/nios2/dl-sysdep.h | 4 ---- > sysdeps/s390/s390-32/dl-sysdep.h | 23 ----------------------- > sysdeps/sparc/dl-sysdep.h | 23 ----------------------- > sysdeps/unix/sysv/linux/ia64/dl-sysdep.h | 4 ---- > 12 files changed, 5 insertions(+), 153 deletions(-) > delete mode 100644 sysdeps/alpha/dl-sysdep.h > delete mode 100644 sysdeps/csky/dl-sysdep.h > delete mode 100644 sysdeps/ia64/dl-sysdep.h > delete mode 100644 sysdeps/s390/s390-32/dl-sysdep.h > delete mode 100644 sysdeps/sparc/dl-sysdep.h > > diff --git a/elf/rtld.c b/elf/rtld.c > index b5070d453f..71f7095def 100644 > --- a/elf/rtld.c > +++ b/elf/rtld.c > @@ -157,16 +157,10 @@ static void dl_main_state_init (struct dl_main_state *state); > extern char **_environ attribute_hidden; > static void process_envvars (struct dl_main_state *state); > > -#ifdef DL_ARGV_NOT_RELRO > -int _dl_argc attribute_hidden; > -char **_dl_argv = NULL; > -/* Nonzero if we were run directly. */ > -unsigned int _dl_skip_args attribute_hidden; > -#else > int _dl_argc attribute_relro attribute_hidden; > char **_dl_argv attribute_relro = NULL; > -unsigned int _dl_skip_args attribute_relro attribute_hidden; > -#endif > +/* Always 0, only kept for not-yet-updated target start code. */ > +const unsigned int _dl_skip_args attribute_hidden; > rtld_hidden_data_def (_dl_argv) > > #ifndef THREAD_SET_STACK_GUARD > diff --git a/sysdeps/aarch64/dl-sysdep.h b/sysdeps/aarch64/dl-sysdep.h > index 667786671c..1516dd7d3f 100644 > --- a/sysdeps/aarch64/dl-sysdep.h > +++ b/sysdeps/aarch64/dl-sysdep.h > @@ -18,8 +18,4 @@ > > #include_next > > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > - > #define DL_EXTERN_PROTECTED_DATA > diff --git a/sysdeps/alpha/dl-sysdep.h b/sysdeps/alpha/dl-sysdep.h > deleted file mode 100644 > index 3099ee419f..0000000000 > --- a/sysdeps/alpha/dl-sysdep.h > +++ /dev/null > @@ -1,23 +0,0 @@ > -/* System-specific settings for dynamic linker code. Alpha version. > - Copyright (C) 2002-2022 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_next > - > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > diff --git a/sysdeps/arc/dl-sysdep.h b/sysdeps/arc/dl-sysdep.h > index da060ceeee..cf4d160a73 100644 > --- a/sysdeps/arc/dl-sysdep.h > +++ b/sysdeps/arc/dl-sysdep.h > @@ -18,8 +18,4 @@ > > #include_next > > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > - > #define DL_EXTERN_PROTECTED_DATA > diff --git a/sysdeps/arm/dl-sysdep.h b/sysdeps/arm/dl-sysdep.h > index ce7a84a7de..7a99107436 100644 > --- a/sysdeps/arm/dl-sysdep.h > +++ b/sysdeps/arm/dl-sysdep.h > @@ -18,8 +18,4 @@ > > #include_next > > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > - > #define DL_EXTERN_PROTECTED_DATA > diff --git a/sysdeps/csky/dl-sysdep.h b/sysdeps/csky/dl-sysdep.h > deleted file mode 100644 > index fc8a58b94c..0000000000 > --- a/sysdeps/csky/dl-sysdep.h > +++ /dev/null > @@ -1,23 +0,0 @@ > -/* System-specific settings for dynamic linker code. C-SKY version. > - Copyright (C) 2018-2022 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_next > - > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h > index 4a5e698db2..f3d3c78927 100644 > --- a/sysdeps/generic/ldsodefs.h > +++ b/sysdeps/generic/ldsodefs.h > @@ -762,18 +762,11 @@ rtld_hidden_proto (__libc_stack_end) > > /* Parameters passed to the dynamic linker. */ > extern int _dl_argc attribute_hidden attribute_relro; > -extern char **_dl_argv > -#ifndef DL_ARGV_NOT_RELRO > - attribute_relro > -#endif > - ; > +extern char **_dl_argv attribute_relro; > rtld_hidden_proto (_dl_argv) > #if IS_IN (rtld) > -extern unsigned int _dl_skip_args attribute_hidden > -# ifndef DL_ARGV_NOT_RELRO > - attribute_relro > -# endif > - ; > +/* Always 0, only kept for not-yet-updated target start code. */ > +extern const unsigned int _dl_skip_args attribute_hidden; > #endif > #define rtld_progname _dl_argv[0] > > diff --git a/sysdeps/ia64/dl-sysdep.h b/sysdeps/ia64/dl-sysdep.h > deleted file mode 100644 > index e3a58bec24..0000000000 > --- a/sysdeps/ia64/dl-sysdep.h > +++ /dev/null > @@ -1,23 +0,0 @@ > -/* System-specific settings for dynamic linker code. IA-64 version. > - Copyright (C) 2002-2022 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_next > - > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > diff --git a/sysdeps/nios2/dl-sysdep.h b/sysdeps/nios2/dl-sysdep.h > index 0354650042..257b37c258 100644 > --- a/sysdeps/nios2/dl-sysdep.h > +++ b/sysdeps/nios2/dl-sysdep.h > @@ -18,8 +18,4 @@ > > #include_next > > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > - > #define DL_EXTERN_PROTECTED_DATA > diff --git a/sysdeps/s390/s390-32/dl-sysdep.h b/sysdeps/s390/s390-32/dl-sysdep.h > deleted file mode 100644 > index 699b50f156..0000000000 > --- a/sysdeps/s390/s390-32/dl-sysdep.h > +++ /dev/null > @@ -1,23 +0,0 @@ > -/* System-specific settings for dynamic linker code. S/390 version. > - Copyright (C) 2014-2022 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_next > - > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > diff --git a/sysdeps/sparc/dl-sysdep.h b/sysdeps/sparc/dl-sysdep.h > deleted file mode 100644 > index f32f16a107..0000000000 > --- a/sysdeps/sparc/dl-sysdep.h > +++ /dev/null > @@ -1,23 +0,0 @@ > -/* System-specific settings for dynamic linker code. SPARC version. > - Copyright (C) 2002-2022 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_next > - > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > diff --git a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > index 0d2a1d093a..aa1de6b361 100644 > --- a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > +++ b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > @@ -48,8 +48,4 @@ extern int _dl_sysinfo_break attribute_hidden; > ".previous"); > #endif > > -/* _dl_argv cannot be attribute_relro, because _dl_start_user > - might write into it after _dl_start returns. */ > -#define DL_ARGV_NOT_RELRO 1 > - > #endif /* dl-sysdep.h */