Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp809152imu; Mon, 5 Nov 2018 09:05:26 -0800 (PST) X-Google-Smtp-Source: AJdET5eVKvTSpL8btf6DtFd0ul51beGbFYMDXzwelAYUoymjJOCkGqs5Za3KtNE1Vm+FAf652xur X-Received: by 2002:a63:ca44:: with SMTP id o4mr20938196pgi.258.1541437526394; Mon, 05 Nov 2018 09:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541437526; cv=none; d=google.com; s=arc-20160816; b=alirmqV28pY6O2hTdETdDNylnI/Wbnba2nR371DDGce9qojY1p8Ra+RUG9AtFxy44k AU9YtivNDVL1zroRm29AlDF3yJVDhmQZAOcd5dxBbbPen5jJy1AlMj46Qa2p6X6K2dbl +M67/98hvF2c1zMpHfzLNZIqnn4qwfbIX0poiRUv2loShjZhUmAiZyBqBq1yaKyoyuiC MEX0p6s9LJHPWKI/FF/GkeAbYG3Ezk51oMNSjWSve0kjyOcHlhpyfuWf6K5DI5+y9B/8 /raPM/pxEbGf3zW911johFJWFhSlV9sXM3TS8M7gtbK6505qEZ6e3h3qrkpQcpTMMcsB zEmw== 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 :references:in-reply-to:mime-version:dkim-signature; bh=hRoZ+kzOnBGfRkKjLexuTFXVrg3YwVJKB0u8D7I0/4U=; b=PrDDwx4OHSe/qjTC4zLPL3f3NrlKkInY01KkRVID2g0BMr9I2xRGwdQpkAAQ9SGXtU Zod8/zHARwKvhgwOHrd9k9kY61umMEjNwng7NZte05TZGZR6EkVdFcqXiRkrusUr3vdr T7C/B9aeGqY/TrMdEQhuJKpl10fnoXSCgexjIx8FP6ZdZVoecak9CxDCg11/CHzXX/Lw 1rztD3A1dukzB6AogpjTJN1JNCzArj2bmF8kWNZWi7Jh4bP/GWIxmFto1QPvVVNWLTM8 7N4eRXSkxJfAGDj7PE58EsxnEPXfWkiJGObH0e2YK0Me4VKf/zxm5kgyv7Q3F78wtDYm G7Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GYMSZYLW; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi11-v6si28760484plb.20.2018.11.05.09.05.00; Mon, 05 Nov 2018 09:05:26 -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=@chromium.org header.s=google header.b=GYMSZYLW; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729867AbeKFCY4 (ORCPT + 99 others); Mon, 5 Nov 2018 21:24:56 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:44893 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729692AbeKFCY4 (ORCPT ); Mon, 5 Nov 2018 21:24:56 -0500 Received: by mail-yw1-f67.google.com with SMTP id k6-v6so3928538ywa.11 for ; Mon, 05 Nov 2018 09:04:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hRoZ+kzOnBGfRkKjLexuTFXVrg3YwVJKB0u8D7I0/4U=; b=GYMSZYLWEq38jFxMlSgfIX0UOurbTp8XArE8Fs/zbl2S0mc0YIF1b94m2GlUFQmQsR VWbgm7IXb1HKRz9h9kkMJGFqPqLBotqJ3kuAfDgB2rYyBko0022l5svC3Vl6QlgapsNl RlduPXAI4lCRSvLgeVIKiNs3jtP+nmt3xvqZo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hRoZ+kzOnBGfRkKjLexuTFXVrg3YwVJKB0u8D7I0/4U=; b=F42uPNM9aaKVFQGYY0wRKyvcQr0hZ/mx5NMVBI+mKOeehKCz7sclxyGcRpSoJ29qxK iMjiUB2BvM+g1EKILqoNZmddqTaBzn90RL/VEfemSCFFlAxZPWk5limYHIWfN4FUGCmm 6xxVijtxkxJAWqGrEjQwAbUSfMDOnzuMLgcYr1TpZhvmgINiH6r7yEIqdHGJLQkAh23L n8B9251h9I/I5deeV/7+J/K9sVUqbPVdo+MAFyd0g2zYb8z8ha5jgZ8CcyO6f3RS3y4a O+TmI+3jZVg6DDbIL3C3pku4pRM3tiCT0rNx/JW5qkTve3aPJwwihRB5uo4nXcTCpdyZ StRA== X-Gm-Message-State: AGRZ1gLIEopYJ3tYA7sMsrT9Ls9XsxHvSRTalIiztEYzfTZ9hn7QdGm3 1VkT4KoxF7cnhOjEWunfNLhJ84icriI= X-Received: by 2002:a81:8103:: with SMTP id r3-v6mr2500656ywf.403.1541437457630; Mon, 05 Nov 2018 09:04:17 -0800 (PST) Received: from mail-yw1-f46.google.com (mail-yw1-f46.google.com. [209.85.161.46]) by smtp.gmail.com with ESMTPSA id e20-v6sm5342544ywe.32.2018.11.05.09.04.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 09:04:15 -0800 (PST) Received: by mail-yw1-f46.google.com with SMTP id l2-v6so3937475ywb.9 for ; Mon, 05 Nov 2018 09:04:15 -0800 (PST) X-Received: by 2002:a0d:fec6:: with SMTP id o189-v6mr22383870ywf.237.1541437455114; Mon, 05 Nov 2018 09:04:15 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:b906:0:0:0:0:0 with HTTP; Mon, 5 Nov 2018 09:04:13 -0800 (PST) In-Reply-To: <20181105044217.GB56850@google.com> References: <20181101235200.28584-1-keescook@chromium.org> <20181101235200.28584-9-keescook@chromium.org> <20181102180111.GA14942@google.com> <20181105044217.GB56850@google.com> From: Kees Cook Date: Mon, 5 Nov 2018 09:04:13 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 8/8] pstore/ram: Correctly calculate usable PRZ bytes To: Joel Fernandes Cc: LKML , Anton Vorontsov , Colin Cross , Tony Luck 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 Sun, Nov 4, 2018 at 8:42 PM, Joel Fernandes wrote: > Dumping the magic bytes of the non decompressable .enc.z files, I get this > which shows a valid zlib compressed header: > > Something like: > 48 89 85 54 4d 6f 1a 31 > > The 0b1000 in the first byte means it is "deflate". The file tool indeed > successfully shows "zlib compressed data" and I did the math for the header > and it is indeed valid. So I don't think the data is insane. The buffer has > enough room because even the very small dumps are not decompressable. Interesting. So the kernel wouldn't decompress it even though it's the right algo and untruncated? That seems worth fixing. > At this point we can park this issue I guess, but a scenario that is still > broken is: > Say someone crashes the system on compress algo X and then recompiles with > compress algo Y, then the decompress would fail no? > > One way to fix that is to store the comrpession method in buffer as well, > then initialize all algorithms at boot and choose the right one in the > buffer ideally. Otherwise atleast we should print a message saying "buffer is > encoded with algo X but compression selected is Y" or something. But I agree > its a very low priority "doctor it hurts if I do this" kind of issue :) Right, this is fine: if algos change across a kernel version, I'm fine with it failing. pstore isn't expected to work sanely outside of a pretty narrow set of use-cases. -Kees -- Kees Cook