From patchwork Fri Jun 19 14:31:53 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: 224226 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,URIBL_BLOCKED,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 66503C433E0 for ; Fri, 19 Jun 2020 14:49:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39AD821835 for ; Fri, 19 Jun 2020 14:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578142; bh=H5xDzHKG9GRHH4R47pWgDEYLAYfTowtEAnmIXJQZqIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xiQOzHyQRxlzEfOkyt7O3qHQMYWlhlAuBpcvVlgoooCYFu4tZqDH1WdgsqrqFi+Ye f/ahSO6Y4fMKXFqRSQP1LitqKxAi1BWABRGnWgTbWNGozhn37tY7xoD53SxLgo+BZc zWDifZ3oWwcXwv821OSgtFWR5MMRU0wonUftym3c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389155AbgFSOtA (ORCPT ); Fri, 19 Jun 2020 10:49:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:41494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389156AbgFSOs7 (ORCPT ); Fri, 19 Jun 2020 10:48:59 -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 AC386217A0; Fri, 19 Jun 2020 14:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578139; bh=H5xDzHKG9GRHH4R47pWgDEYLAYfTowtEAnmIXJQZqIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JByso0eGxXsO4iVU/qmNpMFBZhLXtpU6vZAyowKT6WN7QI2vZve3obxijZ1ni/Mam SRWvkF9ymjwmnOcHMlvqRVQeqpi52keV8sVHUaG97avg550AKQGYqi1riatJirbp5S 1bV3wSWJJaC+aHI/PyT5urjl43jrGmDTEY55sNKw= 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 4.14 068/190] fat: dont allow to mount if the FAT length == 0 Date: Fri, 19 Jun 2020 16:31:53 +0200 Message-Id: <20200619141636.978715334@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141633.446429600@linuxfoundation.org> References: <20200619141633.446429600@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 @@ -1512,6 +1512,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: