From patchwork Mon Mar 24 15:30:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 247 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (caibbdcaaahc.dreamhost.com [208.113.200.72]) by wilcox.dreamhost.com (Postfix) with ESMTP id 9A60C360162 for ; Mon, 24 Mar 2014 08:30:36 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id 4CB6C40A92338; Mon, 24 Mar 2014 08:30:36 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.g.dreamhost.com 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 homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 265AE40A9232B for ; Mon, 24 Mar 2014 08:30:36 -0700 (PDT) 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:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=Bl+btV0Xz1+e1Afvj4w9FkfEIncpc nEMTomWugwwAvBhTG/F/AXNoeWwr/c+dBXTdCDjav928tx3efH7jBiCNot4s7N/0 bXcxz4VAXoc8XuAxR2cWNBbgMcHF4YXmG8ImyRgX2S3Mzng7LGzoG5OCtMJ7D0UG 62LbzOf1MxUNz8= 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:subject:date:message-id:mime-version :content-type; s=default; bh=B2VNII7WheYIIe8otnYtgskp9L4=; b=CfV bRMO6D5A7dNE/0vlZm30ZOAWTrZKkkYB5NAct+uRCBlnLlchIH0KwexBdBx7/JP8 YKA0bUAZwdf3xmIMyuCcJAWjZhSf3axxd12J43grwHpl35g8NGrEaFP73Qr4LC2N rcVNZP5Rv+ka5JAW9Yhd4ZkECRD1QPDq3nz7yeTU= Received: (qmail 25520 invoked by alias); 24 Mar 2014 15:30:34 -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 25508 invoked by uid 89); 24 Mar 2014 15:30:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Never try to execute the file in ldd X-Yow: Go on, EMOTE! I was RAISED on thought balloons!! Date: Mon, 24 Mar 2014 16:30:29 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in Executing a random file is never a good idea. Treat all arguments as if they are invoked with __libc_enable_secure, and run them through the known good dynamic linker. * elf/ldd.bash.in: Always run through the dynamic linker, even if the file has its own interpreter. Remove unneeded executable check. --- elf/ldd.bash.in | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in index 4ff140d..3986bcf 100644 --- a/elf/ldd.bash.in +++ b/elf/ldd.bash.in @@ -150,8 +150,6 @@ for file do echo "ldd: ${file}:" $"not regular file" >&2 result=1 elif test -r "$file"; then - test -x "$file" || echo 'ldd:' $"\ -warning: you do not have execution permission for" "\`$file'" >&2 RTLD= ret=1 for rtld in ${RTLDLIST}; do @@ -164,18 +162,6 @@ warning: you do not have execution permission for" "\`$file'" >&2 fi done case $ret in - 0) - # If the program exits with exit code 5, it means the process has been - # invoked with __libc_enable_secure. Fall back to running it through - # the dynamic linker. - try_trace "$file" - rc=$? - if [ $rc = 5 ]; then - try_trace "$RTLD" "$file" - rc=$? - fi - [ $rc = 0 ] || result=1 - ;; 1) # This can be a non-ELF binary or no binary at all. nonelf "$file" || { @@ -183,7 +169,7 @@ warning: you do not have execution permission for" "\`$file'" >&2 result=1 } ;; - 2) + [02]) try_trace "$RTLD" "$file" || result=1 ;; *)