Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3488115pxf; Mon, 29 Mar 2021 03:45:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIp/R18ugoU9SP/ng/GFsKXkoIcTm30Eg+3HaTUYXh0i+r7L+35D680GH05lPF6L/dFnSY X-Received: by 2002:a05:6402:32a:: with SMTP id q10mr27595342edw.15.1617014726862; Mon, 29 Mar 2021 03:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617014726; cv=none; d=google.com; s=arc-20160816; b=X/05W/wUdB2aQZUOThfY9xxqw35CG2oWi7QJd9+j9cVtPETMWiCVyw3qwPcWCxED17 tbvPe3dgliVtE3boj3uRnf6fmAEvIMEDTTSJTcnPfcci77AiA/HrfXbf8C14fn7l85cS PMOT8xsKyqBLuLtlY5f4/pDaivI87iLfQG+x4jftVjn9PYZyb6P4iL7ZA2KVvYatljzH CLIoxYM6MyheKlCMKL7uUmoPC0oIx/a19JmgHuWNf8AhLS69gMBVexMouo5E3OBGOBtS vedBtNwJwLZzEIX6lCtOYvY7PxheHEzMVhqJLuYz2RVaABRkXKbvls8n7EuqdLAs7bfg yYAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xFrxSvDCdXhPIrxR4Hy6b2wIuCaurkJ4CfW1f3hBI8I=; b=MItuynaSpwDcpMiHv3oASBXrFU4wvsEISvI3DXQo/zl6ie06VHUTSQBS1MdKWeu/GL VZwWadIRcMq6gk7xbZLnxbyX6xG0cZwWbyYZCpUrDdSHvGoj+qcWcUn/2fCYrBtxbNMe 0bBxfg1n1/eki6+5BX92hwb5uHIESsJNBVLHt46iNA5gpLKb7FpVsTdVQMWSXHWoM/Xa LsAnUUd8Dmixb9WQgk+0y7sKEcS2u9OfzXWGPrkozJ2DXbGNupo83dBVeQbPJG6XBgio nikUl6P19ye1OEOfnHkc1bB4DBYVgtpKnvv/aE1nyWHmQBnAkEMo6B+r+k3UMQHGxOCf udOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="u0+sk/iq"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h25si13229520eje.653.2021.03.29.03.45.04; Mon, 29 Mar 2021 03:45:26 -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=@linuxfoundation.org header.s=korg header.b="u0+sk/iq"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232699AbhC2Idz (ORCPT + 99 others); Mon, 29 Mar 2021 04:33:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:37378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbhC2IVA (ORCPT ); Mon, 29 Mar 2021 04:21:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B10D561613; Mon, 29 Mar 2021 08:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006060; bh=IqqgAef8aMSmr7MlycYjfyp1izlvDR167gZ7Dbm1wOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u0+sk/iqBI5l17cfoi7PC/1G4jdyuh7lrSgrKdXhADL1yKnn0NSpamnZkvr3QHn7/ T+zh1ec8nsTKIcVZAspmAlQjOpcDEehbrP4NAyNrmzy2YMkQSPTXib41/vgHkr0lr2 vJr4Qa3ZG7FMrlHdhy9OeaUjHg5s0/qdSfZM2gRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Nyekjaer , Phillip Lougher , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 069/221] squashfs: fix inode lookup sanity checks Date: Mon, 29 Mar 2021 09:56:40 +0200 Message-Id: <20210329075631.484170112@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Nyekjaer commit c1b2028315c6b15e8d6725e0d5884b15887d3daa upstream. When mouting a squashfs image created without inode compression it fails with: "unable to read inode lookup table" It turns out that the BLOCK_OFFSET is missing when checking the SQUASHFS_METADATA_SIZE agaist the actual size. Link: https://lkml.kernel.org/r/20210226092903.1473545-1-sean@geanix.com Fixes: eabac19e40c0 ("squashfs: add more sanity checks in inode lookup") Signed-off-by: Sean Nyekjaer Acked-by: Phillip Lougher Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/squashfs/export.c | 8 ++++++-- fs/squashfs/squashfs_fs.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) --- a/fs/squashfs/export.c +++ b/fs/squashfs/export.c @@ -152,14 +152,18 @@ __le64 *squashfs_read_inode_lookup_table start = le64_to_cpu(table[n]); end = le64_to_cpu(table[n + 1]); - if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) { + if (start >= end + || (end - start) > + (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { kfree(table); return ERR_PTR(-EINVAL); } } start = le64_to_cpu(table[indexes - 1]); - if (start >= lookup_table_start || (lookup_table_start - start) > SQUASHFS_METADATA_SIZE) { + if (start >= lookup_table_start || + (lookup_table_start - start) > + (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { kfree(table); return ERR_PTR(-EINVAL); } --- a/fs/squashfs/squashfs_fs.h +++ b/fs/squashfs/squashfs_fs.h @@ -17,6 +17,7 @@ /* size of metadata (inode and directory) blocks */ #define SQUASHFS_METADATA_SIZE 8192 +#define SQUASHFS_BLOCK_OFFSET 2 /* default size of block device I/O */ #ifdef CONFIG_SQUASHFS_4K_DEVBLK_SIZE