Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2700121pxj; Mon, 31 May 2021 08:33:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzez3SHJEZhAxQkl8OMeTb2M4DPabpHk1MPGgzhEYg7yo3TfCuDH/jwrFmF6JBPGgpjHShf X-Received: by 2002:a05:6e02:1c82:: with SMTP id w2mr18905436ill.15.1622475223817; Mon, 31 May 2021 08:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475223; cv=none; d=google.com; s=arc-20160816; b=xtQbc5pNCZ97d9R6Zv/atPp7KpmroWdGnzRWeiIsmVLb6l0w2utVxP6Sh3AuhgjRaG xpZIK0sI8ob/E5vsMAB2DAOoX4wuM9g//SZPgITXAMlWn+Qe1W7uiN3UHWUIFPb1Innm xMhgfzoU7mBCR9IgwgPAgsjhHvyS+PPXe8sQLJE1cf/HanAbQ7qFx7x8q1nXNP+BdCWf Hj8M5hWHoxCzh9YHiYwpQw2VZkE8J14giWqBBWD5r8UhZmgu8O7NLq8/KCGeoxRgnIbq MIpGB5E4RhN8u7UsFnr2VEMetjzg1hmEEJv2xuGQbdISeZHouxaNL8rRWBcg1h1/oUSd c7IQ== 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=X+M7Vwl0SXYIxh11N+C5LShYzJOkxE5QT4CCBgCuxYA=; b=M7RouxojH0R/xx1DiIT37qMR415+yfaGgDPbcxgAJthAs2/rybAlfoKoW71YuqY/8X lWnTzQH1qw1oets8aVhaxdvs/oePj2R4mtPb5+uZ6HyaJ3t8ISaUX1tHJAPQSaP4PmTk /2V2hhvbeOwWGAwpqKSPrZMY0ZN+amgRBaPAu1dmN/r7CVQCNWQsWKeHAChI6l42iOl8 jgVN8iK57yxvLBBesoYq9ZaIKYruiUdt63yhsy0h9n1ABfGDrplv1+dpXfOh74eSmK1N SNtSjzb1FK7e5p7o67fNSe6d10S3f6FWmTvkYLsoYsSGzv6RlRr/++KXHJvH5OG5+Oyv 6WFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CrDPgQvx; 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 v7si14268884jal.113.2021.05.31.08.33.29; Mon, 31 May 2021 08:33:43 -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=CrDPgQvx; 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 S234682AbhEaPeY (ORCPT + 99 others); Mon, 31 May 2021 11:34:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232141AbhEaOR7 (ORCPT ); Mon, 31 May 2021 10:17:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9C4976141A; Mon, 31 May 2021 13:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468639; bh=gebbVy1Mm2m3Q7MPVEAdTF1Wrgd19Rx2KcBF/R7+kZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CrDPgQvxlhzBtkMp1qprYJfC550hNY9QT4EFA0eTWyP71LzB6Fm11q122zvjBbVfK uLUr6LJGayjd2vbJ1JbbWDb+3H1xsiIBERhmcWbaUUcHrcQL6CXkm+5honvfuSdWsr DfFsW7EcOYjZJ8WZENiMW5lSCGVGvHttYO7BK51s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.4 068/177] NFS: Fix an Oopsable condition in __nfs_pageio_add_request() Date: Mon, 31 May 2021 15:13:45 +0200 Message-Id: <20210531130650.251963044@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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 commit 56517ab958b7c11030e626250c00b9b1a24b41eb upstream. Ensure that nfs_pageio_error_cleanup() resets the mirror array contents, so that the structure reflects the fact that it is now empty. Also change the test in nfs_pageio_do_add_request() to be more robust by checking whether or not the list is empty rather than relying on the value of pg_count. Fixes: a7d42ddb3099 ("nfs: add mirroring support to pgio layer") Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/pagelist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -986,15 +986,16 @@ static int nfs_pageio_do_add_request(str struct nfs_page *prev = NULL; - if (mirror->pg_count != 0) { - prev = nfs_list_entry(mirror->pg_list.prev); - } else { + if (list_empty(&mirror->pg_list)) { if (desc->pg_ops->pg_init) desc->pg_ops->pg_init(desc, req); if (desc->pg_error < 0) return 0; mirror->pg_base = req->wb_pgbase; - } + mirror->pg_count = 0; + mirror->pg_recoalesce = 0; + } else + prev = nfs_list_entry(mirror->pg_list.prev); if (desc->pg_maxretrans && req->wb_nio > desc->pg_maxretrans) { if (NFS_SERVER(desc->pg_inode)->flags & NFS_MOUNT_SOFTERR)