Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp993034ybt; Fri, 19 Jun 2020 20:53:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2TdoWiZfPqi7LwCclpV2w3eizetkhiexSxxV4SZ90QNg945/c3RrMzlvWKKslKn6OkIJB X-Received: by 2002:a17:906:cd06:: with SMTP id oz6mr6848231ejb.434.1592625224135; Fri, 19 Jun 2020 20:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625224; cv=none; d=google.com; s=arc-20160816; b=P8Ae/rss9d/fG+6FleCmOXfJliiSBQT3WJQnAFaAaZakIoZKQqlCRh0nAZrBZVbkrJ H5yZ115mhFrxzlewHysWciw3zBVYwiTCN97tXYqpI7dI2ehl8EUmndscLUQfGkXry+Pw +p/SIeGRtHT1Xlz1sBvELOl76v8U32OFwl9PP3MQ0YSBgIRwmoMvI5KvGWb5j08PJCpn QbOaFJZtv0t2k5rWJ1p9EKnIr4iP/W5Do2JdqbqWRiwm8Tq8X21lz0xWubemwwNXdJr6 fUdc6Id9jkwljPbY8ri84o3yJXD9Q7ywXBLvcFUkUfsugvIDTh5o5fspVcRuhpDUQecH CstQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=I5Hb92ZGHqLNMMlg5VlBAZ9J4NycA3TS5OSAxh8LA68=; b=Q44QEtHytnecztKi2K6HgzoGl+r7lBiUkB+jJYHbeKSoRse4RjhPcGfYGNo6f6wtB/ dwXGjLeORB99KU2f97A3c7c9sXsqqM7Cp8+q9V0zsGf2PcxQm1dLBGBxchiSEU3o2VoM 0XhAuXmvLk4JOq6x+eHK0IkmXUjnmmSedlsbcbtGqYWY6rfU3heXWyIVKu99OT3j5HpT BT6sKPzGgbIrG1tOnrvqaKeU7ORR3GbGUiIKOFff/4LYUVs6G8t97kW1nRdYIoLY72LZ dIlXGw+8l84pEVR6poBbrW9qze+PEiPyyhdnFAjxmURAzsghTxRGpxL2bqruvjxUa6qJ k+7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XMSh2ajA; 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 gf16si5012528ejb.490.2020.06.19.20.53.22; Fri, 19 Jun 2020 20:53:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=XMSh2ajA; 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 S2404687AbgFSQYV (ORCPT + 99 others); Fri, 19 Jun 2020 12:24:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:54252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390389AbgFSO60 (ORCPT ); Fri, 19 Jun 2020 10:58:26 -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 242BC21919; Fri, 19 Jun 2020 14:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578706; bh=SrQIZo4/w6tvt/sn10MdGljp2fb7x+ziSKjuxf924D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMSh2ajAIng1b2yRRwkEI0uiqWiaYbTUqgSo2ywAw8Y4mvJjAJAXcL/nZW+347e7z 7Qy1MlsYRHFKWZ7e0tK9qNJ9eqgG4WyBGGK8YE5PFh9mkeqtLnPc+iIu5I3oJ/YnVi pRyp1wEUI4K6Fu4j37lXdSWUIeVjXhoJWPTL9j3w= 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.19 085/267] fat: dont allow to mount if the FAT length == 0 Date: Fri, 19 Jun 2020 16:31:10 +0200 Message-Id: <20200619141652.962191910@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -1519,6 +1519,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: