Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1017994ybe; Wed, 4 Sep 2019 11:12:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqylcY5AK2KNH7KiK2+4QLKSw8wVjY/zzGJINw80Bg2WOABavo1qxHFqIPGgqBol2FWOWHlD X-Received: by 2002:a63:f907:: with SMTP id h7mr36371789pgi.418.1567620763880; Wed, 04 Sep 2019 11:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620763; cv=none; d=google.com; s=arc-20160816; b=l2jZS+Ylxp5MfTvMj2w+yfw0we5Ysh5de8rZFpcCr9IR1GUBA5y0x5sIlaXI8gwjJU Kr7M7Z5Mg2VLUVaCGNEGni1573tFLiVs5MJmW98BGr+iwAuJckSjOa3zAyzUziED8ERd dMnGE9PLcC2EuyvLX0W9jtBMhh+/rQ5GS4VtFBEKUXv3S2ZZE6+xYeAXspzUci5Am3LC 9GM4feweqZWXYifio8bCZUx9R8mOHKWFdB9oHFuydQX9TqvmHeofwD46F9kMA1OzaZ0V pGW6QZ19hPRMzTtwFfTZn3mB7RZDrv3vHWd1WW7Vfv7cG9HHchzETAxjz8fGu9sbC4BE pe7Q== 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=bwTNDWy1a2DFNTIeSCg7sk3Vy/BQJ0u3CWbYgFiDxfA=; b=ljj2F91TqhTYZsfirZb7vR2wR9dE2DVFcR8wNTkuLh4a0nVvuTqwemqvZJMX1so9F3 VLegN3FG84/RnDhb/ktI6yHglc9q9a7wZnKABbdDHV3kWqq7wXvIT2S3rhiCmch1jIcH ZEqM7LBQsi7GwOU+QkBHkt2weo9fUJZgYJZnOmlBqN10U5CvlPWRlgm+h0eZwB6vZDoO dEUCdPpgRbyBCpuKOIm2L5MNLWaFd819dWrQU0ViRelSnWfsZGv0Tu1bOGby0Gj+O3k5 K8OKbw5JSFlFS/M4qCMDNU75blanFghijtj8F4zbIexO8dkiHTKhDjoph6XSO8uBZoVg b5JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nt8LF6r0; 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 h125si21498755pfb.119.2019.09.04.11.12.28; Wed, 04 Sep 2019 11:12:43 -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=nt8LF6r0; 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 S2389583AbfIDSJl (ORCPT + 99 others); Wed, 4 Sep 2019 14:09:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:52866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389399AbfIDSJf (ORCPT ); Wed, 4 Sep 2019 14:09:35 -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 E071022DBF; Wed, 4 Sep 2019 18:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620574; bh=IH51GWUmZgIxiBJuFdoD1/Ikf2kGDZwYz5VVJH1ge44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nt8LF6r0500hVJ1I1to0YkTlEQYd+StgYupdihkyMxSd5M/Geh0YFSAvE7rherHYG udevyc0nHINrTgh7WP8QHndYCITsZKMRSpSh+oXelodMKuL8nuCMGjmMIYdogXcpjC EEcyAlagr71H5sh8MLz88A5FbwZC+CvPmMxHPBQA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin Subject: [PATCH 5.2 007/143] afs: Only update d_fsdata if different in afs_d_revalidate() Date: Wed, 4 Sep 2019 19:52:30 +0200 Message-Id: <20190904175314.436310246@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@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 [ Upstream commit 5dc84855b0fc7e1db182b55c5564fd539d6eff92 ] In the in-kernel afs filesystem, d_fsdata is set with the data version of the parent directory. afs_d_revalidate() will update this to the current directory version, but it shouldn't do this if it the value it read from d_fsdata is the same as no lock is held and cmpxchg() is not used. Fix the code to only change the value if it is different from the current directory version. Fixes: 260a980317da ("[AFS]: Add "directory write" support.") Signed-off-by: David Howells Signed-off-by: Sasha Levin --- fs/afs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 9750ac70f8ffb..b87b41721eaa8 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1018,7 +1018,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags) dir_version = (long)dir->status.data_version; de_version = (long)dentry->d_fsdata; if (de_version == dir_version) - goto out_valid; + goto out_valid_noupdate; dir_version = (long)dir->invalid_before; if (de_version - dir_version >= 0) @@ -1082,6 +1082,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags) out_valid: dentry->d_fsdata = (void *)dir_version; +out_valid_noupdate: dput(parent); key_put(key); _leave(" = 1 [valid]"); -- 2.20.1