Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2494346imm; Mon, 28 May 2018 09:08:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoAHZUKU8X6DM46SBYpx9mt5tzJqrohX81n/gTWb2z75Ns51JeR7Gn64yCvkGAhqBr1oyit X-Received: by 2002:a17:902:1c8:: with SMTP id b66-v6mr13835442plb.156.1527523713383; Mon, 28 May 2018 09:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527523713; cv=none; d=google.com; s=arc-20160816; b=PtRtaJkzM7JI6lM6lIKFDXYZLsaXMUR6QtkxlGvw3+dVdN+Ux/EYgocVa4vo2ftcF1 d6HMHwXU8/4ijq72CA6FP1EoMNXuTlXkq9RQF2prZug5ZFIr095M8/b+KpbdDWbrSM4U ephFI56/au9Vsr192QrnYyqgwo+JwEVeohqmmnaSNDg9PNBaBVH03EZNt8jXfx3CoZAQ XyOXuCcJyJUEbyDpO8JrpwxE3txJAaxVjVjGrX9yAp3fS2dz2UhSonZutig94cUBYAxm UpNyADT7QJGPh9ErJt0OHybnMTSLrgEHwadrLGICqn1i7kpa7xGjd5pMrUu63/Xnf1H5 tmqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2umPJfAUZ19AgPU7duXIH2dcvKM3XPOIeDMe4GuDmuc=; b=jl7WTge+YkPeBA7ygUiW6W0q1U10B8h4RUbBuSaAVXUW2GY/2TIBIBFS7NOTyGE8gk R1sYKuuZEChEVuyQ01n0KjFZIdcBOHNKYh/yq4vHMSc/ZS85EnH+gxD9TiPzoWjv2htU Pi1V7/pVh2pFEFTBF2+KSkxjXgs3gNC1TXSIIH3BLBkSjEMf1FZX2vfNdNUrExzok2Vo F8p5iqmcxnk2LaX9mbCr69sO/pOLEHAijYm3w5vyikUv110KaNP72hZmsrfCQqOTMeh2 Pt7U94Wcr7UzTecvFiCwriVDePXmTTkwGHBrhlosSnhdXpOkxNDr3pmsciNXEzt/HNCa mc+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wXuK9goh; 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 z23-v6si31375880plo.492.2018.05.28.09.08.19; Mon, 28 May 2018 09:08:33 -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=wXuK9goh; 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 S933499AbeE1QGp (ORCPT + 99 others); Mon, 28 May 2018 12:06:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:34732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936674AbeE1KOk (ORCPT ); Mon, 28 May 2018 06:14:40 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 EFC1A20876; Mon, 28 May 2018 10:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502479; bh=ksPLYXVcg6Wawq7l1124MzC59Lhb2mBlElOekLwdgOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wXuK9gohckbJxtr4LI7E1iRmZu2O8E8OVHgEsY/lmQNe3aqakFIkXjw7FW8/++oMp vd1jybSXdr0jOCTaPQrZQ9dQQgwwce9O2Bw1PCIdMkB/q5VgQwtuzm0K4vPBQwkYF5 99jxkJ27UqaH2/ySb7cRMuojkXYDA5kFApvrTNBY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Foster , Christoph Hellwig , "Darrick J. Wong" , Daniel Sangorrin Subject: [PATCH 4.4 016/268] xfs: remove racy hasattr check from attr ops Date: Mon, 28 May 2018 11:59:50 +0200 Message-Id: <20180528100203.941403919@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brian Foster commit 5a93790d4e2df73e30c965ec6e49be82fc3ccfce upstream. xfs_attr_[get|remove]() have unlocked attribute fork checks to optimize away a lock cycle in cases where the fork does not exist or is otherwise empty. This check is not safe, however, because an attribute fork short form to extent format conversion includes a transient state that causes the xfs_inode_hasattr() check to fail. Specifically, xfs_attr_shortform_to_leaf() creates an empty extent format attribute fork and then adds the existing shortform attributes to it. This means that lookup of an existing xattr can spuriously return -ENOATTR when racing against a setxattr that causes the associated format conversion. This was originally reproduced by an untar on a particularly configured glusterfs volume, but can also be reproduced on demand with properly crafted xattr requests. The format conversion occurs under the exclusive ilock. xfs_attr_get() and xfs_attr_remove() already have the proper locking and checks further down in the functions to handle this situation correctly. Drop the unlocked checks to avoid the spurious failure and rely on the existing logic. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Cc: Daniel Sangorrin Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_attr.c | 6 ------ 1 file changed, 6 deletions(-) --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -130,9 +130,6 @@ xfs_attr_get( if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - if (!xfs_inode_hasattr(ip)) - return -ENOATTR; - error = xfs_attr_args_init(&args, ip, name, flags); if (error) return error; @@ -417,9 +414,6 @@ xfs_attr_remove( if (XFS_FORCED_SHUTDOWN(dp->i_mount)) return -EIO; - if (!xfs_inode_hasattr(dp)) - return -ENOATTR; - error = xfs_attr_args_init(&args, dp, name, flags); if (error) return error;