Received: by 10.223.185.116 with SMTP id b49csp4349993wrg; Tue, 6 Mar 2018 14:15:09 -0800 (PST) X-Google-Smtp-Source: AG47ELu3e4JFvmi1QG6F5e52BSDUka/yslE5KiYBPEtpRGoZ6foLPJvd+Vi48exeZ5gttZob/b3x X-Received: by 2002:a17:902:684a:: with SMTP id f10-v6mr18584372pln.129.1520374509259; Tue, 06 Mar 2018 14:15:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520374509; cv=none; d=google.com; s=arc-20160816; b=SNvpxAbzFHwCc68Vv3guZpHoUcBlo6qcWmgsq8Ag/npj0ArDvvpf5UnHpaUy9bC+md Azk1xOUOqWJvPyLhODJZWiFNSo78AHYYZQKTFOfhARSRB0ifiuPuVyGANTLEIkzBI2CG Wl0a9wti3Ohzl4d3Vf+ZqY1NJoWo4sNPy+7xWAVukL0IkDS6xwooTycqiqxhaIXzg2kS 6q+k+D97P0dkIGrvuKC9ODV0bpOfAUXouiRxedY1UXy/CxV4CY0yqFnrzPFiCKq3yA8b lxIctiXvBgkxYygq2eJhZAAiBtsyI9GPGR4YJ0xcLOAFgJMc53I5jLqpIYPBCQbEpxYI Vrvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MWanSsOBd2PlnMMYbdBCPaVeBl7IdU0Ul4O1a6pFC2g=; b=s4nbHmrhgHpuWBfXbJJ7UZ8mwCTwjso++MM80DhpTAJ4bg+9eMATaP9qUnEgD2Ij+b LGBb9fxBMqTetIAOOBYnxMgCJX9sPaniCjMFZyKNDQq1QPoi6rgvDzIV0Mr0KzUS1kdC 9ILCAxTBKsLIBq4SVuBu6jdNWv+riy83ohAUPPGvbRE3NXwwK2DdwMFrJx1cexOrUXCy aoJZKUT9OgEXydnxth3BT40ywzRTooRKxUPRyTme7tUEImhHU7t3p3oI8692TKHx4l7e Yl2aZ2oJXV9uhUfkl6Z2Cj0ohVkzZ02QXlWujMqDZyDZXPhSSdm+SiybQrLofGKT696H GGfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DLtaxtFf; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si11835661pld.80.2018.03.06.14.14.54; Tue, 06 Mar 2018 14:15:09 -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=@gmail.com header.s=20161025 header.b=DLtaxtFf; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754167AbeCFWNr (ORCPT + 99 others); Tue, 6 Mar 2018 17:13:47 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:53739 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754003AbeCFWNp (ORCPT ); Tue, 6 Mar 2018 17:13:45 -0500 Received: by mail-it0-f66.google.com with SMTP id w63so810093ita.3; Tue, 06 Mar 2018 14:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MWanSsOBd2PlnMMYbdBCPaVeBl7IdU0Ul4O1a6pFC2g=; b=DLtaxtFf8rtuVubzOTxeYLLgk9icyER3L1VWtWFb0CkQB5E1GhLX6q9xy9lHhHZUS6 HVVnLc83fsD1bhoGCv5RJK/BiakXZiPO2II9IJvcn+SVElt6ffYLWtoAU7Oxm0kRZU8+ C/SrT5qTXd0fKTYGldXsoLjoPglJ/+NVYVxqmZPxsi40cAng7Wa0SQlY+XhFUZWXbEBq VYkziF0lPwTTJLaYpf6xRpUzJscCwwlFWXrwS1pM04hcHJ6y/3oIIyI7A3F1JQdXO5CG JKDlrZiuYuIPwXm8L26VDoBoR/OkYh72hZylUZhlFuNWVdaqiphUTn+dG9uzQQMdhLDk RP4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MWanSsOBd2PlnMMYbdBCPaVeBl7IdU0Ul4O1a6pFC2g=; b=V6WPrZcvd9i27dEL5qV7btvx4B9Nqc+6SDjgohZbGXff4agHkpVyOLLL2+7uPEwVBx eRT6821KNoTzbmKj8XAa++foxKa+340PelkG5jYbE3edZ/a0sEqT1mjpM865kv3bgmNA d9uTnl2MLA5bM4LABlRTNtYMACMJmyyOqe+gmPnhs/T/N4kmOPSFtSfnltg9TYLgxLaM 3lqa9CFcM2/TGYltvoTO9ZjFYdv8PM/wKIwlKKIGngzj22UTMrMXJatxZEsc+BFh5LgS pAxZsbqiCPgKu2rY+nvOmwh2dJMJxonmN5Wc5VSLwi9MnzEi5SCbWvsN4eqm1XuwaQbM cWHQ== X-Gm-Message-State: AElRT7FewaeNsBfbCd73Vzrgm8NSsurN8c4nsOXxQb1fzCYQnjHmF9du gKUL6qbGQPdKvGtwIyLvsYc= X-Received: by 10.36.216.195 with SMTP id b186mr19581136itg.86.1520374424902; Tue, 06 Mar 2018 14:13:44 -0800 (PST) Received: from gmail.com ([2620:15c:17:3:dc28:5c82:b905:e8a8]) by smtp.gmail.com with ESMTPSA id f83sm10905067ioj.20.2018.03.06.14.13.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Mar 2018 14:13:44 -0800 (PST) Date: Tue, 6 Mar 2018 14:13:42 -0800 From: Eric Biggers To: Benjamin Warnke <4bwarnke@informatik.uni-hamburg.de> Cc: Linux Crypto Mailing List , linux-kernel@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com Subject: Re: [RESEND PATCH v3] crypto: add zBeWalgo compression for zram Message-ID: <20180306221342.GA178079@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Benjamin, On Tue, Mar 06, 2018 at 09:23:08PM +0100, Benjamin Warnke wrote: > Currently ZRAM uses compression-algorithms from the crypto-api. ZRAM > compresses each page individually. As a result the compression algorithm is > forced to use a very small sliding window. None of the available compression > algorithms is designed to achieve high compression ratios with small inputs. > > This patch adds a new compression algorithm 'zBeWalgo' to the crypto api. This > algorithm focusses on increasing the capacity of the compressed block-device > created by ZRAM. The choice of compression algorithms is always a tradeoff > between speed and compression ratio. > [...] > > Zstd is not in the list of compared algorithms, because it is not available > for Zram in the currently available kernel trees. > This still isn't a valid excuse for not comparing it to Zstandard. Zstandard is already in the kernel in lib/. It would only need glue code to wire it up as an scomp_alg to the crypto API. In contrast you're proposing an entirely new algorithm. Ultimately, by proposing a new algorithm you're on the hook to demonstrate that existing algorithms aren't good enough. Note that many of the existing algorithms including Zstandard also have multiple compression levels available to choose from. It's also rare to add a compression or encryption algorithm to the Linux kernel that isn't already used somewhere else. Have you at least written a formal specification of the 'zBeWalgo' data format? Zstandard, for example, had a well-tested and optimized userspace library and a specification of the data format before it was added to the kernel. And even before that it took a couple years of development to stabilize the Zstandard data format. Now, it's true that you don't strictly need a stable data format if the algorithm will only ever be used for RAM compression. But, if you want to take that shortcut, then you're on the hook to justify it, and perhaps to enlighten the crypto API about algorithms that don't have a stable data format (e.g. using a new CRYPTO_ALG_* flag) so that users have to more explicitly opt-in to using them. You cannot just ignore fuzz-safety in the decompressor either. The existing decompressors exposed through the crypto API are fuzz-safe, so it's not valid to compare an unsafe decompressor to them. If you really do want to add an unsafe decompressor then you'd likely need to look into adding crypto API support for users to request unsafe decompression -- which could also be used to expose the unsafe version of the LZ4 decompressor (LZ4_decompress_fast() instead of LZ4_decompress_safe()). Or if you do make the decompressor safe, then of course you'd actually need to fuzz it; I suggest porting the code to userspace and running american fuzzy lop (afl-fuzz) on it: http://lcamtuf.coredump.cx/afl/ Separately, given that this is a brand new algorithm and it seems to have various corner cases, it would be a good idea to demonstrate a higher guarantee of the correctness of the compression-decompression round trip. afl-fuzz can be good for that too: you could port the code to userspace and write a simple program which compresses and decompresses a file and aborts if it was corrupted. Then by passing the program to afl-fuzz it will eventually cover most of the compressor and decompressor. I've done that when testing compression code in the past. Hope this is helpful! Eric