Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2480120imm; Mon, 24 Sep 2018 05:13:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ciidmEzwUVxeV+CC4nCAMDIBFnefbWUR+DrUGdE+yVPlIBa2WI9Gzp9q2TCxlCKCBdUAz X-Received: by 2002:a63:88c8:: with SMTP id l191-v6mr9324243pgd.340.1537791188305; Mon, 24 Sep 2018 05:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537791188; cv=none; d=google.com; s=arc-20160816; b=fnFGtWfgQdEVD1MZLN507VPg0ePl2HFCVUi3XPIwCF30SYhBFYKk0QboHXMvQhHkqt M/khoAcb+DFPjd0ku+Av61hQBp/jTGhjbrx3Dp/9o9yjw22kRglfKezRRz7Ag+Q9gu+m Jw32GFDOaO9c8nyoRdNmIXYkYDUPLOERpfIz8QXijATxODbpUbhn2kXUUoAkDt4bbanO HmNseRGLLAeO4f6HhPTSeuMORCH6VDyZmaOxQVmmkjlSNcbWkNYg462OhoNKMPHNnYgk Sd/zzNxgEHjaBmBMFzg6hpr+fWvfCzowXA92ijA3R1g7fM1y4hu0hEZhhtQ5dfocu4EH gcTg== 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; bh=q6syL1Zx/szq3vqXpsaYJEEYpHAhIFoYw7mv1iJZje8=; b=XBT1u/ml6IOeEeBY7AFGhzdRwF9Hdh8VMvXKkmi2Mva5cJpXNIg1a1K6WCVK44oJOz FjTovFjTaDv4zd5a5sjHoLeh2rkRRFVFzTPkU7UyQspHtTwmPh8Z4HggTJD8WncUtHaa huOdJ2rMosZUAZMR4rbQcb5kBY/qlzS4gFGWIgRhQYueN0JizWfnPNGtrMMZ7iFYf1xa k+kvETftyk8sQn370cPX0XsNn9ZoVsRIZ2Nwf88EdnOeEfwtXlgWPoL2O7OehV4cCLu3 xLEh12XuAR1SHBMc0R7wMoGmwe226j59sB0OtmhUVabNvoVCodWEInyEtefCT/do4Yop 2lIQ== 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 38-v6si7442964pln.129.2018.09.24.05.12.52; Mon, 24 Sep 2018 05:13:08 -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 S1731039AbeIXSNp (ORCPT + 99 others); Mon, 24 Sep 2018 14:13:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54886 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730490AbeIXSNo (ORCPT ); Mon, 24 Sep 2018 14:13:44 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 861221086; Mon, 24 Sep 2018 12:11:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Christie , Christoph Hellwig , Joel Becker , Sasha Levin Subject: [PATCH 4.9 078/111] configfs: fix registered group removal Date: Mon, 24 Sep 2018 13:52:45 +0200 Message-Id: <20180924113112.656897317@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.337261320@linuxfoundation.org> References: <20180924113103.337261320@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Christie [ Upstream commit cc57c07343bd071cdf1915a91a24ab7d40c9b590 ] This patch fixes a bug where configfs_register_group had added a group in a tree, and userspace has done a rmdir on a dir somewhere above that group and we hit a kernel crash. The problem is configfs_rmdir will detach everything under it and unlink groups on the default_groups list. It will not unlink groups added with configfs_register_group so when configfs_unregister_group is called to drop its references to the group/items we crash when we try to access the freed dentrys. The patch just adds a check for if a rmdir has been done above us and if so just does the unlink part of unregistration. Sorry if you are getting this multiple times. I thouhgt I sent this to some of you and lkml, but I do not see it. Signed-off-by: Mike Christie Cc: Christoph Hellwig Cc: Joel Becker Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/configfs/dir.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -1777,6 +1777,16 @@ void configfs_unregister_group(struct co struct dentry *dentry = group->cg_item.ci_dentry; struct dentry *parent = group->cg_item.ci_parent->ci_dentry; + mutex_lock(&subsys->su_mutex); + if (!group->cg_item.ci_parent->ci_group) { + /* + * The parent has already been unlinked and detached + * due to a rmdir. + */ + goto unlink_group; + } + mutex_unlock(&subsys->su_mutex); + inode_lock_nested(d_inode(parent), I_MUTEX_PARENT); spin_lock(&configfs_dirent_lock); configfs_detach_prep(dentry, NULL); @@ -1791,6 +1801,7 @@ void configfs_unregister_group(struct co dput(dentry); mutex_lock(&subsys->su_mutex); +unlink_group: unlink_group(group); mutex_unlock(&subsys->su_mutex); }