Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4490782imu; Tue, 8 Jan 2019 00:51:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN58meMGAi5vyhau1Z8HcRTH3auGXCQujTp2dnMoQQUW/4xiRvnsOfQY+DBNqVIudc977haM X-Received: by 2002:a63:dc0c:: with SMTP id s12mr760648pgg.398.1546937483090; Tue, 08 Jan 2019 00:51:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546937483; cv=none; d=google.com; s=arc-20160816; b=nJcFf5MWxZ2q0Aqnjqn0pgRuD5mGKTNieSWATtQ9+KLNfjgway3jxSQLOmw6dV5952 SHAAHOL900+IrZ/HuV2L5F3Ef5IzExIiveBtmhTvpJybt7+3NK5N/2r4Aspi/lUSFsPU sG1WuNXcIqCiEWXsV0wHMqXWld6Oz5tD9qE2c7F1Q++uPfykSci9oGJnPkwJxXNCGBZQ dklHA16a71QA3+CJhDqRCnDuB7awolOYXcQbmEQphPmf6l1t6Cn8nv+PF5u+Qh56C7qw ryCGTpTQ6Did3E1USvsoKmC36RtzV/+XNfupgQV+Ykpm9upCW+a765vZhOQxTiW1Q4gt IKAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from; bh=0DN6b/bYBSFy02V6CTHmcndXJNo7+cPGDHpJ3bREbYE=; b=UqC0Fuqg4XnZRDi6SMxBM1Zjn0ryNoPaVEbTXla6otoPh9fc0fwEe9q2QWG2WaIGLo RDJ3r4FNWVKmOFMyGZCBPl+n/iQfQBbyvHKNCibQlfkwGv1DkNay4VkUHbZ2FsxODWuz 2GE1SwZ9od2sevHCh8y38Gl/kbBaCiYdlS6RGz4gy4m4fsho9XlMm4zZFudwDRFOh0Zk fC+FqTsLyLThy4S9zEyk/qrRkG4K8afpFFwEGO2zrIUVJR28U18JQoZqWEBC4OtXglLt DzIyx61pFcijOGKFNY89vggwcqkBfVmIajy53RnXA+cCVlv24/d1KVJBJq6iJM/GV91M 5ZeQ== 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 13si48349966pld.398.2019.01.08.00.51.07; Tue, 08 Jan 2019 00:51:23 -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; 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 S1728065AbfAHItW convert rfc822-to-8bit (ORCPT + 99 others); Tue, 8 Jan 2019 03:49:22 -0500 Received: from ozlabs.org ([203.11.71.1]:56843 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbfAHItW (ORCPT ); Tue, 8 Jan 2019 03:49:22 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 43YmCK6zqpz9sMQ; Tue, 8 Jan 2019 19:49:17 +1100 (AEDT) From: Michael Ellerman To: Christophe Leroy , Horia Geanta , Herbert Xu , "David S. Miller" Cc: "linux-crypto\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" , "linuxppc-dev\@lists.ozlabs.org" , "stable\@vger.kernel.org" , "iommu\@lists.linux-foundation.org" Subject: Re: [PATCH v3] crypto: talitos - fix ablkcipher for CONFIG_VMAP_STACK In-Reply-To: References: Date: Tue, 08 Jan 2019 19:49:14 +1100 Message-ID: <87muobttyt.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy writes: > Le 04/01/2019 à 16:24, Horia Geanta a écrit : >> On 1/4/2019 5:17 PM, Horia Geanta wrote: >>> On 12/21/2018 10:07 AM, Christophe Leroy wrote: >>> [snip] >>>> IV cannot be on stack when CONFIG_VMAP_STACK is selected because the stack >>>> cannot be DMA mapped anymore. >>>> This looks better, thanks. >>> >>>> This patch copies the IV into the extended descriptor when iv is not >>>> a valid linear address. >>>> >>> Though I am not sure the checks in place are enough. >>> >>>> Fixes: 4de9d0b547b9 ("crypto: talitos - Add ablkcipher algorithms") >>>> Cc: stable@vger.kernel.org >>>> Signed-off-by: Christophe Leroy >>>> --- >>>> v3: Using struct edesc buffer. >>>> >>>> v2: Using per-request context. >>> [snip] >>>> + if (ivsize && !virt_addr_valid(iv)) >>>> + alloc_len += ivsize; >>> [snip] >>>> >>>> + if (ivsize && !virt_addr_valid(iv)) >>> A more precise condition would be (!is_vmalloc_addr || is_vmalloc_addr(iv)) >>> >> Sorry for the typo, I meant: >> (!virt_addr_valid(iv) || is_vmalloc_addr(iv)) > > As far as I know, virt_addr_valid() means the address is in the linear > memory space. So it cannot be a vmalloc_addr if it is a linear space > addr, can it ? That matches my understanding. This is one of those historical macros that has no documentation and its behaviour is only defined in terms of other things, so it's kind of hard to track down. In commit e41e53cd4fe3 ("powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash") https://git.kernel.org/torvalds/c/e41e53cd4fe3 I said: virt_addr_valid() is supposed to tell you if it's OK to call virt_to_page() on an address. What this means in practice is that it should only return true for addresses in the linear mapping which are backed by a valid PFN. Each arch can define virt_to_page(), so presumably you *could* set things up such that virt_to_page() worked on vmalloc addresses. Originally virt_to_page() would basically just mask and right shift the address and then use that as an array index to get the page. Things are more complicated now that we have SPARSEMEM etc. but it still only works for linear mapping addresses. Hopefully someone who knows mm stuff can chime in and tell us if we're missing anything :) cheers