Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp638701pxj; Thu, 20 May 2021 18:39:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwuIbyvR20FeBcoM7kx1Vu6LdeJ7goIzh+/bRxjBKKmJDGjTkvC4wT88FGlgloxv9MXcBm X-Received: by 2002:a92:340a:: with SMTP id b10mr8314613ila.301.1621561163604; Thu, 20 May 2021 18:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621561163; cv=none; d=google.com; s=arc-20160816; b=lK1egna8rQoUfOxCs4dcYh+SUdeWSrIQZy906Fwz23BtoEFQUOTLVH+xQJnAgMpBMj 0Gj3VGIvK1h8h9/HvC/PVpm/bI5UvjqADdFwp71pku6eoEdtLtCwqpokw7TqPdOub/ir utfERLB0aEcknU18iCIJ3CGEcX6SVJ/9rEC/wTQ36SteYDalnMy5OdA42hfkiX61jcO0 RtCZgLpcL8u9Cxzs9hJ2Q0a80Ci7z9Ye7laXhpcP5DBP5pWHDdaCUIFsugrLc0TtJubw aAFvDr9Ri3zeOIL+lB08O84ARf4p5mUmFGJY4ypjpz1JCuYvwd73mf9w9Ma1wWSeelVq 63mg== 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=2wZiABwHtIfT3t55tcI1S/WwfDwjvEWXDEN7kR3q2Lg=; b=WE/oyAxtPcFzggMxN1u96ThL1eWKqpLtsD7uVPzL9LRqTl7B7LBhnPbpKN0yvV1ovd dLsaVbuLxyTAfoOPtABA2xJSt0lyHptUasxAi6xufukcFoYfp6wnuFkQkp/Wj1ZrVbxS 13d9+Pzm/Cp9IraKHrAMe9VZ3QqXgnWb7vd6h5lelIcdqTYFUkEvaGGRXwOFOKGS4bc1 lFODfLVu3MLNqWBghAsHtNEoYvPhvPMdIs+XrelEhb5Zzmnia8veEQ6C1Ux/jbOC9NdF t/H4kjgtGBWvfnY/0WYQH/kbRgxpp9YMQPHajOObvNQSE9hKF30NhLGMI3Hwca6vy/Ch JQmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zZGIVcTx; 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 y7si2934949ill.0.2021.05.20.18.39.10; Thu, 20 May 2021 18:39:23 -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=zZGIVcTx; 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 S241818AbhETLpv (ORCPT + 99 others); Thu, 20 May 2021 07:45:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:43606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241425AbhETLY3 (ORCPT ); Thu, 20 May 2021 07:24:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B9D361D94; Thu, 20 May 2021 10:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505557; bh=X98kDD5YzeB93LeO0GdNS9gBYB4waJOgja3tMwkSTDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zZGIVcTxr6A3VD7MmWBpcBRraEUd8pih/i63e2tPbKz3SHL5FZRjYv6g+bkLIBRdZ 4XppUeLSjyYXKDmvEHw7OcNA45b042UXNFiNM6WvDsbEuvg9X7JXzIPtUAwOpWtZHA OuQWnIp2YFGloIoHjNSGy8LEg4vu6Me4sPDrULqY= 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.4 155/190] NFS: Deal correctly with attribute generation counter overflow Date: Thu, 20 May 2021 11:23:39 +0200 Message-Id: <20210520092107.293744130@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 b15236641191..0d7b8c6e1de8 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1430,10 +1430,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; } /* @@ -1849,7 +1849,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