From patchwork Thu Dec 1 16:25:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 18103 Received: (qmail 84416 invoked by alias); 1 Dec 2016 16:25:30 -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 84403 invoked by uid 89); 1 Dec 2016 16:25:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=H*MI:vnet, skips, stefan, Stefan X-HELO: mx0a-001b2d01.pphosted.com Subject: Re: [PATCH] Implement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628] To: libc-alpha@sourceware.org References: <7650651f-f268-6405-c04c-61aa18d166f9@redhat.com> <78fc80c3-d047-2b41-b600-8003f5937ac3@redhat.com> From: Stefan Liebler Cc: Florian Weimer Date: Thu, 1 Dec 2016 17:25:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <78fc80c3-d047-2b41-b600-8003f5937ac3@redhat.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16120116-0040-0000-0000-0000026D948C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16120116-0041-0000-0000-000022C9794E Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-01_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612010281 On 11/29/2016 06:31 PM, Florian Weimer wrote: > On 11/14/2016 04:07 PM, Florian Weimer wrote: >> The attached patch depends on the elf/dl-load.c clean I posted today, >> and the addition of the __sigsetjmp hidden definitions on architectures >> which lack them. >> >> The removal of the two function pointers from libc.so (the one in >> rtld_global, and the receiver pointer internal to elf/dl-error.c) is >> desirable from a security perspective, too. > > I added a test. This is what I want to commit soon unless some objects. > > Thanks, > Florian > Hi Florian, The first dlopen ("tst-latepthreadmod.so", RTLD_LOCAL | RTLD_LAZY) call in elf/tst-latepthread.c fails on s390x with "error: dlopen failed: .../build-s390x/elf/tst-latepthreadmod.so: undefined symbol: this_function_is_not_defined". In elf/tst-latepthreadmod.c, this_function_is_not_defined is a sibling call which leads to a R_390_GLOB_DAT relocation in .rela.dyn instead of a R_390_JMP_SLOT in .rela.plt. As RTLD_LAZY skips the JMP_SLOT relocations, but not GLOB_DAT ones, the dlopen call fails. If elf/tst-latepthreadmod.c is build with -fno-optimize-sibling-calls, a JMP_SLOT relocation is generated for this_function_is_not_defined and the test passes. Okay to commit? Bye. Stefan --- ChangeLog: * elf/Makefile (CFLAGS-tst-latepthreadmod.c): Add -fno-optimize-sibling-calls. diff --git a/elf/Makefile b/elf/Makefile index 33b003b..18b3e2a 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1271,6 +1271,9 @@ LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map # Force lazy binding for the same reason. LDFLAGS-tst-latepthreadmod.so = \ -Wl,-z,lazy -Wl,--unresolved-symbols=ignore-all +# Do not optimize sibling calls as the test relies on a JMP_SLOT relocation for +# function this_function_is_not_defined. +CFLAGS-tst-latepthreadmod.c = -fno-optimize-sibling-calls $(objpfx)tst-latepthreadmod.so: $(shared-thread-library) $(objpfx)tst-latepthread: $(libdl) $(objpfx)tst-latepthread.out: $(objpfx)tst-latepthreadmod.so