Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp460419pxj; Thu, 20 May 2021 13:29:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziUVBBCsRA1Ns8zWATEp45kjd8aLr8qhPFpE9CC9VkJ2tLS+I60GZDwu9/SF0JhrIsjANM X-Received: by 2002:a02:1989:: with SMTP id b131mr8493874jab.54.1621542548891; Thu, 20 May 2021 13:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621542548; cv=none; d=google.com; s=arc-20160816; b=eIogoXAMhe6vyRDO+V53aC/pDAgUK2MmF+jVBsk1pKdAJcMof1O7AO/FHYC/b6hUC7 19xR3012Wig3CIFtehYfFiJUJh9gU69NWffZF+Ikk5Bom7I9n4OgfFAOOKhzREY1sQ6q yLC9jboRNZWs37Ox6iOZbDROsn0dlCujPQk89QUhrnKN8wxPrVbJhOQVArDeuo4dRxKJ pk6hTNg+2EH0Lzh/Y6hhXDy/d1DC/92ELVN3UcF3n6nfas3h7qpXyAl2cL/BoHswrSYx d8sJK0aXebe2oAElNb8CXO+1OpHE7m5NkyFXRqhkXvdGg7ASCFsamAwnHvorURe2J5t3 IUvQ== 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=5wxYKnkn0MgWj749aWN/zq6pTMGD1fIuFsmZHF9+j8A=; b=nPAw2IPP6VRitzF8Qfmi9wwtQA0qLctJNvYksJQRt+E7upIm4784VxV72jbt4gg4A3 wT0FR8bLKNlldtrI89ff/0a5fYGbjbNo3gJH9xv+3YU2ggbD6HazRP06QLf74BLTZ10n G0c/z+z8YzUG8v/zIjBRaT0EwzC3Kb1vNNNVjd+CsF0KmIKCUTfKQtzDX0XSGEwFV++h B9R5SN0dmSWzgetbJN3eUzNoLvtduoXhxu9Z//8REU3Aly6K7TF5ZQ4jgP6H+gTVD9I3 CtGQLsktYh0mlLbUIZe/9tfZ+eLspgkPACDkEyTvDBuLq403SLY5f2OpRSOpFW6Kyzcc i1Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wg1ykS8+; 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 e194si3429576iof.53.2021.05.20.13.28.55; Thu, 20 May 2021 13:29:08 -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=Wg1ykS8+; 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 S238785AbhETKxa (ORCPT + 99 others); Thu, 20 May 2021 06:53:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:39858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236934AbhETKhy (ORCPT ); Thu, 20 May 2021 06:37:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A80361C6F; Thu, 20 May 2021 09:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504479; bh=nKRRezXCNzgWtS4yO3a5DHFve5ywiTt0seCMUzkIUKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wg1ykS8+uB1Rf88wlw+M8blaLV4sY0KTaAAzHb+d8DV23ih0jgygOtCegkuvr8NOz tjC11qTPIicLOVpUCDOPLU7sTl6YLbcyZOW9a4Z45B8Kx+ncmT1XJb+3wgJxv4KmXG bKerfcZ+srAEjLWwjZPXT4F+EHJ3iqqyPfbuFosM= 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.14 264/323] NFS: Deal correctly with attribute generation counter overflow Date: Thu, 20 May 2021 11:22:36 +0200 Message-Id: <20210520092129.265612512@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 f0534b356f07..33cc69687792 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1533,10 +1533,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) @@ -1939,7 +1939,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