Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4614451rwb; Tue, 17 Jan 2023 03:17:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtZCGm5Jb/cT/z3Z1ZN2DKOxyBxNkVrEgLsagdMMTr4OnERpwZvnkXQBYP6iW+844tzPVzq X-Received: by 2002:a05:6a20:ce22:b0:a2:ed21:d820 with SMTP id ic34-20020a056a20ce2200b000a2ed21d820mr21430875pzb.42.1673954245727; Tue, 17 Jan 2023 03:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673954245; cv=none; d=google.com; s=arc-20160816; b=HRB+7XSRS+QF89ialZD6f0pFcolQh2Rv3lLYj9uMqMC99ymQ+eOiKRjtnA7oq/Us3u x0R8D86F51WvM2H28ADgCnhR0fW4T2RE0qd1y4bLVDDRx2mBDwF1ioMrDniRuYPpnP04 73K2Q7XQ+rnKt4tFfMyByZ4S7KJ2Oiw3MY11rS1E+kTMojX4zO4I5IXn+JVcjaR34QjD CdApMihasF73rBdHjawIuscr5a0E0GvPwIiQNDU//H2kkSmfyBuQL8IB+4rJqQtX4EX5 n27yXoueryHmhzdmadxvRW2Ow3f81YHYIPW/Aj99tYS5LwZ7JAe08KK1YaZnDVnVmsQ2 Hz5A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=dGy1xNl2G2/14BqmxD3Z5TPjwoKzMoc8HvevkbhoXhc=; b=yare0Elr0VR/XCdFTe585inmPGvYtgIiL9vcj/yhgStNuZmCohQ38B3vh8UoEOB7kU LSrdmaH+UzrWz7OmnzUgems5NYH2EEGMbavoYovLdFDAlQKtibtsF7sseI14sa81e+d0 n7Qm5aippwDKmBGp5Prs32239nKkmbGTO9/pXHLf9DVPRzvRd3A05UXfVQc1wIpveu+Z NkV9xOsVTNKLYu60u4yT4Z2MoPYV17XT5v519MkP+D8g8YSr37ghpFzL/YAesM9lO5Xi eswD1C9s2FZ/9tQOSMxIl7IFLsp9qTgiNKfhicZIqZD2SKyAEBRY/RtAA9/h/poRBhT0 vzTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=WoptNKAX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a63db44000000b00476e6407413si33101143pgi.15.2023.01.17.03.17.20; Tue, 17 Jan 2023 03:17:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=WoptNKAX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236244AbjAQKxZ (ORCPT + 49 others); Tue, 17 Jan 2023 05:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236594AbjAQKwv (ORCPT ); Tue, 17 Jan 2023 05:52:51 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2573303F9 for ; Tue, 17 Jan 2023 02:52:48 -0800 (PST) Received: from fedcomp.intra.ispras.ru (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 31B2244C101E; Tue, 17 Jan 2023 10:52:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 31B2244C101E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1673952767; bh=dGy1xNl2G2/14BqmxD3Z5TPjwoKzMoc8HvevkbhoXhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoptNKAXc39Pxz4Y3honDfHZmBXpt0/OBWUWHMT+Z6lV+0VPkWdiv4LKFA6bLs3ew Dlq8tu42kMMs+wFekzAoUXq5Fdi3BS0EZ+enHRF4rOa0np4PcoUZpNT0hQy9LxzkKA /m06bW5QjT8JuIP+aQqHw+IuX28oI0dsjbdWi8wQ= From: Fedor Pchelkin To: Phillip Lougher , Andrew Morton Cc: Fedor Pchelkin , linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, syzbot+082fa4af80a5bb1a9843@syzkaller.appspotmail.com Subject: [PATCH 1/1] squashfs: harden sanity check in squashfs_read_xattr_id_table Date: Tue, 17 Jan 2023 13:52:26 +0300 Message-Id: <20230117105226.329303-2-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117105226.329303-1-pchelkin@ispras.ru> References: <20230117105226.329303-1-pchelkin@ispras.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: 506220d2ba21 ("squashfs: add more sanity checks in xattr id lookup") Reported-by: syzbot+082fa4af80a5bb1a9843@syzkaller.appspotmail.com Signed-off-by: Fedor Pchelkin Signed-off-by: Alexey Khoroshilov --- 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.34.1