Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp801250imu; Tue, 11 Dec 2018 07:48:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/UlANPREuBxN+DXYxmKga+cgDzWyE4JEY/eRESDLYqMO1rEH/LwxaQlh6+LuetNsnMXQd/Q X-Received: by 2002:a62:5658:: with SMTP id k85mr16599994pfb.231.1544543315959; Tue, 11 Dec 2018 07:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543315; cv=none; d=google.com; s=arc-20160816; b=maMjr8IT65/ZDNkMZN6FMZOKKhaGvTpyIrarKRLtJfqCDDLXmYLHZRguYf1t0lGWE3 ZiUpepe8iflAO44aoSiD02QWFZUlyibp5EBBa3DnCUCBXqLzw/uTSmOcptPd1hxsG4/F iK9ogfCWK5LbHgk+gYoLf9KTt9nyOyVaeSW9s0xoadUAZwi35OdSYWQR2cPNApQ5DkXV 5QHDOkYaNiUS5larxzO+a8hj2S2Tv/fS9Ai88L/VpT7kVljYwy+G/U+S96k/aPWU95G/ Xu8bz2TFPps69NRDVHiR66rhvojdawNlWj2PIsyfPvK987w6fLEhN7MX9UgM91UyruhH 1Htw== 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=poLTRk+ySOw6ImBHUcmX2jB5Ls3I7rongr0a56ynJlk=; b=gqW4PjFvm/5tB2qHEJQrEdo8hYinguwJbfYA7tcEp/OAqUmwPsoMgn+Xt3AdIIxDhR EX5nZ2ZMlsPuvBTCsNumsN+7VJ3AOV+2oe5hKo4Uvh5ee0uLSeXvWMe0EL3ko0BbFLnf nf/tPMSJUcU23FDV5fq9wWdKbE4zkjtz/mKDv9aELp9iWXDiadxHdIh5glGHp6uK9Ae7 HP5RkVzAeAgjE83u4ujmmkbEGtwtR8R3z+iWRfmuc3vDsjCVAzb22CEBWomOrA7oSkJF PwhvmCzMdfeG3/6vrJR/blGHlorGylv40XgRryT9TTQQAOVU7rQ1bNQ3z0wal1mdUbQQ qjBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ili5hFN/"; 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 7si15053605pfb.226.2018.12.11.07.48.21; Tue, 11 Dec 2018 07:48:35 -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="ili5hFN/"; 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 S1728103AbeLKPp0 (ORCPT + 99 others); Tue, 11 Dec 2018 10:45:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:33840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728092AbeLKPpY (ORCPT ); Tue, 11 Dec 2018 10:45: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 097F720870; Tue, 11 Dec 2018 15:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543124; bh=aPecmDf+aDRZf1h00CyDF1yv5ZDW4FZxLrzTzm87QdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ili5hFN/mQxz44N6OHhQR8mT2gvfuwkbV2vCH+EeQcBBeZleYMAQbpbwZEVyJxgig gWTuSVUHA9/ENPaw9EVlIgA+00YYP8brrPpChoz/nPfGL6ahAPlJ+iHz9l9FLbzhGV D7S8bGp4kYASHwhjaPRy1x7Kf0zZaJzjpUdmMtqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Jan Kara Subject: [PATCH 4.4 14/91] ext2: fix potential use after free Date: Tue, 11 Dec 2018 16:40:33 +0100 Message-Id: <20181211151607.080046791@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@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. ------------------ From: Pan Bian commit ecebf55d27a11538ea84aee0be643dd953f830d5 upstream. The function ext2_xattr_set calls brelse(bh) to drop the reference count of bh. After that, bh may be freed. However, following brelse(bh), it reads bh->b_data via macro HDR(bh). This may result in a use-after-free bug. This patch moves brelse(bh) after reading field. CC: stable@vger.kernel.org Signed-off-by: Pan Bian Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/ext2/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -605,9 +605,9 @@ skip_replace: } cleanup: - brelse(bh); if (!(bh && header == HDR(bh))) kfree(header); + brelse(bh); up_write(&EXT2_I(inode)->xattr_sem); return error;