From patchwork Tue Jun 16 15:35: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: 224439 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=-6.8 required=3.0 tests=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=unavailable 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 14683C433E1 for ; Tue, 16 Jun 2020 15:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC378207C4 for ; Tue, 16 Jun 2020 15:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592323065; bh=LUaGMoUbjdbFQRmoKpjS+1KFdgYIxUgQbBO85tMnjrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2Q6e9qLpRBa3YxxFBnpFCorvsPd9xrO5QPC8mbIffysHc1vwoOCU0wR3Vil0PW7Fj CqyxdsjzECdNfoKRO+rz8Uxy3p053+/G8P9z8zw7wDZAdDLeMEkeetPy0TBTny+a3/ xkiOd4uMIycyQVy/Cny6PnVZp5euxvYWN8k3tKew= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733017AbgFPPyy (ORCPT ); Tue, 16 Jun 2020 11:54:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:54524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732553AbgFPPyw (ORCPT ); Tue, 16 Jun 2020 11:54:52 -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 033012158C; Tue, 16 Jun 2020 15:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322892; bh=LUaGMoUbjdbFQRmoKpjS+1KFdgYIxUgQbBO85tMnjrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PliDeAK+YJNlWt/o2kDLeLs7Fh9lherSnog45q7dR+boE59IKD73g6NUHA/+dKzdJ 6kkT5fCOAYVIfHA7p/ovwYDDKOVQCZD9ty9kR9JLdW9dX6oeddwL4oRX4Xr6kuXCFY jQ/bwysTrFT1kWEDqe0HZvk9+es8UP7flCQiWPmU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6f1624f937d9d6911e2d@syzkaller.appspotmail.com, OGAWA Hirofumi , Andrew Morton , Marco Elver , Dmitry Vyukov , Linus Torvalds Subject: [PATCH 5.6 145/161] fat: dont allow to mount if the FAT length == 0 Date: Tue, 16 Jun 2020 17:35:35 +0200 Message-Id: <20200616153113.251317880@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.402291280@linuxfoundation.org> References: <20200616153106.402291280@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 commit b1b65750b8db67834482f758fc385bfa7560d228 upstream. If FAT length == 0, the image doesn't have any data. And it can be the cause of overlapping the root dir and FAT entries. Also Windows treats it as invalid format. Reported-by: syzbot+6f1624f937d9d6911e2d@syzkaller.appspotmail.com Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton Cc: Marco Elver Cc: Dmitry Vyukov Link: http://lkml.kernel.org/r/87r1wz8mrd.fsf@mail.parknet.co.jp Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/fat/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -1520,6 +1520,12 @@ static int fat_read_bpb(struct super_blo goto out; } + if (bpb->fat_fat_length == 0 && bpb->fat32_length == 0) { + if (!silent) + fat_msg(sb, KERN_ERR, "bogus number of FAT sectors"); + goto out; + } + error = 0; out: