Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5581974imu; Mon, 26 Nov 2018 02:30:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/XSCIB14lhnf2m+KB5/fgDDqvp0+Be+8OnbxrjV4khgPAS4tOUSuBbUCD17/A6UnYxJQz1S X-Received: by 2002:a17:902:108a:: with SMTP id c10mr17965836pla.131.1543228208636; Mon, 26 Nov 2018 02:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543228208; cv=none; d=google.com; s=arc-20160816; b=bTueg8jeBawCiM484QmrJUCnd+cMOlvFqOZ+A3EcLWI3Fj+iekxTdNprzat7qKQ9W/ xu8HTWhgyJ4y1brtSg70//ue/ajWSVPMQWEtUpD2CXp1uPKR9Fl1QCFJO2JRjvUBdOeW RUkg9e6eFq3voRwsw3sDNa5MbuDQFcYkvYpZmz4RzwwB1OwDBHFngDHMvo9+gjaukosz c7I/uf+QH/xwqwMXHYst686UmlUv63ujBqGPsKf+HMjCYS8K6t6Kio97Xh1qPM79LLbY mOF7yxsD4JbDcA1jTMOPjT2bhsef8jktA+nyvfFjmF8aNDzidwxzRQfnx2iAten7CI2W ZBnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=ux+U8wyUJnkvXwjYrMNcav6pS2oNKzFZtSrs7WkdOFA=; b=M/U6uZJN3CkrLEnQsOe+CcX6kNeL+mVWUzWhfzXr063aWlLyrt7KLXmojKk/0sunoM d6p/O+tQ8ZDgQfcnDT5rIy0JzDTP40tGIUMdkY6+9rqp3DqJNK3ubIVOxmHJoM4Jb7rS TsiPJ4zSiycHrDFpdtXGcz6ChSrFXxcwsUxzBoUkf/BMSpP4i2xKj/pRBWDDCREXXHUt zG9KHt+SKJVQYqUENi1VQxDjU/wEzaR2XBwr8bbjwL0c5xZ5VtErvUPG+lL57ueBaF1x cWWVAPePkGBJtPWXKHauAObGBzrABvpHI/bRg/NELf8TQk6suCNlrMeXl7W944xl7P9Y nPrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=JtTVm0Tj; 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 q61-v6si63464460plb.418.2018.11.26.02.29.52; Mon, 26 Nov 2018 02:30:08 -0800 (PST) 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=@163.com header.s=s110527 header.b=JtTVm0Tj; 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 S1726355AbeKZVW7 (ORCPT + 99 others); Mon, 26 Nov 2018 16:22:59 -0500 Received: from m12-15.163.com ([220.181.12.15]:41827 "EHLO m12-15.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbeKZVW7 (ORCPT ); Mon, 26 Nov 2018 16:22:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=ux+U8 wyUJnkvXwjYrMNcav6pS2oNKzFZtSrs7WkdOFA=; b=JtTVm0TjolTbTmSGG8VHN h7vKf5cFivxQvl2KIgpFi0eDQM2gO/svMYz3Ffz2cQHRSaxYKjcBerttX+GwUJ4f racV8kM6Q6iG87RxEIYOJCVwFfYkZh3lGQRxLQXeuHZ4MjrOh9aBXEavqvrtVtxu SLiyOp/50Rxl/Ot7otRjTk= Received: from bp (unknown [106.120.213.96]) by smtp11 (Coremail) with SMTP id D8CowADHSyXYyvtbY+obAA--.923S2; Mon, 26 Nov 2018 18:28:41 +0800 (CST) Date: Mon, 26 Nov 2018 18:28:41 +0800 From: PanBian To: Chao Yu Cc: Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] f2fs: read page index before freeing Message-ID: <20181126102841.GA94853@bp> Reply-To: PanBian References: <1542884326-74903-1-git-send-email-bianpan2016@163.com> <3ebe6814-586e-77e8-52fa-47fb61d760f5@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ebe6814-586e-77e8-52fa-47fb61d760f5@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-CM-TRANSID: D8CowADHSyXYyvtbY+obAA--.923S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jw4rAw13Xr4ftF4ruFWfKrg_yoWxKrc_WF WvqrZ7Aw4kJF1fGanxGrW3Xr4FgF45Xw4kCrWrtr4ft3yrJ3yDX3srJw1DXFn7Ww42ya47 CFn0ya10kwnrujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUe_9N7UUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiDhkLclXlpmw9vAAAsV Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 05:13:53PM +0800, Chao Yu wrote: > Hi Pan, > > On 2018/11/22 18:58, Pan Bian wrote: > > 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. > > I notice that you found another use-after-free bug in ext4, out of > curiosity, I'd like to ask how do you find those bugs? by tool or code review? I found such bugs by the aid of a tool I wrote recently. I designed a method to automatically find paired alloc/free functions. With such functions, I wrote two checkers, one to check mismatched alloc/free bugs, the other to check use-after-free and double-free bugs. Best regards, Pan Bian