Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp588900pxj; Thu, 20 May 2021 17:08:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydtzxUfcJGv9iC4ns3l6snnw1pUr6leLwzo+ZMJYydGF60Yj1M+u3UpxJHHIdjqX30bVBQ X-Received: by 2002:a5e:8a08:: with SMTP id d8mr8405360iok.192.1621555702518; Thu, 20 May 2021 17:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621555702; cv=none; d=google.com; s=arc-20160816; b=K4uoQFQcHWrdB1ngB1JEzpGMAOoTDD/wmxTaZnMyw1Ix8qpfdXB5YF2z1kL1D63p7w EjFMon5VvPecXqjgBjl1ocm0JoyNoQiwwyzGkRqsuFCB9e2H8vlUB93xNjyeHX88caJo YRUDJZLP89/GGsHbXFh6iEMQW/Neno3SMQnEkbwb9zZEp8ceP/fqcm2vodDTpGwIg73w FVSADYYA7rnSZYkXVq9SDOG2tMm+QgLVKcQMKGAnr6oqR+JZlmWZ0UV6z7/t1PZeDB2B zNYdVyAU4yYrTiRWxdUJ3lXrUxnakXB0t0877NlWqh3aSqKUDWgM8O/6uW6gBGr+yKXk 18KA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pEjPWP6mbngPLL5RImwRlWiVuquE4tj/Gd3cGwFa6nc=; b=N3i0AxfrZLuXk1XmZF9kSyzkxhHE1lJNVTazdJG12nU34BQ96slDcnk3lsuZwtv7gl hm1UINY4b2yrfVxU9DR9ZNUdbb1W305QvDAAwjIC17SrctDxKmifIOkdhR4khwVjCryx gNA0q1MNwZ8QrEXgjCY4MolMWb/otGXopj9k9MyOzuSZ9zIOVBxnfycCIvSPrmFPnLBP k+hhCf7/EJukdOBt4pNiGM0hRhwZ9w4eA4GifmNFY0iqEFlnkjUNTzrFaIYq15RuWRqw awsLirHuTT63zpBb7cc9Yk+G8egcNgRlfA7d25TJIK/OXh5VrXyOu4KQw11wPT10DJrP h6jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rMwoc8yR; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si4457558ill.70.2021.05.20.17.08.09; Thu, 20 May 2021 17:08:22 -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=@linuxfoundation.org header.s=korg header.b=rMwoc8yR; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239713AbhETLWc (ORCPT + 99 others); Thu, 20 May 2021 07:22:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:57206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238800AbhETLCB (ORCPT ); Thu, 20 May 2021 07:02:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 08F9D61436; Thu, 20 May 2021 10:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505040; bh=9giTw0wQ5kVztn1UFDEgT73nxsq2oDRznyPpL6XQJNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rMwoc8yRzbQn1M75bZKfM70TlgqvfYz+gh39vM97L3/TizKunNawskY3LTT/m3dIT e7vsenGl5m/hvj6Rumw6l0SggUJvrYdz0VAvWMTjg2nnWdsic5PiB2Y3ymjLrM1SxH 1Mmj6b8VTqdyurQtQrn+gBDxpKVH3i0H1MPTqIvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 4.9 196/240] NFS: Deal correctly with attribute generation counter overflow Date: Thu, 20 May 2021 11:23:08 +0200 Message-Id: <20210520092115.242539100@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 9fdbfad1777cb4638f489eeb62d85432010c0031 ] We need to use unsigned long subtraction and then convert to signed in order to deal correcly with C overflow rules. Fixes: f5062003465c ("NFS: Set an attribute barrier on all updates") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 6c0035761d17..7a94f5a5f8c8 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1469,10 +1469,10 @@ EXPORT_SYMBOL_GPL(_nfs_display_fhandle); */ static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr) { - const struct nfs_inode *nfsi = NFS_I(inode); + unsigned long attr_gencount = NFS_I(inode)->attr_gencount; - return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 || - ((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0); + return (long)(fattr->gencount - attr_gencount) > 0 || + (long)(attr_gencount - nfs_read_attr_generation_counter()) > 0; } static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr) @@ -1882,7 +1882,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->attrtimeo_timestamp = now; } /* Set the barrier to be more recent than this fattr */ - if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0) + if ((long)(fattr->gencount - nfsi->attr_gencount) > 0) nfsi->attr_gencount = fattr->gencount; } -- 2.30.2