Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp382263pxj; Thu, 20 May 2021 11:30:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1Hh3sB0QCKlcmdFFPBYJwcgn++1Z8IKF3ylVjYshb37CWPQKvS90ZbIzbowx5XKwi5V5V X-Received: by 2002:a17:907:10c7:: with SMTP id rv7mr5994871ejb.125.1621535411332; Thu, 20 May 2021 11:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621535411; cv=none; d=google.com; s=arc-20160816; b=bD3FGDvKAnVjxy6FGOLKNvFCDBOK8lV/b/hR1o6zxDo4415saKfSN0WUMIR5RXSTYc 6B3ViOSxjUXQGnhbOWvCaHDRMCT1ZzCZEZT0A0FBKpvVXCoyDlotpulnG/Obs17hBGeN o1yDK6KxMJXQKYDSM8VfThK5TASXlZalb65r0nm/sGUfWE8DJgcEnpJGc04wr0CK7Zxi zh58cn/JYzpEf9loNZ7KP8IqX7htVabaixHBIk9DvWQRCg5+z9HSohWK+JWkO6K++FtS YYdjd3nWHuOo9bk0d2uRyhe6NyLFIoo2jgqMzKwOq/KL+SImsTXWQ1KGc4LuWgOdRa32 7low== 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=9e8ccz33pr3ZmZqgKcKDARm6zON/N+I5x6Ovq5MQ6ys=; b=nsXeRsOIPRHMPKjjEK0dgLTN8Scke2MhZc/9Wu4DUDFsCSezZ0S69MPysyrJK4HrwH MlXF+qwWmqhzpa0PPrXUXFgQqP6ntbtbUWE9CuR3uOX6Za19qhgAA+/eKC+Ikq2cydAR eU2JdYrHe4QT/y/YpG7N4tn4xvLrTdy0kjmEfyvztV9qtCY6JPQPP4pfSRbb0dMBBIto 5zd9L3BBdBzuFcOGeyx6aPG0DmeqAomPpo2rgDU7c4bhwOLnbseI4QlQij1OESJEpR/9 CRFmV6VJXbV3W/OpE5D1C2M+Hwxn1GywS3aXVU5p73NP/lo9Mwaj1zrgQJ6zpKfDS6pX r3hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=skngE6Jl; 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 b13si3414932ede.603.2021.05.20.11.29.46; Thu, 20 May 2021 11:30: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=@linuxfoundation.org header.s=korg header.b=skngE6Jl; 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 S235468AbhETKRO (ORCPT + 99 others); Thu, 20 May 2021 06:17:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:42256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235661AbhETKHZ (ORCPT ); Thu, 20 May 2021 06:07:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6416461943; Thu, 20 May 2021 09:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503698; bh=3815qEHAbsf9QKNsQXwevPPBvPISNLP1EHcAZmzPt/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=skngE6Jl/D0LcIOa5bt1Wz72JqpDoxsPovtQTZF8m7hIi1cqWt8GlRF95QBDjfgtS +HO9S3lX503wfvjPySzUfeiMTraNhW8X0ZerDFS2cjRg6vDefsJwi0S0EUI44oUQMw RmupmHF4IUjBWFklukjKjS4SCzzfKbH89e3j7LuQ= 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.19 340/425] NFS: Deal correctly with attribute generation counter overflow Date: Thu, 20 May 2021 11:21:49 +0200 Message-Id: <20210520092142.591109291@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 aee66d8f1330..dc55ecc3bec4 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1607,10 +1607,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) @@ -2034,7 +2034,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