Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2354092imm; Sun, 7 Oct 2018 02:11:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62vb0RZvncTdZ6WYB0hEPB4x2JVJkryXABNwojJCNBcBtr0KNkksdxetTkLaNb7T3ik6J4V X-Received: by 2002:a62:9586:: with SMTP id c6-v6mr19796068pfk.234.1538903519854; Sun, 07 Oct 2018 02:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538903519; cv=none; d=google.com; s=arc-20160816; b=yTaLl3OXWHdaQ2sg9cO0c/DY8shRIqs6LpJgNqpKGpclR6pYsjpr0WhfinV45TW1cH 7BM3X2iRr5LifrNryObTuzPotVH9C0hnCMYjnvg09ihB8Xmjw2ZDpVWFD9S0+T4Yz1P/ b6DjFZMbiGaU3gREJ8ZSjAJD7qyY88nx1mdLsisZgQKvUvq6uyYCu9uoBDLN2Mj/hI95 0DJjsTHWxQES81DG/rmJYBxmNMtuqtPVLc+R9ZVn5SiHIZWDa3cRzSFRGKz3E0PrdSoJ ShCJnxewu21hNY5qQB8jvbhzs55I4F97Fctch2Ix+4/8ETi8bH30C4DWKTk/ZbILrpmd dSIg== 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:openpgp:from:references:cc:to:subject; bh=GmaX46bBCb0vy+Fk25JXLdlX+TKDoCJicM9LeCDeWQ0=; b=Esiw+Wjwbu/vdDpDBTVxXimCSmr5A0eIhSh4qY8x3xVsG3rlRSFyqLJkIdjtMSXUUb 02y2tJxiGPLDHqNAbKZf6LqwFUyuBwgoX0ChIwb0k28SS5QJOxd0kbjD/JNC1jCT3NpP WCjLrbjlgAYASJkEcedM9l8vf4FfNzS5IFPKgNXdffx119tYy0ot/NyzGpiDECCPmhZr PGNSvq0sq6uJTAtNBfS3L6xi/SabeksrusOQwnGf1ESpwoG6bs5LcB/ozQyfroAewALM pDn9mhCJexcBmzJrMkEKLMZi+iMsXO83+oQO97hXtZWQUlXgGTzbv7UxBY99WUChSZ3B 9cuA== 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 o5-v6si14118145pgm.222.2018.10.07.02.11.42; Sun, 07 Oct 2018 02:11:59 -0700 (PDT) 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 S1727383AbeJGQSP (ORCPT + 99 others); Sun, 7 Oct 2018 12:18:15 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:33305 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726402AbeJGQSP (ORCPT ); Sun, 7 Oct 2018 12:18:15 -0400 Received: from [192.168.100.1] ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MCb2L-1g0alP1ygF-009hK7; Sun, 07 Oct 2018 11:11:04 +0200 Received: from [192.168.100.1] ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MCb2L-1g0alP1ygF-009hK7; Sun, 07 Oct 2018 11:11:04 +0200 Subject: Re: [RFC v4 1/1] ns: add binfmt_misc to the user namespace To: "Serge E. Hallyn" Cc: linux-kernel@vger.kernel.org, Andrei Vagin , linux-fsdevel@vger.kernel.org, Eric Biederman , linux-api@vger.kernel.org, Dmitry Safonov , containers@lists.linux-foundation.org, Alexander Viro , Jann Horn , James Bottomley References: <20181006193546.29340-1-laurent@vivier.eu> <20181006193546.29340-2-laurent@vivier.eu> <20181007050224.GA3035@mail.hallyn.com> From: Laurent Vivier Openpgp: preference=signencrypt Autocrypt: addr=laurent@vivier.eu; prefer-encrypt=mutual; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgVGVLYthYSfTtN0Y60OgNkWCMtFwKxRaXt1WFA5ceqinN/XkgA+vf2Ch72zBkJL RBIhfOPFv5f2Hkkj0MvsUXpOWaOjatiu0fpPo6Hw14UEpywke1zN4NKubApQOlNKZZC4hu6/ 8pv2t4HRi7s0K88jQYBRPObjrN5+owtI51xMaYzvPitHQ2053LmgsOdN9EKOqZeHAYG2SmRW LOxYWKX14YkZI5j/TXfKlTpwSMvXho+efN4kgFvFmP6WT+tPnwARAQABzSNMYXVyZW50IFZp dmllciA8bHZpdmllckByZWRoYXQuY29tPsLBeAQTAQIAIgUCVgVQgAIbAwYLCQgHAwIGFQgC CQoLBBYCAwECHgECF4AACgkQ8ww4vT8vvjwpgg//fSGy0Rs/t8cPFuzoY1cex4limJQfReLr SJXCANg9NOWy/bFK5wunj+h/RCFxIF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0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181007050224.GA3035@mail.hallyn.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:UQR9P06QS6m7HAMwk7fFt47FCHvBBRqCiBbx4OnMBJBEDT762hF kt60xsCj7EU/Pwm8YJK+K+bgLX1ZdDc0BlxzSgYkyS5rPVvxogBm4FtjB2rGbmDX1LGGdOm zpAwDj5SxrXYGbrEEnb/wvwmuiwDyN+57KJ1CNPZxUg8560NUZhktzUj52AUnjaTcDq2JW1 vAWlvYZtepQcSuYQeqXtw== X-UI-Out-Filterresults: notjunk:1;V01:K0:e5yJX/G5PnQ=:FA28uddt6x5K4EDsIxB43o 4PWQ0Zuz3SxooEF2zmperNhT4nhbxcuq90sumIjkVi5FEwcMKusy3x7wYUWgebM04EYz8P0qp nTaMwVQKOlBphmPk8ZSsSjQAtzQtQOMif7aRywXuZ68KKSGjVLiTdIEqNf0qRbfls9pjxogdg vzeBHzUiEjhn+7q8t2GI90Db9I2zZ/LTfETB6R88BuwYXGKkP+iq9tN2BDfooo9WJCH2SVecL 5UjmSEzvClBUt6kj59HauAy8PxJpZB1uK3h4riUKNLGwEWsPrDFhq/inlYh24ZYHX2D/bDpyR wePudQzQZTSan3q0XYGwL1Er32TxJ+H2/FMzhsW7asVBAEZOoMYu4JXHkTusugk7kyHDVasCm ulmOdnL2S7Dpw/wDwLdzzV9u6A8Xpkaso3zI71LPjgAA9Qo/nV0MsAj7SATvq/R3abzHr+Wqr 7QPhxxVBxSHtMeIGQWfcv8Kk2MSY7hxFLxiWN4BUng0RjlS2mMiQyJVAmwMxA2BtjyJQWMJNa oM/9L4+cDqV+HFg3kE/WtZb7KfsZuSDioSasR3qEfvNZp/QM7hoVJZIHxW7mmYBxFxf2pzWNQ h+J1fFLTqDv0G9pbhlFebAUDCznadKryRsqxCPRV9khbs3anz2AaB1rf1UzWxuSQ2niDki4qn +cWrx7IF6FAK13vrmI1PI0oFFw3A+Ntkz5MyrDN0CpeJjOLmVC1z4QS3H+SkA/kFeDUBjW8qi UnnNQC5lcB25iW2W Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 07/10/2018 à 07:02, Serge E. Hallyn a écrit : > On Sat, Oct 06, 2018 at 09:35:46PM +0200, Laurent Vivier wrote: >> This patch allows to have a different binfmt_misc configuration >> for each new user namespace. By default, the binfmt_misc configuration >> is the one of the previous level, but if the binfmt_misc filesystem is >> mounted in the new namespace a new empty binfmt instance is created and >> used in this namespace. >> >> For instance, using "unshare" we can start a chroot of an another >> architecture and configure the binfmt_misc interpreter without being root >> to run the binaries in this chroot. >> >> Signed-off-by: Laurent Vivier > > Hi, > > quick question below, > >> --- >> fs/binfmt_misc.c | 99 ++++++++++++++++++++++++---------- >> include/linux/user_namespace.h | 13 +++++ >> kernel/user.c | 13 +++++ >> kernel/user_namespace.c | 7 +++ >> 4 files changed, 104 insertions(+), 28 deletions(-) >> >> diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c >> index aa4a7a23ff99..1beefafcb416 100644 >> --- a/fs/binfmt_misc.c ... >> @@ -725,12 +736,16 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, >> >> if (e->flags & MISC_FMT_OPEN_FILE) { >> struct file *f; >> + const struct cred *old_cred; >> >> + old_cred = override_creds(file->f_cred); > > What exactly is this aiming to do? See comment from the version 1: https://lkml.org/lkml/2018/10/1/377 "This looks wrong. A write handler's behavior should not depend on the namespace of the process that is using it. Ideally, the affected namespace should depend on the file you're writing to. If that's not possible, the affected namespace should at least be the namespace of the process that opened the file." -- Jann Horn And from version 2: https://lkml.org/lkml/2018/10/3/872 "Something else: bm_register_write() currently calls into open_exec(), which uses the credentials of current. That's not really allowed in this context - but so far, it's not a big deal because only init-namespace root can reach this code. Before you expose this stuff to unprivileged userspace, this needs to get fixed; perhaps by wrapping the open_exec() call in override_creds(file->f_cred) and revert_creds()." -- Jann Horn Thanks, Laurent