Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3020884rdb; Wed, 15 Nov 2023 19:14:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0BQHXQjzOiO8JwN0JmkAZd3g0ziNMJihgAlk11Hl/smQ1zxt2LV1d9bj0aVHb6kbFI5yQ X-Received: by 2002:a17:903:444:b0:1ce:a0b:7314 with SMTP id iw4-20020a170903044400b001ce0a0b7314mr1114889plb.61.1700104451893; Wed, 15 Nov 2023 19:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700104451; cv=none; d=google.com; s=arc-20160816; b=RQQm8LyrVEfQbKizN6Ku5qwxUx8GZ2p4LCCJdCKTll7IqOayCU15eZW5UsFvve7Msm jiiSDeKAKfBmNrs/KY/ie6K9aJASjyeOszxPzuAsmrxKQv0sDHePRnirswBHmE9cdrBm v/GV+iS2hFuZHhXUTWTLGegmPn/IqXma4JtHXPOzpoP3ClZn7zOhjJDI9n3SQpjrJKQW rVNl3WSup/KscAYq5Vm97CDC46lyplSXqp1/lHFI+TAbY/NI7oge8An0VrAFkPCJm4hn nVLCmUW0fZeyjKGskq7VcGp00yayFkuVGciJbEnhmEovFT9RZMnscAyV7f2fn8r4flvA c33g== 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; bh=/U+OKTrjTaTjZpiPlxKE8wMpB+i1XVATRI/cqJG1CRE=; fh=MdCRGaC5PXVAO+USBBtBQp+1enz4kA4LTd3k06dG6QM=; b=UZxhx5pkg4dfJ/oFRA5y1gf/y/0e9mydlLdcdbhi+Fgekl99mUh78Mrqv6PSGrYCva gU9u6gdDoQSCzqnxKvStfht+/aLBVyOZ3obf7q/zZgb3vOnrycsxPMUjPzUNCHtk7TLx JzyS0Hv4Ff7pH6AcoBdD5/M12Lht3xv8c4yjP1FDHgcrqynL4608mwiyHaQYXhmFe/Li 79raqPqOUycpdcuUVJ5PZoUZzt9uG50wm83118lMJb5iOAxwPszG22fySxCOcnCby5fm 5cuC9P17evER51m/HP1B95zUcrbyMPBuiwTEj4fcZoN+H1gwmKhJGT/g5YoW3g9xaMWy h/dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@windriver.com header.s=PPS06212021 header.b="Q/xS+7bM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=windriver.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m4-20020a170902db0400b001ca1bd194b4si12336828plx.416.2023.11.15.19.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:14:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@windriver.com header.s=PPS06212021 header.b="Q/xS+7bM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=windriver.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B507B8051B6C; Wed, 15 Nov 2023 19:14:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235471AbjKPDOJ (ORCPT + 99 others); Wed, 15 Nov 2023 22:14:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbjKPDOJ (ORCPT ); Wed, 15 Nov 2023 22:14:09 -0500 Received: from mx0a-0064b401.pphosted.com (mx0a-0064b401.pphosted.com [205.220.166.238]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B23EE98; Wed, 15 Nov 2023 19:14:05 -0800 (PST) Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3AG2lIlD018161; Wed, 15 Nov 2023 19:13:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PPS06212021; bh=/U+OKTrjTaTjZpiPlxKE8wMpB+i1XVATRI/cqJG1CRE=; b= Q/xS+7bMF1oWAKSMMWiqRlZ7zyXDVCZMbbCN+2rdc844rOagw+Gqg7sLqoaXBIy2 yQApR/tzpwa0JQBgkJs/M1kZCHeLISeNUJHhc6RiC/88+hdgh/akZZ0LZyESnSHB +7sNhlFPSzsw+lWuGXp58EoeTalOZPzIUtwq4E9kRKzEA3+bzrai2G5xsT4taquG f/FyRg5p2qdP2Fl2D2tbyOsXrNNpUb+zRGVIA58kojmUzghA/AQSobjaPZZo/WDZ InERDLUNi+iZUIsd37oSqnlz8gPmtAi+JVkwibedgNrJgUZDil30odTuNlNtvgeU OdvjWoJDqLNfIPFYBgTGOg== Received: from ala-exchng01.corp.ad.wrs.com (ala-exchng01.wrs.com [147.11.82.252]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3uaa0km94p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 15 Nov 2023 19:13:55 -0800 (PST) Received: from ala-exchng01.corp.ad.wrs.com (147.11.82.252) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 15 Nov 2023 19:14:00 -0800 Received: from pek-lpd-ccm6.wrs.com (147.11.136.210) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Wed, 15 Nov 2023 19:13:58 -0800 From: Lizhi Xu To: CC: , , , , Subject: [PATCH] squashfs: squashfs_read_data need to check if the length is 0 Date: Thu, 16 Nov 2023 11:13:52 +0800 Message-ID: <20231116031352.40853-1-lizhi.xu@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <0000000000000526f2060a30a085@google.com> References: <0000000000000526f2060a30a085@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Wlqcm3DvHphV4joZwIaJWP-_HNpXNzkX X-Proofpoint-GUID: Wlqcm3DvHphV4joZwIaJWP-_HNpXNzkX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_20,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 mlxlogscore=871 lowpriorityscore=0 adultscore=0 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311060001 definitions=main-2311160024 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 19:14:10 -0800 (PST) when the length passed in is 0, the subsequent process should be exited. Reported-by: syzbot+32d3767580a1ea339a81@syzkaller.appspotmail.com Signed-off-by: Lizhi Xu --- fs/squashfs/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 581ce9519339..2dc730800f44 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c @@ -321,7 +321,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length, TRACE("Block @ 0x%llx, %scompressed size %d\n", index - 2, compressed ? "" : "un", length); } - if (length < 0 || length > output->length || + if (length <= 0 || length > output->length || (index + length) > msblk->bytes_used) { res = -EIO; goto out; -- 2.25.1