Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1301846pxa; Sat, 15 Aug 2020 15:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWLgmK8fMSD+PT5I056OiH+Jg4JCV520Tq0uXu8xB+gw6k/7J6G9/Ogyqm4gAAwCm2x/po X-Received: by 2002:a17:906:3b18:: with SMTP id g24mr8309220ejf.420.1597529026671; Sat, 15 Aug 2020 15:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597529026; cv=none; d=google.com; s=arc-20160816; b=WJm6Zw/ByEOXpuxSHAPQeJN4o56S/x9X7Ou40v6EVxZXjNPK0zSWRwWlM6GX4xwrgC N+uCqzvaCcniLu1qcYRxnJAtqaZeNJZB7U2xXjXA1oHMt3l8P1SODS+mDVFqvZ5V4+aK rbJ+J35dH+RtV8+0Pku1mYA6HpW/zOVYfd9Nh6RjQbw12gssQVqBQHsVIHN5l+RtbkV1 nq/UOl+Z1BBfmSbmM+Drp9eMabkcjMTvrNzMXwubtWH0HWwZoqb9mp/wc9c/0vO8PVqB 0ff4YEQDQ1aKiVM4ZUBzRoF4s6WksIAg8fnp6DLT2B7/THs6J/3y/t1UMRWZNOLzPqfQ Wsog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Lb/0nSfoiGHoV9aiughZ8p2N7GNR02yUBKEW4+jp7MU=; b=ISh8iVipqRsR4aupU4Kbyk/+/mBWfk2xMJYKshvMzWtp1FSPyhcEeB35J7Pc35SGnG XWgRuK5uBx8o3cj6gNbMzUIlpUyuhKseRLxD5BbqdlgaDCU8dp7YH64XEJCTQ7CkYw3q 7yyqviBuW37fLZatPw58hCuVfnTHg4EXaj8aqfco865G52Lx6aTo95GRF0rVydNvRHXi ySWOSU9D58Seb4Q9yRgWH/xC1aLKzLysLqvPpxHHt0Ls3XSqYmNv4SCMHhY4nc9tsEY0 DP4e5H+MUAt0CkUT0uieii9rIs7ogioW5wonzIiXsR4Wsdo4CevGnhvuAIjEkGPLY01C ENsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c34si9857777edd.267.2020.08.15.15.03.23; Sat, 15 Aug 2020 15:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729628AbgHOWAP (ORCPT + 99 others); Sat, 15 Aug 2020 18:00:15 -0400 Received: from mailex.mailcore.me ([94.136.40.62]:44384 "EHLO mailex.mailcore.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729445AbgHOWAN (ORCPT ); Sat, 15 Aug 2020 18:00:13 -0400 Received: from 82-69-79-175.dsl.in-addr.zen.co.uk ([82.69.79.175] helo=phoenix.fritz.box) by smtp04.mailcore.me with esmtpa (Exim 4.92.3) (envelope-from ) id 1k6nJo-0006KR-8t; Sat, 15 Aug 2020 04:57:20 +0100 From: Phillip Lougher To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, pliard@google.com, hch@lst.de, adrien+dev@schischi.me, groeck@chromium.org, drosen@google.com, Phillip Lougher , Nicolas Prochazka , Tomoatsu Shimada Subject: [PATCH] squashfs: avoid bio_alloc() failure with 1Mbyte blocks Date: Sat, 15 Aug 2020 04:56:37 +0100 Message-Id: <20200815035637.15319-1-phillip@squashfs.org.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailcore-Auth: 439913985 X-Mailcore-Domain: 1686784 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a regression introduced by the "migrate from ll_rw_block usage to BIO" patch. 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. Reported-by: Nicolas Prochazka Reported-by: Tomoatsu Shimada Signed-off-by: Phillip Lougher --- fs/squashfs/block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 76bb1c846845..8a19773b5a0b 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c @@ -87,7 +87,11 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length, 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; -- 2.20.1