Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp829447ybl; Wed, 11 Dec 2019 08:08:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwVGPvhbCAyyZkJT93AZcBV7kEEeGKy1mIWMNpkfo9bzJUI8S3EJ40pe3Ukj+rUPrXcJnIW X-Received: by 2002:aca:b588:: with SMTP id e130mr3198307oif.169.1576080487768; Wed, 11 Dec 2019 08:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080487; cv=none; d=google.com; s=arc-20160816; b=kYFFkH3FUpF9fhIc/3Z956/C+jNLgusSWHlTPyZhsmnKDklrJ7bHrRD8coNXhWaQqF xB8bIM9PeZzPSJK9eepHEgrM/R8NjLGXWLc9GDmophcZiFzlvh2BFlRNR8ZFm7sPJpFD bnGo6NaiqWl887iJ9/F+EqQUtjkTydmIhYdJKDFS3UkzUrvE4Mw5ADDYCMHxBwAmz/oQ 2aSopj6KD1ZsKuNoQAteWecBP33kj7FQc5MmtZfrWxbM2m7ZA4bOXdtEjY6TAJJHaT2r E4vTmMvHFvWQ5DnCOHShbHfA7rsjO/gHsUm5eWVWyMTCSzBvvLnf9xgn1HlQig9arKYE 92AA== 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=OpDTi4r3vQlJrdubEBT6iPpGrCfsSJbzfHwHRHFkS4w=; b=tJYea1ECCCDIygO9zHN4W2lu7CzZKPEmpHGS+jcOwB1+59hy9we2qQVIBfKVrkRbi4 8ytwF+wdxS7TiMl6CFE//2kp7xOmvwXu1I0BPYDqL/+G4bMwMZEYG1yszelTu7wjJxck ca9AvUUiLM4v5oUd+Woxr/mPH4jMBkN8cuc1U0kAPdc7rzjG0XmFB1RFNMKS5LA/siIi zhbXw4ZUi+7KqhZUrgD3h8hz+9e6e9WZuToBtBp88suJL8rtJGqshavc1+rhKoiQhsGS pYjte219wuKSbvFnxhLem1vWKQsj5RyJpLUu5RMXxhlGwVtaoZAivIircwMKWBhyp5ZC NcSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pzMfoyfB; 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 t23si1427969oij.23.2019.12.11.08.07.54; Wed, 11 Dec 2019 08:08:07 -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=pzMfoyfB; 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 S1731357AbfLKQF3 (ORCPT + 99 others); Wed, 11 Dec 2019 11:05:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:35148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730855AbfLKPMt (ORCPT ); Wed, 11 Dec 2019 10:12:49 -0500 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 5B66124683; Wed, 11 Dec 2019 15:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077168; bh=AYCKDEj7tCppYmTX/i7HqzmL1YG16MndjEzUSKcYsA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pzMfoyfB612bzquUkTbTtH0MMYZX1WdSzfb6wyROUbdaVjmTKO1sDWLLm7pd1Pzph 7HVI4NI/Jf5nzTMY4Jn4/YE/ICAvkfDzRlLq9aO+AzGjyejcBz1KGwDad5lhGWYETa 1yutuBHx8ons3mSM38w4L4H6fUw2nkE+SbRhemCs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Marc Dionne , Linus Torvalds , Sasha Levin Subject: [PATCH 5.3 041/105] afs: Fix race in commit bulk status fetch Date: Wed, 11 Dec 2019 16:05:30 +0100 Message-Id: <20191211150237.770839148@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@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: David Howells [ Upstream commit a28f239e296767ebf4ec4ae8a9ecb57d0d444b3f ] When a lookup is done, the afs filesystem will perform a bulk status-fetch operation on the requested vnode (file) plus the next 49 other vnodes from the directory list (in AFS, directory contents are downloaded as blobs and parsed locally). When the results are received, it will speculatively populate the inode cache from the extra data. However, if the lookup races with another lookup on the same directory, but for a different file - one that's in the 49 extra fetches, then if the bulk status-fetch operation finishes first, it will try and update the inode from the other lookup. If this other inode is still in the throes of being created, however, this will cause an assertion failure in afs_apply_status(): BUG_ON(test_bit(AFS_VNODE_UNSET, &vnode->flags)); on or about fs/afs/inode.c:175 because it expects data to be there already that it can compare to. Fix this by skipping the update if the inode is being created as the creator will presumably set up the inode with the same information. Fixes: 39db9815da48 ("afs: Fix application of the results of a inline bulk status fetch") Signed-off-by: David Howells Reviewed-by: Marc Dionne Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/afs/dir.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 139b4e3cc9464..f4fdf3eaa5709 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -803,7 +803,12 @@ success: continue; if (cookie->inodes[i]) { - afs_vnode_commit_status(&fc, AFS_FS_I(cookie->inodes[i]), + struct afs_vnode *iv = AFS_FS_I(cookie->inodes[i]); + + if (test_bit(AFS_VNODE_UNSET, &iv->flags)) + continue; + + afs_vnode_commit_status(&fc, iv, scb->cb_break, NULL, scb); continue; } -- 2.20.1