Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3423439yba; Tue, 16 Apr 2019 11:01:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaMwah50QuMwXI4UmSVjVDxWtUvEWOxqHd0wtwHehfMHbO1es35DR/9TWOCsKGR3QMQeo4 X-Received: by 2002:a62:474a:: with SMTP id u71mr83809484pfa.87.1555437675046; Tue, 16 Apr 2019 11:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555437675; cv=none; d=google.com; s=arc-20160816; b=c3sFw6bzExVpeegcu74PKjHniUiDfj9S0c8peAee3xydIrCyRBd87/RvweszjvkJRM tSKWrkeEKloKxalqxlOWerCddqBhn0BPnRGxjEV5hXyN2M+TCk2K7SSfPhx/xr42CKMk SQAcC3WgWabbYi/WdeQ2EgqqXslE8mxYC0hMdKfym+pOtUTDVSrr1S4SQFBo65tmUBmL GJbkZKPDHPsxTHe//4VS3hy9Te4bVdvHxveasD9XgaTDyU3pPzoLcXvAP/3t7BtkAGto x7boAsj+5bzIQFQMh6ac/FDhx2Rz6dO1mJgHo19viRdJIje/pQ06lTbgiuSB0SSuWKiv ZIFw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TYLRZR7+d1B3xViJ7D9CGhkzo4wCUkU4NJlmt0ANrq0=; b=n637LO1buTtpXo+2P4TuB/Tn70YO9a/xmDNWFdZJS54HJRxsEZUGdl6JUiebSEI064 xK4CopE7ODkeONec2eVrVStFRE45Pv8zpC9GBvqslhatD/WhfavCtmptSgm9FuTi3uXS IVxGM1EhRgLjq6OCZRhEjM4TVwT56CVlijbg/CpFMAFsCM5z5eRIq/badk0auBNtA7cZ Z++tHWmJEibH9tn5bA2fdu/6/iJMD9jnEK+SwP/UQ8kwNBFU2iOXGVcM0MKN0/A9NAI8 +znaKsiSJ1Og5r6WDwExWXO/PYfRN8qvkCOuqw3Im5XzF8/UDjaMwBOQs/BsG1e1t2i/ v8NQ== ARC-Authentication-Results: i=1; mx.google.com; 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 e7si40266798pgc.307.2019.04.16.11.00.56; Tue, 16 Apr 2019 11:01: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; 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 S1730249AbfDPSAW (ORCPT + 99 others); Tue, 16 Apr 2019 14:00:22 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:57490 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbfDPRxm (ORCPT ); Tue, 16 Apr 2019 13:53:42 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hGSH6-0005UU-Nu; Tue, 16 Apr 2019 17:53:40 +0000 From: Al Viro To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH 02/62] apparmorfs: fix use-after-free on symlink traversal Date: Tue, 16 Apr 2019 18:52:40 +0100 Message-Id: <20190416175340.21068-2-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416175340.21068-1-viro@ZenIV.linux.org.uk> References: <20190416174900.GT2217@ZenIV.linux.org.uk> <20190416175340.21068-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro 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 --- 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 fefee040bf79..b9298d2e8165 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -123,17 +123,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.11.0