Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3024766rwb; Mon, 15 Aug 2022 16:22:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR4nzBh8G/aUmTv494FZozIlu1cHRN1TBMiWkLcRlt1GtxBz4mdfqwdcRI7C5pM/nSzD9VPl X-Received: by 2002:a17:90b:3b8a:b0:1f5:56c3:54ac with SMTP id pc10-20020a17090b3b8a00b001f556c354acmr20898573pjb.2.1660605766590; Mon, 15 Aug 2022 16:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605766; cv=none; d=google.com; s=arc-20160816; b=BqWTY9ANieNRJiEitM7iMRuu6qcIo+jHLLLaCF5NMoonfG95lmalodKh8hWh0mJoIz C1qsZNAWW+iESIEoNcIqoisz5UUuvkKzBCwsilBTnwFK+0V8tjRB7zt3KN03XIOK9sbZ NBB5twl4n4llgLRetAEsFBJTTzlYdlNzrpLQ9pVqCxWhZFLzG2Ttg1Lof+rIEINFnxkZ YVhBXvPuigIOUnWhc8B2s1kEOfo+Y3IVa9NkWw7yqYBsMBfNL8e6KTPStEI/HOfmjbp1 px8fTdtLSvR3ozSNWbrqOWziEJ8RnkrB4PAqnU//QbOWxH4RMYI4ivAhROrjxiKijC7F hBUw== 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=Qo/wTOsRIVqESV9pU+zzNoCO86Nf2FZ7BiHFV8GuzL8=; b=RAThldJSbB3EGdi7lCWSDSfJzaPpPj76tNBmafCfq/vBqc427DsbcVVijkivuHeY6a WWwpvW/nNjfcc1ziU/mwuoJ8YFnP660ttzPWNRKdT0FSV/aapimJSBuKdZ357KgbqeJx qY/vZDrbXlaBslHJHXSD25l+WDgJg6dUlOoodSEWo6L6f/alV3G2oACqlRx3LMPnaZFt gjIydIrUuTHHQV+i1rra6XKZwAKOXUzNXFttjI1/lee9EItb3aHQ7Rm5NfLEvV+sp46Q T4o2zvxN7OzpnkqrqJALt1oGbNdcMb64jBf1jsaxO3Xc8N5TvZlwCkxeTkKZRecXciN2 Mepw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O2hbG9WG; 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 84-20020a621757000000b0052ac8eee909si10196288pfx.300.2022.08.15.16.22.35; Mon, 15 Aug 2022 16:22:46 -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=O2hbG9WG; 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 S1348296AbiHOWWz (ORCPT + 99 others); Mon, 15 Aug 2022 18:22:55 -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-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 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 static int fuse_release(struct inode *inode, struct file *file) { + struct fuse_conn *fc = 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); /* return value is ignored by VFS */