Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2462193yba; Mon, 15 Apr 2019 12:09:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUyzprTuX4bN/ZYoUQ7mMYoDen/iyHxSMSula9FPJGszeQOYhiJ0eXHlG/gnpvKsK3OA2r X-Received: by 2002:a63:ad4b:: with SMTP id y11mr69055377pgo.405.1555355349518; Mon, 15 Apr 2019 12:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355349; cv=none; d=google.com; s=arc-20160816; b=Qpjtp8gMu11NSlfmrjt86yRHZy8iibXxF3/Bp9NEe00KdX5DGsyHJ0U/PqKalYPaY2 NQqf7DqrQN8rVrsDe7QlvGBAtaeXpQNJENjRfCcwV8QAwRwTIBH3CAyzYOJb4TAG21yI EzgN0oPPkuTzF56U0bWOIpkQNDkIXMjg2/Dh9aSxbX2bv4oqeb7oPy/aRTzwMYIjpcZz MgAtGybpK1a8oYMvgGhWsa9jhnb7EoBSyPPXLnZlIbQzSnpepZrHSd3SaXD6aWtOuqFM aL3SNl7d5l1V872f4B6UHIDJ1VInpfQ6lsfQUQYsMfrMCbGOQHtoV9aicn1mId9/LnEk AVTw== 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=coo1CAFUnqVHSENXyi+Mq2jc3+YGaXj8bPNQLC8jjoo=; b=pKEu/+HuJKDl+PzitBAFJbS3MOIGiXtqXIjD+VQt1VrAuB/EnYHuunbSCS1cZ3Fqfl H4D2Qf/xmyv2dp3Ye6mDSAS1ga9/M5Husenp3K+9T9+owv9Spd270Br+y/oIEbKb3V+K HsZsISC2oNQnD5ACM2IZzrlC0xlmeq0QiCh7S9lltuKYig4gnAZ8Qgmg33l0F2T1yMOF xu0ZWEn/Mpbq2zcYzElvfhSl5Y3X/5Rr5lB4Uy40KvjxXW9QrOLBjIanaxDBj1oQ0yiq 1U3+kzdAALvAv651k8KY3+vVhsUs5qwTdy0p8EPKERI7ZcH8pAubuKT4GsfzW2BU5ADc ZOCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WN6o4Ytq; 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 cv17si46295487plb.380.2019.04.15.12.08.53; Mon, 15 Apr 2019 12:09:09 -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=WN6o4Ytq; 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 S1730253AbfDOTHl (ORCPT + 99 others); Mon, 15 Apr 2019 15:07:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729730AbfDOTHg (ORCPT ); Mon, 15 Apr 2019 15:07:36 -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 58245218A1; Mon, 15 Apr 2019 19:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355255; bh=VaXOLE2WGm9xCzg1zqcLDIlB8qNwohGne1xxPBGKNy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WN6o4Ytq0zT2qdhESU2VkxK4+ntW6Q87+mXxDZHUrCrWcfyGXylsfHclOwL1B3e2P uEtEz2eTegeoRZPq/wKqJCSSK2K834HjzcWgorxNLIJHxtQRS/Xw4sms84CBRgQSHc XUXZUVSQDodwHItnCNoAypvWTlc5QAl/5ITSEO5c= 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 069/101] btrfs: prop: fix vanished compression property after failed set Date: Mon, 15 Apr 2019 20:59:07 +0200 Message-Id: <20190415183744.122598536@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 272e5326c7837697882ce3162029ba893059b616 upstream. The compression property resets to NULL, instead of the old value if we fail to set the new compression parameter. $ btrfs prop get /btrfs compression compression=lzo $ btrfs prop set /btrfs compression zli ERROR: failed to set compression for /btrfs: Invalid argument $ btrfs prop get /btrfs compression This is because the compression property ->validate() is successful for 'zli' as the strncmp() used the length passed from the userspace. Fix it by using the expected string length in strncmp(). Fixes: 63541927c8d1 ("Btrfs: add support for inode properties") 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c @@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct bt static int prop_compression_validate(const char *value, size_t len) { - if (!strncmp("lzo", value, len)) + if (!strncmp("lzo", value, 3)) return 0; - else if (!strncmp("zlib", value, len)) + else if (!strncmp("zlib", value, 4)) return 0; - else if (!strncmp("zstd", value, len)) + else if (!strncmp("zstd", value, 4)) return 0; return -EINVAL;