Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2518998imm; Mon, 24 Sep 2018 05:50:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ltgwTuDrvuer40qzDXDAjU/mY4fOa7oTl0I0NhxcO4/LVgtkzRDDH9+LYYWPnW3HkjpWa X-Received: by 2002:a17:902:5ac9:: with SMTP id g9-v6mr10706751plm.311.1537793413409; Mon, 24 Sep 2018 05:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793413; cv=none; d=google.com; s=arc-20160816; b=QRTgpzrJeBw/gIjwq/nj6aTCEPhQLZn2+vaJkQa9H8N6KADpFCichnh/GCI/etaf85 euKW9ftHCLBOekG6HGslQ3VT9eStVTYHxy8ypWx1ui+dLDr2SRG2q4bfFnSSCDZ7PqQf 8WuyUXBmTDmpmvxFGq0dk3XLZJ9Q9rPOUkUyEk6kioSNn57d3nUFlc4ZRTfPqKvlTblp D6s7G92SmAYCqEpsCn1S8PaT/moms2SkG8DD/Gt1z35EYKSG8UHSfWmCumCbzfII7x4D wL99S0Ocg0EpsE/GVeVWP1irWpRucMZrgNmkOwQkzh0xNnseRI0mKzYzvDlXv3v8vPZR qwKA== 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=PHv9q9RkRjGtrXX/yUbCb+djR1ObOR6soXWqBpBRXBE=; b=W5L+bbULeE0HODhFtO/7ZDt+I4vcGw120Wl64Lp2NmNKrRVPi7XuT9pBPaNSLRNwKw VnvVhCxxPzP+Geays0vOAd01XPE1FV4QbPqB0FEyvY3JLGKc4xKZU14KB6YoecHVlIb2 xqDqo0NY5mOaRATrck+b4i1X7wp0+ledFskPZzbSbjzemtcjO7zSKgSZRigPGgazg3hQ tPn0NhGuigXL9/4CkftXMjmcF38eLQh8ozUpBdzL++TNLO5Dufqc+h3RgNhtb68hnfYW 77b2IncU9BwEgZvS/SpyquJBtuo/yyLI7zzZWtgK7SdwdL4p1oyhS5G8ZY3blRswxN6T U2UA== 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 e186-v6si35553572pfc.176.2018.09.24.05.49.58; Mon, 24 Sep 2018 05:50:13 -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 S2388641AbeIXSmg (ORCPT + 99 others); Mon, 24 Sep 2018 14:42:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59016 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388623AbeIXSmf (ORCPT ); Mon, 24 Sep 2018 14:42:35 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B7B07109B; Mon, 24 Sep 2018 12:40:37 +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.18 161/235] configfs: fix registered group removal Date: Mon, 24 Sep 2018 13:52:27 +0200 Message-Id: <20180924113121.241203878@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@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.18-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); }