Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp847313imu; Tue, 11 Dec 2018 08:27:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3OL4rPScuJ1vgoHX/yfVVo7AyE0A0eanpsXIwpomw2SBCwvyKa5scQU5UH3+f1YmsISL+ X-Received: by 2002:a62:5b83:: with SMTP id p125mr17109560pfb.116.1544545662217; Tue, 11 Dec 2018 08:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545662; cv=none; d=google.com; s=arc-20160816; b=xrRsQteMuYrjVPGLb7StE8EhfhCbsrwREowybqdAZynWJCJ4+HRwtlEKR+oxtcoEU8 9EX2sRhV3oMfeUdqZqQWGbrHd6E2yZdM64uuPLSH+FcUBkdhJTEhF/AC3hvpqfOIrR07 9jGPNCz3hH1sDeEsAeUwBu7HWwD7sp74AFHFSa3jU79K22rHtHdVvP0YH6VF7Y9PbmxA LPi7mLV9wbbFJEMCagIeaI7Wmfnb5v6xR6gPs7LW73Y4fnrdw+26BmvFjeLUmftIrA8h N5SW9Qk4Y4aJBbNtkPCmHv/L6XtXZQn066s8Re5sJPqTnaQQwtf0JHeBVBGw6Tto5MU2 yxwg== 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=yHysrc/POXOKu0MUaZ5Fuo5DYsrPzpLUV5e1BDrmeMc=; b=JalxQ0FyT/4rYV/bJrlw6M8RfvwbM3Rqf/ECcJNquPF38+Aw62Qthb5psxX7LK4bAP v0JqnmhcG3MOYDiPufohlI/3IR22nNIdRT79hBYmfRD9nu2yrnASed+nxvoHuLxVzRb0 Dnp/CXG5cBfNhJhec4uCz/KlhirkQUbyX2h3Q7N6gpCvIlGK5Nl2aVaTithu77MIQpMC lwm/9CviRhhtCAp+ybOjzUmW3zUA7nFNSz86sMtFWyKLpLiAkDhXoOvzpsszdstWbp6e krgi7lT0Myl8Rz5OQwJtMFk0giOcCnD3dN/cxa4OJHmed33go7xscoCKR5IeKvKSOOVN GbSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TJ1mMQRl; 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 n3si12420084pgk.405.2018.12.11.08.27.03; Tue, 11 Dec 2018 08:27: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=TJ1mMQRl; 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 S1727898AbeLKQYY (ORCPT + 99 others); Tue, 11 Dec 2018 11:24:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:59176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727332AbeLKPmq (ORCPT ); Tue, 11 Dec 2018 10:42:46 -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 C2EB420879; Tue, 11 Dec 2018 15:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544542966; bh=8DfYzkFUREWSWmB+LVJtf2vMQzZpCR4OCH71SI2dcTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJ1mMQRlddZ2MZxq2WCu+77mJsUjVf0kMYIQLUUtNwpxbT0kVhsRGR94AxN9mlMRF 6mfbVUDmbeq+erstE/3R8gWI6mi3tDq4D5/tWRGaY3YOTQi5Ytk5F74uT0nyCMHkyq ZUppImFXiq52VFM5v2ObFex7JEnGbNguj14roMkE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Jan Kara Subject: [PATCH 3.18 08/54] ext2: fix potential use after free Date: Tue, 11 Dec 2018 16:40:56 +0100 Message-Id: <20181211151546.448597786@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151546.010073210@linuxfoundation.org> References: <20181211151546.010073210@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 3.18-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 @@ -606,9 +606,9 @@ skip_replace: } cleanup: - brelse(bh); if (!(bh && header == HDR(bh))) kfree(header); + brelse(bh); up_write(&EXT2_I(inode)->xattr_sem); return error;