Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp652184img; Fri, 22 Mar 2019 05:59:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOmet2GOEzJIS5/c4wWYoaV1mGn1494ajzpLcoQ0Xim607Us6aVSvuz8+ZZIhtuMDZUdQF X-Received: by 2002:aa7:8b96:: with SMTP id r22mr8971793pfd.223.1553259564557; Fri, 22 Mar 2019 05:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553259564; cv=none; d=google.com; s=arc-20160816; b=VPGEUSsr9YoIk6wj8W8KiLtBXXsUhdiQbz79JSUyERZAYrTG8xhL9a40dzR4FGj5eQ nhJBCdzE+hinZnQChUod2DxHxNymwU2oM9zwgpM5RlmA0r2+dz2h4tDulX9Uv5qi0Bm4 wUptSIYz0k7I4O7FL5JypRjcQeRFU6/mXQLlg6nifMvMLgtiZohlDb8zwn2uHVDBnafu kfnTlp0A61jWi6l5NvGBhtylBgxVodD8OMGvFKGMNWApoDhwcg2Wtukc/iLZ7Lsul1As AkxQdiBN/b1zpUA7WAdxbQumcaUHSPmy/YKGL+Z2Bk0V5ucMfHpxzxdvMedE9LrFt3AD jAQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2LZOG79zDnJbor10dSePLXpABnTAxPb/I0dyP1km2mo=; b=zjF4yaBSRJ4gFAQ2v3Sgp+5fVuGxjFvfK7Vu2teGx15tCpbbDc5GEfUu5Bv8gaGOE9 QcKhfUMpNTTyg6DoXNMnuYCV0EEk1L0rreaH1VsOi4u4nyMGF/Ar0H9tl+THXr9AP87U zlBsfikW3bvX0KrNu0nGRWdAg/jvyRtobMFuE9zmrFe0+CX51gcyTFifQXsjyKHlcXA3 6XlC8DUpU2FVEA7Hlw9g2CC57SWv5YFSHJ12jiY/TwngaGO+HxV8xk+Zk+GsZ+gPIal0 hBYPXEpOYKnaNIkrXcnPJy2FUoNvMn7IiMFj5s8rHiZiyqV9pYw81DQbav/gG7UiNXnJ XuLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HV5e6dV5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a40si7362471pla.234.2019.03.22.05.59.07; Fri, 22 Mar 2019 05:59:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HV5e6dV5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732162AbfCVLrU (ORCPT + 99 others); Fri, 22 Mar 2019 07:47:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732158AbfCVLrQ (ORCPT ); Fri, 22 Mar 2019 07:47:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D30E7218B0; Fri, 22 Mar 2019 11:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255236; bh=TwIzy3FxDzvZ6pJLMHZe1ospJvhB/racGeR8Zebyndg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HV5e6dV5jGeZUDT5n8Ip2a+mqKWN2AlAbMVigk3xCaG38oFlevPmYSTedLmbLEuNq etMcY2QFZTkfnTahDP8mT0Zb9aV5TGjvnQEWOdWk2aqMsXdLX6ODgKKKJ10k2/HASM jh7hA5neDerCp/6+sMu9KHSTFyoH13SVZGoDgX+M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Coddington , Anna Schumaker , Sasha Levin Subject: [PATCH 4.14 028/183] NFS: Dont use page_file_mapping after removing the page Date: Fri, 22 Mar 2019 12:14:16 +0100 Message-Id: <20190322111243.784596897@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d2ceb7e57086750ea6198a31fd942d98099a0786 ] If nfs_page_async_flush() removes the page from the mapping, then we can't use page_file_mapping() on it as nfs_updatepate() is wont to do when receiving an error. Instead, push the mapping to the stack before the page is possibly truncated. Fixes: 8fc75bed96bb ("NFS: Fix up return value on fatal errors in nfs_page_async_flush()") Signed-off-by: Benjamin Coddington Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/write.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 2d956a7d5378..50ed3944d183 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -236,9 +236,9 @@ out: } /* A writeback failed: mark the page as bad, and invalidate the page cache */ -static void nfs_set_pageerror(struct page *page) +static void nfs_set_pageerror(struct address_space *mapping) { - nfs_zap_mapping(page_file_mapping(page)->host, page_file_mapping(page)); + nfs_zap_mapping(mapping->host, mapping); } /* @@ -994,7 +994,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr) nfs_list_remove_request(req); if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) && (hdr->good_bytes < bytes)) { - nfs_set_pageerror(req->wb_page); + nfs_set_pageerror(page_file_mapping(req->wb_page)); nfs_context_set_write_error(req->wb_context, hdr->error); goto remove_req; } @@ -1330,7 +1330,8 @@ int nfs_updatepage(struct file *file, struct page *page, unsigned int offset, unsigned int count) { struct nfs_open_context *ctx = nfs_file_open_context(file); - struct inode *inode = page_file_mapping(page)->host; + struct address_space *mapping = page_file_mapping(page); + struct inode *inode = mapping->host; int status = 0; nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); @@ -1348,7 +1349,7 @@ int nfs_updatepage(struct file *file, struct page *page, status = nfs_writepage_setup(ctx, page, offset, count); if (status < 0) - nfs_set_pageerror(page); + nfs_set_pageerror(mapping); else __set_page_dirty_nobuffers(page); out: -- 2.19.1