From patchwork Tue Jan 31 17:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 1734980 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=U+4vuzrf; 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 4P5sYm5JGjz23gY for ; Wed, 1 Feb 2023 04:32:11 +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 1pMuUC-00055t-My; Tue, 31 Jan 2023 17:32:00 +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 1pMuUB-00055b-Ej for kernel-team@lists.ubuntu.com; Tue, 31 Jan 2023 17:31:59 +0000 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 1355C41AC7 for ; Tue, 31 Jan 2023 17:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675186319; bh=5BJvnVDObolSL7G3zj5BQwmH+GnXiuXBC2pQnKty0Fs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U+4vuzrfJuf8CNDFuuP/B6Fsnw0pQuoM2eIrk2Yw7keNuxMqKA8ZKuGtVRRNqmCwW tOV5d0DvZKFzSaXn9DoAiKN3Gr5GiZK7s3PC3iVu0ql0eGX/G3S23vWjgSjGofSLHu iolxg3YgtVyI2cEiNkx1wFPJG8aVKy2StPztmwSBfw+zW6QwlUOHKz7w9PQpUJ9IPx +vjsO5M8HGNknzRUxwnYWoRMGolgTjIuWX4rZy6Mytvg1eca9m9FtaUNEcHBIlpCZh hdySJDZr62xzstABU+DdmFYavrCGz4llS17G83Hrv4h3Vvd/ezeCkNz960VuBPT1KH DusJPNoAPsuKw== Received: by mail-ed1-f69.google.com with SMTP id g19-20020a056402115300b004a26cc7f6cbso1616342edw.4 for ; Tue, 31 Jan 2023 09:31:59 -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=acXt9y0k4DmrvNnwkWW8n8gIMiQIcZ7bXL2OsD5DL176hf9y2KpRGOriazhgpTX+UE tthmlvJ9JVDwczTB3pyvmdovoGNyGgy7AQo56jp5/ocJckPhd+Mp6BGyfSlZR0YsJitv +jKGEIjd921vJ1/psOtsHK4+/CFc+JzQbrZ9x9QVnVxU85+7SgHkX9s6ALTSvLfFfVpD VGki+hfMoEaSGt8qTuhZs9w0HWMIowgsb6BziDZqdJoQaFstxQrAi7ADZYBhOX4sNly+ rxRX+fLhm8i9Iu/+7a0q8QACMJw57CPG4GtxYVAgOiQ7CCLuWsxlMhq88CEjX8kZH0L6 IK5w== X-Gm-Message-State: AO0yUKVwWD+UQCpblE0RHzePTtKlmXexkP1MUaAzoyZNWmkIoC/9yhkR ZJB4sMkxmNBdEADMOB84gOYLTI3OmCHwSz56BB+LwXzKBW+TAwvtfJ94s+5J40xgIcGjrJJBT8y abtj/evOGc4hf/3bWwQaImk5Pb3PYDTuA/JxFTdbcAQ== X-Received: by 2002:a17:907:8d1a:b0:88c:24f0:2db2 with SMTP id tc26-20020a1709078d1a00b0088c24f02db2mr3727833ejc.4.1675186318409; Tue, 31 Jan 2023 09:31:58 -0800 (PST) X-Google-Smtp-Source: AK7set/22Sls5MeZf/0A9XKE1i3yNxBQuxXnqpsFsOdys+3xXkKASYV4biT9q3maXpHtSlsrgzerrw== X-Received: by 2002:a17:907:8d1a:b0:88c:24f0:2db2 with SMTP id tc26-20020a1709078d1a00b0088c24f02db2mr3727815ejc.4.1675186318129; Tue, 31 Jan 2023 09:31:58 -0800 (PST) Received: from amikhalitsyn.. (ip5f5bf399.dynamic.kabel-deutschland.de. [95.91.243.153]) by smtp.gmail.com with ESMTPSA id qu21-20020a170907111500b00884c611145fsm5056182ejb.62.2023.01.31.09.31.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 09:31:57 -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:31:46 +0100 Message-Id: <20230131173146.552420-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131173146.552420-1-aleksandr.mikhalitsyn@canonical.com> References: <20230131173146.552420-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) {