From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 286E4C64ED6 for ; Mon, 13 Feb 2023 15:01:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbjBMPBg (ORCPT ); Mon, 13 Feb 2023 10:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbjBMPB0 (ORCPT ); Mon, 13 Feb 2023 10:01:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495A71E1CD for ; Mon, 13 Feb 2023 07:01:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D86B86116D for ; Mon, 13 Feb 2023 15:01:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EED55C433D2; Mon, 13 Feb 2023 15:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676300469; bh=m+TNEsz8dbJ0d15DKk4YxJBuspM3Jw4BWIo5z3wKX5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UDw653z6oOMlPxRvLoLmPUwHQZlRbzsqtO7N4CRPcLrHRSv4ViNktUHSF0NcUj1yE uSaL3qiedQ/vSd/e7uTGcweBtfU+sGv+xtl55bXOPwbh3v7IB84fo4Dr/vG7QNMP20 kYbYBAuBob8EAZwQY0E2v4grhfl/EQ2AmKHNg6Rc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+082fa4af80a5bb1a9843@syzkaller.appspotmail.com, Fedor Pchelkin , Alexey Khoroshilov , Phillip Lougher , Andrew Morton , Sasha Levin Subject: [PATCH 5.10 025/139] squashfs: harden sanity check in squashfs_read_xattr_id_table Date: Mon, 13 Feb 2023 15:49:30 +0100 Message-Id: <20230213144746.974747059@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213144745.696901179@linuxfoundation.org> References: <20230213144745.696901179@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Fedor Pchelkin [ Upstream commit 72e544b1b28325fe78a4687b980871a7e4101f76 ] While mounting a corrupted filesystem, a signed integer '*xattr_ids' can become less than zero. This leads to the incorrect computation of 'len' and 'indexes' values which can cause null-ptr-deref in copy_bio_to_actor() or out-of-bounds accesses in the next sanity checks inside squashfs_read_xattr_id_table(). Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Link: https://lkml.kernel.org/r/20230117105226.329303-2-pchelkin@ispras.ru Fixes: 506220d2ba21 ("squashfs: add more sanity checks in xattr id lookup") Reported-by: Signed-off-by: Fedor Pchelkin Signed-off-by: Alexey Khoroshilov Cc: Phillip Lougher Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- fs/squashfs/xattr_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/squashfs/xattr_id.c b/fs/squashfs/xattr_id.c index 087cab8c78f4..f6d78cbc3e74 100644 --- a/fs/squashfs/xattr_id.c +++ b/fs/squashfs/xattr_id.c @@ -76,7 +76,7 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 table_start, /* Sanity check values */ /* there is always at least one xattr id */ - if (*xattr_ids == 0) + if (*xattr_ids <= 0) return ERR_PTR(-EINVAL); len = SQUASHFS_XATTR_BLOCK_BYTES(*xattr_ids); -- 2.39.0