From patchwork Thu Nov 16 03:13:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lizhi Xu X-Patchwork-Id: 165673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2960015vqg; Wed, 15 Nov 2023 19:14:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IH41J56Yw50m24XM8jkIU2GrYfNLdQLA7TXRMvdhZfSCrWme6ylIu57OiO+I+yjPcj3ALTo X-Received: by 2002:a05:6808:1891:b0:3a7:55f2:552d with SMTP id bi17-20020a056808189100b003a755f2552dmr18443589oib.58.1700104455658; Wed, 15 Nov 2023 19:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700104455; cv=none; d=google.com; s=arc-20160816; b=cErWcWIzurrib2/nSfyxRSRDXHKoBY4sFrWc3BQpf9O8U7v7I6sFPB9Ug3b3SzkhVL I+7HUd+Ovp59UGm3YRFbXooUMLGr9DpMpn4333R76v748V4hjg+nNf1p1C3pJCBRPIBI 8duoULpPavvtZmZjKPmOebWa74Ea6oBHIpyihxFxD/DTYnPU7p+CJaiMxYM6bxtOuQIH tkLMZHEASj1q8q2Df6aXMNwFQnPHHtHmsxKNSnpa/spG23Grar387SEiyoNssNmrBVNc 25vDgbNWEhvhFYtyD58UuXlYOeLa/johUf9EWMwHFeDTXSEp2QYfrEUIeQMSK3RjFAZA 15gA== 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 Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ck27-20020a056a02091b00b005aee0914b6csi12519822pgb.8.2023.11.15.19.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:14:15 -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 CD6CE804C537; Wed, 15 Nov 2023 19:14:14 -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 S235663AbjKPDOJ (ORCPT + 28 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 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:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782688729200842809 X-GMAIL-MSGID: 1782688729200842809 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 Reviewed-by: Phillip Lougher (phillip@squashfs.org.uk) Reported-by:. --- 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;