From patchwork Fri Nov 27 16:27:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Champetier X-Patchwork-Id: 549535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 86811140319 for ; Sat, 28 Nov 2015 03:44:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=LjIjvKHo; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 392BC28C16A; Fri, 27 Nov 2015 17:32:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 0E21728BD7C for ; Fri, 27 Nov 2015 17:29:14 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 27 Nov 2015 17:27:34 +0100 (CET) Received: by wmec201 with SMTP id c201so64241532wme.1 for ; Fri, 27 Nov 2015 08:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jYQDRPULxX6npW9hPR5ZaP8+xIbN8J2UxLEBxROXUdM=; b=LjIjvKHoQNzEF8yE8/PmDTjrWhliTJQqNILbttGWByAIXPM66WeiKhrOARNwbrE866 XdIN2zGy70F5q0oR2TJOCeSZ1s5FVLi1riQVBZIkq4lJcH5dV+KAvEJF58HFHgh4ebJ4 PRhkKIXSXGsCSqZF8X8/aQglJ6YuhG9v4hqCORnp1rmfdt5ys+xU9/MBgwBUBiJ9fwLn k0UUrG2nXvoiLsqDHcO/LIbvQSeSBYSALI53n4K6feUR7Wd2V0vAU8zrrPxkB87MH/3y LyvBZ8Jb4Rbo7udWY2TlrVLKDR3Ti6JWhEaLPs+nmASV1gh5s+8fr85Ny7tDain0FCxw tguw== X-Received: by 10.194.24.226 with SMTP id x2mr54279wjf.43.1448641655454; Fri, 27 Nov 2015 08:27:35 -0800 (PST) Received: from ubuntu1404.lxcnattst (ns623510.ovh.net. [5.135.134.9]) by smtp.gmail.com with ESMTPSA id w67sm8170842wmw.17.2015.11.27.08.27.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Nov 2015 08:27:34 -0800 (PST) From: Etienne CHAMPETIER To: OpenWrt Development List Date: Fri, 27 Nov 2015 16:27:16 +0000 Message-Id: <1448641636-42493-18-git-send-email-champetier.etienne@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448641636-42493-1-git-send-email-champetier.etienne@gmail.com> References: <1448641636-42493-1-git-send-email-champetier.etienne@gmail.com> Subject: [OpenWrt-Devel] [PATCH procd v3 17/17] ujail: add ELF interpreter (DT_INTERP) to the jail X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" this is needed by musl (openwrt DD) uClibc/glibc is working without this this partly fixes https://dev.openwrt.org/ticket/20785 we still don't handle DT_RPATH, DT_RUNPATH, nodeflib, ... see http://man7.org/linux/man-pages/man8/ld.so.8.html Signed-off-by: Etienne CHAMPETIER --- jail/elf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jail/elf.c b/jail/elf.c index 136789e..b8f2cc5 100644 --- a/jail/elf.c +++ b/jail/elf.c @@ -234,6 +234,7 @@ int elf_load_deps(const char *path, const char *map) { unsigned int dyn_offset, dyn_size; unsigned int load_offset, load_vaddr; + unsigned int interp_offset; if (elf_find_section(map, PT_LOAD, &load_offset, NULL, &load_vaddr)) { ERROR("failed to load the .load section from %s\n", path); @@ -245,6 +246,10 @@ int elf_load_deps(const char *path, const char *map) return -1; } + if (elf_find_section(map, PT_INTERP, &interp_offset, NULL, NULL) == 0) { + add_path_and_deps(map+interp_offset, 1, -1, 0); + } + int clazz = map[EI_CLASS]; if (clazz == ELFCLASS32)