Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp486193imm; Wed, 26 Sep 2018 01:57:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fdtVNQE+0rElEC4wj4fUNzvMFJSP/tb0o80ARNHN5Om/tKFQa+Js/O5D8kVnyN2SKP50F X-Received: by 2002:a63:9a42:: with SMTP id e2-v6mr4803324pgo.263.1537952250835; Wed, 26 Sep 2018 01:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537952250; cv=none; d=google.com; s=arc-20160816; b=VP3cHb89TEhex3cue1u3xYX1+R2v+gT63iZ0E1wSuTsrCIk/dzujreYWE0n3I9aedN LnbXjGjLf07l3q1I6a6TDYK5BDWZCvUTP3b6JenGLTPBvt6DyWBXaDUAxAe0gmiXM7bV iuXhS7PWSWOE6M6fXnFQaYVJzpFvnJouOlSDE586kVdM5jBmUsxIogBkDHahpVNgfS2F xG0eKc+b5jqZAzmH1bhEyQeNT9LkSD9VbFDW6HVdAWgafEBr/3JFRFZxbCHKjX4gtQiI ZJ4kFg6dVgYKgHyyeIs6YbmOf8GOrWk3J8eHNpmQI+0TzZcgRwrRtM1o3pHcxIJM5faW zFOg== 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=jOhRVP6KsxqBS3K3JpP/wBi2fHYX86Elzq9kElS9vUY=; b=XElqzQtmkrKcfooYp0I3lKDuHcjOAp6mXePQOddTOQthwrKRZFn7Br3CSDXWhG7bTf za5cBLiIUjActPKVnAM6VRq7eXuiT0QeUiBEEYFMitszCCaUPod+lvL2LKcWPG2zKsJJ JToJ4KhzqKUm1VWZHCBUqMRZn21Rd0yl/1rmw1gv2bsBTtKZd7G19+CSGpIB8J33kXb1 fla3OXQFFM6MvgHsNHNzHjbnmvJVJwr3x0ozML4XR4LH1/Uzp+aEyKS/Czm74Fa5crxk +NSUBgfmBDEp7YSk7YxLWUcDPSe8zjQVwvIDKataL9Ck+jvP5cBincUmbM/OBpUVl4e9 5BYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JNgteHuU; 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 a123-v6si4765957pgc.49.2018.09.26.01.57.15; Wed, 26 Sep 2018 01:57:30 -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; dkim=pass header.i=@linaro.org header.s=google header.b=JNgteHuU; 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 S1727568AbeIZPHS (ORCPT + 99 others); Wed, 26 Sep 2018 11:07:18 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:54552 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbeIZPHS (ORCPT ); Wed, 26 Sep 2018 11:07:18 -0400 Received: by mail-it1-f193.google.com with SMTP id f14-v6so1901550ita.4 for ; Wed, 26 Sep 2018 01:55:24 -0700 (PDT) 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=jOhRVP6KsxqBS3K3JpP/wBi2fHYX86Elzq9kElS9vUY=; b=JNgteHuU/dwmfX2TjLZyhg9CSoixS3RXyUAucDRV96CFEOezU6jWmrGWwLsLRf+EeE F13Ge4vlxaLTkGdgeW6vq8B3a8RwFt78a5GauEZcugtZPt//2dDqhDVzVX2DWjTJmLE1 HdP6KMCNM/tFibx6BcW3zxo9tKpeCDViUiLQY= 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=jOhRVP6KsxqBS3K3JpP/wBi2fHYX86Elzq9kElS9vUY=; b=EgPdzGUbUB0AynB49urenI6A3m7+zvzAviXAXG+1Jos38Qq2Yo1W1+CKcIVCMdh2Xn S216i3V4LsF9wn/stFwx4hkS/thtqZU3nSx/B6xi7F/7VmeQzc1Qu5gS4b4Pla5s2lQp mIM2ym/OA5u0SH4QnFvaxroa8tMomN9HqqRgl/0BoeJXzP/0hFmS4+pylVZlJLTTIQe8 iOXcO36C4DcyzE+UWTkju4Pg+ginCPB9XzzQACfO/lJrhqBF7rwcbCXcWaMGntbw7T1y giPuVpYStAPrKMp+5N3qmE/wYrajLvyfy0WR9V0Y/bfLV9FL+Zxay6c1p1qjeWG9SrKW OWnA== X-Gm-Message-State: ABuFfogJGPaQ27H54zjoqCvlqZ9ce5yLeKUzeUs+v3L6og3xtHGuSFGY c07PVopMiRHQmEXecsUVFk3+fzEG8VigsKrNVszT2w== X-Received: by 2002:a24:8309:: with SMTP id d9-v6mr4114345ite.123.1537952123775; Wed, 26 Sep 2018 01:55:23 -0700 (PDT) MIME-Version: 1.0 References: <20180807211843.47586-1-keescook@chromium.org> <20180807211843.47586-8-keescook@chromium.org> In-Reply-To: From: Ard Biesheuvel Date: Wed, 26 Sep 2018 10:55:10 +0200 Message-ID: Subject: Re: [PATCH v8 7/9] crypto: qat: Remove VLA usage To: Arnd Bergmann Cc: Kees Cook , Herbert Xu , Eric Biggers , Giovanni Cabiddu , "Alasdair G. Kergon" , Mike Snitzer , Tudor-Dan Ambarus , Andrew Morton , Thomas Gleixner , Geert Uytterhoeven , Will Deacon , Rasmus Villemoes , David Woodhouse , Matthew Wilcox , "David S. Miller" , "Gustavo A. R. Silva" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , device-mapper development , qat-linux@intel.com, Linux Kernel Mailing List 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 Wed, 26 Sep 2018 at 10:54, Arnd Bergmann wrote: > > On Wed, Sep 26, 2018 at 10:44 AM Ard Biesheuvel > wrote: > > > > On Tue, 25 Sep 2018 at 18:12, Arnd Bergmann wrote: > > > > > > On Tue, Aug 7, 2018 at 11:18 PM Kees Cook wrote: > > > > > > > > In the quest to remove all stack VLA usage from the kernel[1], this uses > > > > the new upper bound for the stack buffer. Also adds a sanity check. > > > > > > > > [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com > > > > > > > > Signed-off-by: Kees Cook > > > > > > After rebasing to linux-next, I now get a warning about this file: > > > > > > drivers/crypto/qat/qat_common/qat_algs.c: In function 'qat_alg_do_precomputes': > > > drivers/crypto/qat/qat_common/qat_algs.c:257:1: error: the frame size > > > of 1112 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > > > > > > I assume it was already possible to get into that state with the VLA, > > > but it seems bad enough that I think we need to do something > > > about it. > > > > > > The large stack variables add up to 1084 bytes, which fully explains > > > how we got here: > > > > > > SHASH_DESC_ON_STACK(shash, ctx->hash_tfm); /* 360 */ > > > struct sha1_state sha1; /* 92 */ > > > struct sha256_state sha256; /* 104 */ > > > struct sha512_state sha512; /* 208 */ > > > char ipad[MAX_ALGAPI_BLOCKSIZE]; /* 160 */ > > > char opad[MAX_ALGAPI_BLOCKSIZE]; /* 160 */ > > > > > > The question is what we can do about it. One simple step I've tried > > > is to move the sha1/sha256/sha512 into a union, which saves around > > > 200 bytes and should bring us (slightly) below the warning > > > limit, but I suspect we can do better than that. Any ideas? > > > > > > > All the processing takes place in the context of a setkey() operation, > > which means only one such operation should be in flight per tfm at any > > given time. So we could move all these pieces into the tfm context > > struct instead. Something like the below [untested] (whitespace > > mangling courtesy of Gmail) > > Ah, right, this is what I was hoping for. I assume we already guarantee > that this context is never put on the stack somewhere else, right? > Yes.