Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3033191pxj; Mon, 17 May 2021 16:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwGwWAlPdd/OxU5rzrjtOTcaDY4Kr8qj/CpRJDZD9e9bjVqEUX1qTMIpw7bDSHPfI8VlfN X-Received: by 2002:a17:906:1e0b:: with SMTP id g11mr2447308ejj.291.1621292668442; Mon, 17 May 2021 16:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621292668; cv=none; d=google.com; s=arc-20160816; b=rO6mU1Ldvmp0ptp3DNOG6NidVS8gUEKtg6UECmZrjl2yRUFG3AKmObVW4pt7kSCD2x 7xnW60LGE/23S0tN9kBEgJMGNEypLhW6FID8wj+kTxT6nT/RbbWiEGB2BX3OYbp21uVB YjCgueNs5Y8IZUwLG9fkZtA4nN7/sltdl2QqJLIvypKzCrRZ9yw2eTgH2WXRw6sWvBp2 95yy1BM9Xh0yZVCdAiR5CoZ4MN6+mWsU8PxUI+K5261kr0f+mDS9OZLB4RTt7Q5EZ6rB NAU8Sx3tkPy8b4BUoDRJNTpA62yY/oPldE6koW9PD7LukSb03DxAI7VBZjrYxVshjlCw 7pEw== 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=s/j8rzFgAEhc9DrAp3A9KvPFcmW2kOlKGbekuC7iFQc=; b=qricLaPGUAMAh8yvOJfjQJDkfTIGyeu3zpH+7xztJ5hU06KBdFT6B+Nyxs33hNzF/F 9CVufiKlamqZ5ScnVz76srcR4wpZfvQURAK5hr3w55qXPH2LO8pf8RACszVwPgVepYoq KEV4inLMVyJF3WM5NPtSaeX1pcX8DjsH+4h+AsE7fQEzDMEwPjTVV9YW/nMXa+AnLDg6 hnHEQxSkPsVeJP+zQ/A2qe9wqmdISzAnJjCHewD5XJAIz3x4Fpua3thIWwVFIfcb9oxa +aD4Dac1oiE58jN/RT7WaemjCwl8GNr3D0siw109oAjQh3TsUfNN8Zc23QIkYFhVhPP5 l+Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="fQj+Z5/d"; 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 au28si11876178ejc.426.2021.05.17.16.04.03; Mon, 17 May 2021 16:04:28 -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="fQj+Z5/d"; 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 S239169AbhEQOTJ (ORCPT + 99 others); Mon, 17 May 2021 10:19:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:46778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238879AbhEQOQr (ORCPT ); Mon, 17 May 2021 10:16:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 005C66140E; Mon, 17 May 2021 14:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260594; bh=4jPGcbGKhWMBX30tJbhPe+aFn+Lc5QNLRXkPjNCatYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQj+Z5/dqCxUSEqIe5Htpw6AX5YUrKZlZlSVZt6Q5novYGMwXHquQyEdUnqZNQBl2 vnY4TRC+qa2UevI737ocPHLe5lJj9qSoLoh5lPNuDDRfO/gGSqj6zAi9RHgaL4lRw4 +0nLEAWVbP3EmDLa2WQGVEQeOUpoL5ltRJxY4B54= 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.12 153/363] NFS: Deal correctly with attribute generation counter overflow Date: Mon, 17 May 2021 16:00:19 +0200 Message-Id: <20210517140307.790428909@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 a7fb076a5f44..7cfeee3eeef7 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1662,10 +1662,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) @@ -2094,7 +2094,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