Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp14750imu; Thu, 8 Nov 2018 13:57:50 -0800 (PST) X-Google-Smtp-Source: AJdET5dL127F5TfpXSoW51pg1Kire3+27RiJkQ1A/bAIZiyPdyqCMiZI+bstipoDf/OzZQus7IFd X-Received: by 2002:a63:d547:: with SMTP id v7mr5105792pgi.339.1541714270829; Thu, 08 Nov 2018 13:57:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541714270; cv=none; d=google.com; s=arc-20160816; b=U6sc869rUXKCjze3tZv/ztQQygtIFur9l9d0KorIzVVMvSL6tkUQTdfJWTz2cc53qG OylGw1pAsVW3usmzouRUxQtRFfb3L2IR6N+XlXlMO5ws7VPc2rbUQBWdBkz7+1oSOsO/ 4p4QrpUC0otDphbF4RYZPTaj7NgE6mXEDAIIMuW9gtKY2+YnNbUTmTdF/19EPr3NXJYc pODfyWE2h/6ghfU9rX6ad2BvRXXcv4g8kcbYehrxaC08oMjbXyhTX8LR/UlCK2ChZneH SiOOBS6hmNyAwoOpxYuYBcnf/UzE6Ns848yyJWOHPk6Jznu9i4gpMMzpdSPK8Xc07t9Z jEWg== 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=G6dMAL1QNOOtQuzN4sFVDbmNrvSi2RW5IS6N8RyfUII=; b=xYr3SMyY1zYPB3ujyXohiyGEsjIbEF3oBIRN8wmVheDBr4s+JBktDb6rhNI7cWUvQb /C++Xyyv32zAaZX/zmFrdOtHVPj+io2HpcR3bDzNA1tCZVbjGU6iw9mbaIegEKEtSwNv Hi2nsgTNq0/G8Hg0opd9MbYGVgGdjs3In8FQljAmC8fuCuO9jrJdu2vT4aDPHlJ86/Tv XjEUXA4IuI0yWvwp/RDfVgSi6V4Q42mXILKqseB9AE2FdSmYBGrJdSDmv13XO9gxNPM6 rXScfCEToBp6UoVMCGjiDTXRQu7v8IZkq5npc2KOZhwI56mx6HIvLzFUjtSLyNiSc3i7 SNRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WXg17P9H; 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 a5-v6si4272675pgw.352.2018.11.08.13.57.35; Thu, 08 Nov 2018 13:57:50 -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=@kernel.org header.s=default header.b=WXg17P9H; 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 S1729202AbeKIHdy (ORCPT + 99 others); Fri, 9 Nov 2018 02:33:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:50174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbeKIHdx (ORCPT ); Fri, 9 Nov 2018 02:33:53 -0500 Received: from localhost (unknown [208.72.13.198]) (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 79AA620989; Thu, 8 Nov 2018 21:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714185; bh=T8hLcoGkrM9HCUpAUGJrHhnx7PDWbP8+reHjbOTT2zU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXg17P9HyAL/NdorW9spqHru/aa7Nd76AF13OSDtudxheAmNyzpyz8HzpsHbv/A7E Uj9qVSrtIW2Fh+jwsENxcyYwa035aUHQ6wARhTejCMHa/q/UZmRzA3/lN1x1Lfn+OX daRUc38JaMA1VQN7CjFgK9E991bf/5sNe+XhEjp0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Chris Mason , Sasha Levin Subject: [PATCH 3.18 109/144] Btrfs: do not ignore errors from btrfs_lookup_xattr in do_setxattr Date: Thu, 8 Nov 2018 13:51:20 -0800 Message-Id: <20181108215105.755120337@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 5cdf83edb8e41cad1ec8eab2d402b4f9d9eb7ee0 ] The return value from btrfs_lookup_xattr() can be a pointer encoding an error, therefore deal with it. This fixes commit 5f5bc6b1e2d5 ("Btrfs: make xattr replace operations atomic"). Signed-off-by: Filipe Manana Signed-off-by: Chris Mason Signed-off-by: Sasha Levin --- fs/btrfs/xattr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index fbb0533e977f..de5d69a63e3f 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c @@ -111,6 +111,8 @@ static int do_setxattr(struct btrfs_trans_handle *trans, name, name_len, -1); if (!di && (flags & XATTR_REPLACE)) ret = -ENODATA; + else if (IS_ERR(di)) + ret = PTR_ERR(di); else if (di) ret = btrfs_delete_one_dir_name(trans, root, path, di); goto out; @@ -127,10 +129,12 @@ static int do_setxattr(struct btrfs_trans_handle *trans, ASSERT(mutex_is_locked(&inode->i_mutex)); di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode), name, name_len, 0); - if (!di) { + if (!di) ret = -ENODATA; + else if (IS_ERR(di)) + ret = PTR_ERR(di); + if (ret) goto out; - } btrfs_release_path(path); di = NULL; } -- 2.17.1