Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1394857ybn; Wed, 25 Sep 2019 17:42:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt3Ck5R6mb45eHgtBQzVg2R/oYPOI8Hv6QRs8Dl7FAaHskdx5Xc8Lsj1PX+nZcw7yRq6oj X-Received: by 2002:a05:6402:a4b:: with SMTP id bt11mr798893edb.175.1569458520835; Wed, 25 Sep 2019 17:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569458520; cv=none; d=google.com; s=arc-20160816; b=uivjXe36MfD8hQOurJavAkk42ClSzRSLNK1iSzTN8YZg6wScqVEbhSfJLgARJiaAGv A4qWdup+T41qYKBHmB8XkNm1lssNef9TkbKSTMIUmKLtvkm8mcd7prN0TkF8FFRM6bmV 4x0OyUNOh285VHNcHE/I4fkA02O5VzDXBQKTC0QoIn7ZUF+HdtmTM75cijzjKOAoIhUc FhT3pZVTjsZ1y1ADShHFlmDJKtkEcVuqO/9JXQwx0kAi2cECn22odx4EZgk6AaydCS1A fSei2SLyGXY4F1dM1Rz8bvrdqV3NV+xqJ6TiBdvobmycCWHduaL85gkqm7+bQsi7Twcx 8clw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date; bh=fvkcDSiEbM/XqtPe0FzvlCWEdBcZFQzVpG6dTd99SgY=; b=MW6TQR1tAR0K/OoxBDOMjcuXFpx84wro1L6boNHb7vstPGj8U+LsNlS8izMIBWLufd anrssNzprmVUJDRUL++obhrXIWmJ2lZL1XuKVcTOCSQXOB6bCgFiu1hW0sMKyONm4ydg DuCv/jPPQzoBwvOwQllmrlCLeBl33Obko1wIR3RAIvMwW4ivfeNgOB6C+CcuUq5LOGqG JLUVQRbdu8XYM24LgMvPw3v2peuVPaU+SQbt8Aa3tipIUlUmLZv/3E8HaOMe5rWweyTk 8qM2N6qOENXjhN+iesmQ+yS5quiEwEUMl+bJiFxVfJYtMwRroizU8Xu6IeycZIOH/VHZ c2mw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oa24si253676ejb.41.2019.09.25.17.41.37; Wed, 25 Sep 2019 17:42:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438706AbfIXGOz (ORCPT + 99 others); Tue, 24 Sep 2019 02:14:55 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:49376 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438592AbfIXGOz (ORCPT ); Tue, 24 Sep 2019 02:14:55 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id D37F180602; Tue, 24 Sep 2019 08:14:38 +0200 (CEST) Date: Tue, 24 Sep 2019 08:14:52 +0200 From: Pavel Machek To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs compression: check string length Message-ID: <20190924061452.GA31397@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable AFAICT, with current code user could pass something like "lzox" and still get "lzo" compression. Check string lengths to prevent that. Signed-off-by: Pavel Machek diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index b05b361..1083ab4 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -51,7 +51,7 @@ bool btrfs_compress_is_valid_type(const char *str, size_t= len) for (i =3D 1; i < ARRAY_SIZE(btrfs_compress_types); i++) { size_t comp_len =3D strlen(btrfs_compress_types[i]); =20 - if (len < comp_len) + if (len !=3D comp_len) continue; =20 if (!strncmp(btrfs_compress_types[i], str, comp_len)) --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --UlVJffcvxoiEqYs2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl2JtFwACgkQMOfwapXb+vImNgCeIrP68oJefLVVShRBFhny/37h 274AniqO9oCZ36VAfgTLlXl+FJ7vSZm8 =MF++ -----END PGP SIGNATURE----- --UlVJffcvxoiEqYs2--