Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp874488pxk; Thu, 17 Sep 2020 19:59:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwozYMgeYRS61DMhOBz6WJhy/D9VV/bVr5B5tsvSbrMepjShbjvz8PpY2zKeQptqGSLlqRN X-Received: by 2002:a17:906:14ca:: with SMTP id y10mr11197440ejc.542.1600397951344; Thu, 17 Sep 2020 19:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600397951; cv=none; d=google.com; s=arc-20160816; b=xQkpVfAD8GtKyZSJ1LlDsQoWFxPL7K+hFjHOPFlt8I2eKEWq+ziH2hoBVwyNmm6rt4 TvnfI9doEeD979K6LXBrCdoKem3xlh5UPgVJqFxKJ2jRSMbQyEUN0ne/uFb86u+DeT6U e/fwiWaWj1G8uj7wqrJOouckhRetLfilELU9wH+LQKN4jEAcb2vgYd5KbXeDE7iBaXK1 9Nldz2AKkno940B49JIvK844VljtIDoETaRBpQ0E5YRHU4e45iG7IhXe80HSbLn60Au/ 6eot5WfpTu+S/jSLY8nIJrOMDn0jxzZzjew0SIcAzHOKsrFtdMIcLmtEC95WIYGWeUfD utDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wue75Tzwt5eYZFzg1JMsQijbLgqV9xEy30wWAHAGNNc=; b=TOTV0V818Pj7g1B0akrdRH8F8z9GeKZAm7mlIle2q2IFHo8Tz0s3cfSDgcHw/mhW3I 2k9HzWVbT69KdVgnk+ZaRUlmlwv2C39anNsJvs6K27eUDywbsvSJe6IIa0lmyaBGG1NW XJPJSDKE+6FADPD737SnBUuJK96bebnmGUbaNChDzE1/uOMVYwj7Wlt1gP5LmibfTTkz Qnxv9BztNw2RoiZuzd1ENwUjfdBuOcAQDl98Vq9iUwSZtCk1iUOVZ/bBSepJBKp3a5Hu h0D27BgbK5vglyNpPSeEJreDj1e4JisD65HAyKkE+tBV1UlcaGJMy7roVWwVC0Dl+sSa 2NFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I+0yJ+Gk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si1231102ejj.566.2020.09.17.19.58.48; Thu, 17 Sep 2020 19:59:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I+0yJ+Gk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728601AbgIRC47 (ORCPT + 99 others); Thu, 17 Sep 2020 22:56:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:56484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726605AbgIRCGt (ORCPT ); Thu, 17 Sep 2020 22:06:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AB002395A; Fri, 18 Sep 2020 02:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394804; bh=DE7SCW9moeshv/1VrDqcJQRsTInKF3qjHMUPLCrLqTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+0yJ+GkAH7GamIOMtNO54gSI2ffqV2cGIU+3bbv7B6ge3gE3RjMSAShLOfFj5Elu 9jNSru6MhbtPCxI5M661Y1y3a7QisQtrN2M52IY3PQQEs8ShKCnBZyvtByqPRlt0SV pKstWQyjnOoMnUYFG6bbglO3wlPdGMSguB0KNxQ4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Miklos Szeredi , Krzysztof Rusek , Sasha Levin , fuse-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.4 273/330] fuse: update attr_version counter on fuse_notify_inval_inode() Date: Thu, 17 Sep 2020 22:00:13 -0400 Message-Id: <20200918020110.2063155-273-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi [ Upstream commit 5ddd9ced9aef6cfa76af27d384c17c9e2d610ce8 ] A GETATTR request can race with FUSE_NOTIFY_INVAL_INODE, resulting in the attribute cache being updated with stale information after the invalidation. Fix this by bumping the attribute version in fuse_reverse_inval_inode(). Reported-by: Krzysztof Rusek Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/fuse/inode.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 5dca643a257c9..f58ab84b09fb3 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -323,6 +323,8 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid, int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid, loff_t offset, loff_t len) { + struct fuse_conn *fc = get_fuse_conn_super(sb); + struct fuse_inode *fi; struct inode *inode; pgoff_t pg_start; pgoff_t pg_end; @@ -331,6 +333,11 @@ int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid, if (!inode) return -ENOENT; + fi = get_fuse_inode(inode); + spin_lock(&fi->lock); + fi->attr_version = atomic64_inc_return(&fc->attr_version); + spin_unlock(&fi->lock); + fuse_invalidate_attr(inode); forget_all_cached_acls(inode); if (offset >= 0) { -- 2.25.1