Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3421623pxf; Mon, 29 Mar 2021 01:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNCsgYAvPZlyYPj2JlJifzICASD74Zx6i2SdjYIKdGPiJltL7qIVecVb2NkXku/Lf09HX/ X-Received: by 2002:a05:6402:48c:: with SMTP id k12mr27641451edv.237.1617006908241; Mon, 29 Mar 2021 01:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006908; cv=none; d=google.com; s=arc-20160816; b=O0Z5b7bSre5ZntnygvJ/8RA4Aej78kQKEyFgDjeg+YHcd9mR+hsqigPckZxmwzmJP+ VrYrLFpWaCkuY7Up7IWal5STxa7UupHhhmXUoJzi4ArbqqUmoL/X/N3/9++QZm7REZhJ v7BcEZQDzrtSy2atsD4V8kfzf2luZ3bBjm2iOqpYqkeef7I8IbQwlL/R/ymx0MppJDEs U7nyJjTwDcCMdorOFDfpYKOALrTRqfJ9cD9Uo/r2kf1M5+QeQj6KxADUcdPjGjKgDhDW Cy3pCorber6i87PfDa/irNnwRQRmZSijHksZluXrlHS0zumRQMT3Y2+TxUpwedOMSlDD 9ElQ== 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=Z4rVy2h+m2fgFohq8H9yQJY+jkBo/+xKLoWxM15fOkk=; b=uOSYR2EhTZAZzM+veJHatB+HgZ5wGVPv+TnnNuM01hTJ7qXEJktxLZwbExblEJBUf+ NfsXC91gxjL62mabAonfdgsGn064hSCpcqli/kgjXU24N3KO8qBj2V4cyocIJw8VpAZd G4PeZeN09GixdEV45CYymLNnQQzENgt75I34vCRViatUkWrwcjl69ghP0cFv+D4U2pm3 iREbolM8NbWVzZHAjHcDSCwEtPIQXYRb2HtETg//WRzXIqLJUVbEj/suESmGLvJOnt51 yjhqBCdCi0RRaGQh62t0mpqH8UDQNxByzDkTBgBvIdRwIhMncylANVwWJNSQ7rX0W9VV xw+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kKfOLOq2; 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 c17si11538612ede.535.2021.03.29.01.34.45; Mon, 29 Mar 2021 01:35:08 -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=kKfOLOq2; 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 S233132AbhC2Id6 (ORCPT + 99 others); Mon, 29 Mar 2021 04:33:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:37726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbhC2IVD (ORCPT ); Mon, 29 Mar 2021 04:21:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC80461481; Mon, 29 Mar 2021 08:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006063; bh=sWzzsCkJggXUYwjaqk3ZNQKl7qOP3H5UYuNl4wv49dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kKfOLOq2SHFih1FxcAyQRFVTBS/fULAAb+AkKzBbEvwpocNfLYv95lbABCCKydnPc mZMAasDqc8fKvtQ6GxGfEr3qpS4o25CASfbG9dg6c1i4HzHxT44C6Gbjaxv1SWRMG/ 9oQOIwIgFQSAJAfQ4sPFmIXTmQIc0kML1i5eD2ec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phillip Lougher , Sean Nyekjaer , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 070/221] squashfs: fix xattr id and id lookup sanity checks Date: Mon, 29 Mar 2021 09:56:41 +0200 Message-Id: <20210329075631.517785964@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: Phillip Lougher commit 8b44ca2b634527151af07447a8090a5f3a043321 upstream. The checks for maximum metadata block size is missing SQUASHFS_BLOCK_OFFSET (the two byte length count). Link: https://lkml.kernel.org/r/2069685113.2081245.1614583677427@webmail.123-reg.co.uk Fixes: f37aa4c7366e23f ("squashfs: add more sanity checks in id lookup") Signed-off-by: Phillip Lougher Cc: Sean Nyekjaer Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/squashfs/id.c | 6 ++++-- fs/squashfs/xattr_id.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) --- a/fs/squashfs/id.c +++ b/fs/squashfs/id.c @@ -97,14 +97,16 @@ __le64 *squashfs_read_id_index_table(str 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 >= id_table_start || (id_table_start - start) > SQUASHFS_METADATA_SIZE) { + if (start >= id_table_start || (id_table_start - start) > + (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { kfree(table); return ERR_PTR(-EINVAL); } --- a/fs/squashfs/xattr_id.c +++ b/fs/squashfs/xattr_id.c @@ -109,14 +109,16 @@ __le64 *squashfs_read_xattr_id_table(str 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 >= table_start || (table_start - start) > SQUASHFS_METADATA_SIZE) { + if (start >= table_start || (table_start - start) > + (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { kfree(table); return ERR_PTR(-EINVAL); }