Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp32693pxb; Tue, 12 Jan 2021 19:08:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTYClO2fQ3mIaKrP4i3ajjKqwB9JQeFBfdKUkzGlR/MfxC3H6ASnu6u6fiWRecTR8Rs85e X-Received: by 2002:a05:6402:c4:: with SMTP id i4mr104771edu.152.1610507293363; Tue, 12 Jan 2021 19:08:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610507293; cv=none; d=google.com; s=arc-20160816; b=duS2YzWo0wpgn+arMSajTUb311En4oIT3EJv4ZO+X1cems8G86Y59KB+M2pdYPJ5A2 ziuxEg4RXPKmIII1Boks8+OCHqux6rxEO8QYJgE64BmPCVudLd49MFI26X1kKAXMVVGx j+ldDdnPRpoYxhcjjsrAbd3L8FPnauROHhz5C2SmO0PBAPNT0shqNEUstfbqm3MJ8feB BIbcATUt9Ar5YoCuvkYAcLPnWBVIhCPTL5ttb9dBm8RUN+LaMoL57OZIYpB6No+pXYaC 5EQzwL8Ksj1wkk7TQQkkBkgYrQq25tGBsWBSr64tY4iV3AHjUI1m6/hy1cUHCvGlpkwM DWig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=faEP2U/GLH0XWbnop9cIHAhOWoCMvwcHEoYdUtyevyY=; b=f6LdfhQ12D4qxzbwxihy1WX0LASilI28VMVfgoeW395lijHLZ6qmY6lVNvikJ4XWcT ybZKcUHnzwMKBww3jPIuEGL7S3CzIMRjIOPuAn95Xbir//GqofmkkIs83rwohZwcZPZJ +fnBgId7txTk5TucH6xYA+MIFhrOc73YXjwZ0RomYjxm2u+rV+p2iUjx1TQQ6HOu2wbn drj13QmnTFKsK2IOcfv/lrCXl6f8W5v0HsNSFx0KewhfvJeKs8/Am7nKAtXS2qbUUmvl S29O9ftQRpbbCm+yHAvSvioSQHWnzyxxZoHVEJfNdi5qgsI6vHOB70G7OuZKCB6NzgHs 00AQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 i3si297305ejk.273.2021.01.12.19.07.49; Tue, 12 Jan 2021 19:08:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438272AbhALWRn (ORCPT + 99 others); Tue, 12 Jan 2021 17:17:43 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:45122 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437163AbhALWRj (ORCPT ); Tue, 12 Jan 2021 17:17:39 -0500 Received: from ip5f5af0a0.dynamic.kabel-deutschland.de ([95.90.240.160] helo=wittgenstein.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kzRlV-0003bd-9W; Tue, 12 Jan 2021 22:03:49 +0000 From: Christian Brauner To: Alexander Viro , Christoph Hellwig , linux-fsdevel@vger.kernel.org Cc: John Johansen , James Morris , Mimi Zohar , Dmitry Kasatkin , Stephen Smalley , Casey Schaufler , Arnd Bergmann , Andreas Dilger , OGAWA Hirofumi , Geoffrey Thomas , Mrunal Patel , Josh Triplett , Andy Lutomirski , Theodore Tso , Alban Crequy , Tycho Andersen , David Howells , James Bottomley , Seth Forshee , =?UTF-8?q?St=C3=A9phane=20Graber?= , Linus Torvalds , Aleksa Sarai , Lennart Poettering , "Eric W. Biederman" , smbarber@chromium.org, Phil Estes , Serge Hallyn , Kees Cook , Todd Kjos , Paul Moore , Jonathan Corbet , containers@lists.linux-foundation.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, Christian Brauner , Christoph Hellwig Subject: [PATCH v5 24/42] af_unix: handle idmapped mounts Date: Tue, 12 Jan 2021 23:01:06 +0100 Message-Id: <20210112220124.837960-25-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210112220124.837960-1-christian.brauner@ubuntu.com> References: <20210112220124.837960-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=bTjAWrcqQEv0S0d4FYAs3/GqS1T6sx1KbcrCQIdbMQ0=; m=PW2GEMJupmFRQwqgQB7xOoleAqfp7VFtnUtVvLqr8u4=; p=dgP8cuWlJveUhxS/52mzPRIcTb9iQYL13P/6xTWp/W8=; g=076397a88a8e9760309cf71739c9f57e47ff41b1 X-Patch-Sig: m=pgp; i=christian.brauner@ubuntu.com; s=0x0x91C61BC06578DCA2; b=iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCX/4YtwAKCRCRxhvAZXjcosT7AQC8x2b mym3qoBDLlklwDs759tng21Cgfx9XiGYXHDOCoQD/Y/4rxkN0xXVX8YjdyPWiBF3/Ci/CNw/F8TXK HzFg2w4= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When binding a non-abstract AF_UNIX socket it will gain a representation in the filesystem. Enable the socket infrastructure to handle idmapped mounts by passing down the user namespace of the mount the socket will be created from. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before. Cc: Christoph Hellwig Cc: David Howells Cc: Al Viro Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner --- /* v2 */ unchanged /* v3 */ unchanged /* v4 */ unchanged /* v5 */ base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837 --- net/unix/af_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index b4987805e5e5..4be33240e9cc 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -996,7 +996,7 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res) */ err = security_path_mknod(&path, dentry, mode, 0); if (!err) { - err = vfs_mknod(&init_user_ns, d_inode(path.dentry), dentry, mode, 0); + err = vfs_mknod(mnt_user_ns(path.mnt), d_inode(path.dentry), dentry, mode, 0); if (!err) { res->mnt = mntget(path.mnt); res->dentry = dget(dentry); -- 2.30.0