Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7530209ybl; Thu, 16 Jan 2020 00:58:35 -0800 (PST) X-Google-Smtp-Source: APXvYqw6T2Ug96/tkFpIWoVLs4RjwbwwcURBOCcoOYApQOqK2QNHOxhQSoK5YGEuO4W+Xm0u799r X-Received: by 2002:a05:6808:a9c:: with SMTP id q28mr3349630oij.176.1579165115158; Thu, 16 Jan 2020 00:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579165115; cv=none; d=google.com; s=arc-20160816; b=JipMpCuKXUMGwukxYG9tFJXlFHe6UksFoMlGRBEjOjvvGD593ICcCP+uhUX90NfBya 7BBdZkAfCO4/bdut+uG+dhSicx9ouQZ+dla6GsIP9D57HYmuAHL/je5r+IID7GJFhE7M iU/HSuhaXfY5dCCm1gOFi1c6hbj+k3y1IzfvAmr4WP3f/HlaKqZBvJJ3tYxgACteYsUM PgZ6BtYzpGxkf+pgkQrOf1LgG4BuP4B2ONn7MUcdtHUd3i6LFbMdgxRJEgOYehcZ6ZNO v+BvQ2co4kl9FNV4arfGlhR62pdbeoi5SSFfTbOa2IXBr9DYnoCiC2S33Q4hvROwxw3E lEJA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=/8xL0qo5HJC5Gak7qJ4Y4U1Ty6p6MmEm4zvba5NjexY=; b=KLQkKOe5YOO7/F0mdyNSQP74Y1l5am5S0+O8x1WBcv8pjb0zrznc9GcWmFPbAv4DFx qHx5wfTi1aziZcC0Iflk9XbbtMceQNZrC5rXev9L179unt6jcyxcbdg14bcZU63V1xsT hIMBTH09yT6dJy88FHdQ1bmS4t+fx8qXTbkMTFAH5ucwKZMAHsqsoZIqEdmYJI7EA1WK KV0uX640cxhkWXxFbXLZ6vNTk/CGDE5RlUwjsZ+JVDfPXNfWRd3mnpDCU39890SMilsq WlC/eA7LKiRxjvrfdt+7ik1DwSh5GpK+K9TBv7A9J8aUnsqs0VYgmSnaVuPb/wcL63rv ca0g== 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 z22si12704236otq.94.2020.01.16.00.58.22; Thu, 16 Jan 2020 00:58:35 -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 S1730613AbgAPIRQ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 16 Jan 2020 03:17:16 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:42023 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbgAPIRQ (ORCPT ); Thu, 16 Jan 2020 03:17:16 -0500 Received: by mail-qt1-f195.google.com with SMTP id j5so18183913qtq.9; Thu, 16 Jan 2020 00:17:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SHx+W0xgTOIdgDlSNYwe3t+59KMiJbuoH0CsD6blozI=; b=M+aOV9CTzAoDYhj89ExWq/tuq11a5wbN5OuI2/Wfq6y+JAZfvCyP5l0u9/h51xTtGj bmKClpXVImCk6M8r+CfOTsqZWxzTPHRYvG5XDNGqYApIM0DUez3My3uf+uhFhw8t6/Mg f1OYt85b5MiAUbpBvEEk3kGXYHcj5oVGXfaOnkmKa5iFt/50gXr2m8yk3hYMYm1vThuN 8wtN77FwzFGecmkiTZCl/4PM0f3UaG648bn1KeiCrC5uh6vEUoraz4WC37QiLgTkow+f JdsWTizd6ByBlKQtsvl6orpAshq2G2Ld7G4Rb9Abr1NCmwN5t4Cf8MCH+XsgIgOFBjCZ 46Mw== X-Gm-Message-State: APjAAAW0Ybn+09lO9zjLf4eyJ9GxSBMIfK6Ejpeh35wCK8d+uvcCOawi NTp9/faMyLazXDqFrqhNWWynwbfc/dV68ZXwJUvNs1L5SJg= X-Received: by 2002:ac8:ff6:: with SMTP id f51mr1256489qtk.60.1579162635612; Thu, 16 Jan 2020 00:17:15 -0800 (PST) MIME-Version: 1.0 References: <20200116022049.164659-1-syq@debian.org> <7af5c24d-dd24-b728-92cf-a5a759787590@vivier.eu> In-Reply-To: <7af5c24d-dd24-b728-92cf-a5a759787590@vivier.eu> From: YunQiang Su Date: Thu, 16 Jan 2020 16:17:04 +0800 Message-ID: Subject: Re: [PATCH v2] binfmt_misc: pass info about P flag by AT_FLAGS To: Laurent Vivier Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, James Bottomley , Al Viro , YunQiang Su Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > > Al? > > Thanks, > Laurent >