Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6441939imd; Wed, 31 Oct 2018 11:45:50 -0700 (PDT) X-Google-Smtp-Source: AJdET5fQF2oJDIVWCP75crBMPd3BwNSlG4IhKuBaZjyocNsYDJEUPIrC9wowVW/TkAGA/5+yRwIh X-Received: by 2002:a62:90db:: with SMTP id q88-v6mr4512904pfk.98.1541011550828; Wed, 31 Oct 2018 11:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541011550; cv=none; d=google.com; s=arc-20160816; b=pr/Vt59tIvuFuFi3R1IuOm6nYiwyVtziZE4gcQzhqkOAEb8JVvSg2wbgKrepBxmaG6 SqelnaleDOF3wf+XHbhDvtLzuqYEqoDHauUKRyJCW8RmK4csDVuTJnYLKLFRg3XU+Nfd 4cNTH9SJRiNuH+yf0gkAtFzFzLFRxYyBrJeVavgyM5HUu9L8/dXmHD/59haUEryq122j h6EdGRqGQNIIWxFek9J9MXkRCvqDeEOLT+W/N+66JJ0cbVGDeVfQyj1t55CVbgio0TKi Myclf9V1Ax95zg5LhsfsnWy5zc3dbQrthcvjD6YTHgPxJBrNih7MiZoFTxnwyd0YZCFU LT8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-id:mime-version :subject:cc:to:references:in-reply-to:from:organization; bh=5e973GIrznYd6XoECbvlnrU41Uds16G/jmDVTWEsGhM=; b=M+wsqADY0udF4Ueg2suxyQUZKYzpuC+T1F7ylMbHqzh2fdhrBDY6FI8D4EAauOWY7C hZ3aNf1qmKGqGrVC0jZUR0RF+BCcCvvgJATrH4mRwgep0rN/FKNdbCx+SYvNOlrA6/ei vnqNx57l5RcXlFnIS9k1YMJtR+ixd+85Bx7AqPAM7dDBtqEd+0P5I+/uiBQhXKinJ1Er JRMPQQJJHcz0sD4B4QT2AmhTDSU4FxEVDdLNCuOvIVUuLa6nsr5m0aXGwGdtHpkKcaVh Nvzup1AkM5w4P5a1KO3WQGzEucl6OFmBk20uXBO88/X9pk1y9og1aipFW5VVRrhZagD8 OrwA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si27602599pgw.401.2018.10.31.11.45.35; Wed, 31 Oct 2018 11:45:50 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730109AbeKADoW (ORCPT + 99 others); Wed, 31 Oct 2018 23:44:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6764 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729785AbeKADoW (ORCPT ); Wed, 31 Oct 2018 23:44:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE8D758E2A; Wed, 31 Oct 2018 18:45:06 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-113.rdu2.redhat.com [10.10.120.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 687EF19744; Wed, 31 Oct 2018 18:45:05 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <7505.1541011140@warthog.procyon.org.uk> References: <7505.1541011140@warthog.procyon.org.uk> <87a7mut9cm.fsf@xmission.com> <20181031053355.GQ32577@ZenIV.linux.org.uk> To: ebiederm@xmission.com (Eric W. Biederman) Cc: dhowells@redhat.com, Al Viro , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: [PATCH] vfs: Fix incorrect user_ns assignment in proc and mqueue MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7825.1541011504.1@warthog.procyon.org.uk> Date: Wed, 31 Oct 2018 18:45:04 +0000 Message-ID: <7826.1541011504@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 Oct 2018 18:45:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The user namespace set on a proc superblock should derive from the pid_ns that the superblock is associated with and, similarly, an mqueue superblock should derive from the ipc_ns that that is associated with. Fix both of these to set the proposed user_ns appropriately in the respective get_tree() functions. Fixes: a593f22857a3 ("proc: Add fs_context support to procfs") Fixes: ec772aa43dc7 ("ipc: Convert mqueue fs to fs_context") Reported-by: Eric W. Biederman Signed-off-by: David Howells cc: Alexey Dobriyan --- fs/proc/root.c | 2 ++ ipc/mqueue.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/proc/root.c b/fs/proc/root.c index b0627e622850..3033a900d421 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -162,6 +162,8 @@ static int proc_get_tree(struct fs_context *fc) { struct proc_fs_context *ctx = fc->fs_private; + put_user_ns(fc->user_ns); + fc->user_ns = get_user_ns(ctx->pid_ns->user_ns); fc->s_fs_info = ctx->pid_ns; return vfs_get_super(fc, vfs_get_keyed_super, proc_fill_super); } diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 869687d586a2..9e793c02f350 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -354,6 +354,8 @@ static int mqueue_get_tree(struct fs_context *fc) { struct mqueue_fs_context *ctx = fc->fs_private; + put_user_ns(fc->user_ns); + fc->user_ns = get_user_ns(ctx->ipc_ns->user_ns); fc->s_fs_info = ctx->ipc_ns; return vfs_get_super(fc, vfs_get_keyed_super, mqueue_fill_super); }