From patchwork Tue Oct 27 13:54:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312057 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=-12.8 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, URIBL_BLOCKED, 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 D5B28C55179 for ; Tue, 27 Oct 2020 17:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BE2E21D24 for ; Tue, 27 Oct 2020 17:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603819480; bh=NMbRKQtIo06DCqElI09OojTwuYhyr225CCCA9tMoc+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WlVmACyelrBkO0wkDKa2dI2SWbcbc/A43CJNQN6EfSEq+Qjz4ye9CFcFavI+EtWL/ IGPmcsd1JJTz1cd9mKxubw75FpdaVfyykdNExSU9LfkF6JUZN+UChgfDIjrDLBGQwz AwNoM/YOdx9kY68nWE4jBsPhLo9Pf7vmOnsX9ZsM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1780288AbgJ0OyE (ORCPT ); Tue, 27 Oct 2020 10:54:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:44820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762347AbgJ0Ooz (ORCPT ); Tue, 27 Oct 2020 10:44:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 C8FE921D7B; Tue, 27 Oct 2020 14:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809895; bh=NMbRKQtIo06DCqElI09OojTwuYhyr225CCCA9tMoc+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J7KHtT9od7FXNW+DjKignJyZ9LpwwkXyt0tT6OSafeucwAZrvl2fjrbX9RlGf6se6 aWT/fiCs4Im+O8Bf0VYEiaNXEZfyHveVzxaa6FrzXBPXRj3HhHAsqhBrL+lQqFFzvM XbIEsYTE1PL2bPEPBluFUkunBdHQ2DiogeIjRvdU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+9991561e714f597095da@syzkaller.appspotmail.com, Jan Kara , Sasha Levin Subject: [PATCH 5.4 358/408] udf: Limit sparing table size Date: Tue, 27 Oct 2020 14:54:56 +0100 Message-Id: <20201027135511.624985906@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jan Kara [ Upstream commit 44ac6b829c4e173fdf6df18e6dd86aecf9a3dc99 ] Although UDF standard allows it, we don't support sparing table larger than a single block. Check it during mount so that we don't try to access memory beyond end of buffer. Reported-by: syzbot+9991561e714f597095da@syzkaller.appspotmail.com Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/super.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/udf/super.c b/fs/udf/super.c index 4baa1ca91e9be..a0cd766b41cdb 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1352,6 +1352,12 @@ static int udf_load_sparable_map(struct super_block *sb, (int)spm->numSparingTables); return -EIO; } + if (le32_to_cpu(spm->sizeSparingTable) > sb->s_blocksize) { + udf_err(sb, "error loading logical volume descriptor: " + "Too big sparing table size (%u)\n", + le32_to_cpu(spm->sizeSparingTable)); + return -EIO; + } for (i = 0; i < spm->numSparingTables; i++) { loc = le32_to_cpu(spm->locSparingTable[i]);