Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3479636pxu; Tue, 15 Dec 2020 08:00:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJy52ACmYV78c1+UaUCAFw3e43bs9eSyCdiIhkVJIKqRi4ZuDxtu02ofIy0Wnr7EfpTS2ew3 X-Received: by 2002:a17:906:6a45:: with SMTP id n5mr27907749ejs.514.1608048004920; Tue, 15 Dec 2020 08:00:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608048004; cv=none; d=google.com; s=arc-20160816; b=bx6IMiSnl/p0JAHqkClgpH4SW/VyvP17EUBVxjsabaZHtmzPYBA44EOylSWJNVy82L lMJrmfNDeYO+/aAMIvdMZLONMlF55oS8Jr5mRdikKzzCIw67jsQ+DWMRxQ6gAL6YK7+w F6cnaa0oGdpq19sffB5pbAIk7NyNaLovm22ybq0sFJ9aYyvIFcQrLGYYy5CcXT6PoZ52 msZznoC+JmVELM/jb0NiFzzAeSfca76E8TYxyx21kZvcRBQIQV85TL6rdQSjaZ4F5kHg NgSeqmn2d/sCiHnOBAyFQ+zA6jZHWvPsc5balXjqOu5jcBAXvtIb45zifyicT3uDRo4y 4HNQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pzIRFRpjyESY6LaUi9tJzCmYrWeI4uwEo5FPUXif2pU=; b=jG1OE0k/cmcBu+KQH6JvhQO9U5IsqZ2o+PRT93j42mpCgdKIq4BFqVcR+1PUyhD4rk HOnDQk2fmDWmbOxWsKP9AJ8xRiVSCuxTna9XMRgz60FQFQhUBIUwJNGCH1ldH1M6s2s+ E6LjRY6GaotO9I7+XBWIjNQ7EC3PSzbLdDV2Sf8CpLhdM4341s0bdlKWi2E7RcePHiZi QrP7KggwhtuRG5kcEv6fu1B7SDj0+FrQMY/IX7OxC4HXpvuZXFg9Z1YFYKoYr4dSoQzN /TWOUxMjiJfK6E7giAkq5Wk733N7DIriro+5NM5FX/22tUQ0LszjNVrcwQ2gN/L6rqA9 kc9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jd+CePVp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si1032730ejr.754.2020.12.15.07.59.41; Tue, 15 Dec 2020 08:00:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jd+CePVp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730683AbgLOP5y (ORCPT + 99 others); Tue, 15 Dec 2020 10:57:54 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58024 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730483AbgLOP5E (ORCPT ); Tue, 15 Dec 2020 10:57:04 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0BFFmkTC125611; Tue, 15 Dec 2020 10:56:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=pzIRFRpjyESY6LaUi9tJzCmYrWeI4uwEo5FPUXif2pU=; b=jd+CePVpv2uPJXznHXm9UHEcMws3U6C8OMlZlUAmnjObn8J4tLbNdZDuEaEi5zcfzgdy NH8s2f9auQE8SpkgY6ofPJQxPwZE5V2Yw6v4WCbBdO2dKtfESg2nCsKaWS32c9Uc3AEr +G18zFB52y9QeU/x5+3sz5/Jv+EzFt10pOCCSFxn15BIQNBxkNfUQKzeqSjY5OPYohtF exh7RPLFlc+ZzX7KNn67067Ija8AlsBcktcNX6nO7ABV6Epc25QHNY8WxLJyZD1vGPbP Ep6s8UlNequfOtKlQmzCW8YZL5HWb5qZVpnZ7xOOvvTiE3ksBEpGDoLjHDD9NJ4E85fl HA== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 35etrq93qj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Dec 2020 10:56:18 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0BFFVqcD014304; Tue, 15 Dec 2020 15:56:06 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 35cn4hbee7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Dec 2020 15:56:05 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0BFFu0Yh19595642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Dec 2020 15:56:01 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C11D952052; Tue, 15 Dec 2020 15:56:00 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.2.72]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5E43252065; Tue, 15 Dec 2020 15:56:00 +0000 (GMT) From: Ilya Leoshkevich To: Andrew Morton Cc: Heiko Carstens , Vasily Gorbik , Mikhail Zaslonko , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH] lib/zlib: fix inflating zlib streams on s390 Date: Tue, 15 Dec 2020 16:55:51 +0100 Message-Id: <20201215155551.894884-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-15_12:2020-12-15,2020-12-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=747 adultscore=0 bulkscore=0 clxscore=1015 suspectscore=0 mlxscore=0 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012150109 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Decompressing zlib streams on s390 fails with "incorrect data check" error. Userspace zlib checks inflate_state.flags in order to byteswap checksums only for zlib streams, and s390 hardware inflate code, which was ported from there, tries to match this behavior. At the same time, kernel zlib does not use inflate_state.flags, so it contains essentially random values. For many use cases either zlib stream is zeroed out or checksum is not used, so this problem is masked, but at least SquashFS is still affected. Fix by always passing a checksum to and from the hardware as is, which matches zlib_inflate()'s expectations. Fixes: 126196100063 ("lib/zlib: add s390 hardware support for kernel zlib_inflate") Signed-off-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_inflate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/zlib_dfltcc/dfltcc_inflate.c b/lib/zlib_dfltcc/dfltcc_inflate.c index db107016d29b..fb60b5a6a1cb 100644 --- a/lib/zlib_dfltcc/dfltcc_inflate.c +++ b/lib/zlib_dfltcc/dfltcc_inflate.c @@ -125,7 +125,7 @@ dfltcc_inflate_action dfltcc_inflate( param->ho = (state->write - state->whave) & ((1 << HB_BITS) - 1); if (param->hl) param->nt = 0; /* Honor history for the first block */ - param->cv = state->flags ? REVERSE(state->check) : state->check; + param->cv = state->check; /* Inflate */ do { @@ -138,7 +138,7 @@ dfltcc_inflate_action dfltcc_inflate( state->bits = param->sbb; state->whave = param->hl; state->write = (param->ho + param->hl) & ((1 << HB_BITS) - 1); - state->check = state->flags ? REVERSE(param->cv) : param->cv; + state->check = param->cv; if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) { /* Report an error if stream is corrupted */ state->mode = BAD; -- 2.25.4