Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3424542yba; Tue, 16 Apr 2019 11:02:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqy92etxZGV9dEu85N6ACUayHclXATT8QMaZid4M0y71TJ3Tx/fuU9a2FfR1NDgbzjo1w9Zx X-Received: by 2002:a63:550d:: with SMTP id j13mr77361524pgb.18.1555437743760; Tue, 16 Apr 2019 11:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555437743; cv=none; d=google.com; s=arc-20160816; b=y4JYBJ3R0AD7aPN/eb8qXTJRgyH4VD+tk9b+VR/vmpDmX0lDNlMdlgPNssGosX8Qge lXEOPEIfNBQTCHpuFZW4P0Qlm2xSbS+H+k6DS9ymU/pK0gj6LE2Obj30uniTSM5xjbY8 uS1y9Z+37uMsKL4Hcj8zoshQlCjc2Gd7op3255ulQS/+iPqJeZpG6kmYICqSt8cOen64 YnL4ANAa5DUL4s1FwLuAm1ULoE6uRbe6ZlYKLM7ud71RC0o1Ir7B1o4LTP08F/rsoi5u n4qMsMJ/i2YoxyFSQymXOPp/Rpq33Jq95yFNxt6/bt+G9t+19fcrLq88pHsFoeJJ/hpQ 5/8Q== 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=oJ+vNdhRQp6WT7hipbrx7EVpdDi9iT0/VHg+Cs5HC6c=; b=MM/2Vug8Us4vWSwjsFfiaGztE2qsJ18MUiJPR6n6St9l7NsiUY2JFfrDCo+GRwYCjW GDfoYGMuaqMqNOQdyFWYq9cqYBJzIQRyvuVQEtGb3Y4BEvDWjvXD5mQOFvL5L5v1pWw0 56NH8/anpgf+jGUztjAIObQlvcDgtKO0LbsS9d/pLqnDGfbrAkotNsSwYDQhO/hWklI4 Fko1qKSHc2gH+8Py8EfYc4mu0RmMoswddjEZEiJ6mLTJVPotqHSVEGvdkt9n2HVThTD4 54iMVIVOnfmSQJNpbsqwbaydixNlE+TjufkdTc3SPqAfROHbHsqoyFvX+7jwPeDD1IhU iBaA== 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 ba5si18310056plb.24.2019.04.16.11.02.02; Tue, 16 Apr 2019 11:02:23 -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 S1730210AbfDPRxm (ORCPT + 99 others); Tue, 16 Apr 2019 13:53:42 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:57486 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbfDPRxm (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-0005UR-HH; 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 01/62] securityfs: fix use-after-free on symlink traversal Date: Tue, 16 Apr 2019 18:52:39 +0100 Message-Id: <20190416175340.21068-1-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416174900.GT2217@ZenIV.linux.org.uk> References: <20190416174900.GT2217@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 securityfs to ->destroy_inode() and use of call_rcu(); free both the inode and symlink body in the callback. Signed-off-by: Al Viro --- security/inode.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/security/inode.c b/security/inode.c index b7772a9b315e..421dd72b5876 100644 --- a/security/inode.c +++ b/security/inode.c @@ -27,17 +27,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.11.0