Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2656897rwb; Sat, 8 Oct 2022 11:43:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DNF/HETx1RkNVGUFfY+lO9Oh3OJGQA6qe7tte97K7B+FKhEqonWtHfrM4HCL1LIYC0fDp X-Received: by 2002:a05:6402:2547:b0:459:1752:2a97 with SMTP id l7-20020a056402254700b0045917522a97mr10039623edb.323.1665254585188; Sat, 08 Oct 2022 11:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665254585; cv=none; d=google.com; s=arc-20160816; b=o3GtIjYU/08hooAnsNO5PM2FoNYQjS29EfozEUuBsW7D2+Mheg32AauCKR8beIkNOn YMkxR56flAmmj/PApaEQXWarb0syP2TMM/VyZ7t0nuiduvexEmu8ilsAE//KPDbF23+e CVaGuxsISHHOOG3PR0g0Rx9NrmKGKELOGIgiJ6RvOpuNQb0P2WGRNtQ3K0Mt0K/tDgSf GH2RNnXH2wYfUC5KtFsrn1ph0DHoL1XL23U/8MAZa3fvpv9EXPiVRFCSG7QRLV61Yduu TD5EdMnRORq2z+QQbSg7PAaDOEF9G2CXwfo/OAK+Fsy4KDhzaiX09BipAEFWrhK0q28r 37RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=TNYuzkx0DGl3YY6akP9WyoKTqZEYCLgGMvwC1YP1f64=; b=T5wqKI9f9U1sI0jItaOOy0mf8GAa4xjnSblsUuykdjLecVZ2DywE5EjD10YZ2R2Pi5 mASWz4Bt7Ts9FskZh6yoS5gpgXmcJ7/Kt7Z7YT+ungbl1z2rIKJfrZ3GQ1fwlIXCOa+c eDKAVV7kQ/gsjyvC+0wT8PE2M17XN/gNiuOgo0gLPVWJt/utBPT1+wuTgQcKFevquzML ZTAZUhG08Ofyq83CIDBt1dTjctptvFuok9AzSYoHMXO6NWLovr9DKQ8E8QYueSQAWWZn +lVvftbEkJt87RCQ3664wXL8GU89oC3pJ7Fgd0FY5dvg02haDYd0mNQZd0gFsJhiI/V/ MZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b="r5/3dX3z"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd8-20020a1709069b8800b00789e061a56fsi6160420ejc.98.2022.10.08.11.42.38; Sat, 08 Oct 2022 11:43:05 -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=fail header.i=@igalia.com header.s=20170329 header.b="r5/3dX3z"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbiJHSNI (ORCPT + 99 others); Sat, 8 Oct 2022 14:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbiJHSNG (ORCPT ); Sat, 8 Oct 2022 14:13:06 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1364F3A14D; Sat, 8 Oct 2022 11:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TNYuzkx0DGl3YY6akP9WyoKTqZEYCLgGMvwC1YP1f64=; b=r5/3dX3zF7a8uN5Kl+ACSNY7+Y K1LkEsk20Z3soFvyj7DObMgWbKDraV5UTMKJGyS66DQ3tmD/yRDci/EXB0rkPuqNWCTKrFIqnmeHg 42jKGSlx35qXM/Infto9WGwr6lsh0iEop8rrUCby1wYU1SIGpZHLEcJUZqweJmA7YjKKas1LoNBtS mpL1KF7aT/mDVw1cv6NPKzquRjNjXUmOnr2A9gcywj0TwLw5Tq81/8MYamsb/6QwsOcLPPTpFSgTr 9boC0N//x3X1rlOd5RDQd2DhDAf4Kjc+AOfxttrO/b4eaNSq/Ygv2IuXtSnfTMj7hkL1JzPrehN+g upwMqbKg==; Received: from 201-43-120-40.dsl.telesp.net.br ([201.43.120.40] helo=[192.168.1.60]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1ohEJk-00Elx8-5F; Sat, 08 Oct 2022 20:12:56 +0200 Message-ID: Date: Sat, 8 Oct 2022 15:12:40 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 5/8] pstore: Fix long-term implicit conversions in the compression routines Content-Language: en-US To: Ard Biesheuvel , Kees Cook Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, anton@enomsg.org, ccross@android.com, tony.luck@intel.com References: <20221006224212.569555-1-gpiccoli@igalia.com> <20221006224212.569555-6-gpiccoli@igalia.com> <202210061634.758D083D5@keescook> <202210071234.D289C8C@keescook> <11e03e8d-7711-330d-e0d4-808ef9acec3a@igalia.com> From: "Guilherme G. Piccoli" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 08/10/2022 14:52, Ard Biesheuvel wrote: > [...] >> This is exactly what 842 (sw compress) is doing now. If that's >> interesting and Kees agrees, and if nobody else plans on doing that, I >> could work on it. >> >> Extra question (maybe silly on my side?): is it possible that >> _compressed_ data is bigger than the original one? Isn't there any >> "protection" on the compress APIs for that? In that case, it'd purely >> waste of time / CPU cycles heheh >> > > No, this is the whole point of those helper routines, as far as I can > tell. Basically, if you put data that cannot be compressed losslessly > (e.g., a H264 video) through a lossless compression routine, the > resulting data will be bigger due to the overhead of the compression > metadata. > > However, we are compressing ASCII text here, so using the uncompressed > size as an upper bound for the compressed size is reasonable for any > compression algorithm. And if dmesg output is not compressible, there > must be something seriously wrong with it. > > So we could either just drop such input, or simply not bother > compressing it if doing so would only take up more space. Given the > low likelihood that we will ever hit this case, I'd say we just ignore > those. > > Again, please correct me if I am missing something here (Kees?). Are > there cases where we compress data that may be compressed already? This is an interesting point of view, thanks for sharing! And it's possible to kinda test it - I did in the past to test maximum size of ramoops buffers, but I didn't output the values to compare compressed vs. uncompressed size (given I didn't need the info at the time). The trick I used was: suppose I'm using lz4, I polluted dmesg with lz4 already compressed garbage, a huge amount of it, then provoked a crash. I'll try it again to grab the sizes heheh