Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7569136ybl; Thu, 16 Jan 2020 01:45:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzJafTuBk+fTCjHmxcb9lc8QGLOVfhbCTDkkvrEtIzmQvitLtBw01SlHyVpaaUVL0dKfg80 X-Received: by 2002:aca:1b01:: with SMTP id b1mr3313745oib.6.1579167954358; Thu, 16 Jan 2020 01:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579167954; cv=none; d=google.com; s=arc-20160816; b=ocMPIO3Q1WzvraEmnGHALj3kfeDcn98XTjyjEZneZYGEsYVunlC1Sx0hacuNN1Ldx5 4Jk7cwCy9P5Ic37kDyXsxhEkXYU5fv1X6NNWYJJ193IdadBzKGL51reh931amyHHZCNE 9NU0E9KPQ6nkml4sRS9HZ19rHufe3osvxeT6xVHQguWf2OC3pDf0J+nsPRDR5W6PumSF auv0Qzmr8B6Jnx1zuZoVwsItOb1xjBLaQj9zjF0dYQsJ2Vl9E0/fAlyMrO1faisdYzg5 9ZD6etL1OrBePeJ722z7aqaPUxDNFs6iiftNKtobP4lOWl1uTStfYzFwdbfliuJxI6hw 4gMA== 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:subject:autocrypt:from:references:cc:to; bh=adioglGa7zusXl2fwLMatbWqnYQg/tsiakudeHWjCxE=; b=cmen2z8lAb9BVoP33jSeTcH39uwpNroxJ63aeyqlNw4eDC8n2779SRy2iV63iJ03dc RNfhJdjEV8Ck3IP5bN21X+ZNk3ZfIBbzcoNCakZmDpH4g2g+jzu6jfrZjFl65SGHQbBP xxVtW5Ge7++WbmOSjo7MPWTi3SBqt7dMvB0MaOnOqik5NjMzdIB1yxjuYtW+j4FHSV3M IuPNPLE5PpodOp25mC/pYLH1BLHz+v35Jy5z5Prn0GKQDq3PnogpBxNpDSlRfAtDS4MV uA82JqscQaQRuVxJNTQqkeyAYJksS+AlsKJREbjQ+sUhKBN/y/Z13dbaMJzGWyRmRv+g Wqug== 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 u3si11987048oif.167.2020.01.16.01.45.41; Thu, 16 Jan 2020 01:45:54 -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 S1730163AbgAPHyY (ORCPT + 99 others); Thu, 16 Jan 2020 02:54:24 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:48321 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbgAPHyX (ORCPT ); Thu, 16 Jan 2020 02:54:23 -0500 Received: from [192.168.100.1] ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.119]) with ESMTPSA (Nemesis) id 1M5gAG-1iz8ag3qI6-007Dg7; Thu, 16 Jan 2020 08:54:09 +0100 To: YunQiang Su , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, James Bottomley , Al Viro Cc: YunQiang Su References: <20200116022049.164659-1-syq@debian.org> From: Laurent Vivier Autocrypt: addr=laurent@vivier.eu; prefer-encrypt=mutual; keydata= mQINBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX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vEMRQGbx0GacqpydMEWbE3kUW0ha 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== Subject: Re: [PATCH v2] binfmt_misc: pass info about P flag by AT_FLAGS Message-ID: <7af5c24d-dd24-b728-92cf-a5a759787590@vivier.eu> Date: Thu, 16 Jan 2020 08:54:06 +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: <20200116022049.164659-1-syq@debian.org> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:7/OcgETe0F66YHTSEaDjSJ3GZorzr7u9jao/T8a657xQPaisHxO mY5jeY1DYG4JDuRH36PJtn0jkDsWnayqPmLFf49iG01x8F0BRwZrmUIEkRfQ9kQvFYHq2n+ Ug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gh3fkfPrkG6VTtmTU= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Al? Thanks, Laurent