Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1548167lkv; Wed, 19 May 2021 12:30:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4TrA8kIFGRz2a4E6QGv0kS9vMPFwWiFnp4d3WKGhlMI9g7cYFJcwVrQ7O1CDOw9hUoUZO X-Received: by 2002:aa7:cf03:: with SMTP id a3mr668003edy.314.1621452610970; Wed, 19 May 2021 12:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621452610; cv=none; d=google.com; s=arc-20160816; b=GnTEVJljMYINQjnEpOuN2LwGyGVHUz8itUh6jFdXD3EPcO2UTSdy/2iklE2TsMcWS7 qmJdAbdkVy2VRQ647xJx7N71r607Hh52E64WI4DAtd7tC7xcunI9T9TgzGyVRokxLP1u zzqpCCF8I64zAGFqbajsLyiUSZN9FlQLtmjo4leZNQOL/h21zPxFe3trQN3KjaM26yIw wXLbMeP56FiHlXxohHK6b33aYoB3G6BZWnxQvWDeO6+k1k9y8gQzmhNEtO1IyWtB03ST 1ToRTl7HNVQyeIiDpj8nlpwgpJ5p97nQKrkwevUPobZmFWWDmK3tQ0EceMQF2VDyg6xb QAPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fxHSTiwDQmijU6VLnEodzP7WmpdFywPbBIz/yDucU0A=; b=saRBFmG9ZFfXbO+uChopKhTqyD32HDzEBFtQBOW/y9+4nJ5V77kYER4vRc+AwkN78V e7/zxH+YoL6U96iQ+o6jOAXnr6Vak+W5RU6/jEYrhquLjJ/R9oLTPIwbyQusdNNtQsEf TCrzhPqkyecVddvr3jqvCmMpKJjalYWMf4qRxAvjX8cPMH3jAVIktrJ3svx5HszTFPP9 SnZFsXaJKxwMeo0FLgcraJ2sWFAnSsHzy4IJ/NTBinhRIyHmJ5lQPtDX9eRJFVIq7EDX 8DuJAAEBrZUF8dlXg4t+dyquDM3b2GerX9xa32q4ZKJms+oiCMW9lziO21tavY5Qux3K DlyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KEygD9R9; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id eb8si129101edb.103.2021.05.19.12.29.45; Wed, 19 May 2021 12:30:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@kernel.org header.s=k20201202 header.b=KEygD9R9; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S240529AbhESLiK (ORCPT + 99 others); Wed, 19 May 2021 07:38:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:56192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbhESLiI (ORCPT ); Wed, 19 May 2021 07:38:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 57E4F6135B for ; Wed, 19 May 2021 11:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621424209; bh=xpCSnOj5OqOTmpmQNj3CEeVzOjrSk2CT158iiJBHiR0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KEygD9R9ovcTam+Y63Rmw4J37/nbYMaZsLqafTkftg3S1nKsSBtN7drQc3GDAwnyr w9tC0leLTL1QS9F+tLN1Vhl33v/cN1nBS8vLM54oTf5eNwt/mQATXSXfKh/fjSzHHV BWkWsdU/tEQRVMaGI9HGmXK9xDHSq4DI95Gj6tSwatWjuiC04vEXqCzXPMbGssz6Vh IiUVRz9Um4VT+9+AD1x0c+pf6dXbVsGj9x2+5o0B95hyox9XuzXDj0mIwveQlT223O I2mkZLj56za7F5ywxRmdlmO41Faz5j62qX4sbTaTWyAmpoLdDRZ2xorBSBlLSfVp0k zP5J6/OXuE+2Q== Received: by mail-oi1-f170.google.com with SMTP id h9so12847154oih.4 for ; Wed, 19 May 2021 04:36:49 -0700 (PDT) X-Gm-Message-State: AOAM5307YiIgCNGXISG/MGFHX56XWl02FSY7DqWt1cHre/gGErYg4B+x GpPV1+kFK/liDzKy3hElvnJVSsXCi8eKojSmaI8= X-Received: by 2002:a05:6808:a96:: with SMTP id q22mr7394508oij.47.1621424208675; Wed, 19 May 2021 04:36:48 -0700 (PDT) MIME-Version: 1.0 References: <20210519112239.33664-1-ardb@kernel.org> <20210519112239.33664-3-ardb@kernel.org> <20210519112930.sgy3trqczyfok7mn@gondor.apana.org.au> In-Reply-To: <20210519112930.sgy3trqczyfok7mn@gondor.apana.org.au> From: Ard Biesheuvel Date: Wed, 19 May 2021 13:36:37 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 2/7] crypto: aead - disallow en/decrypt for non-task or non-softirq context To: Herbert Xu Cc: Linux Crypto Mailing List , Linux ARM , Eric Biggers , Will Deacon , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 19 May 2021 at 13:29, Herbert Xu wrote: > > On Wed, May 19, 2021 at 01:22:34PM +0200, Ard Biesheuvel wrote: > > > > crypto_stats_get(alg); > > - if (crypto_aead_get_flags(aead) & CRYPTO_TFM_NEED_KEY) > > + if (!(alg->cra_flags & CRYPTO_ALG_ASYNC) && > > + WARN_ONCE(!in_task() && !in_serving_softirq(), > > + "synchronous call from invalid context\n")) > > + ret = -EBUSY; > > I don't think we've ever supported crypto in hard IRQ contexts. > So this should be done regardless of ASYNC. > OK. > Then again, do we really need this since the assumption has > always been that the crypto API can only be invoked in user or > softirq context? > With this series applied, some of the arm64 accelerated s/w implementations will no longer work correctly when this rule is violated, and so it would be nice to have a sanity check somewhere. And policing rules like these is best done in generic code, right? So if we do need to check this, we should check it here. If we don't, then we can drop these patches.