Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1320168yba; Tue, 2 Apr 2019 06:49:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqytBtq3MsL5hwkbe0qJ/dJ5BvI5gmsS4kznTtgrY7RrYLH3U57OXPN/TG4//0WKxzSGEGIM X-Received: by 2002:a63:c204:: with SMTP id b4mr66264221pgd.335.1554212962033; Tue, 02 Apr 2019 06:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212962; cv=none; d=google.com; s=arc-20160816; b=D7Cjuag95S/hO2pKgbi1SRjDjOLuuNbsvdvaUoq9tbY5V6TbIcvbbe9AO3YurmbcAu fqBeSOC/d9YesDwcSkkmOYo91OIMk7GrlKvjU1L6IeYEeKIB2Wp2mbKFYTekz0lehZvf /LiMXDsDN5tO3AiCluftfttrDhbTrLc0Jgq8bX0cmdWeY46boVLv5KyfmsCjuAs4TLys /z3D35yL7Nq1dRCcZyFvKjtFTNuprvldhtNtroKOH9sLfNi/m/X1kEmh4ClYL2O0Q0lN KOlr22vXRCr/+OApzNJqyoaBYoSbWfZpf0mpElsBKkU2Yj7vcg7o2AYviiMq8huU8mha 4d/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=8rAA/4AKBxdqAPMYaGhde2wXFJjjWOMP5TtbnNIUB4o=; b=stEb394UNdBrPtP46/5xh9DeJh31VHqfgtjESq9whNu/9pJwFec/kMrj2GybAh4UZl Elubq7nGyhCiZRSAr0/T1jsbQVetrJdx1DDF6WOhbQ91gHlvXHBoQ7rf5njJ0kt4f7kD IstiHCVnVcLCOmK/75vWWG3orUJe76GPkRpQ0BBXZG4isg1jN0VI4XlU9gzf44FxVV9J cOx9jnzKUeEcCUbOmrMu5nZxhUUpFCDyMigjRi5s6bTmq2/O1gJuIZKk6C9KcZwbA6ZH XoboY/wVIKD8tiD3KFEwm6E39NOJPW5dqPZN4VQ88YAXj+bZ1S5brNaOofYvrGKl9+t+ ipog== ARC-Authentication-Results: i=1; mx.google.com; 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 o9si11001187pgv.25.2019.04.02.06.49.06; Tue, 02 Apr 2019 06:49:22 -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; 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 S1732135AbfDBNru (ORCPT + 99 others); Tue, 2 Apr 2019 09:47:50 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43038 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731387AbfDBNkE (ORCPT ); Tue, 2 Apr 2019 09:40:04 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdv-0002ml-3v; Tue, 02 Apr 2019 14:39:59 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdu-0004ri-3x; Tue, 02 Apr 2019 14:39:58 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Pan Bian" , "Chao Yu" , "Jaegeuk Kim" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 16/99] f2fs: read page index before freeing In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 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") Signed-off-by: Pan Bian Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -509,6 +509,7 @@ static void truncate_node(struct dnode_o { struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); struct node_info ni; + pgoff_t index; get_node_info(sbi, dn->nid, &ni); if (dn->inode->i_blocks == 0) { @@ -532,10 +533,11 @@ invalidate: clear_node_page_dirty(dn->node_page); F2FS_SET_SB_DIRT(sbi); + 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);