From patchwork Mon Aug 24 08:28:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88DE7C433DF for ; Mon, 24 Aug 2020 08:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 627B92087D for ; Mon, 24 Aug 2020 08:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598257950; bh=aRx+YliMIlfhHADwgY6F1wy2b/b10bc5vVPUkcz9jwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RDdph9vFGqMCREbh5HXgCNHQCvD8NHvbTjxrSItAex9iMWAG6iZXXbzODBq/VBhZs 32JREdgcHlJJcQaPL4FePRVlCUCuMkuIM1qMc08nMpP4RNr7ZpxOvvFf2mEYCB/mqP D1gK73iBHJ6q16chuUa9PM3/0QACnA+yU1KHr22U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbgHXIc0 (ORCPT ); Mon, 24 Aug 2020 04:32:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:39218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726682AbgHXIcY (ORCPT ); Mon, 24 Aug 2020 04:32:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 201A5207D3; Mon, 24 Aug 2020 08:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598257943; bh=aRx+YliMIlfhHADwgY6F1wy2b/b10bc5vVPUkcz9jwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DMjlXSHGOjMP5wDgzvM6nVWtFmBCznS2q2R7wV3nd8fPZNFhEaq/w+i1knW2cZQ4P hdvR/k35pL4FnMSIqljAL17nOS+XJOE7NduymfPQpU/n/hCbqWtqH3aM/BIlHSJnFQ ocVUagGwlpCdziVtBJj7gXsJKIBV31XLdqw9IVgY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Prochazka , Tomoatsu Shimada , Phillip Lougher , Andrew Morton , Guenter Roeck , Philippe Liard , Christoph Hellwig , Adrien Schildknecht , Daniel Rosenberg , Linus Torvalds Subject: [PATCH 5.8 017/148] squashfs: avoid bio_alloc() failure with 1Mbyte blocks Date: Mon, 24 Aug 2020 10:28:35 +0200 Message-Id: <20200824082414.791473408@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082413.900489417@linuxfoundation.org> References: <20200824082413.900489417@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Phillip Lougher commit f26044c83e6e473a61917f5db411d1417327d425 upstream. This is a regression introduced by the patch "migrate from ll_rw_block usage to BIO". Bio_alloc() is limited to 256 pages (1 Mbyte). This can cause a failure when reading 1 Mbyte block filesystems. The problem is a datablock can be fully (or almost uncompressed), requiring 256 pages, but, because blocks are not aligned to page boundaries, it may require 257 pages to read. Bio_kmalloc() can handle 1024 pages, and so use this for the edge condition. Fixes: 93e72b3c612a ("squashfs: migrate from ll_rw_block usage to BIO") Reported-by: Nicolas Prochazka Reported-by: Tomoatsu Shimada Signed-off-by: Phillip Lougher Signed-off-by: Andrew Morton Reviewed-by: Guenter Roeck Cc: Philippe Liard Cc: Christoph Hellwig Cc: Adrien Schildknecht Cc: Daniel Rosenberg Cc: Link: http://lkml.kernel.org/r/20200815035637.15319-1-phillip@squashfs.org.uk Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/squashfs/block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c @@ -87,7 +87,11 @@ static int squashfs_bio_read(struct supe int error, i; struct bio *bio; - bio = bio_alloc(GFP_NOIO, page_count); + if (page_count <= BIO_MAX_PAGES) + bio = bio_alloc(GFP_NOIO, page_count); + else + bio = bio_kmalloc(GFP_NOIO, page_count); + if (!bio) return -ENOMEM;