Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2155193ybm; Thu, 23 May 2019 12:15:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+duvzs+TEnvAk/KrU8YQXd5zssGGGXNTU+6cdzA48iZsUv06MUMx6UHCSpspFxGX7KSgY X-Received: by 2002:a63:5608:: with SMTP id k8mr99550358pgb.393.1558638957541; Thu, 23 May 2019 12:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638957; cv=none; d=google.com; s=arc-20160816; b=vp5NNQQVfrJdzSG10IzqsaituLnKWpWY5j7rcQxIZOExpK5iMYfrdbkEsu5cUnI0Ch zjX2iUi+g8zNXiRv/ZhqXqBrjcFw0YruCJXjZcPMkTQxraAj++/z4LOwTUijDt3vwxrW E963aYNyDkTvfQi54C6PnUKtjxva53e35EBCfZvJZHywCZZ0uhjYwy0MpuLVucKifUjQ 79VZwwXRCzLI+/3IlZKqqKAJ53F7DDcHtOdzzvZpyX73vWoovVyNmLxAVz9Y8q0d0QgR DSoLdscLPP/mu1ylbd+7eXez89r4LEFVZDifLVcOkLsTY8V2cuM7Tt522bx7ZctJ6VId Xs0w== 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=miQap+dPLxGzN8w9Ybl4Z5CFiVpjk/D2UtgGiPL+bKnPzaLGcFpTonvKiPl7IWrCU+ 1J48ToMlxknEilMmsKLnY4Ye3mZlgLjWEvXZdh1bl9LdExa77l5013oMWSBMtCnLQJ0N K0nJpXIU08eslG4jlP1LTC2NZoIxlby2dx5UVhNtsIIQ1vYMkajYoxLyg6YSxAjB4bDs 3JP/b6Kk3+2cOWiUJQueJb0u3TV19rykvW8/VbjHDDCorCup1n4wB2OfAtfqFpCRR+V7 3OEPvF3063ttllva6XWuJ6p0I50gUJ+Zzj/oHOJ4upm3JqbtGlQg19OIifOl2/ca2bRw BnPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0D2otx9; 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.15.42; Thu, 23 May 2019 12:15:57 -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=b0D2otx9; 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 S2388344AbfEWTN7 (ORCPT + 99 others); Thu, 23 May 2019 15:13:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:47840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388311AbfEWTNv (ORCPT ); Thu, 23 May 2019 15:13:51 -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 5007720863; Thu, 23 May 2019 19:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638830; bh=lXNckAZnpcx/r52Bhu7DZWMItin9YE9HIlmcNz015hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0D2otx9dqJ1BtqPf1Cy9c5ni6fpoU7PSqH55ULp/yhUHT9nMt7mKaB3Ja7wAGRme VTQKBKcaO4HiADBh3/+nkR6obmO27MTTl3X7X/Hhem4S2WRHxUG4J0gYBlTVtg+jMb xHtWzdFqfLufXVd6wKxgfbED5VTtMzezE5BFGrm4= 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 62/77] securityfs: fix use-after-free on symlink traversal Date: Thu, 23 May 2019 21:06:20 +0200 Message-Id: <20190523181728.540271608@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 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