Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2655967pxj; Mon, 31 May 2021 07:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7tiGFwCaBVwzfdmF/vGkwd+uCoolHJ9aj+hyYGcTsm1tNbiudJ7HSnxjABn59EBsx4QvU X-Received: by 2002:a05:6e02:1a68:: with SMTP id w8mr18184512ilv.122.1622471522560; Mon, 31 May 2021 07:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471522; cv=none; d=google.com; s=arc-20160816; b=DI4780fHKfWBZ7mJertb0LTP7FbtftpNS3Y9paTtfZrZs0F1j++D50hDD0jI9YJWJc 0mYsSuyGPiSzYchw+OshXiSNbd/R2K53leZVyzU64pZhfha0wP8Jt/Um4OPmb1zeQjHU jCqYlVMr35bltVZvX4QabhDiBfJVK22l6m+X7XWrKVO5dErBcQeyS9mtbXA8YF8mLi6g v3RIdkCflfjWuLYtbBKGkTBsg8Bppzx4xG7BAY7MxPc+zAUMUzsRzXrQ+WmMOzQa6gzZ WpG8lq++kYbKON+VXMBatvcBlZjtiouuegjfohxNolEcTmEfPFjTt/e4CfZ+3ZZdJCeM LRiQ== 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=zp9W/ENsbI/3ay6HZvth6TaRJ1A3F7YXqjvJFT+eOU8=; b=EiMswQLk8ZsAFePkAIhiRcXPAYpKzrRo0fNcDWMO3aXw8TYuuTOD6UI073Su1rXuWA idSzA5jf1eBv7fLLqF6nS0lTm3VySCzHzFbBu6ZTXjIX0e3YxdDc+J2SF9DUK/IWxn9Q HPjKSLa3AKHU+LiixN6KMxNa/RB9+vugBU8G5xDrlrwvXJV11UvjGErlCthqu2JIUKat geL2Rf11HRiLg5D4T53cLZPLa8eCL9jVZrIMrCUopAz7RfVQGn5LNSCQAqA+oyXTuq/h i27IrYeKnZbtWooUPyeHez1BH1Qw/F0LgGFUsu7Di1qQVO+VgcLvKwtEMKwoIGdua7XI nQDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zrTaPjfz; 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 r21si1117641jai.29.2021.05.31.07.31.49; Mon, 31 May 2021 07:32:02 -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=zrTaPjfz; 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 S232416AbhEaOc5 (ORCPT + 99 others); Mon, 31 May 2021 10:32:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:56076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233194AbhEaNyt (ORCPT ); Mon, 31 May 2021 09:54:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 36EAD613F8; Mon, 31 May 2021 13:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468035; bh=HvEV8rv5k3A5x5JzTug7RpZ58CxkXYwa9Jnzi+dxA0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zrTaPjfzDJKEylXDf25NYPZMS4aE65zUV1LOXNL+pqW3qPGCeCfTaFfChEFe6iNfF 9LGTo/CblDbTsZSUfLv2Eltdy+FyvALdzniboGue6I9jZifcXPGK7h4oKRXXvLyoDq P7PAYMRnVKMF9YVChtFh+YDDErxZ20/YHAnI+t44= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.10 093/252] NFS: Fix an Oopsable condition in __nfs_pageio_add_request() Date: Mon, 31 May 2021 15:12:38 +0200 Message-Id: <20210531130701.125103728@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 @@ -1094,15 +1094,16 @@ nfs_pageio_do_add_request(struct nfs_pag struct nfs_page *prev = NULL; unsigned int size; - 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)