Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1004421imu; Fri, 7 Dec 2018 12:27:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/X5hgOC/vfSL6s3hBH/4/3aLTG37JqPnqTRkoDNCaFSreFhhiyxyEdN2GwRlwMIysKc4ERQ X-Received: by 2002:a63:104d:: with SMTP id 13mr3181104pgq.303.1544214470912; Fri, 07 Dec 2018 12:27:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544214470; cv=none; d=google.com; s=arc-20160816; b=xP2HChmQpymQ8G/udfgGTRVApzxmsJGS4nwUXh/jXgbgleWmmWWD90OEKGtslxIbPj Ekji5eaeg5DJQxhJhm1v6hyBvgunNp5GmsvrG7S4K3GVHoZ4r82Eaps9QrxGBgXrOqGT 0RmucQ6gX8BPFH5RZFVE2SLGg8ThmmYafoCswgntVSHP4S7IYo+A7KFiDf/kEa7uls3w QV4xhxO0slSqmsJ/0eLZNRXe3T4vAo2wU4RqANltAKa4zOWKo4xhJ+ZVOlZpXbMaLPUn 9PdS4N6LhlRlZM6RLIaQB704jIzXQee0sKOjsAm5M1k6CQU2boc6x898zF86Balafgk7 W7/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KLYwNXnzoVvepzSuxQ5p4veFSZuSN5QPAisGoFQq+eo=; b=U58Z53eD2icCNM89HeB6SI2OQ09Kpm22XRJDvmAZpvAh83/H8k4XBcG+Zc1ty2FEtW sxjIU4/SuCoqn0zaWoeeug49JSa3XnBn+omXH9FsgnudAujHPVcFcjmnCm8He/AI6S1r qO0IRly2jYDfXMko8axTgVRypmjulfEZh4PcJMfr7+GMjsdqaNrrtr7UZrQGG9DnRbn/ ZbEoph9M37BKTkLjOGKksFeJCxDvR/XB9BwSdH5UxSIHqPRRluBWPrBngjnMV7e+13UK PwwHeMIVVo7I/SUww5X/VrkrI4WnHL/mYw4fBw7d1ikmTe5klOnBFsdABH+mVAB6QtD8 ok+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q+G7N6R9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d65si3951581pfc.201.2018.12.07.12.27.36; Fri, 07 Dec 2018 12:27:50 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=Q+G7N6R9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbeLGU02 (ORCPT + 99 others); Fri, 7 Dec 2018 15:26:28 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:39808 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbeLGU02 (ORCPT ); Fri, 7 Dec 2018 15:26:28 -0500 Received: by mail-it1-f193.google.com with SMTP id a6so9008782itl.4 for ; Fri, 07 Dec 2018 12:26:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KLYwNXnzoVvepzSuxQ5p4veFSZuSN5QPAisGoFQq+eo=; b=Q+G7N6R9cNmw2rFHSHCBK/LyjNfFNjK6oJlQ9JyHKZBsMx0HxymipERlO49GeMH+20 KhxyCMfcVstVMdHpB0rtXG0FadSe+4UM6hpo8dZy0naiJ49nd9djvcPExigmA9q6YjPE X9GOzFNFMdixUDbASur84eKVfqpCpgVQbFM6M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KLYwNXnzoVvepzSuxQ5p4veFSZuSN5QPAisGoFQq+eo=; b=VxiLC2pMthIDmporrV+yxODTgfW0W55YK2znHMdVtopOT9FkhICR8Fsukjh/Nnc5Hz xgnItmgElsM8J4L8xADWjdvoDZoOrjsl9/jGU8BiRV732Zb6doUh62a4aKCx0idiPBXk u+53fUwtAhnXAY+dY63+uvmnZ5ayes1kkeNySzjq2mLDl6TZCLDx9+uY0Ic9dfKeSTgk NS8D/9PttxKEQio/bnpS67v29WWV4JTo1QNOt4qmkaWkFM+rMWs546DVIuEMHlz9PI3q vXsoxqeyzo1D4rv5a09q3QlB8Nnliq+E/AsjReZZpqNQv7IF6VkiF25WRDwS79Iuswd3 uHLQ== X-Gm-Message-State: AA+aEWbPaLNHgTZ2Sdo2dteiXiACmJeQ2VT+HGpXYkzf1Kr/CMz2A0Oh xzh1UApTgfFo8efFoadwJ7f6sX+KCrKzvEfJZKDtmA== X-Received: by 2002:a05:660c:4b:: with SMTP id p11mr3437505itk.71.1544214387289; Fri, 07 Dec 2018 12:26:27 -0800 (PST) MIME-Version: 1.0 References: <20181207173309.82A0E6D165@po14163vm.idsi0.si.c-s.fr> In-Reply-To: <20181207173309.82A0E6D165@po14163vm.idsi0.si.c-s.fr> From: Ard Biesheuvel Date: Fri, 7 Dec 2018 21:26:15 +0100 Message-ID: Subject: Re: [PATCH] crypto/testmgr: fix skcipher test with CONFIG_VMAP_STACK To: christophe.leroy@c-s.fr Cc: Herbert Xu , "David S. Miller" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Kernel Mailing List , linuxppc-dev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 Dec 2018 at 18:33, Christophe Leroy wrote: > > [ 2.364486] WARNING: CPU: 0 PID: 60 at ./arch/powerpc/include/asm/io.h:837 dma_nommu_map_page+0x44/0xd4 > [ 2.373579] CPU: 0 PID: 60 Comm: cryptomgr_test Tainted: G W 4.20.0-rc5-00560-g6bfb52e23a00-dirty #531 > [ 2.384740] NIP: c000c540 LR: c000c584 CTR: 00000000 > [ 2.389743] REGS: c95abab0 TRAP: 0700 Tainted: G W (4.20.0-rc5-00560-g6bfb52e23a00-dirty) > [ 2.400042] MSR: 00029032 CR: 24042204 XER: 00000000 > [ 2.406669] > [ 2.406669] GPR00: c02f2244 c95abb60 c6262990 c95abd80 0000256a 00000001 00000001 00000001 > [ 2.406669] GPR08: 00000000 00002000 00000010 00000010 24042202 00000000 00000100 c95abd88 > [ 2.406669] GPR16: 00000000 c05569d4 00000001 00000010 c95abc88 c0615664 00000004 00000000 > [ 2.406669] GPR24: 00000010 c95abc88 c95abc88 00000000 c61ae210 c7ff6d40 c61ae210 00003d68 > [ 2.441559] NIP [c000c540] dma_nommu_map_page+0x44/0xd4 > [ 2.446720] LR [c000c584] dma_nommu_map_page+0x88/0xd4 > [ 2.451762] Call Trace: > [ 2.454195] [c95abb60] [82000808] 0x82000808 (unreliable) > [ 2.459572] [c95abb80] [c02f2244] talitos_edesc_alloc+0xbc/0x3c8 > [ 2.465493] [c95abbb0] [c02f2600] ablkcipher_edesc_alloc+0x4c/0x5c > [ 2.471606] [c95abbd0] [c02f4ed0] ablkcipher_encrypt+0x20/0x64 > [ 2.477389] [c95abbe0] [c02023b0] __test_skcipher+0x4bc/0xa08 > [ 2.483049] [c95abe00] [c0204b60] test_skcipher+0x2c/0xcc > [ 2.488385] [c95abe20] [c0204c48] alg_test_skcipher+0x48/0xbc > [ 2.494064] [c95abe40] [c0205cec] alg_test+0x164/0x2e8 > [ 2.499142] [c95abf00] [c0200dec] cryptomgr_test+0x48/0x50 > [ 2.504558] [c95abf10] [c0039ff4] kthread+0xe4/0x110 > [ 2.509471] [c95abf40] [c000e1d0] ret_from_kernel_thread+0x14/0x1c > [ 2.515532] Instruction dump: > [ 2.518468] 7c7e1b78 7c9d2378 7cbf2b78 41820054 3d20c076 8089c200 3d20c076 7c84e850 > [ 2.526127] 8129c204 7c842e70 7f844840 419c0008 <0fe00000> 2f9e0000 54847022 7c84fa14 > [ 2.533960] ---[ end trace bf78d94af73fe3b8 ]--- > [ 2.539123] talitos ff020000.crypto: master data transfer error > [ 2.544775] talitos ff020000.crypto: TEA error: ISR 0x20000000_00000040 > [ 2.551625] alg: skcipher: encryption failed on test 1 for ecb-aes-talitos: ret=22 > > IV cannot be on stack when CONFIG_VMAP_STACK is selected because the stack > cannot be DMA mapped anymore. > > This patch allocates it with kmalloc() > This looks like a driver bug to me. Other accelerators in drivers/crypto all take a copy of the IV before mapping it for DMA, so it would be better if talitos did the same. > Fixes: da7f033ddc9f ("crypto: cryptomgr - Add test infrastructure") > Signed-off-by: Christophe Leroy > --- > crypto/testmgr.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > index b1f79c6bf409..eea498f9030d 100644 > --- a/crypto/testmgr.c > +++ b/crypto/testmgr.c > @@ -1112,12 +1112,16 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, > struct crypto_wait wait; > const char *input, *result; > void *data; > - char iv[MAX_IVLEN]; > + char *iv; > char *xbuf[XBUFSIZE]; > char *xoutbuf[XBUFSIZE]; > int ret = -ENOMEM; > unsigned int ivsize = crypto_skcipher_ivsize(tfm); > > + iv = kmalloc(MAX_IVLEN, GFP_KERNEL | GFP_DMA); > + if (!iv) > + goto out_noiv; > + > if (testmgr_alloc_buf(xbuf)) > goto out_nobuf; > > @@ -1339,6 +1343,8 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, > out_nooutbuf: > testmgr_free_buf(xbuf); > out_nobuf: > + kfree(iv); > +out_noiv: > return ret; > } > > -- > 2.13.3 >