Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2268062pxu; Sat, 17 Oct 2020 18:37:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy49b82JaRqOa+tsefSekcXtgx6tbmwcEC1tskkbz4dLdBvGH+oO5mQAY8RkJ3Qb8eyfty X-Received: by 2002:a17:907:20d6:: with SMTP id qq22mr10607852ejb.187.1602985071237; Sat, 17 Oct 2020 18:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602985071; cv=none; d=google.com; s=arc-20160816; b=p8rDsji/C+C8XOLAlnsKPdCbJF7NLznivr7IMq7hAwrWxKJkcrSEvH1JiaFR84vc+M 0nccFtMvray/E+KeAmQhtrNdGIlnfgEjfDdcKbsYkR1sqOOtoAAsGAo/gxJwcyefbKOD P0QHEWru4a3hqypOnsAHXKQII1DoAkZWrrV1i73b4Qo2duEeprkdcEmgWYWvK4ee34JC tgFAot0KX0lsJE9PPsSp55SI9RZV+B7JXMsJdFfTebWMnqYqRtqp3CU7JC7kIvTEejig 754OizhVHyATQwNugkht7DoL0fg1k5lrbpn984y9YXYnNfuLjSODDDRTKmI9w1rNojOr L0DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=h2GtTlshfWWUrnm7ALXf8OWo2w1JGw4rOyTg09mkVyQ=; b=ctP2f2cdJTAXdbdMqmVhvH97EDjGPGlTydo/Z59lcE395I71N2Nti8ojGdFGi9frJ4 lYRN+menDI9f3g4pYGDmrB/6zQO2qmGBd0MvJwOdxeQLd8bAzFMO2AppxRoIZlSGscte qzXGL+1wxnih99z3F8YIxKi+4ljhP4lZMjhgbO36WcIW5qyYin0n5aBo/tcjSqMz4HyC PruNsrr6auS0XqReMPlqDApZMukvOWqS+p/eMghqgtjmB0DRXgGgLRTclupLeuPcqq2M s+N/ioJ/ZnJ3KDB4KyYgjxQzakrO7npPh2yCS9trEfKBrIqY5CZRcOKh+FHb8s8mykSM LDwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=ApP7c5sX; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si5064764eju.630.2020.10.17.18.37.13; Sat, 17 Oct 2020 18:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=ApP7c5sX; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439933AbgJQX7i (ORCPT + 99 others); Sat, 17 Oct 2020 19:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439715AbgJQX7i (ORCPT ); Sat, 17 Oct 2020 19:59:38 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA3F6C061755 for ; Sat, 17 Oct 2020 16:59:37 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id z5so103372iob.1 for ; Sat, 17 Oct 2020 16:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=h2GtTlshfWWUrnm7ALXf8OWo2w1JGw4rOyTg09mkVyQ=; b=ApP7c5sXrBNPlNOq+WcG1+06dnSbHDjMN70f3T4VJGPh1N27Qb/LtYEGbhNfSHBb7B nLR4DA01wYpPOnLgEiNsu6tBSIpmzoNeGFiWGS8Dx8OVcLpr+QWfzIThlZrTChAH7e/z 6RT+zavq8V9k4N627FbdpMzyYwlBswSG7Prds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=h2GtTlshfWWUrnm7ALXf8OWo2w1JGw4rOyTg09mkVyQ=; b=GDOLk35t84kKSe9L4bp+dC3PML267AkQ57I2krGLtHTV3ufyQVh/QRK7S5XCnLjq1Z QUm8EmzKHBBNhARACn3VjSmwF/mD84GQ9AQjp9dsDGNmyWyjhlSl8/J8FGuzAgYMMVAC V2DqwQRrDN/5sLOkg6Ozg0symQhlHWfYbk95wS0i4fQsnLcBJ+7vF5uB0mqhtHypdwC1 oIwCi0EPOx9HkeOtoSvK68qEYO/4s4y4urY93TWNJIWI9E5k+jdK32aBulDug6+pZqLv XoLTfGOWZ0RZy9R6yIh4wcCWvBWHMDGxxXhQBORTUOxvA25Pxelub5h5jcCjVz0qbzSg udKA== X-Gm-Message-State: AOAM531S5tp0EBhOhKMo+NWhLYSyrWUcdmh1hl5UY7AbJfNuryKl2S2r M4lIozzkaU0tFuP5Gue0m+Fs3Q== X-Received: by 2002:a02:6d4b:: with SMTP id e11mr6791283jaf.41.1602979176779; Sat, 17 Oct 2020 16:59:36 -0700 (PDT) Received: from ircssh-2.c.rugged-nimbus-611.internal (80.60.198.104.bc.googleusercontent.com. [104.198.60.80]) by smtp.gmail.com with ESMTPSA id e11sm6726478ioq.48.2020.10.17.16.59.36 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Oct 2020 16:59:36 -0700 (PDT) Date: Sat, 17 Oct 2020 23:59:34 +0000 From: Sargun Dhillon To: "J . Bruce Fields" , Chuck Lever , Trond Myklebust , Anna Schumaker , David Howells Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH v2 0/3] NFS User Namespaces with new mount API Message-ID: <20201017235933.GA1516@ircssh-2.c.rugged-nimbus-611.internal> References: <20201016124550.10739-1-sargun@sargun.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201016124550.10739-1-sargun@sargun.me> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Oct 16, 2020 at 05:45:47AM -0700, Sargun Dhillon wrote: > This patchset adds some functionality to allow NFS to be used from > NFS namespaces (containers). > > Changes since v1: > * Added samples > > Sargun Dhillon (3): > NFS: Use cred from fscontext during fsmount > samples/vfs: Split out common code for new syscall APIs > samples/vfs: Add example leveraging NFS with new APIs and user > namespaces > > fs/nfs/client.c | 2 +- > fs/nfs/flexfilelayout/flexfilelayout.c | 1 + > fs/nfs/nfs4client.c | 2 +- > samples/vfs/.gitignore | 2 + > samples/vfs/Makefile | 5 +- > samples/vfs/test-fsmount.c | 86 +----------- > samples/vfs/test-nfs-userns.c | 181 +++++++++++++++++++++++++ > samples/vfs/vfs-helper.c | 43 ++++++ > samples/vfs/vfs-helper.h | 55 ++++++++ > 9 files changed, 289 insertions(+), 88 deletions(-) > create mode 100644 samples/vfs/test-nfs-userns.c > create mode 100644 samples/vfs/vfs-helper.c > create mode 100644 samples/vfs/vfs-helper.h > > -- > 2.25.1 > Digging deeper into this a little bit, I actually found that there is some problematic aspects of the current behaviour. Because nfs_get_tree_common calls sget_fc, and sget_fc sets the super block's s_user_ns (via alloc_super) to the fs_context's user namespace unless the global flag is set (which NFS does not set), there are a bunch of permissions checks that are done against the super block's user_ns. It looks like this was introduced in: f2aedb713c28: NFS: Add fs_context support[1] It turns out that unmapped users in the "parent" user namespace just get an EOVERFLOW error when trying to perform a read, even if the UID sent to the NFS server to read a file is a valid uid (the uid in the init user ns), and inode_permission checks permissions against the mapped UID in the namespace, while the authentication credentials (UIDs, GIDs) sent to the server are those from the init user ns. [This is all under the assumption there's not upcalls doing ID mapping] Although, I do not think this presents any security risk (because you have to have CAP_SYS_ADMIN in the init user ns to get this far), it definitely seems like "incorrect" behaviour. [1]: https://lore.kernel.org/linux-nfs/20191120152750.6880-26-smayhew@redhat.com/