From patchwork Tue Jan 31 17:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 1734983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=eOudilBs; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P5sjS0kcHz23gV for ; Wed, 1 Feb 2023 04:38:51 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pMuaj-0005mQ-Pp; Tue, 31 Jan 2023 17:38:45 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pMuah-0005lp-Pv for kernel-team@lists.ubuntu.com; Tue, 31 Jan 2023 17:38:43 +0000 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 84EBB41AC7 for ; Tue, 31 Jan 2023 17:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675186723; bh=jHIlAgcgy6XBSTodbDIEF9/sj/0By0kgOYBMpPJZxNU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eOudilBs8u338Q1VOZKegTpG5etTW3Xlj9cVi5EyphoiIvbZgtUfbSuoC2lX5igSK YNdeLRfsqonE6Iwf2SmQ7NEE48/U3JANutGODsXG4Iw+gSkkQld7nJKQM4tfXItDLv Tn9Tov8i5ZWTi5qkcMnE9vbtmtODVmOmP/z93N3g4m4FgrRcvikPRPO1reNXjGnCgZ WxX32phLXCbyTnadrZnKbvF/nmembqdyR85KCU9CpL1JdcPNe57IsNLVzDtDaM6dW1 Cion/jFYXe8dlC5MeFzEMtzhDTd2SJ6J7i2+UKsyCHvc2XE8tPoyMAu7M11gUBzEu+ YCtQy3rLE0Qog== Received: by mail-ed1-f70.google.com with SMTP id j10-20020a05640211ca00b0049e385d5830so11212473edw.22 for ; Tue, 31 Jan 2023 09:38:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jHIlAgcgy6XBSTodbDIEF9/sj/0By0kgOYBMpPJZxNU=; b=yyv6A+CGoPcHaUhP35PfFxQxjHlC9z8v4GrlRg6u0tTd3Ulnx7TmTjGKUeaGJxE+nu rISW0te41GHIreATNZik96yNymwfk/LEwXJ1eVK6h28mlFGH4X1MEeV/r9RoO5cWCJ+I +j18oD9Wj0Nvr10XCRZzG/GBvvWv5VLgrqR7mDm4JwV6x+RlsNju42Vdw4/RtMYGeFFy 7LWxps/0TuTsZnz2aUjYzQNB3YuUAw3A/yKU0TBXnlJjOBdYcb5Sg9Ln9rsohNKLc7iN rAo1Sp1UtfqUoOlc4Ffrf+bB0CFOa1sxaHn+vHOA8mVs5s7sNipjSGVgucL0a2zjARft HZqw== X-Gm-Message-State: AFqh2kpVS5Sxqie4J4H/03zlGvmLR4yfbR/2c4fbptiwyEJE6lCoWzAY Wt+9/KTu+Tp4RJ7YRqfoHtqTeRCCZeKk5kPOc0IB2gJtoCwO4E1XDxqqLqzXtSJmnnJM2OZF8Qz yeWS0Ts2bfJWL3UWeXsL/IXuhPbs37gIgFC9yJS8GyQ== X-Received: by 2002:a05:6402:294c:b0:49e:28b6:4cf5 with SMTP id ed12-20020a056402294c00b0049e28b64cf5mr62492055edb.12.1675186722566; Tue, 31 Jan 2023 09:38:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXvEiqIQIZ2XXO6SqQy3rWAsR/HFiJLFa74F3uTDaM/mfHU/tdLiDO4izou//1bfvheDNuOtow== X-Received: by 2002:a05:6402:294c:b0:49e:28b6:4cf5 with SMTP id ed12-20020a056402294c00b0049e28b64cf5mr62492042edb.12.1675186722324; Tue, 31 Jan 2023 09:38:42 -0800 (PST) Received: from amikhalitsyn.. (ip5f5bf399.dynamic.kabel-deutschland.de. [95.91.243.153]) by smtp.gmail.com with ESMTPSA id g5-20020a50ee05000000b004835bd8dfe5sm8693631eds.35.2023.01.31.09.38.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 09:38:41 -0800 (PST) From: Alexander Mikhalitsyn To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/2] UBUNTU: SAUCE: shiftfs: always rely on init_user_ns Date: Tue, 31 Jan 2023 18:38:32 +0100 Message-Id: <20230131173833.557692-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131173833.557692-1-aleksandr.mikhalitsyn@canonical.com> References: <20230131173833.557692-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Andrea Righi BugLink: https://bugs.launchpad.net/bugs/1990849 With the porting of shiftfs from 5.15 to 5.17 some filesystem-related functions are now passing struct user_namespace as argument, however shiftfs logic is still relying on the fact that these functions need to use the main filesystem namespace. Make sure to always use init_user_ns to prevent breakage of system components that rely on shiftfs. Without this fix lxd was showing some issues, like failing to create any file inside a container when shiftfs was used (e.g., using zfs as storage pool). Signed-off-by: Andrea Righi --- fs/shiftfs.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/fs/shiftfs.c b/fs/shiftfs.c index 76c54bc12018..a21624c529f0 100644 --- a/fs/shiftfs.c +++ b/fs/shiftfs.c @@ -308,8 +308,7 @@ static const char *shiftfs_get_link(struct dentry *dentry, struct inode *inode, return p; } -static int shiftfs_setxattr(struct user_namespace *ns, - struct dentry *dentry, struct inode *inode, +static int shiftfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, int flags) { @@ -318,7 +317,7 @@ static int shiftfs_setxattr(struct user_namespace *ns, const struct cred *oldcred; oldcred = shiftfs_override_creds(dentry->d_sb); - err = vfs_setxattr(ns, lowerd, name, value, size, flags); + err = vfs_setxattr(&init_user_ns, lowerd, name, value, size, flags); revert_creds(oldcred); shiftfs_copyattr(lowerd->d_inode, inode); @@ -363,7 +362,7 @@ static int shiftfs_removexattr(struct user_namespace *ns, const struct cred *oldcred; oldcred = shiftfs_override_creds(dentry->d_sb); - err = vfs_removexattr(ns, lowerd, name); + err = vfs_removexattr(&init_user_ns, lowerd, name); revert_creds(oldcred); /* update c/mtime */ @@ -379,8 +378,8 @@ static int shiftfs_xattr_set(const struct xattr_handler *handler, int flags) { if (!value) - return shiftfs_removexattr(ns, dentry, name); - return shiftfs_setxattr(ns, dentry, inode, name, value, size, flags); + return shiftfs_removexattr(&init_user_ns, dentry, name); + return shiftfs_setxattr(dentry, inode, name, value, size, flags); } static int shiftfs_inode_test(struct inode *inode, void *data) @@ -394,8 +393,7 @@ static int shiftfs_inode_set(struct inode *inode, void *data) return 0; } -static int shiftfs_create_object(struct user_namespace *ns, - struct inode *diri, struct dentry *dentry, +static int shiftfs_create_object(struct inode *diri, struct dentry *dentry, umode_t mode, const char *symlink, struct dentry *hardlink, bool excl) { @@ -457,7 +455,7 @@ static int shiftfs_create_object(struct user_namespace *ns, inode->i_state |= I_CREATING; spin_unlock(&inode->i_lock); - inode_init_owner(ns, inode, diri, mode); + inode_init_owner(&init_user_ns, inode, diri, mode); modei = inode->i_mode; } @@ -468,22 +466,22 @@ static int shiftfs_create_object(struct user_namespace *ns, if (hardlink) { lowerd_link = hardlink->d_fsdata; - err = vfs_link(lowerd_link, ns, loweri_dir, lowerd_new, NULL); + err = vfs_link(lowerd_link, &init_user_ns, loweri_dir, lowerd_new, NULL); } else { switch (modei & S_IFMT) { case S_IFDIR: - err = vfs_mkdir(ns, loweri_dir, lowerd_new, modei); + err = vfs_mkdir(&init_user_ns, loweri_dir, lowerd_new, modei); break; case S_IFREG: - err = vfs_create(ns, loweri_dir, lowerd_new, modei, excl); + err = vfs_create(&init_user_ns, loweri_dir, lowerd_new, modei, excl); break; case S_IFLNK: - err = vfs_symlink(ns, loweri_dir, lowerd_new, symlink); + err = vfs_symlink(&init_user_ns, loweri_dir, lowerd_new, symlink); break; case S_IFSOCK: /* fall through */ case S_IFIFO: - err = vfs_mknod(ns, loweri_dir, lowerd_new, modei, 0); + err = vfs_mknod(&init_user_ns, loweri_dir, lowerd_new, modei, 0); break; default: err = -EINVAL; @@ -545,7 +543,7 @@ static int shiftfs_create(struct user_namespace *ns, { mode |= S_IFREG; - return shiftfs_create_object(ns, dir, dentry, mode, NULL, NULL, excl); + return shiftfs_create_object(dir, dentry, mode, NULL, NULL, excl); } static int shiftfs_mkdir(struct user_namespace *ns, struct inode *dir, struct dentry *dentry, @@ -553,13 +551,13 @@ static int shiftfs_mkdir(struct user_namespace *ns, struct inode *dir, struct de { mode |= S_IFDIR; - return shiftfs_create_object(ns, dir, dentry, mode, NULL, NULL, false); + return shiftfs_create_object(dir, dentry, mode, NULL, NULL, false); } static int shiftfs_link(struct dentry *hardlink, struct inode *dir, struct dentry *dentry) { - return shiftfs_create_object(&init_user_ns, dir, dentry, 0, NULL, hardlink, false); + return shiftfs_create_object(dir, dentry, 0, NULL, hardlink, false); } static int shiftfs_mknod(struct user_namespace *ns, @@ -569,13 +567,13 @@ static int shiftfs_mknod(struct user_namespace *ns, if (!S_ISFIFO(mode) && !S_ISSOCK(mode)) return -EPERM; - return shiftfs_create_object(ns, dir, dentry, mode, NULL, NULL, false); + return shiftfs_create_object(dir, dentry, mode, NULL, NULL, false); } static int shiftfs_symlink(struct user_namespace *ns, struct inode *dir, struct dentry *dentry, const char *symlink) { - return shiftfs_create_object(ns, dir, dentry, S_IFLNK, symlink, NULL, false); + return shiftfs_create_object(dir, dentry, S_IFLNK, symlink, NULL, false); } static int shiftfs_rm(struct inode *dir, struct dentry *dentry, bool rmdir) @@ -716,12 +714,12 @@ static int shiftfs_permission(struct user_namespace *ns, struct inode *inode, in return -ECHILD; } - err = generic_permission(ns, inode, mask); + err = generic_permission(&init_user_ns, inode, mask); if (err) return err; oldcred = shiftfs_override_creds(inode->i_sb); - err = inode_permission(ns, loweri, mask); + err = inode_permission(&init_user_ns, loweri, mask); revert_creds(oldcred); return err; @@ -760,7 +758,7 @@ static int shiftfs_tmpfile(struct user_namespace *ns, return -EOPNOTSUPP; oldcred = shiftfs_override_creds(dir->i_sb); - err = loweri->i_op->tmpfile(ns, loweri, lowerd, mode); + err = loweri->i_op->tmpfile(&init_user_ns, loweri, lowerd, mode); revert_creds(oldcred); return err; @@ -776,7 +774,7 @@ static int shiftfs_setattr(struct user_namespace *ns, struct dentry *dentry, str struct shiftfs_super_info *sbinfo = sb->s_fs_info; int err; - err = setattr_prepare(ns, dentry, attr); + err = setattr_prepare(&init_user_ns, dentry, attr); if (err) return err; @@ -793,7 +791,7 @@ static int shiftfs_setattr(struct user_namespace *ns, struct dentry *dentry, str inode_lock(loweri); oldcred = shiftfs_override_creds(dentry->d_sb); - err = notify_change(ns, lowerd, &newattr, NULL); + err = notify_change(&init_user_ns, lowerd, &newattr, NULL); revert_creds(oldcred); inode_unlock(loweri); @@ -980,10 +978,10 @@ shiftfs_posix_acl_xattr_set(const struct xattr_handler *handler, shift_acl_xattr_ids(inode->i_sb->s_user_ns, loweri->i_sb->s_user_ns, (void *)value, size); - err = shiftfs_setxattr(ns, dentry, inode, handler->name, value, + err = shiftfs_setxattr(dentry, inode, handler->name, value, size, flags); } else { - err = shiftfs_removexattr(ns, dentry, handler->name); + err = shiftfs_removexattr(&init_user_ns, dentry, handler->name); } if (!err) From patchwork Tue Jan 31 17:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 1734984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=aA+Isgz3; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P5sjV6TWbz23gV for ; Wed, 1 Feb 2023 04:38:54 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pMuan-0005oq-39; Tue, 31 Jan 2023 17:38:49 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pMuaj-0005mC-BA for kernel-team@lists.ubuntu.com; Tue, 31 Jan 2023 17:38:45 +0000 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id EA41D41AC7 for ; Tue, 31 Jan 2023 17:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675186724; bh=5BJvnVDObolSL7G3zj5BQwmH+GnXiuXBC2pQnKty0Fs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aA+Isgz3y/JbMEKbSQtqlc+wXlLW/9DQF7vrInO5afaj/G7Q1hMJ9unnzdfYPGb7t uV22S+ziR02JRosKjKjYMHFr/qA5r1NAsPPXYvZ0ko1owzP0XeaExPtinf7NKIjDv2 Thn668pHB9t9Ug/3/U5mioNaZRZr1Wth+4zlu+lZPCIQFkaTIUKvebft8pfI6ncAi8 pvAzhcZzLp9IyLMRr4+m1rtWPfLNlTQeK+4huH1YxW5bbshgwQ7gHbiyNri1dzuzs/ PDOfVGhO9/h9pykkNYEx+VcZkdaJEugJOyPmc/IibJnkYH9F9JuJVuUVWTh2quz1fA JS8+Rxt6yiNmw== Received: by mail-ej1-f69.google.com with SMTP id wz4-20020a170906fe4400b0084c7e7eb6d0so10231585ejb.19 for ; Tue, 31 Jan 2023 09:38:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5BJvnVDObolSL7G3zj5BQwmH+GnXiuXBC2pQnKty0Fs=; b=TuCDIXk6dnzsR3x+Xm8z85qR93nEHMcPr9k/v+gNc3Ww5PULOa5qDWHCTbLVcgSQpE dLAhCpPjX/4ewyVKUn9tMEZJY5m59i+OS1XsVo/SkQjUp429hk8vIOlUqrLcPudUIrOz ZCPxi3XdYzt45qGNfz55Hr4cVHYX+xt+e4qs4rf/7S1PNKcmoxeVfYiNCE5nVMSkt9rS N0H24NSFYnPLlB8dKgIfpgAonC2g69C6QbUfUoZIqKXRrnyblrE9rzM5QRTtYHIZIVEW kW6JIIKz91UWjHNNHZlRryHl80aLDtZIu/38Bl9EjnhBjTw/3A0uUeNc3lySlahR8OMG 9WOQ== X-Gm-Message-State: AFqh2kp7M5brPKyKcyXqCoRKk8acuDsKjH9N3U8f+OYVXJTqSTfuYeDm LgpYRvuODhlu3cmAfkRiD/z2ceGF5v9hL1CK9TvP+kXYlRq+1o3Qa+vFDF5wo8gVPLZ7rpFlTBY z7eDIMdKAw4n8211/H+9EoKpjuzxyB493n+CWYR/u8A== X-Received: by 2002:a05:6402:3986:b0:49d:5c6:3e5f with SMTP id fk6-20020a056402398600b0049d05c63e5fmr69428072edb.41.1675186724345; Tue, 31 Jan 2023 09:38:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuktpaCmZ3AhxTWvL1tg2fpXqU/MRpcrzfRsS0n9Fp9/0ANFm0ChKvOigmf8MRWO97lW2p7tQ== X-Received: by 2002:a05:6402:3986:b0:49d:5c6:3e5f with SMTP id fk6-20020a056402398600b0049d05c63e5fmr69428057edb.41.1675186724140; Tue, 31 Jan 2023 09:38:44 -0800 (PST) Received: from amikhalitsyn.. (ip5f5bf399.dynamic.kabel-deutschland.de. [95.91.243.153]) by smtp.gmail.com with ESMTPSA id g5-20020a50ee05000000b004835bd8dfe5sm8693631eds.35.2023.01.31.09.38.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 09:38:43 -0800 (PST) From: Alexander Mikhalitsyn To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 2/2] UBUNTU: [SAUCE] shiftfs: fix -EOVERFLOW inside the container Date: Tue, 31 Jan 2023 18:38:33 +0100 Message-Id: <20230131173833.557692-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131173833.557692-1-aleksandr.mikhalitsyn@canonical.com> References: <20230131173833.557692-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1990849 We haven't supported idmapped layers with shiftfs and moreover, that makes no sense. Once lower fs support idmapped mounts when shiftfs is not needed. Starting from linux-image-5.15.0-48-generic users started seeing EOVERFLOW errors from the userspace side on a trivial fs operations inside the containers. This is caused by patches ("fs: tweak fsuidgid_has_mapping()"), ("fs: support mapped mounts of mapped filesystems"). These patches extends and enables idmapped mounts support in Ubuntu kernel, but the problem is that shiftfs was not properly ported. See also: ("namei: prepare for idmapped mounts") https://lore.kernel.org/all/20210121131959.646623-15-christian.brauner@ubuntu.com/ ("overlayfs: do not mount on top of idmapped mounts") https://lore.kernel.org/all/20210121131959.646623-29-christian.brauner@ubuntu.com/ as a reference. This patch should be appied on top of kinetic/master-next and based on the changes by Andrea Righi 4c934edc66 ("UBUNTU: SAUCE: shiftfs: always rely on init_user_ns") This commit together with 4c934edc66 ("UBUNTU: SAUCE: shiftfs: always rely on init_user_ns") have to be ported to the jammy tree too. Fixes: d347e71d2c0 ("UBUNTU: [SAUCE] shiftfs: support kernel 5.15") Reported-by: Thomas Parrott Signed-off-by: Alexander Mikhalitsyn --- fs/shiftfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/shiftfs.c b/fs/shiftfs.c index a21624c529f0..5944d6310dca 100644 --- a/fs/shiftfs.c +++ b/fs/shiftfs.c @@ -631,10 +631,10 @@ static int shiftfs_rename(struct user_namespace *ns, struct inode *loweri_dir_old = lowerd_dir_old->d_inode, *loweri_dir_new = lowerd_dir_new->d_inode; struct renamedata rd = { - .old_mnt_userns = ns, + .old_mnt_userns = &init_user_ns, .old_dir = loweri_dir_old, .old_dentry = lowerd_old, - .new_mnt_userns = ns, + .new_mnt_userns = &init_user_ns, .new_dir = loweri_dir_new, .new_dentry = lowerd_new, }; @@ -971,7 +971,7 @@ shiftfs_posix_acl_xattr_set(const struct xattr_handler *handler, return -EOPNOTSUPP; if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) return value ? -EACCES : 0; - if (!inode_owner_or_capable(ns, inode)) + if (!inode_owner_or_capable(&init_user_ns, inode)) return -EPERM; if (value) { @@ -2015,6 +2015,16 @@ static int shiftfs_fill_super(struct super_block *sb, void *raw_data, goto out_put_path; } + /* + * It makes no sense to handle idmapped layers from shiftfs. + * And we didn't support it properly anyway. + */ + if (is_idmapped_mnt(path.mnt)) { + err = -EINVAL; + pr_err("idmapped layers are currently not supported\n"); + goto out_put_path; + } + sb->s_flags |= SB_POSIXACL; if (sbinfo->mark) {