From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22FBB5336F; Mon, 1 Apr 2024 15:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711986676; cv=none; b=PwkwhpZtKZ8T7bodOEl8z3sIMr5e5TKzFtOJRUxAdd4gEExBRYVbM4p2GNlIPvfIEp/n4KtBygN8AOUJzu7f/VwFaGqeE7KLIK+6tY7m4URj8PDR5J+536UTfmZQ3lODvzo2HeOJa6om+wFGsb2iBBFowc8GYFqJPRpCfwfsFh0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711986676; c=relaxed/simple; bh=bBIuNmKxMz4YZJIchlM+M6np95Az3d8Tuo73huLva88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YiGGQv2B2+WLEvs2SKlR4pII7QVrb7r3RDSXsN3UVz+hjqZDw9mpPy/bV4n8QiJpFi2sZC6lDk2Z+UjLjQje2MXcW67k95uBD9WCF89I1C69a99/2svjEC0rd+CXjoLw/aZrLPn0jacTGA8CnW2BN4Jj5iBQ95qX6xWnb9KjF6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U+hVmFNO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="U+hVmFNO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91875C43394; Mon, 1 Apr 2024 15:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711986676; bh=bBIuNmKxMz4YZJIchlM+M6np95Az3d8Tuo73huLva88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U+hVmFNOMawpDhlDxvLD/OJ0OEamE9tm5gM7orvXglJg92C4amzryyWFgCyH6+ePl TDKSjJsfNTRJ4seesFYs5Hq7fTt/fNfxaZlswSJwcgDbqOm+lIhCpDS8Azd8gwO8nV TzvIAl74e0DxG1CAyMhKSObX8eQspHuiyotRlkVE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Matthew Wilcox (Oracle)" , Zhihao Cheng , Richard Weinberger , Sasha Levin Subject: [PATCH 6.8 050/399] ubifs: Set page uptodate in the correct place Date: Mon, 1 Apr 2024 17:40:16 +0200 Message-ID: <20240401152550.678391609@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152549.131030308@linuxfoundation.org> References: <20240401152549.131030308@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthew Wilcox (Oracle) [ Upstream commit 723012cab779eee8228376754e22c6594229bf8f ] Page cache reads are lockless, so setting the freshly allocated page uptodate before we've overwritten it with the data it's supposed to have in it will allow a simultaneous reader to see old data. Move the call to SetPageUptodate into ubifs_write_end(), which is after we copied the new data into the page. Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Zhihao Cheng Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- fs/ubifs/file.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 5029eb3390a56..d0694b83dd02c 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -261,9 +261,6 @@ static int write_begin_slow(struct address_space *mapping, return err; } } - - SetPageUptodate(page); - ClearPageError(page); } if (PagePrivate(page)) @@ -463,9 +460,6 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, return err; } } - - SetPageUptodate(page); - ClearPageError(page); } err = allocate_budget(c, page, ui, appending); @@ -475,10 +469,8 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, * If we skipped reading the page because we were going to * write all of it, then it is not up to date. */ - if (skipped_read) { + if (skipped_read) ClearPageChecked(page); - ClearPageUptodate(page); - } /* * Budgeting failed which means it would have to force * write-back but didn't, because we set the @fast flag in the @@ -569,6 +561,9 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping, goto out; } + if (len == PAGE_SIZE) + SetPageUptodate(page); + if (!PagePrivate(page)) { attach_page_private(page, (void *)1); atomic_long_inc(&c->dirty_pg_cnt); -- 2.43.0