Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409644rwa; Tue, 23 Aug 2022 04:25:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7bkKEZOoJFXwnAgtTYN5QywXJkHdnTpRNQ7NpfsAzcryqFk4yRtQpJG0UXKJgmvIUpz3E/ X-Received: by 2002:a63:e25:0:b0:41c:30f7:c39c with SMTP id d37-20020a630e25000000b0041c30f7c39cmr20119856pgl.147.1661253842172; Tue, 23 Aug 2022 04:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253842; cv=none; d=google.com; s=arc-20160816; b=ISqfwWZil0qv5tMplKLDT27JgyZMH9Ne5L7CuL3O2HNNgJ1GbClx5149iZIGKqSq1V equr0k+8nUhhHad0V6o48VNq7FdSrXCdS+c5QUWpe7pgbZAgEkf00r8CqVafE0jdbnQv imaN1c+JLbFj3IftxmLnm5lOawArQADx89z8khruiYP5AUwni3FiBLv2FiSd1C0A7Kv4 UjMHtR9QCPdBTbLP6GIs/ljjJfnFmkEGrecVJtVUyIiLvsMgqA80pWoutcRhtaEFzxiD GiiKtgRgov8jdEhesWqhSvqBIe1f0rxNvE5Gm7bdBYcNgka/9AgU/c7Dtza78Px5EbIy gibg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OKTqWk4fQIBjCbUfz4j119QAXqtJoBm/eJgw/fTMBbg=; b=pJbY5OIUA7wJjSJfhH1dacpV8mst74gcoK1+b/nyWPKjADGAFNqBwUT40FsrNX557Y c5x1N33yzpKoz2zpoy01droiIPBRlwTG62VuG5d6gQetJkX4XJ5FIGh2VkfJ2sLBezrU VbUXDFBmLAOZJD+94tVarv2iFlCd/BvXnRQgIlwPRHxwSmcSB/MJVQhIaTWgK+pYsQFe CadetxVP39JQrYyuIUCyq6z437uFOkDg7ZZ6a8x7jFTXFgplyrCMtWmd3gnKQBCGH/rj VSA8zU2YkLtrANYCeyC0dIRnvek6xII51HVT0X2JUz8TXF+h7Kx9huvjU0IqUYC0G1mi BmIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y6zbjlrI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a170902e88700b0016f18b82145si10776585plg.265.2022.08.23.04.23.51; Tue, 23 Aug 2022 04:24:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y6zbjlrI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355064AbiHWKaz (ORCPT + 99 others); Tue, 23 Aug 2022 06:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353186AbiHWKPD (ORCPT ); Tue, 23 Aug 2022 06:15:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF297434D; Tue, 23 Aug 2022 02:00:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D066E6157F; Tue, 23 Aug 2022 09:00:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5D11C433D7; Tue, 23 Aug 2022 09:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245210; bh=mZ1Eal+wbCJp/DyeVGMHEXpw1g7FqIdE0Oc7xwcTgtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6zbjlrINU8f7xEk0uYga8BFjdpCkL0XiauAhHUuaxphEWSQHN4qIQ01TUQ3TNbpW qxqN3Pd1GCupqJs/ja2f2/hVr+gJQ4/pCWet/te9JxeZXwzi4oPsZiyCk0JHIE10oN NfY30RUBIt23/lJ7RiOsLeVrRanphrgwoPdjQoL0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alois Wohlschlager , Miklos Szeredi , Sasha Levin Subject: [PATCH 5.15 222/244] ovl: warn if trusted xattr creation fails Date: Tue, 23 Aug 2022 10:26:21 +0200 Message-Id: <20220823080106.954894142@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi [ Upstream commit b10b85fe5149ee8b39fbbf86095b303632dde2cd ] When mounting overlayfs in an unprivileged user namespace, trusted xattr creation will fail. This will lead to failures in some file operations, e.g. in the following situation: mkdir lower upper work merged mkdir lower/directory mount -toverlay -olowerdir=lower,upperdir=upper,workdir=work none merged rmdir merged/directory mkdir merged/directory The last mkdir will fail: mkdir: cannot create directory 'merged/directory': Input/output error The cause for these failures is currently extremely non-obvious and hard to debug. Hence, warn the user and suggest using the userxattr mount option, if it is not already supplied and xattr creation fails during the self-check. Reported-by: Alois Wohlschlager Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/overlayfs/super.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 7bb0a47cb615..9837aaf9caf1 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1413,11 +1413,12 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, */ err = ovl_do_setxattr(ofs, ofs->workdir, OVL_XATTR_OPAQUE, "0", 1); if (err) { + pr_warn("failed to set xattr on upper\n"); ofs->noxattr = true; if (ofs->config.index || ofs->config.metacopy) { ofs->config.index = false; ofs->config.metacopy = false; - pr_warn("upper fs does not support xattr, falling back to index=off,metacopy=off.\n"); + pr_warn("...falling back to index=off,metacopy=off.\n"); } /* * xattr support is required for persistent st_ino. @@ -1425,8 +1426,10 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, */ if (ofs->config.xino == OVL_XINO_AUTO) { ofs->config.xino = OVL_XINO_OFF; - pr_warn("upper fs does not support xattr, falling back to xino=off.\n"); + pr_warn("...falling back to xino=off.\n"); } + if (err == -EPERM && !ofs->config.userxattr) + pr_info("try mounting with 'userxattr' option\n"); err = 0; } else { ovl_do_removexattr(ofs, ofs->workdir, OVL_XATTR_OPAQUE); -- 2.35.1