From patchwork Thu Aug 16 07:34:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Vagin X-Patchwork-Id: 10567109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 447601390 for ; Thu, 16 Aug 2018 07:34:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C3112A74F for ; Thu, 16 Aug 2018 07:34:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F5C12A766; Thu, 16 Aug 2018 07:34:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30BF02A74F for ; Thu, 16 Aug 2018 07:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731138AbeHPKan (ORCPT ); Thu, 16 Aug 2018 06:30:43 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42770 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727160AbeHPKan (ORCPT ); Thu, 16 Aug 2018 06:30:43 -0400 Received: by mail-pg1-f193.google.com with SMTP id y4-v6so1653068pgp.9 for ; Thu, 16 Aug 2018 00:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=eb/V6PryPxaczYyXFH7VynLXVPy3MRfztIFllhIcwqg=; b=EZ6526De8eRg/OqvcCsBCuruNSkArZ3p4yHvyChGYAgo/fUp4Lsllpj+JjBXhyS5ve 4k1nOjrLjkvIpPDCIH8gLwgoRu1PaLNylOL4aEqjQWY8B6ZCTSlDWEvZX4XJoP4mgtMU awBTIyoIzPktkT1Y6aQHfJYiSKh2zWah0diIEfyMdiFnlj5nvUK2lhzc4dTE3APxuhwD 59EDep+3N3eI5G0rjWmpd4n0kdE5Oud8WlftZZhy3ykOxXfa+DB/bwfBTbjFRm8eeTOd sn8oO7yncuFx3RyCBM7dc0VKg5zNIJ02tOFYSxLScwpwfUHXhMPDqL3rb4xRSINwvjD1 cPOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=eb/V6PryPxaczYyXFH7VynLXVPy3MRfztIFllhIcwqg=; b=tIis9U+yW77RAlNpvtOA2ecbmTsbmUU8sd1O1G1pSSgcHWB1mvFdfB2qOS46THy/U5 k/GLzR6gWWic4/A4y+lZDQv6xXhoSs2Ro3mtUugVxJolTZDz0LUdQq2A/F87mylDAX3d 5psvdjLhd7b6nivoN/o1exBe/TdKoZa9bqOqRGhx8ysHFJkQinujJxM3ZggidtlIIa6X 2GdrjrGg2ZVL7hUEZ8pMPyF7GAzVodkODzgNp+nunmw4gKN7t6lcbGqCbgJY1jzWGoKR c39bHhl4kDF4ax9sdkZx7KU/fQpCg0yP6E5RNsnyfpzZdXZIDzLPri/idYCHR6bKyj6X b0sw== X-Gm-Message-State: AOUpUlEIilrWdRAL0i5ZaCxlm+gvAS7qHJW2WFZ2nl9DjcpWcYKCzGHL ZAnUQoVnvpOg9wPTE8Wd2Wg= X-Google-Smtp-Source: AA+uWPymEpprmPOQAkRQ/S+Gn1zxv6LPOIBasmTePIiw8zcL/RelZP5xl5lFoRPLUUQkL2ksxs0CPg== X-Received: by 2002:a63:c608:: with SMTP id w8-v6mr27881965pgg.16.1534404850292; Thu, 16 Aug 2018 00:34:10 -0700 (PDT) Received: from localhost.localdomain (c-73-140-212-29.hsd1.wa.comcast.net. [73.140.212.29]) by smtp.gmail.com with ESMTPSA id 22-v6sm40995704pfl.126.2018.08.16.00.34.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Aug 2018 00:34:09 -0700 (PDT) From: Andrei Vagin To: David Howells Cc: linux-fsdevel@vger.kernel.org, Andrei Vagin , Andrei Vagin Subject: [PATCH dhowells/mount-api] proc: set a proper user namespace for fs_context Date: Thu, 16 Aug 2018 00:34:07 -0700 Message-Id: <20180816073407.12567-1-avagin@openvz.org> X-Mailer: git-send-email 2.17.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A user namespace should be taken from a pidns for which a procfs is created. Signed-off-by: Andrei Vagin --- fs/proc/root.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/proc/root.c b/fs/proc/root.c index 1d6e5bfa30cc..1419b48a89ab 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -315,6 +315,11 @@ int pid_ns_prepare_proc(struct pid_namespace *ns) if (IS_ERR(fc)) return PTR_ERR(fc); + if (fc->user_ns != ns->user_ns) { + put_user_ns(fc->user_ns); + fc->user_ns = get_user_ns(ns->user_ns); + } + ctx = fc->fs_private; if (ctx->pid_ns != ns) { put_pid_ns(ctx->pid_ns);