From patchwork Mon Aug 24 08:29:28 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: 265201 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=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, 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 468C8C433E1 for ; Mon, 24 Aug 2020 08:34:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19C4B207DF for ; Mon, 24 Aug 2020 08:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258092; bh=O7cbD4PDnM0EpN7J17/wF5KKMXAJKy5EqjAcay2JH+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MsuPe516fe4vUkUV2IBSR4n/wd2xIO40WZUQHt/Cjsr4flSkS8AshUv8NDXCkyPac 6dGzbxjrA1cL2NArYkMCmewj1qVGmFPYqrALfZx7wRsqJ17msS4Hmq/S+WQO+RpcmU QefBcAQSq7qegDp+Bx4/GbqDiakDMKzPeMf7IPLs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbgHXIet (ORCPT ); Mon, 24 Aug 2020 04:34:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:43868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728006AbgHXIep (ORCPT ); Mon, 24 Aug 2020 04:34:45 -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 7EA23207DF; Mon, 24 Aug 2020 08:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258085; bh=O7cbD4PDnM0EpN7J17/wF5KKMXAJKy5EqjAcay2JH+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vkDtlR2+iBO4rZG/WI/5q8meN2FFmY4nTVKB84RaaNzuku/0CMcaeOx4IYLKRFV9u YbodYaPqmVYlaEUMvwhHlbXuMM/tjURThgK2ftcqVjmNXdQQ5xU9aA+FMjassysLul L6b6CaDZ9NQsr7E+6NAH0LrFL9hJueokl4OGa+Zw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+756199124937b31a9b7e@syzkaller.appspotmail.com, OGAWA Hirofumi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.8 070/148] fat: fix fat_ra_init() for data clusters == 0 Date: Mon, 24 Aug 2020 10:29:28 +0200 Message-Id: <20200824082417.430597987@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: OGAWA Hirofumi [ Upstream commit a090a5a7d73f79a9ae2dcc6e60d89bfc6864a65a ] If data clusters == 0, fat_ra_init() calls the ->ent_blocknr() for the cluster beyond ->max_clusters. This checks the limit before initialization to suppress the warning. Reported-by: syzbot+756199124937b31a9b7e@syzkaller.appspotmail.com Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton Link: http://lkml.kernel.org/r/87mu462sv4.fsf@mail.parknet.co.jp Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/fat/fatent.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index bbfe18c074179..f7e3304b78029 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c @@ -657,6 +657,9 @@ static void fat_ra_init(struct super_block *sb, struct fatent_ra *ra, unsigned long ra_pages = sb->s_bdi->ra_pages; unsigned int reada_blocks; + if (fatent->entry >= ent_limit) + return; + if (ra_pages > sb->s_bdi->io_pages) ra_pages = rounddown(ra_pages, sb->s_bdi->io_pages); reada_blocks = ra_pages << (PAGE_SHIFT - sb->s_blocksize_bits + 1);