From patchwork Thu Nov 22 19:52:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 151820 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1150699ljp; Thu, 22 Nov 2018 11:53:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/X2Uyi1uf7HFcvdAYTTfCo8B9at8VBSd8nl40aq9z0zqFi0qVWypVOadWUXPtAfPHz4dgXd X-Received: by 2002:a17:902:166:: with SMTP id 93-v6mr12270129plb.68.1542916405371; Thu, 22 Nov 2018 11:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542916405; cv=none; d=google.com; s=arc-20160816; b=HmMFgd1V2rHtvOk3NrdB9Q+0XNoGl3usL7EZddyOG/ntkpZuvFEZY5BVVS3PgS60m0 319PVQtq3UyIbC9eoWZShCIO6dCGAGC0s4EA+zRnrhKLeAs8NL4Bhbc2375JQzdfzylw Jd8d95NteXdwtjVmHOxVvA+WERPu2UsIhVPHyLXLMGyUCHbavOw5XtvMAnA/C9ty17Ob i5QycKQ9EEa6QaHJagyOwCZocNU/l5byrhaM7bwZcEyfkhGIUZB5sjsLe5nKltltmD3/ DCWlCLl5X+HZBpRSd/2sS4mN7qyFE4X5kN/d18EYQ/xGa9xo7a9T5oWBD6GmKu+/G17E ENSQ== 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:dkim-signature; bh=MVQTrs9iHQ+CY+gQFyKjiupXHSVsy+25paMprXgfnsk=; b=G2D8CEsEFwdksWBOwjXmd7tYjTaQ1pm27QnCzs2MDGEGHpJr5dWpaN5bmDGZwU6L7G w3CxWIqPeWjqGX/g7w5pgRwhmE9DgEMv/Zs5EiIExQhUF0iuoGrlFFybDuyZWVbkncoz vPUwSwHDYCnDuVne0WU4vU5bqJI5dLi7BaHtE/5eNZe8A6CSjFz9LbuJphiSSq/HjZYg ZO4bT4yupxJN/ylK1CGh6PJiV0btdwRGK4IUh/xrWRN8CDm7GTkvbIUQXPOkYfqTrsYm oDTmuw1M4BENfVk4wNBicqE2K2GUx39kPJ4d6P0JI5q3uc9F0Wti7yVPWFC3oK57FC12 XROw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hi3lEarl; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j14si40687001pgg.44.2018.11.22.11.53.25; Thu, 22 Nov 2018 11:53:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hi3lEarl; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438450AbeKWGeO (ORCPT + 2 others); Fri, 23 Nov 2018 01:34:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:33262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438433AbeKWGeN (ORCPT ); Fri, 23 Nov 2018 01:34:13 -0500 Received: from sasha-vm.mshome.net (unknown [37.142.5.207]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 20C5020672; Thu, 22 Nov 2018 19:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542916401; bh=6RUJEfJlBGdqlMbSFuHQ+T+0gUZPjlsiUj9zYICB1i8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hi3lEarlMmEKFITzF6SFk5JqNjUeL4ouz7c/9Jv5KmFlMzFhZS+9ItzGASzysy/bl 2ieQTWcV78F51HwPH4G9uyvaBw0EKKEDvrTv1MheG8q2C8Cb7AIcd3qZ6zBfWkDsm3 VUatLveEzm1m3a77OSEMA6RDBc3VnuI5+FHeo7wc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , Sasha Levin , linux-crypto@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 14/36] crypto: simd - correctly take reqsize of wrapped skcipher into account Date: Thu, 22 Nov 2018 14:52:18 -0500 Message-Id: <20181122195240.13123-14-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122195240.13123-1-sashal@kernel.org> References: <20181122195240.13123-1-sashal@kernel.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Ard Biesheuvel [ Upstream commit 508a1c4df085a547187eed346f1bfe5e381797f1 ] The simd wrapper's skcipher request context structure consists of a single subrequest whose size is taken from the subordinate skcipher. However, in simd_skcipher_init(), the reqsize that is retrieved is not from the subordinate skcipher but from the cryptd request structure, whose size is completely unrelated to the actual wrapped skcipher. Reported-by: Qian Cai Signed-off-by: Ard Biesheuvel Tested-by: Qian Cai Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/simd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/crypto/simd.c b/crypto/simd.c index ea7240be3001..78e8d037ae2b 100644 --- a/crypto/simd.c +++ b/crypto/simd.c @@ -124,8 +124,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm) ctx->cryptd_tfm = cryptd_tfm; - reqsize = sizeof(struct skcipher_request); - reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base); + reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)); + reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base)); + reqsize += sizeof(struct skcipher_request); crypto_skcipher_set_reqsize(tfm, reqsize);