Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2514511rwd; Fri, 26 May 2023 07:32:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4OBAkG4zj7uytjv4iLAYpswak9y5kOU1NmJuq6qWEFTRKUycxSRZHdomzARFpiC10YJSW4 X-Received: by 2002:a17:90a:4f0c:b0:24b:755a:9e99 with SMTP id p12-20020a17090a4f0c00b0024b755a9e99mr2572735pjh.31.1685111569569; Fri, 26 May 2023 07:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685111569; cv=none; d=google.com; s=arc-20160816; b=a/fFaw50Q4FZCrwL8vVGZ3xhO4AYVXVPiWghTBxNoKYpEz27Qsc5+r7GPlvTMhCsV4 iYh3lDGdkMcQgJnyRmlxzkIacMhRcr3LIggkkNmAQQ3IQ6GJGCkbqgXFWypsoU4YkcXV oXPm+ELWn90Udue79amda671paepwH6/VfMPR3p/qCJ9YEvaoYewDS5K/lrzTpe3R7ve 1I83zshQYX9FwnWE2/346HBzLLgLFy8/wHDvYQbCFxevKB2E0SIE7TPo1zmKXmxZH09i OAwl7K9V+ek5Qx0JnukNV2Aos9jTDT/9yLaNTDjsq/Q0BoPpVUytpj4MmVHR4iStObVR WHVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=TLZNcw1d9SH4wI8Zf0nXKgmi5A3y+ZK1ObXJei0thLo=; b=gYL69dQTkybr1GpeFm1357KOFQOpTbpEd8oTIeQnrVwm+SLxLL5HxUYUuCGkW+KKK9 fjStt/63boBolEfQcx2rdL2nr/6PyDic3WZCGuh6du8al+24oDfhMGFSOZEzMTV6u0wf aWNTN0hScgCaGLtI1OD9vLRJi7PasPLeLTTyZ/YaE97vaptnuPj+g73J36yjPsHybraK RSj0VGcIGzR9EfTkEo380A3EW5lNcUWa0wJXfJpw1eDRMmlSDBdk8+LBvt7uyvbdQzxJ 1po6RXrJrDVKlOVpOVHioRTrmNg8mzd2B2iHKH4pA8a8XarTWjNW3BDdykpoiZfLAyC9 k/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=KIeWF3uC; 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=axis.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w16-20020a17090a8a1000b002535c437f9fsi4376349pjn.33.2023.05.26.07.32.34; Fri, 26 May 2023 07:32:49 -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 (test mode) header.i=@axis.com header.s=axis-central1 header.b=KIeWF3uC; 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=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243786AbjEZN5n (ORCPT + 99 others); Fri, 26 May 2023 09:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243783AbjEZN5l (ORCPT ); Fri, 26 May 2023 09:57:41 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86ECF1A8 for ; Fri, 26 May 2023 06:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1685109460; x=1716645460; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=TLZNcw1d9SH4wI8Zf0nXKgmi5A3y+ZK1ObXJei0thLo=; b=KIeWF3uClVvlsfAMx2vhn4bzptqW0/pgvvIOvLxDrV8IKL46g9myRjha xbKOdYYsgmWvQ5RZLoeyyIddl52ebGi5CthFEPoO70hhKEbEtD5Zoq33S yV2y3zkJ9I/oRCDVnzlL2gurATkhVpKsKQDfwPVqdUMr7unVv2bq/RL0M 5O3c3IccIzS47reo6mTG6fpOWF/8FGCPM37hxibB8zt3eoTKplaDQmIru AOnhKbsCByrhbYkUZJc33FSJLA9kyXqU5/r66EiMIDTjwhfnGyJtzSsJg qa6M7k0SbgyaG7z9iwthtPlmC1rvWec66jbYWgl1vPgsOLbJfvbVV6pPW w==; From: Vincent Whitchurch Date: Fri, 26 May 2023 15:57:30 +0200 Subject: [PATCH mm-nonmm-unstable v2 1/2] squashfs: fix page update race MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20230526-squashfs-cache-fixup-v2-1-6fb7723c3647@axis.com> References: <20230526-squashfs-cache-fixup-v2-0-6fb7723c3647@axis.com> In-Reply-To: <20230526-squashfs-cache-fixup-v2-0-6fb7723c3647@axis.com> To: Phillip Lougher , Andrew Morton CC: , , , "Vincent Whitchurch" X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 We only put the page into the cache after we've read it, so the PageUptodate() check should not be necessary. In fact, it's actively harmful since the check could fail (since we used find_get_page() and not find_lock_page()) and we could end up submitting a page for I/O after it has been read and while it's actively being used, which could lead to corruption depending on what the block driver does with it. Reviewed-by: Christoph Hellwig Signed-off-by: Vincent Whitchurch --- fs/squashfs/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 6285f5afb6c6..f2412e5fc84b 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c @@ -92,7 +92,7 @@ static int squashfs_bio_read_cached(struct bio *fullbio, bio_for_each_segment_all(bv, fullbio, iter_all) { struct page *page = bv->bv_page; - if (page->mapping == cache_mapping && PageUptodate(page)) { + if (page->mapping == cache_mapping) { idx++; continue; } -- 2.34.1