Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2183705ybm; Thu, 23 May 2019 12:44:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCxyzyj1cTCa7gdHd9l+BJuKFlhPosdrWI6eV2mzeRuY4j+qRsWcyVuT3F+XHYbRrnPXJj X-Received: by 2002:a17:902:d892:: with SMTP id b18mr57035673plz.216.1558640672941; Thu, 23 May 2019 12:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558640672; cv=none; d=google.com; s=arc-20160816; b=qZqlP69jR2xbC5xWfp4SGKljKYH4PnX6IlFqluw3mk3WwFc6qjCavS4cbNAeC4falm rdIgCzYD9HMU8onV1w/f3ekujJhvPklbwb/u3bCVwaL0ymQJkDmCKa8aTht0T6JPVYF7 GWEEuZJdouUNACjRFU7DNzU9poSzMtsyvUXi1CfsHamaTQQVpnRugFs4AeCavhzWktTK IryR+dT5sTSSPY+8eiwDwZUvIkSYsrY9b93E6COa++3SNvEebasUIfwiYkuHMYfxjSiY 7EM4xjoSUA+4VLTcGvNG7C68vVU/Js2PC1Jd/IwRncfR1X7b6DLpG6/5AjSD19GlgE/7 UidA== 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=cKI8hwTbvweUc76oW+13SdBwh7VIPzziRKt7DZkH42I=; b=SYdt+7XSxvFNS2stt0D2YjCpKC+dGHEyBbw4c5Yh60bp8WmZzVStI2CPJh8KPVksuH FOYIjHsVXvnARao7joOF19JZZEbmQdVHPJy4fK+fnYXWaTOHVomn0hJFhygbplWxN+FT P4iOJc1k9hYPB+JVXxIlgQUpDEi0zgmF1c3+5qU+/YZY8pITwfgLOsgTcwezJrFy8WFq s2r6y676HniZ+1fMxbPGmJvD+8gvlNNvbIMDZqos/HGFRlLhzQSVrH3dXAsg55Zhvadx ueRDWF8gV2GqXeZxsvPn4i68WfMKVrowhW5WFYktlxncvS2H9oFiFW2Eb6meArDU7ugh zSkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=byIJa+sK; 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 i193si557196pgd.88.2019.05.23.12.44.17; Thu, 23 May 2019 12:44:32 -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=byIJa+sK; 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 S2390243AbfEWTm3 (ORCPT + 99 others); Thu, 23 May 2019 15:42:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:54782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389379AbfEWTTA (ORCPT ); Thu, 23 May 2019 15:19:00 -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 84D7F20863; Thu, 23 May 2019 19:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558639140; bh=lXNckAZnpcx/r52Bhu7DZWMItin9YE9HIlmcNz015hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=byIJa+sKc7iY/E6dfS/cmuEsqGMmVd5ACTWE7OmQjOdRoEQNx0aSNd4Jo4SdhvOSD leL7NZx85kPeKqP7ytP8APCiEDHXw1f9WNKdcCYXQVy9qJ3+/PIUFkPEQ2nOUGG3Un C2gezRZiTqlCNAJFiXFezQ/k3vARp8RtAjbrRReM= 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.19 092/114] securityfs: fix use-after-free on symlink traversal Date: Thu, 23 May 2019 21:06:31 +0200 Message-Id: <20190523181739.782821877@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181731.372074275@linuxfoundation.org> References: <20190523181731.372074275@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 46c874419652bbefdfed17420fd6e88d8a31d9ec ] symlink body shouldn't be freed without an RCU delay. Switch securityfs 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/inode.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/security/inode.c b/security/inode.c index 8dd9ca8848e43..829f15672e01f 100644 --- a/security/inode.c +++ b/security/inode.c @@ -26,17 +26,22 @@ static struct vfsmount *mount; static int mount_count; -static void securityfs_evict_inode(struct inode *inode) +static void securityfs_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 securityfs_destroy_inode(struct inode *inode) +{ + call_rcu(&inode->i_rcu, securityfs_i_callback); } static const struct super_operations securityfs_super_operations = { .statfs = simple_statfs, - .evict_inode = securityfs_evict_inode, + .destroy_inode = securityfs_destroy_inode, }; static int fill_super(struct super_block *sb, void *data, int silent) -- 2.20.1