From nobody Mon Sep 29 21:20:49 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD073C00140 for ; Mon, 15 Aug 2022 22:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347992AbiHOWWl (ORCPT ); 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: quoted-printable 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=3D/test/upper,lowerdir=3D/test/lower \ -o workdir=3D/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=3D-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=C3=BCtter 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 =20 +static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *ar= gs) +{ + ssize_t ret =3D fuse_simple_request(fm, args); + + /* Translate ENOSYS, which shouldn't be returned from fs */ + if (ret =3D=3D -ENOSYS) + ret =3D -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 =3D true; ap.args.out_argvar =3D true; =20 - transferred =3D fuse_simple_request(fm, &ap.args); + transferred =3D fuse_send_ioctl(fm, &ap.args); err =3D transferred; if (transferred < 0) goto out; @@ -393,7 +404,7 @@ static int fuse_priv_ioctl(struct inode args.out_args[1].size =3D inarg.out_size; args.out_args[1].value =3D ptr; =20 - err =3D fuse_simple_request(fm, &args); + err =3D fuse_send_ioctl(fm, &args); if (!err) { if (outarg.result < 0) err =3D outarg.result;