From nobody Mon Sep 29 21:26:14 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 94B17C00140 for ; Mon, 15 Aug 2022 22:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348318AbiHOWW4 (ORCPT ); Mon, 15 Aug 2022 18:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350642AbiHOWSJ (ORCPT ); Mon, 15 Aug 2022 18:18:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87534123C94; Mon, 15 Aug 2022 12:41:14 -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 BC4E960FB9; Mon, 15 Aug 2022 19:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A88B9C433D6; Mon, 15 Aug 2022 19:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592473; bh=Dh+emGNHm1D8DGNCBwnBuEUQw+j66ciJrWboMiUcFmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2hbG9WGG4a9VKrgFlXqECyjd++5MFlOy1+Qj5h+2OI/SFB9zz1I91s9vy8BVIFTi +p9f+IsC+a6+jBCmPHTXs1dzfijkh2Pr0zZjwRsJ3c1owln7iU1hkORpausK3I0B4g C/ERQa1Bv7oQ0nS4R/9+ZLYRNO//c8V0hWVo8xac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6e1efbd8efaaa6860e91@syzkaller.appspotmail.com, Miklos Szeredi Subject: [PATCH 5.19 0115/1157] fuse: write inode in fuse_release() Date: Mon, 15 Aug 2022 19:51:11 +0200 Message-Id: <20220815180444.224814123@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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miklos Szeredi commit 035ff33cf4db101250fb980a3941bf078f37a544 upstream. A race between write(2) and close(2) allows pages to be dirtied after fuse_flush -> write_inode_now(). If these pages are not flushed from fuse_release(), then there might not be a writable open file later. So any remaining dirty pages must be written back before the file is released. This is a partial revert of the blamed commit. Reported-by: syzbot+6e1efbd8efaaa6860e91@syzkaller.appspotmail.com Fixes: 36ea23374d1f ("fuse: write inode in fuse_vma_close() instead of fuse= _release()") Cc: # v5.16 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -338,6 +338,15 @@ static int fuse_open(struct inode *inode =20 static int fuse_release(struct inode *inode, struct file *file) { + struct fuse_conn *fc =3D get_fuse_conn(inode); + + /* + * Dirty pages might remain despite write_inode_now() call from + * fuse_flush() due to writes racing with the close. + */ + if (fc->writeback_cache) + write_inode_now(inode, 1); + fuse_release_common(file, false); =20 /* return value is ignored by VFS */