Received: by 10.213.65.68 with SMTP id h4csp2778367imn; Mon, 9 Apr 2018 08:53:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/u8ydasWDVuVD1T9dsLiY+PvAmKPOv+9CCeb2axBFd3QJSmEFh09f2Qffgz5vEmK/kq1Gi X-Received: by 2002:a17:902:9046:: with SMTP id w6-v6mr10209915plz.393.1523289238411; Mon, 09 Apr 2018 08:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523289238; cv=none; d=google.com; s=arc-20160816; b=QTfXCeNurEtjnXapjEBWqMRYOiOA7g+kcNi34BeVj2J3xfECQy5dw6jwvj5ooKnHct 4wLINVZ9wUUfj0kHq7JYxdWS9mkqRnUAleibFExiGsxHXoiBkTHck+WYlFGoKMHVJcJ4 jtJ70Ry3mgzCQwYxZFFFDO0l9www+kUcO8RgYr78Z6q1orxCXbRGtM5oYtWdY7cKGTQr +bULg7n/O/5nYb2VF201Rp731IKdgH9bvxZhmuCoB2oAdI5+k7tjPHYIZ7d5DlW7QZwF F8fF04RaTMynPvKV0GuPnK9TcEI9uUNe9YIxz8rO6qbsykTLmTnVYSJBypNYukYyshwb kzQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=0v1lQVJNGcHOMyE4flzH5k1U1H1u0EgITMeDANJZIKs=; b=FyRdNLLMLt4WEV26Ir1MD1uTPNZbcjZK9W/H6hh6hrqYxJ2Tyl/nCE4UB+Zi1Vb432 X9F6W4PT+F3fYPFFWSWRJbmbJ+IeCbNiXzAqYzM7jfPE526YyI2n/POEcVYQKas9kUsf 0Rg3rNNnPsM+pvSs1eLrLUF8A150KDcT5kbVEIzhccfdsrSNfqj6tsBtcOCA+OH4YgD/ O287eV9veRgpxQlNg+bDgQ5q0JF5WbTI+uIrKJvcTOhGw2PUDC4Dgxm/pH9j7Zg5lwg3 wimJa3PI2rVd119fetbEJ1uC1c7LFqUzD3WMq7GI35k/Z3UH2G51NK4/taSnAjny5uxJ DtfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si392546pgf.715.2018.04.09.08.53.20; Mon, 09 Apr 2018 08:53:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753392AbeDIPsD (ORCPT + 99 others); Mon, 9 Apr 2018 11:48:03 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39070 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753196AbeDIPqh (ORCPT ); Mon, 9 Apr 2018 11:46:37 -0400 Received: by mail-wm0-f67.google.com with SMTP id f125so17656529wme.4; Mon, 09 Apr 2018 08:46:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0v1lQVJNGcHOMyE4flzH5k1U1H1u0EgITMeDANJZIKs=; b=HeJNmZV8S3xpP3TBXuVfpnt24ad7wzieLg9yOVsWdvByIki6e4/qTBXLTD4TbUHg9U L2W8f/sSs+fPjbmQyrft72FjdaEb+g20H2ENTygPEa+rbeYt194U2FsMV1KE0TW3et6e 92OPagF6AixeCMG9tG1Qq4c2TTEy9AFx2qow8V6k82n/10w3eWR9osTUb/82E9Yqea8j jAikb1lUfkiElkvInaaPti09NYLoj5ycAXWh3uBn9D+/w2y4tROObGNBiQKpl8c5DxBi I+t3kT8pFE1JXDCKOEl+qi9IPhs/4Ew7ZG2lSvbp6Gf912aSBdkHRtmJANjIBRrls6pC 41Xg== X-Gm-Message-State: ALQs6tAVb2zhhurKpLydbEQvWiP7ElEZYDkiCBC9vZfwBPkmPPit1Shh 9zPRIstqrQrDfjxpopkV+M/FaSvm X-Received: by 10.28.129.80 with SMTP id c77mr331702wmd.154.1523288795456; Mon, 09 Apr 2018 08:46:35 -0700 (PDT) Received: from wintermute.fritz.box (HSI-KBW-078-043-196-194.hsi4.kabel-badenwuerttemberg.de. [78.43.196.194]) by smtp.gmail.com with ESMTPSA id w40sm881163wrc.33.2018.04.09.08.46.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Apr 2018 08:46:34 -0700 (PDT) From: Jan Glauber To: Herbert Xu Cc: "David S . Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Mahipal Challa , Robert Richter , Jan Glauber , stable Subject: [PATCH v2 1/5] crypto: thunderx_zip: Fix fallout from CONFIG_VMAP_STACK Date: Mon, 9 Apr 2018 17:45:50 +0200 Message-Id: <20180409154554.7578-2-jglauber@cavium.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180409154554.7578-1-jglauber@cavium.com> References: <20180409154554.7578-1-jglauber@cavium.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enabling virtual mapped kernel stacks breaks the thunderx_zip driver. On compression or decompression the executing CPU hangs in an endless loop. The reason for this is the usage of __pa by the driver which does no longer work for an address that is not part of the 1:1 mapping. The zip driver allocates a result struct on the stack and needs to tell the hardware the physical address within this struct that is used to signal the completion of the request. As the hardware gets the wrong address after the broken __pa conversion it writes to an arbitrary address. The zip driver then waits forever for the completion byte to contain a non-zero value. Allocating the result struct from 1:1 mapped memory resolves this bug. Signed-off-by: Jan Glauber Reviewed-by: Robert Richter Cc: stable # 4.14 --- drivers/crypto/cavium/zip/zip_crypto.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/cavium/zip/zip_crypto.c b/drivers/crypto/cavium/zip/zip_crypto.c index 8df4d26cf9d4..b92b6e7e100f 100644 --- a/drivers/crypto/cavium/zip/zip_crypto.c +++ b/drivers/crypto/cavium/zip/zip_crypto.c @@ -124,7 +124,7 @@ int zip_compress(const u8 *src, unsigned int slen, struct zip_kernel_ctx *zip_ctx) { struct zip_operation *zip_ops = NULL; - struct zip_state zip_state; + struct zip_state *zip_state; struct zip_device *zip = NULL; int ret; @@ -135,20 +135,23 @@ int zip_compress(const u8 *src, unsigned int slen, if (!zip) return -ENODEV; - memset(&zip_state, 0, sizeof(struct zip_state)); + zip_state = kzalloc(sizeof(*zip_state), GFP_ATOMIC); + if (!zip_state) + return -ENOMEM; + zip_ops = &zip_ctx->zip_comp; zip_ops->input_len = slen; zip_ops->output_len = *dlen; memcpy(zip_ops->input, src, slen); - ret = zip_deflate(zip_ops, &zip_state, zip); + ret = zip_deflate(zip_ops, zip_state, zip); if (!ret) { *dlen = zip_ops->output_len; memcpy(dst, zip_ops->output, *dlen); } - + kfree(zip_state); return ret; } @@ -157,7 +160,7 @@ int zip_decompress(const u8 *src, unsigned int slen, struct zip_kernel_ctx *zip_ctx) { struct zip_operation *zip_ops = NULL; - struct zip_state zip_state; + struct zip_state *zip_state; struct zip_device *zip = NULL; int ret; @@ -168,7 +171,10 @@ int zip_decompress(const u8 *src, unsigned int slen, if (!zip) return -ENODEV; - memset(&zip_state, 0, sizeof(struct zip_state)); + zip_state = kzalloc(sizeof(*zip_state), GFP_ATOMIC); + if (!zip_state) + return -ENOMEM; + zip_ops = &zip_ctx->zip_decomp; memcpy(zip_ops->input, src, slen); @@ -179,13 +185,13 @@ int zip_decompress(const u8 *src, unsigned int slen, zip_ops->input_len = slen; zip_ops->output_len = *dlen; - ret = zip_inflate(zip_ops, &zip_state, zip); + ret = zip_inflate(zip_ops, zip_state, zip); if (!ret) { *dlen = zip_ops->output_len; memcpy(dst, zip_ops->output, *dlen); } - + kfree(zip_state); return ret; } -- 2.16.2