From nobody Sun Feb 8 05:19:58 2026 Received: from sxb1plsmtpa01-02.prod.sxb1.secureserver.net (sxb1plsmtpa01-02.prod.sxb1.secureserver.net [188.121.53.15]) (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 11B3B183CC8 for ; Thu, 22 Aug 2024 23:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.121.53.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724370601; cv=none; b=eMjgNtLPip2NS7JIu7dHwoEDBtBqAJxskIJ5pFqiYK8JVahbnSzBLmMZXb7CTdx2zXoZCRyTmfChSWLERR/WWLYzUqUlaVYmDwB8LLoX9b0CyQwbFx3H9geXQKcDv4ixA2dfQgZHB/mS91U0o3JVxxRyZFsydC7LUCM1NHoJWzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724370601; c=relaxed/simple; bh=pGEKN+wc+DZuM3ExeQa9PJHgawcNAtSwfDs6zevQAN4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=n6Vcm2zkKSt7t/zofczw474rey6xS3Jm3AZGH3zyp06gGiud1qcIi1edtTXHybytdfHSBeHa78z5FBy6HLfIgjimtsXVlmUDSMCEp/dMVfU1yuT5/ja7XtClbskFBHsKfxjp0wmGFxbikZF3fW2Zdrzy4NdL2aAGbOKJQSSa5kc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=squashfs.org.uk; spf=pass smtp.mailfrom=squashfs.org.uk; arc=none smtp.client-ip=188.121.53.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=squashfs.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=squashfs.org.uk Received: from phoenix.fritz.box ([82.69.79.175]) by :SMTPAUTH: with ESMTPA id hHGOsHsK5LW3HhHGasoxDN; Thu, 22 Aug 2024 16:30:57 -0700 X-CMAE-Analysis: v=2.4 cv=Lan36Sfi c=1 sm=1 tr=0 ts=66c7ca31 a=84ok6UeoqCVsigPHarzEiQ==:117 a=84ok6UeoqCVsigPHarzEiQ==:17 a=VwQbUJbxAAAA:8 a=FXvPX3liAAAA:8 a=s94iO8TKwuVpzBr5ofsA:9 a=AjGcO6oz07-iQ99wixmX:22 a=UObqyxdv-6Yh2QiB9mM_:22 X-SECURESERVER-ACCT: phillip@squashfs.org.uk From: Phillip Lougher To: akpm@linux-foundation.org, brauner@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Phillip Lougher Subject: [PATCH V3] Squashfs: Ensure all readahead pages have been used Date: Fri, 23 Aug 2024 00:31:06 +0100 Message-Id: <20240822233106.121522-1-phillip@squashfs.org.uk> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4xfGQ+ljdeCwq4R4QkaKRx4wdqc1EIsUZnsGZe4Fozhg5f2rSUiwnsc2fSCza2HVTuq2Hjj+hsCxkLODof5DxMDw6pYeyt+iePY5bb7sd70GLNkVIYBm1J DqVPQIXRjw8yw6I5kPvMfSSJOgE/4Fr1IcBJnoizmrLPeP/DjWA+UddC0V6CBifXdLTGBjMzbnQFh0oX9P9GuWOZ1dd2czyKCV5QLhKAwCTEm9plrmii5x9I 3JnwDtT17En/PIpQhO6gZcIVA+VWSvkdVo+cEz5gvmVOyozcD32otj+vECCmey4CAxGOcnzffcFQtkQnBHos8GJQOeY5SO+4XrEzxZ5QN9DycdW1fTwPEh+m bxwmRVT+ Content-Type: text/plain; charset="utf-8" In the recent work to remove page->index, a sanity check that ensured all the readhead pages were covered by the Squashfs data block was removed [1]. To avoid any regression, this commit adds the sanity check back in an equivalent way. Namely the page actor will now return error if any pages are unused after completion. [1] https://lore.kernel.org/all/20240818235847.170468-3-phillip@squashfs.or= g.uk/ Signed-off-by: Phillip Lougher -- V3: last_page should be actor->last_page --- fs/squashfs/file.c | 4 ++-- fs/squashfs/file_direct.c | 2 +- fs/squashfs/page_actor.h | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 5a3745e52025..21aaa96856c1 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -535,7 +535,7 @@ static int squashfs_readahead_fragment(struct page **pa= ge, =20 last_page =3D squashfs_page_actor_free(actor); =20 - if (copied =3D=3D expected) { + if (copied =3D=3D expected && !IS_ERR(last_page)) { /* Last page (if present) may have trailing bytes not filled */ bytes =3D copied % PAGE_SIZE; if (bytes && last_page) @@ -625,7 +625,7 @@ static void squashfs_readahead(struct readahead_control= *ractl) =20 last_page =3D squashfs_page_actor_free(actor); =20 - if (res =3D=3D expected) { + if (res =3D=3D expected && !IS_ERR(last_page)) { int bytes; =20 /* Last page (if present) may have trailing bytes not filled */ diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c index 646d4d421f99..22251743fadf 100644 --- a/fs/squashfs/file_direct.c +++ b/fs/squashfs/file_direct.c @@ -80,7 +80,7 @@ int squashfs_readpage_block(struct page *target_page, u64= block, int bsize, if (res < 0) goto mark_errored; =20 - if (res !=3D expected) { + if (res !=3D expected || IS_ERR(last_page)) { res =3D -EIO; goto mark_errored; } diff --git a/fs/squashfs/page_actor.h b/fs/squashfs/page_actor.h index c6d837f0e9ca..ffe25eb77c32 100644 --- a/fs/squashfs/page_actor.h +++ b/fs/squashfs/page_actor.h @@ -33,10 +33,11 @@ extern struct squashfs_page_actor *squashfs_page_actor_= init_special( loff_t start_index); static inline struct page *squashfs_page_actor_free(struct squashfs_page_a= ctor *actor) { - struct page *last_page =3D actor->last_page; + struct page *last_page =3D actor->next_page =3D=3D actor->pages ? actor->= last_page : ERR_PTR(-EIO); =20 kfree(actor->tmp_buffer); kfree(actor); + return last_page; } static inline void *squashfs_first_page(struct squashfs_page_actor *actor) --=20 2.39.2