From patchwork Thu Jan 26 13:14:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264962wrn; Thu, 26 Jan 2023 05:18:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWmDhoalFbT9ZL05W95DZtrh2zUBkAz1c64U9PKj8APDHOPtaK4nhtWuwHcHIHSW/D3Njd X-Received: by 2002:a17:907:c5c6:b0:877:8a55:2a26 with SMTP id ts6-20020a170907c5c600b008778a552a26mr26416532ejc.60.1674739083477; Thu, 26 Jan 2023 05:18:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739083; cv=none; d=google.com; s=arc-20160816; b=ok00Jk4NscTB6QyrzB9zM8f4y8yMJOnaVqXTaLYNxdP+e/k2foi5ei9fjr4A355YOE ttRzxFzmwfjZJj3gT6cz79eS7elzJAiKDNK1nvrhS2U/pQvmjnd3SGBxnz2Wf1uloYpI 2fguX6j5gADuIqand4Bpuc+uHd7YF6eB1ekzWjTRgnNb/jDq/JrrchZidQe+Y26Vgq5p ZoVXjvQOEqwR83dK2eH17476cdnKHugDqD1JUYQKTieXA/+gnbyt8jBA+nJjYqOLjItp 6FYFF5TVffV2AXqBaFnpAcNViTouEoW1Apo2cj47enc8pcntR2wAL9i1WNwtehF9PiiT LvRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8gE6mK45lDqgsDNu1OfK5EkeRgwy2GF3MN9FQh0hxkI=; b=n/T9hYklDn5MEqBkzGc70B2IDOe+b68TWwgTNAANTm2GU3WiTSQSX7aGovmz5nWnPA PcHkOPqvoiLO3lIeJ/j+Hyg8ba6TcI8cMS2oODHXSAdK0XNNrKlvwXIZ+DaEBjXaoBp8 s1alHeRx5va/+O5UX71jtd2P4HPEnYzZGm3c02RnbMlK8eqYaBBttah5rhJjQ+/k5JQp wQ7rSXm4Iob5CaWUYzH/OWdGx/2tbXVS31v75jIoqYMc23uHrnBfGZCZlDdVoXxp3RdS uclv2y3gu8424s7zHofORr9G8k3pGK3bmQCrRG20vt0LDBe/vjgdOozT2ttPKy/ayKEq 7f6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=pZtHwRQJ; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vf17-20020a170907239100b0086fcc2f95c0si1069209ejb.455.2023.01.26.05.17.40; Thu, 26 Jan 2023 05:18:03 -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=@ibm.com header.s=pp1 header.b=pZtHwRQJ; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236794AbjAZNPg (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236668AbjAZNOy (ORCPT ); Thu, 26 Jan 2023 08:14:54 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F1F6952C for ; Thu, 26 Jan 2023 05:14:39 -0800 (PST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCEDhp016689; Thu, 26 Jan 2023 13:14:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=8gE6mK45lDqgsDNu1OfK5EkeRgwy2GF3MN9FQh0hxkI=; b=pZtHwRQJ13qxmLQIF3Jt8yOdeKjHKNBlW0kuSaSksP8Xo8du2RObcsem+yUyoGoqR1Fj PCRe/paPZroWbubEgQpkg2tOH/v7Wjj3tkoqBPa13WjyHh8OCV2Um/LrAYkynEJGUyv+ hgPL+KEA+Amnlszgovme7qzIPHHsF9/3njmUn2i6dcN3JJV07ZTxebUOlKCv/OVLucUn bk+WTEJMe1NaR85l8cmtrf5CK2WjXvX0sl3C3cNSm/s7LaPo2sGSmITE1afP5rfhjvkB V4mYfJLFsiyEOU4lJpUKDTfSuJBUxKmWHClODAppEtLNfyduIJ/1dYy5TLkb4b6uRIvn /A== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbsbe1cay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:38 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30PEm5SY031955; Thu, 26 Jan 2023 13:14:34 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3n87p64kar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:34 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEU0247448484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB1D820040; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77E6A2004E; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 5/8] lib/zlib: DFLTCC not writing header bits when avail_out == 0 Date: Thu, 26 Jan 2023 14:14:25 +0100 Message-Id: <20230126131428.1222214-6-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: X5Wz3b56pYRq5y1Zk6XneiEpKyjN0dl- X-Proofpoint-GUID: X5Wz3b56pYRq5y1Zk6XneiEpKyjN0dl- X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=976 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091209254805714?= X-GMAIL-MSGID: =?utf-8?q?1756091209254805714?= This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/ce409c6 Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_deflate.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/zlib_dfltcc/dfltcc_deflate.c b/lib/zlib_dfltcc/dfltcc_deflate.c index 211d344710d5..d4c92f99808e 100644 --- a/lib/zlib_dfltcc/dfltcc_deflate.c +++ b/lib/zlib_dfltcc/dfltcc_deflate.c @@ -170,13 +170,18 @@ int dfltcc_deflate( param->bcf = 0; dfltcc_state->block_threshold = strm->total_in + dfltcc_state->block_size; - if (strm->avail_out == 0) { - *result = need_more; - return 1; - } } } + /* No space for compressed data. If we proceed, dfltcc_cmpr() will return + * DFLTCC_CC_OP1_TOO_SHORT without buffering header bits, but we will still + * set BCF=1, which is wrong. Avoid complications and return early. + */ + if (strm->avail_out == 0) { + *result = need_more; + return 1; + } + /* The caller gave us too much data. Pass only one block worth of * uncompressed data to DFLTCC and mask the rest, so that on the next * iteration we start a new block.