Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2003248imu; Fri, 14 Dec 2018 04:20:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uz5XzcGyGczfWPgQUIyVI5SA13Ftn3ZPs/wbCGKQFUJ3JhI7ME38+ePMhmp1T1cXoP5otp X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr2609911plq.195.1544790042267; Fri, 14 Dec 2018 04:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790042; cv=none; d=google.com; s=arc-20160816; b=oSH5CW42RtqRxqW/4hT4kKmD02x60Oi1JM4IBO1s/BsuOea+Oi3wZu7Qc8QMxMuc3T LlnWFgS0eDMXyKoRsgx1725wn0Z3MKZCNg1Q6COg0pYkj+FeDgU0FwiDopvRU4NZpb6I 7qaPDPjiUXz8vWvspNQX49mkoKy5CjTJ5ykAD87S2counlLg6sp6Uz0GnULIjDILMY0a ra/kKSOlkLb/997PjgTL0RgZoBzxYbqAmN2i12g5IdE/k27FmR58fp5UhzmDZoj4Avzc e6v8CzLxqE7bBgGPITf+A7QVeaBj4ysXspvgFmsGRw4wp8thfciyV9Uz9yRpu9iDum5f m6OA== 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=3czOkCnkFFaTaqclLd0OuUlMkJCA8prim+FPlG61/P0=; b=k2YabmOqEmIaX7TWjnj7SyUTt2EDFKc47pfSFF/HgTZzny+TwD59cGypdZufCVojho 9jd0L2gGoR51ApiewPlcBP4gMjiY59rYGEqPOZnleTkSjFp3AP6Ni0trCJrEtkHfHsQn R70LDr/GXw4TVoJl3M9QPUd1ynHvwIV3bSZloBnfytu43m60tl2FNuxVaf8TWOXBsv7v hgLCAGHj4YeQL877qBLZzo1IroiyMkNVt4UicBhzA6+FGS93zTrtdAoXiTba7u4p8973 tiR6U3pVSHPepcfZGxKokbHb3+YHnaMQSbmPX9XzaJ2grEzzBnBnNQBZeMW7jQWHzo8L Uaqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O93HDYGq; 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 y17si4009799pgh.353.2018.12.14.04.20.24; Fri, 14 Dec 2018 04:20:42 -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=@kernel.org header.s=default header.b=O93HDYGq; 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 S1732616AbeLNMPm (ORCPT + 99 others); Fri, 14 Dec 2018 07:15:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:35682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732043AbeLNMPi (ORCPT ); Fri, 14 Dec 2018 07:15:38 -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 A3F342148E; Fri, 14 Dec 2018 12:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789738; bh=55gdGfUIwTfy8iaJWhllaXnLOZbt9qUZ7SClwvxQYCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O93HDYGqiBXnv1DlLIuhw/nYA4l25P55LT2lb94SHOHBNbVZy2XSdInRMSHR/P1wB TCimBmGBMTgEc924H+QICqkTpmqV/yB3JRd/fO8pP/597kjwuo+s6DRxa0Z6nCd6df I790jfyrJ1nEimakMZjRM3JA2c7TINL1WA2j8l80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Andrew Morton , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi , Changwei Ge , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 38/88] ocfs2: fix potential use after free Date: Fri, 14 Dec 2018 13:00:12 +0100 Message-Id: <20181214115705.313584507@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 164f7e586739d07eb56af6f6d66acebb11f315c8 ] ocfs2_get_dentry() calls iput(inode) to drop the reference count of inode, and if the reference count hits 0, inode is freed. However, in this function, it then reads inode->i_generation, which may result in a use after free bug. Move the put operation later. Link: http://lkml.kernel.org/r/1543109237-110227-1-git-send-email-bianpan2016@163.com Fixes: 781f200cb7a("ocfs2: Remove masklog ML_EXPORT.") Signed-off-by: Pan Bian Reviewed-by: Andrew Morton Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Joseph Qi Cc: Changwei Ge Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index 827fc9809bc2..3494e220b510 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c @@ -125,10 +125,10 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, check_gen: if (handle->ih_generation != inode->i_generation) { - iput(inode); trace_ocfs2_get_dentry_generation((unsigned long long)blkno, handle->ih_generation, inode->i_generation); + iput(inode); result = ERR_PTR(-ESTALE); goto bail; } -- 2.19.1