Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2462164yba; Mon, 15 Apr 2019 12:09:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXM5WDBHnVkEKp4S90QNXcW7WF69BuZTdeCILzrqg88R8Ijil64BezMAh8DVYdqYV0izvk X-Received: by 2002:a62:7089:: with SMTP id l131mr78512529pfc.158.1555355347522; Mon, 15 Apr 2019 12:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355347; cv=none; d=google.com; s=arc-20160816; b=oAIVzjjwDOaC9X7k3P9P54zTV1YdGNH6IG3AZ8iTyoIaLdskUNTN99mPQJ7X08sGem Hf7JxAw3isPWv26RRl/VA6rQPwBWJ2u3zq0WAfR69gi8zTPL7CPa/2VAeb+sTmrv+njf vvqD+spJZZH2OdJEQQFuzpZXy1ry7bGCrzEXaknn29CmCM9SsOTNj6j82EboyKhKih1o 9RhQOdAYiIMt7duhfsVnT4fiW26APSp8MrOCUL26msIIkAYioGZXemFfg0iHspjM4dI4 KBK4L+yZaoj2Vlvq63zQdpbYZlCZ6ePYwQ8fR/oCGQzgE3ksOIG7aGZUqmWjqn9H9UOs y5HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NXgXsgBsf97fZgYWJBmSfJCc5Yf27scYKKiKt6Pi4qE=; b=iMdsAEh+pHoK5ttBp+xa9JZIyVlTnZpMCdGV/4gYI9+G+Qk/KgvXCtuDFmKrk/8eLv Sq/120XWUMgKK9OWX25LsafcpZrgTwx3E2mGwSeCV7hUsvRcRDwPZJEa40bb1i0LUyYW gdjsv97+i9jos+uugs3MXtKJYLoO4i3xwvhAB1OWHJm5RSPbukirI4uJkpKcI7Rd7lsz KI3u3A7oDf/XBitqinUQJWmvdZZ73l3Lr0aam8NjBJUitSB1KKKomnXacm6kxMh6Iycb jjA2zypQynGePd0HvddaLQr7bdC/SJT1W5O34+VpqrVuw5alT2x0nEABtiRPm5BWFCje BH1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZAaR1Q9M; 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 b91si26253677plb.426.2019.04.15.12.08.51; Mon, 15 Apr 2019 12:09:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZAaR1Q9M; 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 S1730235AbfDOTHg (ORCPT + 99 others); Mon, 15 Apr 2019 15:07:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:42558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730208AbfDOTHd (ORCPT ); Mon, 15 Apr 2019 15:07:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1F7920880; Mon, 15 Apr 2019 19:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355253; bh=1QUr1HOEiVC48iGBBFI3teoaKM3RtaomYix4dALh23E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAaR1Q9McvqoXRUCS7fBLTjCElNWUAi7bHwM+mmhS1qf6Y1KNZ+v1DkjJyGY7zbPF YhjbOuS07qanjaRqaY/YXsEg32LeHi4kfm6KwLPxbILdAbTkJ4pZqa3KSN+bJhEtkb 1JcoDpFLhJqixtoey0t6nG1wXcmYPxQ0yTkarrx0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Anand Jain , David Sterba Subject: [PATCH 4.19 068/101] btrfs: prop: fix zstd compression parameter validation Date: Mon, 15 Apr 2019 20:59:06 +0200 Message-Id: <20190415183744.077806404@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anand Jain commit 50398fde997f6be8faebdb5f38e9c9c467370f51 upstream. We let pass zstd compression parameter even if it is not fully valid. For example: $ btrfs prop set /btrfs compression zst $ btrfs prop get /btrfs compression compression=zst zlib and lzo are fine. Fix it by checking the correct prefix length. Fixes: 5c1aab1dd544 ("btrfs: Add zstd support") CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Nikolay Borisov Signed-off-by: Anand Jain Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/props.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c @@ -396,7 +396,7 @@ static int prop_compression_apply(struct btrfs_set_fs_incompat(fs_info, COMPRESS_LZO); } else if (!strncmp("zlib", value, 4)) { type = BTRFS_COMPRESS_ZLIB; - } else if (!strncmp("zstd", value, len)) { + } else if (!strncmp("zstd", value, 4)) { type = BTRFS_COMPRESS_ZSTD; btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD); } else {