Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3013728rwb; Mon, 15 Aug 2022 16:09:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Q+ZPpZrhDlr8tnboMKp9TOOkKUSqJOBClA69w9Rla7T8Hv6UymG8XNszjpgsAmRC+T/Qp X-Received: by 2002:a50:ee85:0:b0:43d:3e0:6157 with SMTP id f5-20020a50ee85000000b0043d03e06157mr16781554edr.19.1660604970920; Mon, 15 Aug 2022 16:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660604970; cv=none; d=google.com; s=arc-20160816; b=oAmb3OANXNrzogjCP4q8sJYTfPOSvymDv+mKz7E2lDX2vVnJg3SIa8jK171gYEzpsM JQej4UlG7CZMbyRBaBd3UA4OJ6c3hbE2Dzgq31uEoclu8YMzBdMuKV3kgJvHvlK19yP3 7oWf4aX/rD5MBbO3hSOuQjxWd4ZgjSCmvSdxN67IwKhYAjNRFtJw8hbETradLNVX8tkJ k8FQcpzRLal0PwILeMTMTNvzPsVR4rOOjUXFNxslCRwGnD18a4axM95P35ARK6urVFpe wuFoHH0ckVO108og/xfxuMjKl+mUMDmTBfAAOxvsNtxj8RPxXV99zqz3EBuZNeL85MTw yS1w== 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=Bm8LFbOTId6kMtcuD+I0wguy0q9zJ2GPGpPCvmoTfLs=; b=X8cKhkOTz/kgcHNSD4PJMDtRyDx5SIc48AfNafAlbaRQT3Nb+1QaIn6uby5i+FI3O7 Atcga5RcNUGzWSSJDx0p16oP2NUbeOSMIWn5NaG/lm9p2QpqE3LjxOCQAgRm2TYtNPL+ a5jUgNNEb34O3jozdv4uYh4vabdh6v6JnOWVCbMs8eac5rrWvb3k+RFWgI/23AMEF8Vo aqplAO/YkO9qZ8rYUcZjL65w/9ginv+C0h0dC4WskRHOK6waDoE40iTwAku4O/34QrK1 JiUEKaGHmI6nGF9gFnRKknEX1fOtoMi911/F9me/5p1BZcam2GITsMkpKky4yqmQ8mPL ydWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OdS3B07L; 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 wt11-20020a170906ee8b00b00730881cddb4si6576351ejb.454.2022.08.15.16.09.05; Mon, 15 Aug 2022 16:09:30 -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=OdS3B07L; 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 S1347973AbiHOWWl (ORCPT + 99 others); Mon, 15 Aug 2022 18:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350560AbiHOWSC (ORCPT ); Mon, 15 Aug 2022 18:18:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F306740BCD; Mon, 15 Aug 2022 12:41:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 734CFB80EA8; Mon, 15 Aug 2022 19:41:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9810C433C1; Mon, 15 Aug 2022 19:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592467; bh=qW6yXE9ud1P1tuP49WumpWs1UmmGtf+87D75l29Nzf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OdS3B07L7WuXKRt/Ii8MxGYa3F9JlI7E4MhioW+udR8ywo8rf5CTxx39f3KveWnbC hxeAXaiMu6UNPDLx8KH6tsct2sq9nhszbOk7s08VikFdO3NGL9yRtm2oEckXPhnRm5 rrsXjnqPvwvHjO/INHVvVrpfUO7O3hZtUGUdgeNs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20Kohlsch=C3=BCtter?= , Miklos Szeredi Subject: [PATCH 5.19 0114/1157] fuse: ioctl: translate ENOSYS Date: Mon, 15 Aug 2022 19:51:10 +0200 Message-Id: <20220815180444.187824796@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 commit 02c0cab8e7345b06f1c0838df444e2902e4138d3 upstream. Overlayfs may fail to complete updates when a filesystem lacks fileattr/xattr syscall support and responds with an ENOSYS error code, resulting in an unexpected "Function not implemented" error. This bug may occur with FUSE filesystems, such as davfs2. Steps to reproduce: # install davfs2, e.g., apk add davfs2 mkdir /test mkdir /test/lower /test/upper /test/work /test/mnt yes '' | mount -t davfs -o ro http://some-web-dav-server/path \ /test/lower mount -t overlay -o upperdir=/test/upper,lowerdir=/test/lower \ -o workdir=/test/work overlay /test/mnt # when "some-file" exists in the lowerdir, this fails with "Function # not implemented", with dmesg showing "overlayfs: failed to retrieve # lower fileattr (/some-file, err=-38)" touch /test/mnt/some-file The underlying cause of this regresion is actually in FUSE, which fails to translate the ENOSYS error code returned by userspace filesystem (which means that the ioctl operation is not supported) to ENOTTY. Reported-by: Christian Kohlschütter Fixes: 72db82115d2b ("ovl: copy up sync/noatime fileattr flags") Fixes: 59efec7b9039 ("fuse: implement ioctl support") Cc: Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/ioctl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/fs/fuse/ioctl.c +++ b/fs/fuse/ioctl.c @@ -9,6 +9,17 @@ #include #include +static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *args) +{ + ssize_t ret = fuse_simple_request(fm, args); + + /* Translate ENOSYS, which shouldn't be returned from fs */ + if (ret == -ENOSYS) + ret = -ENOTTY; + + return ret; +} + /* * CUSE servers compiled on 32bit broke on 64bit kernels because the * ABI was defined to be 'struct iovec' which is different on 32bit @@ -259,7 +270,7 @@ long fuse_do_ioctl(struct file *file, un ap.args.out_pages = true; ap.args.out_argvar = true; - transferred = fuse_simple_request(fm, &ap.args); + transferred = fuse_send_ioctl(fm, &ap.args); err = transferred; if (transferred < 0) goto out; @@ -393,7 +404,7 @@ static int fuse_priv_ioctl(struct inode args.out_args[1].size = inarg.out_size; args.out_args[1].value = ptr; - err = fuse_simple_request(fm, &args); + err = fuse_send_ioctl(fm, &args); if (!err) { if (outarg.result < 0) err = outarg.result;