From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6AB2C282CC for ; Mon, 4 Feb 2019 11:08:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D4922075C for ; Mon, 4 Feb 2019 11:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549278527; bh=B2YvBwCut0BcLPs1dU7gya9CXx6DBq2kZevJluPLjO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aONcMbh2y5yQB3ZuraUN3cKY8bzYltBRxftksdLRLVAfRXd+zE/WinATk8t9qS5m8 Fqs+/Hs0ipGAa3NVDzhl7Z+tPamTHVx5E8wwOSdozyTnQfaz1O7V6uBIZIVVAgb3R+ t8IcalhNyj3yusgGlsVr6+dFgqraYbwbhMo83pYI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729603AbfBDKlZ (ORCPT ); Mon, 4 Feb 2019 05:41:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:39374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729060AbfBDKlY (ORCPT ); Mon, 4 Feb 2019 05:41:24 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 913CF2176F; Mon, 4 Feb 2019 10:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549276884; bh=B2YvBwCut0BcLPs1dU7gya9CXx6DBq2kZevJluPLjO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yMQy74RUzi/FXVb/6VFk3r9BqbX6YfpbbeG6YqbKIzzJP99U4xQsA/n6v/c+USAsH /SuwvSVbyz0uUJLq9WG3w2xyz/6ThtGPRjA2iTdOuPJ2kdcF11qKKZ1F7Cnq/HG0Za KJe2CtUGZMyzP3U5VA0gniZB4w4ZqvwSAZ/bdkOM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Chao Yu , Jaegeuk Kim , Sudip Mukherjee Subject: [PATCH 4.4 28/65] f2fs: read page index before freeing Date: Mon, 4 Feb 2019 11:36:21 +0100 Message-Id: <20190204103615.462336126@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103610.583715954@linuxfoundation.org> References: <20190204103610.583715954@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pan Bian commit 0ea295dd853e0879a9a30ab61f923c26be35b902 upstream. The function truncate_node frees the page with f2fs_put_page. However, the page index is read after that. So, the patch reads the index before freeing the page. Fixes: bf39c00a9a7f ("f2fs: drop obsolete node page when it is truncated") Cc: Signed-off-by: Pan Bian Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -590,6 +590,7 @@ static void truncate_node(struct dnode_o { struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); struct node_info ni; + pgoff_t index; get_node_info(sbi, dn->nid, &ni); if (dn->inode->i_blocks == 0) { @@ -613,10 +614,11 @@ invalidate: clear_node_page_dirty(dn->node_page); set_sbi_flag(sbi, SBI_IS_DIRTY); + index = dn->node_page->index; f2fs_put_page(dn->node_page, 1); invalidate_mapping_pages(NODE_MAPPING(sbi), - dn->node_page->index, dn->node_page->index); + index, index); dn->node_page = NULL; trace_f2fs_truncate_node(dn->inode, dn->nid, ni.blk_addr);