Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2188157ybm; Thu, 23 May 2019 12:49:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwur4WLNXLmEf7RUG0O5b90+vVf1HcoERIvjHSLuZ/Y2qpBuQaEarqwMyj/MB2L7VMt+nSj X-Received: by 2002:a63:fa16:: with SMTP id y22mr60645552pgh.15.1558640955657; Thu, 23 May 2019 12:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558640955; cv=none; d=google.com; s=arc-20160816; b=UdBFyu3kVqQC/zmXkVHwsqnPuKS2WJLGOwH7jOsrxNhMRtdPTk0XpY8Jh9w8YiK/eD GatyJvayBBEZNa/SseD0EQ5DiFoDcpBUBi3EtlBdeO9XUCboKVyEN8az7HqZWHnLEKu4 gazT/MaTxXiXERbVFgmxFYI4wEL5QEAhsG9C0dB2fFBGTD3pbSaWvHf3lvVkRp4/BSuV UDIVkErS9girikR8rty2ARYYKuatAxkfUWYbABABDMjL9HY6uqkl+wJ+ANAvYTeoNI9f aR8DXYPOYLZMLSYW8wPF49zwmWwT66mR5nB6bTN262JhLEoSBqaOA69uBmb5QdtqIe4l HGvw== 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=Zqn3JgSa8Z+6TIFnsZaxcK8cCXR9j6JQo5XKFPP8j0c=; b=gGgRr7sUSwQ35QvzOFWZV0lSJ098dE8P5aZgywS/4+f6Px5oRBp1UwUS5Z6P7YBwk8 xStnYRZP79Nn7tNgxojpZkG3Se1ylRA1h9hmKhQ2t6+Szfk/+a0VU3GRlEl68kzmSiHC EOswGIqll8pSZFx0J09EHaBjYgYtyBLzmlr75ixviI1WVGh0VO86y/dFLQEYunzhGXzv K22b0bb42FSZItVBMMiFdWenQWdCyJ6IRTzSvmm07V4CcAf438ze5OCG+qoBr3pJeEoB ff9ln98y2izZMKnVtakMjzlJuJJymHWGi865iP5MkIjFcsMpja6oHxeyH/PLKqlsGiKs 3wyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fz+3yuiP; 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 x32si579324pld.190.2019.05.23.12.49.00; Thu, 23 May 2019 12:49:15 -0700 (PDT) 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=fz+3yuiP; 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 S2388561AbfEWTq5 (ORCPT + 99 others); Thu, 23 May 2019 15:46:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387867AbfEWTN7 (ORCPT ); Thu, 23 May 2019 15:13:59 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 278C6217D9; Thu, 23 May 2019 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638838; bh=Yt3FjdJeDqmwJIX+H6jtdQ7dkyINtBL76TztmOZ5O+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fz+3yuiPf3VBr+g51dusjIKpNWv0FPLeXpaaX1/kE2jUkrJnmSpallH3Qne3jAheg OIiFc5HOk8ldI1JfoY/uXrimLEiL4fYx8lfyE3ZzAsCp89V/ce07eBKBsXFlkpAh5r DtnQZmWmjbSWRVGj6roR7YaZLKlhJrxbUXjCw1/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Sasha Levin Subject: [PATCH 4.14 63/77] apparmorfs: fix use-after-free on symlink traversal Date: Thu, 23 May 2019 21:06:21 +0200 Message-Id: <20190523181728.674674667@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit f51dcd0f621caac5380ce90fbbeafc32ce4517ae ] symlink body shouldn't be freed without an RCU delay. Switch apparmorfs to ->destroy_inode() and use of call_rcu(); free both the inode and symlink body in the callback. Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- security/apparmor/apparmorfs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 0e03377bb83ea..dd746bd69a9b2 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -126,17 +126,22 @@ static int aafs_show_path(struct seq_file *seq, struct dentry *dentry) return 0; } -static void aafs_evict_inode(struct inode *inode) +static void aafs_i_callback(struct rcu_head *head) { - truncate_inode_pages_final(&inode->i_data); - clear_inode(inode); + struct inode *inode = container_of(head, struct inode, i_rcu); if (S_ISLNK(inode->i_mode)) kfree(inode->i_link); + free_inode_nonrcu(inode); +} + +static void aafs_destroy_inode(struct inode *inode) +{ + call_rcu(&inode->i_rcu, aafs_i_callback); } static const struct super_operations aafs_super_ops = { .statfs = simple_statfs, - .evict_inode = aafs_evict_inode, + .destroy_inode = aafs_destroy_inode, .show_path = aafs_show_path, }; -- 2.20.1