Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp434866pxj; Tue, 18 May 2021 06:44:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5p9i36wgGMY+XjTIb76rBy02TSRbcGzBCR70LmPtl6R5uuLUbzApWzhE/gILDHre2vv5z X-Received: by 2002:a05:6e02:1ca3:: with SMTP id x3mr4455319ill.150.1621345458937; Tue, 18 May 2021 06:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621345458; cv=none; d=google.com; s=arc-20160816; b=OE4YrlUJ/yLtrwFGhVw5IYk9b/R+6pjaLbmDQPFqDnjs5NRDnfXuc9Gxt53EJu5Qte Ym2mb6tbnW+JOLicKCDekWPlAlikPjhhpaRKF+rPOSUh64FeUZlcxkLJ/X84Ef4D/tOW KYwGWsIhAoClUeTSi4bwjG9bCUQzN8jUicxRF1kPaBffoeeKywFKp5OZSRssZumcr+ZV EXP08KAhDtUzNsNwVHg1+9YiPLZhQ/oe8qZMMCuSizH8yXEnDACWXc6/7TNk45relEhK HUNR6VEiwW8IUb9x2hmWEUKMKsEsADwB9ZAW+zQmhwX9jzoMriN1NKGxij4cf3flV3jF Cb5A== 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=AVHQHXbr1hkSYdBSVF4m5w2zZdhVTOO5jtDsLYTcQp8=; b=o5lqKbRfsQZIQrVSafm29voj0507bJQWWeOuQTo+NV3mui3js13kclUVDlcSdyNL6M rGi/Nul0lcExht+/4trdgBhD44Uvz10WLK7sAgOluNi8u7Z/WmEK4/1bL7ywDa71JiU0 GfFWt3nO4vKAp1sFGLYKSsk3uMvTyc5dZY9Qf5jvnJ0XSoKe0Up/mPkl5EGKz8kUoabK +apjqpobaWfoH94wgrl0rGirnh3ATZn+ahV1hsBpEOi95BSJNGxHmLWHmoBxSLIjLia+ qAtMV55quzjuiijkzxBspWoBbgpLIYZZEUJmni4SsbY37JsYV6/QveMfum7B/mtdcZC9 E0kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qCVghcbA; 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 o67si23564735jao.17.2021.05.18.06.44.06; Tue, 18 May 2021 06:44:18 -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=qCVghcbA; 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 S1343497AbhEQPjg (ORCPT + 99 others); Mon, 17 May 2021 11:39:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:40800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243748AbhEQPYS (ORCPT ); Mon, 17 May 2021 11:24:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B2A9C61C92; Mon, 17 May 2021 14:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262138; bh=NMzwDcfSwN2wMq4QsCBXmYWJuU/T/xGzb/6CKBv3INY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCVghcbAu8Kh30VpCpio4mW/LhR8BhndQmZCSSIdYKBttV4LcjS0VZWGj3gVflNca qzoQdbAs/4znzJNCgcM5Eom1A32nvQ84Z4WxS6zXx2P5QMtjABYofZ8PFW2TkMbLdx lEms5p2klsB1PSnDxywELY83RrEPrw3s+lHJobOU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 119/289] NFS: Deal correctly with attribute generation counter overflow Date: Mon, 17 May 2021 16:00:44 +0200 Message-Id: <20210517140309.171011615@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 43af053f467a..6e2e948f1475 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1642,10 +1642,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) @@ -2074,7 +2074,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