Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4939437rwi; Mon, 17 Oct 2022 13:01:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GWl3pnIowzBP/EEek6xru4Y1JDsbh9XqkwJDUutvJ2G5dr/g674Zdu5uN4zNe/oJE10Rk X-Received: by 2002:a17:90b:224c:b0:20d:8828:3056 with SMTP id hk12-20020a17090b224c00b0020d88283056mr35078732pjb.136.1666036877208; Mon, 17 Oct 2022 13:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666036877; cv=none; d=google.com; s=arc-20160816; b=AGflz8vgd8+WQ0iKgN5H5iiQVzcPXwgxxvCuxhat1NKngKpYNOeiCNzlunl2V5pjwI n+Tmx6qgQfQfclHOidXvVX3wxSvB2M9gFXDAEt833wJ8G+PO2BQaGvQz6SAOzlgGC9AQ FGuV2tq2rft50IxQvxvgo7ja5pDnf4bFv0C4TO4ykMREFcw2vAyP7UszFqsw9vXCjcuK 52knaE/54UbX9V9Hp61bLCOZzoQonSsV8zXSGSPN9Gr6/ed5hEQbUaEfrOpS8dljZ47Z Xh9r/aVL8U1YRnZD40DhCCNhuw+DQoMiuZmAKcbjcZjApmhq/gBprbyNfVaKWp9kTPG3 ZuMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E40amjbnNYxi3bHXc6L0DGbJMK1J+X/tuw892jtBoNU=; b=JvYXSc+LKbbRZXJYB7TM/KnoFLD9qSucPplrPrgafQNENLFzHh+UCQWN3nyQPIU3IM BSQU1OZYQehP2bZxUIXYrEcCcDlUfqxPiispxWYkQIg45dxnL6TrtkmlwTimZdp9vEys UFqIlIGzOQQVGtu5duBxILu0dlJr2uueGr+sias/MKJlPDHt3Db0UZ4h7KfsN3BznNAm oaynH4L4TDb3IEC4AqXnPsDCXDa0tX+8NOH9FYIVtMMBozIXDAMXUycdU//H/dvLgo1S eDADOy7gELU9xrchl2abcz76XPeKnV4c+RT0GvmS3HhY7xfn14guJS/445e+D4q1pFLD Wtzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HioGEo0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x33-20020a056a0018a100b00536f8a6acadsi14441777pfh.2.2022.10.17.13.01.04; Mon, 17 Oct 2022 13:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HioGEo0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbiJQTkT (ORCPT + 99 others); Mon, 17 Oct 2022 15:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbiJQTkR (ORCPT ); Mon, 17 Oct 2022 15:40:17 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BA5691AB for ; Mon, 17 Oct 2022 12:40:15 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id 204so12012010pfx.10 for ; Mon, 17 Oct 2022 12:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=E40amjbnNYxi3bHXc6L0DGbJMK1J+X/tuw892jtBoNU=; b=HioGEo0tu/fTff5p7+5URNAqsTkxuMUcprVmRw/RLbDP+9Ri1kpdI3gsf1OIic19gm xGAVgJUoBW3KWNpp6oXrIR88dslb5v5TP/lP9ayZ1ZD9mOilpohAAD5qLMSqfpEu/gRr 2MNTC75SbLXwE0eIPwW2MqRqpQVROdq8dz3As= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=E40amjbnNYxi3bHXc6L0DGbJMK1J+X/tuw892jtBoNU=; b=GZTbLbS6V93TwoeHfeaHNInNolxGPH+/lkUDpdv51dFj2+1tg2NcmZEgzzqUvOIGw1 kzBjt8ATxus77VOMlhX8/ixxMKgdbFKy2AuL5lyzCp9W+yZxjply5E2S3ByMAhp6E40N ShZx0dvT+5CwTA+SDj6dYOrIUNV+5NJyzqxPTefAW1B4n1AiprOdLANke84Fa7FB0dwS x0h+4IEXOWwJVI18RFZrT9G24GNn65wHWcsWoiupeOZqxnzAldd1dTXIEIvdAXCFW6yJ SCDM/sulYWOXIDItraUrSegVrmlSPsWHy6Tf402SA9+OOgjj54Mui+XE8WJISEtfXHGc NvXg== X-Gm-Message-State: ACrzQf0g6UWZCx/REseCgXMDf9oQc+SYxLztoj2euRBRMiM4qsJyQF1P CrKczNlJXE/vun6VEHPThiW9ow== X-Received: by 2002:a63:91:0:b0:461:f509:2a31 with SMTP id 139-20020a630091000000b00461f5092a31mr11831239pga.108.1666035615423; Mon, 17 Oct 2022 12:40:15 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x14-20020aa7940e000000b0056389e00a83sm7479253pfo.63.2022.10.17.12.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 12:40:14 -0700 (PDT) Date: Mon, 17 Oct 2022 12:40:13 -0700 From: Kees Cook To: Ard Biesheuvel Cc: "Guilherme G. Piccoli" , Anton Vorontsov , Colin Cross , Tony Luck , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] pstore: migrate to crypto acomp interface (take 2) Message-ID: <202210171237.DF5D4A3FD7@keescook> References: <20221006234138.1835739-1-keescook@chromium.org> <191ec24d-35d4-e4e5-85f7-d7301984e647@igalia.com> <202210171100.5BAC4A5CC8@keescook> <202210171227.35ED875219@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 17, 2022 at 09:33:06PM +0200, Ard Biesheuvel wrote: > On Mon, 17 Oct 2022 at 21:29, Kees Cook wrote: > > > > On Mon, Oct 17, 2022 at 08:14:14PM +0200, Ard Biesheuvel wrote: > > > So once we use the same size for input and output, I was curious > > > whether we could encrypt in place, and get rid of the big_oops_buf. > > > And the answer is 'yes', precisely because we have this horrid per-CPU > > > allocation which serves as a bounce buffer. And this is not specific > > > to acomp, the old comp algorithms get wrapped in scomps which receive > > > the same treatment. > > > > Ah, in the sense that "in place" is actually happening in the per-cpu > > allocation, and only if it succeeds does the input buffer get > > overwritten? > > Something like that IIRC. > > > > So at that point, I wondered what the point is of all this complexity. > > > Do we really need 6 different algorithms to compress a couple of K of > > > ASCII text on a code path that is ice cold by definition? Wouldn't it > > > be better to drop the crypto API altogether here, and just use GZIP > > > via the library interface? > > > > Well, my goal was to make the algo "pstore doesn't care". If someone > > picks deflate, do they still get all the per-cpu allocations? > > > > Not if you use the library interface directly. > > The issue with the percpu buffers is that they are only kept if any > scomp TFMs are active, but this is always the case for pstore, as you > don't want to allocate it on the panic path. Okay, so strictly speaking, eliminating the per-CPU allocation is an improvement. Keeping scomp and doing in-place compression will let pstore use "any" compressions method. Is there a crypto API that does _not_ preallocate the per-CPU stuff? Because, as you say, it's a huge amount of memory on the bigger systems... -- Kees Cook