Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7530991ybl; Thu, 16 Jan 2020 00:59:46 -0800 (PST) X-Google-Smtp-Source: APXvYqw1u4GbS0n8qsW1/NCAKE4PKb/4+VqJOWF09AbmeIJwat7tiiI/WFW6hky7MddFq4nZ4u5d X-Received: by 2002:a05:6830:160c:: with SMTP id g12mr1180461otr.82.1579165186412; Thu, 16 Jan 2020 00:59:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579165186; cv=none; d=google.com; s=arc-20160816; b=JbQtDjJ3ENxX/xk5FO9ADZIFqRDxlbl81TRS+OFo0BPrifhJuC16YFXW6T44Evhr+v EFRWmp3+KLGviPY9R1J6+FsobRZ3mOdxQhGF4EeXHEcz1P9cSIaok9nO6PQAuj4GFmU9 Wze42tCPTqCLDoBjOy9EuuF3LMr8ujjCeLxKqYiNTXwVG4aXxgR3mZ5EYAj/+c70dA9G kSUiBtQFxK5i5CB6qU5SvjmsvO87pPTk2MP0HNqcTM/G0tHDT4m8NiT7PjDVpf9fFcsC 567Kt1K/CZlyU337jPtLH7cNB1dqEwngu49Qvo3oB30tN7ldf6q4ujDgNx2dIqt5TZtG b82Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=JRYrr8oYeY6LIAHt7FIkRSNiLM41pHgSxYrUU8o1wPA=; b=B0Xxeax0AXaq6mloT7Ow34FCtdKWl9LH4kDLxG6jrb0idjN3Bzeoi66lI5RqD21Jne wF34HcQD9B8G+te/6sPxKvL5Fb2tvkcSznjHFBHxOJmabTZQbp/cGmChQrsJpYqL9XlA D2g0F/WTDctOCTv4SA2IRdDNmXHXC3bJMucKA7W+TEylsViS6mtpfSMdm1CSwENgqqXp D5mgo1JefghgJxtMyrc3+KtqzjWyy+D4VEFqKH7jE4NOA+vKZBVdBtLeYbrQFaI8t8yA 0lmRqEpuERjLTyhTOhgIie7CPV83nLUMG9X1+LTSMhd53HW6mPyB03Q4wjTJJx+n4elI /iMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si10817168oic.116.2020.01.16.00.59.34; Thu, 16 Jan 2020 00:59:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730910AbgAPITO (ORCPT + 99 others); Thu, 16 Jan 2020 03:19:14 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:47493 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730354AbgAPITO (ORCPT ); Thu, 16 Jan 2020 03:19:14 -0500 Received: from [192.168.100.1] ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.119]) with ESMTPSA (Nemesis) id 1MCJvA-1ijn9g2WJO-009Pbj; Thu, 16 Jan 2020 09:19:02 +0100 Subject: Re: [PATCH v2] binfmt_misc: pass info about P flag by AT_FLAGS To: YunQiang Su Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, James Bottomley , Al Viro , YunQiang Su References: <20200116022049.164659-1-syq@debian.org> <7af5c24d-dd24-b728-92cf-a5a759787590@vivier.eu> From: Laurent Vivier Autocrypt: addr=laurent@vivier.eu; prefer-encrypt=mutual; keydata= mQINBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GT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BEF0AcELOQzitbJGG5UAEQEAAYkCHwQYAQIACQUC VgUmGQIbDAAKCRDzDDi9Py++PCD3D/9VCtydWDdOyMTJvEMRQGbx0GacqpydMEWbE3kUW0ha US5jz5gyJZHKR3wuf1En/3z+CEAEfP1M3xNGjZvpaKZXrgWaVWfXtGLoWAVTfE231NMQKGoB w2Dzx5ivIqxikXB6AanBSVpRpoaHWb06tPNxDL6SVV9lZpUn03DSR6gZEZvyPheNWkvz7bE6 FcqszV/PNvwm0C5Ju7NlJA8PBAQjkIorGnvN/vonbVh5GsRbhYPOc/JVwNNr63P76rZL8Gk/ hb3xtcIEi5CCzab45+URG/lzc6OV2nTj9Lg0SNcRhFZ2ILE3txrmI+aXmAu26+EkxLLfqCVT ohb2SffQha5KgGlOSBXustQSGH0yzzZVZb+HZPEvx6d/HjQ+t9sO1bCpEgPdZjyMuuMp9N1H ctbwGdQM2Qb5zgXO+8ZSzwC+6rHHIdtcB8PH2j+Nd88dVGYlWFKZ36ELeZxD7iJflsE8E8yg OpKgu3nD0ahBDqANU/ZmNNarBJEwvM2vfusmNnWm3QMIwxNuJghRyuFfx694Im1js0ZY3LEU JGSHFG4ZynA+ZFUPA6Xf0wHeJOxGKCGIyeKORsteIqgnkINW9fnKJw2pgk8qHkwVc3Vu+wGS ZiJK0xFusPQehjWTHn9WjMG1zvQ5TQQHxau/2FkP45+nRPco6vVFQe8JmgtRF8WFJA== Message-ID: Date: Thu, 16 Jan 2020 09:18:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:5gekEDFq6ApMxdo31EQO60DK7ecvC29vrFCg7fqkyJ+zYysBube EQp7lW8LyhYv76QADEzx6PYIAw83sXQblbzHFyJkfU+/VolHIX2JVL0TsSjQhbR0FID/5v+ /gXuTFyEmnCMa6Zowr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Qzr+eYhHI8jUSQkRRK3br9AWgo8KXoIz9HDA5QaZIp/ s8Jzsh3hrNOC6aGB/8IaVZdlr/QacUlV9Orvv+tssm6UB3xzhbOMMg1AI8ctcaMSjzLoXnxnH pv9IsMeG3pstC8kBPjo1fbHELachBsyfzgDIWqdr1OtY Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 16/01/2020 à 09:17, YunQiang Su a écrit : > Laurent Vivier 于2020年1月16日周四 下午4:07写道: >> >> Le 16/01/2020 à 03:20, YunQiang Su a écrit : >>> From: YunQiang Su >>> >>> Currently program invoked by binfmt_misc cannot be aware about whether >>> P flag, aka preserve path is enabled. >>> >>> Some applications like qemu need to know since it has 2 use case: >>> 1. call by hand, like: qemu-mipsel-static test.app OPTION >>> so, qemu have to assume that P option is not enabled. >>> 2. call by binfmt_misc. If qemu cannot know about whether P flag is >>> enabled, distribution's have to set qemu without P flag, and >>> binfmt_misc call qemu like: >>> qemu-mipsel-static /absolute/path/to/test.app OPTION >>> even test.app is not called by absoulute path, like >>> ./relative/path/to/test.app >>> >>> This patch passes this information by the 3rd bits of unused AT_FLAGS. >>> Then, in qemu, we can get this info by: >>> getauxval(AT_FLAGS) & (1<<3) >>> >>> v1->v2: >>> not enable kdebug >>> >>> See: https://bugs.launchpad.net/qemu/+bug/1818483 >>> Signed-off-by: YunQiang Su >>> --- >>> fs/binfmt_elf.c | 6 +++++- >>> fs/binfmt_elf_fdpic.c | 6 +++++- >>> fs/binfmt_misc.c | 2 ++ >>> include/linux/binfmts.h | 4 ++++ >>> 4 files changed, 16 insertions(+), 2 deletions(-) >>> >>> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c >>> index f4713ea76e82..d33ee07d7f57 100644 >>> --- a/fs/binfmt_elf.c >>> +++ b/fs/binfmt_elf.c >>> @@ -178,6 +178,7 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, >>> unsigned char k_rand_bytes[16]; >>> int items; >>> elf_addr_t *elf_info; >>> + elf_addr_t flags = 0; >>> int ei_index; >>> const struct cred *cred = current_cred(); >>> struct vm_area_struct *vma; >>> @@ -252,7 +253,10 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, >>> NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr)); >>> NEW_AUX_ENT(AT_PHNUM, exec->e_phnum); >>> NEW_AUX_ENT(AT_BASE, interp_load_addr); >>> - NEW_AUX_ENT(AT_FLAGS, 0); >>> + if (bprm->interp_flags & BINPRM_FLAGS_PRESERVE_ARGV0) { >>> + flags |= BINPRM_FLAGS_PRESERVE_ARGV0; >>> + } >> >> Perhaps we also need a different flag in AT_FLAG than in interp_flag as >> BINPRM_FLAGS_PRESERVE_ARGV0 is also part of the internal ABI? > > yep. It may be really a problem. > So, should we define a set of new macros for AT_FLAGS? Yes, I think. Thanks, Laurent