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=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 21DBDC433E1 for ; Fri, 21 Aug 2020 16:19:37 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EA46822CF8; Fri, 21 Aug 2020 16:19:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="hQipDYKa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="i6JZQ/wG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="LCdMu8Oi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA46822CF8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1k99lQ-0000sQ-Eg; Fri, 21 Aug 2020 16:19:36 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k99lO-0000sD-NZ for linux-f2fs-devel@lists.sourceforge.net; Fri, 21 Aug 2020 16:19:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=F28S4Ms9MZBN4P5PjpooJenn7++BbwU4zPTsNhMcFoc=; b=hQipDYKaVVRY53JKi2P2D3K0nZ 0d+se8ETxUZ8yytzEloLbmYMpzDhHcupdRNwZvMPr6OIawseIScu1/wGnIpVR0NQ3wQhixB8nHNvX +POtk6xe9t94Rq5ulwAfuwnPadtdzsky8yeakKsE3Hd/weCjauZhnOGG0f8qZ91lNZ8k=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=F28S4Ms9MZBN4P5PjpooJenn7++BbwU4zPTsNhMcFoc=; b=i6JZQ/wGQkNfVlUIn7SzofeSCx XKHkNCle/o5HmWKqhntibrUmxBHkcGJ22ThWFNYwkyutK7Yhe1G6zbSOnbB4yFxMklzJrtyLrrygx aWI2jroTNVAsU+x1GfV7REXbddRAZDiXWxW2aDYtxcrUoUQE/2QWAM01dEhUEIh1bmCQ=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1k99lN-003I84-HI for linux-f2fs-devel@lists.sourceforge.net; Fri, 21 Aug 2020 16:19:34 +0000 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FA1020FC3; Fri, 21 Aug 2020 16:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598026768; bh=x7OVgJvlaRrLCQacPk05iX576FtirOsPaf9wehDa5GQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCdMu8OiEeVjm6dslMfZum+s0EZ6096SG8kGXbDlNZ01H4026etZMklUkvryfRIec FXk4c9FWU0yjLBPXw6EFDmxdg9HnWFM6cdnOyj+2dZ0OJFDwBkkQGZFonazwyeg18c SoiEQRsIXouXvv7W0VfENWNT4roztd9suy5kkt6o= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Fri, 21 Aug 2020 12:18:50 -0400 Message-Id: <20200821161857.348955-23-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821161857.348955-1-sashal@kernel.org> References: <20200821161857.348955-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-Headers-End: 1k99lN-003I84-HI Subject: [f2fs-dev] [PATCH AUTOSEL 4.14 23/30] f2fs: fix use-after-free issue X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Li Guifu [ Upstream commit 99c787cfd2bd04926f1f553b30bd7dcea2caaba1 ] During umount, f2fs_put_super() unregisters procfs entries after f2fs_destroy_segment_manager(), it may cause use-after-free issue when umount races with procfs accessing, fix it by relocating f2fs_unregister_sysfs(). [Chao Yu: change commit title/message a bit] Signed-off-by: Li Guifu Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 89319c3524061..990339c538b0a 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -782,6 +782,9 @@ static void f2fs_put_super(struct super_block *sb) struct f2fs_sb_info *sbi = F2FS_SB(sb); int i; + /* unregister procfs/sysfs entries in advance to avoid race case */ + f2fs_unregister_sysfs(sbi); + f2fs_quota_off_umount(sb); /* prevent remaining shrinker jobs */ @@ -834,8 +837,6 @@ static void f2fs_put_super(struct super_block *sb) kfree(sbi->ckpt); - f2fs_unregister_sysfs(sbi); - sb->s_fs_info = NULL; if (sbi->s_chksum_driver) crypto_free_shash(sbi->s_chksum_driver); -- 2.25.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel