Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4467873pxb; Tue, 2 Mar 2021 16:37:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDgkj3IvKKZwPqRTcfMyq7OkEGFuGogS9a5yVp2k982wTtO0EQHzmhpOs3o7UMYF5ulQez X-Received: by 2002:a17:906:cc89:: with SMTP id oq9mr12016213ejb.258.1614731846883; Tue, 02 Mar 2021 16:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614731846; cv=none; d=google.com; s=arc-20160816; b=dNdKEsgteiTVDu16BlHsjjcEB5/yOUuXtiqJnkRWkUbsIrJa87LmxePcJhse8wSToI jWyFVuWJMUxyR9882Vr+KkhN0thkT6UvpEL79ktXmM0nOtfKh2INPscYcxnKs6UuDZR/ z8mctsWSXPBfZQxiU6q7eOujFUVAjGF0nApMBtm25gJnp7YOoqnf87KD9JjqWTMuBFH3 zBZYhWoAQxcQNvsNzktzg05sjcGHBbMte6B5LmyEabDJyY26miMefJQsWK5hSlngs6oS OxzDN/xG2yIa8GUvnDCz2QprVRf9axc0QaPs6nHTEaZf9f5Hu+1vnO0lwB/DuX4790F/ yVlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:importance:content-transfer-encoding :mime-version:subject:message-id:to:from:date; bh=jsa9v/EYONip4Vl4/QsXWxaodgHgrJpLdoW+aVY3lFw=; b=DlaqhujW7vHEFCef3XJ5HrFPB+cx6tfJDOAcesiOD9K8i5dhlXnCq7rNEj+MgAFn6d MA5BG5wFlKYrLRtPvOZfaEiPLBA9hLEI2D1McDrItvIH7yCZVs+tV1WBhWqoagLDmoDI v6ylttpC9AlvZJs3hijMLFCEFcmkreHJmObpbXZaVp8pGiPQ+Vuh5sCqU0v0flruIisI ze+6qdhpng/2Cd0ZDTzn3qrelx4XYau/f+0fsJ45ns+sTwo5cTu6gDO6db5MvyIcbnT0 KctgSttBHPrVORNWNrqwM2L11og9T/RXlw1ug5SlMTbPZh7hC8Mrh/Ie4+2g+IMsdHsk HQ+A== ARC-Authentication-Results: i=1; mx.google.com; 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 mp4si3070468ejc.677.2021.03.02.16.36.50; Tue, 02 Mar 2021 16:37:26 -0800 (PST) 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; 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 S232505AbhCAH3B (ORCPT + 99 others); Mon, 1 Mar 2021 02:29:01 -0500 Received: from outbound-gw.openxchange.ahost.me ([94.136.40.163]:44512 "EHLO outbound-gw.openxchange.ahost.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232286AbhCAH3A (ORCPT ); Mon, 1 Mar 2021 02:29:00 -0500 Received: from localhost ([127.0.0.1] helo=outbound-gw.openxchange.ahost.me) by outbound-gw.openxchange.ahost.me with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (Exim 4.94) (envelope-from ) id 1lGcyD-0005Mf-FP; Mon, 01 Mar 2021 07:27:57 +0000 Date: Mon, 1 Mar 2021 07:27:57 +0000 (GMT) From: Phillip Lougher To: "linux-kernel@vger.kernel.org" , Andrew Morton Message-ID: <2069685113.2081245.1614583677427@webmail.123-reg.co.uk> Subject: [PATCH] Squashfs: fix xattr id and id lookup sanity checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.3-Rev22 X-Originating-IP: 82.69.79.175 X-Originating-Client: open-xchange-appsuite Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The checks for maximum metadata block size is missing SQUASHFS_BLOCK_OFFSET (the two byte length count). Cc: stable@vger.kernel.org Signed-off-by: Phillip Lougher --- fs/squashfs/id.c | 6 ++++-- fs/squashfs/xattr_id.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/squashfs/id.c b/fs/squashfs/id.c index 11581bf31af4..ea5387679723 100644 --- a/fs/squashfs/id.c +++ b/fs/squashfs/id.c @@ -97,14 +97,16 @@ __le64 *squashfs_read_id_index_table(struct super_block *sb, 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); } diff --git a/fs/squashfs/xattr_id.c b/fs/squashfs/xattr_id.c index ead66670b41a..087cab8c78f4 100644 --- a/fs/squashfs/xattr_id.c +++ b/fs/squashfs/xattr_id.c @@ -109,14 +109,16 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 table_start, 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); } -- 2.29.2