From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 880AD63B8 for ; Mon, 20 Feb 2023 13:40:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB604C433EF; Mon, 20 Feb 2023 13:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676900427; bh=0kcqojmEZ309t71xizM8PrsJiaoyHNud+3yHVa+U/+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1QO2oxvbuoWDQDwuXnukkH2kEKU0oMH3yGzqWfNLsWhC/Hf/sMs7ytDKRYa6Mr7uN ymYZALpCazmypm60Foboldlm+AA8uMC8wE3eT2+Bws/73JGfl5lmKURr/N9NX39TGM Qh6sknKut5bEVCnPo0tfDp/oyAHt4+X1TY7NCRs8= 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 4.19 05/89] squashfs: harden sanity check in squashfs_read_xattr_id_table Date: Mon, 20 Feb 2023 14:35:04 +0100 Message-Id: <20230220133553.273986847@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220133553.066768704@linuxfoundation.org> References: <20230220133553.066768704@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 7f718d2bf357..0c0d7882bcca 100644 --- a/fs/squashfs/xattr_id.c +++ b/fs/squashfs/xattr_id.c @@ -89,7 +89,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