Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3589307ybz; Mon, 20 Apr 2020 05:54:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJ/A42Mvq5SlRMquHlMy1eRoFop/zeoQ5QzsoaVw7+Wr7WlCYloJVC0C11fg7t01KJDUS0I X-Received: by 2002:aa7:c606:: with SMTP id h6mr5072723edq.265.1587387290411; Mon, 20 Apr 2020 05:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587387290; cv=none; d=google.com; s=arc-20160816; b=dPWeF+L+kFrvKXkWlP3P7wUso5f05TrETK86yL0y3aiwSvqCGTxe+/HsTafiBcDb/h Z36m1QzbMBAS3AqTqW2cmZPHUu5m2OQSpUKsmnrVDgkrYuM8abe9oQO39Xg++s8hvYCZ GAmbtL6FAL0jduwpRIzHIErLZbe83GnZhYcl5QqwoDAP9R/JbJIzx9wOwAfGH7Hw+K3O IXfLusZO4rsyr6U5iqvHH5OV6uztMfLDzjlrKdnPmXtcjUZtz626SpUcaH2LGHakihsX IkVAHO1nckOdtgPgsus7uCqOTmqO9bX8SINxOvCLFy3G7l7iKsV0xpKRDMBwStIrMPIr 9R5g== 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=uRbx2beMzMPUoVo/HwYXJoiy/PlBY4FpPKETAQiNVXI=; b=puXG4i6UFnBDyAMlhGbBPY8Phx96f4c5DYEmejiARe/UzBsVjJxq2lD2qx6LBilybN IPpEbGK9AjCOTMiNlT6AErYy3/D6EaTJLSosauSnqPcU+XZA2hMsTYw2pGY8s+T9tFyS +V8FYEvELYabpGkLdjHTFMdGZ8LrB2US4pREua8+AbNX5iDM8PU+RVTD2j/Waf/7Zv64 k9ZUxALICSxAhSlPaNH3yJEgGQXZBPEy279BGqu+fqJ4ZiIh0dL9Weh9luGozN1zQKXM h8/h3oMDFjH0R0ulGvvCui9lkcSXdDPKBLltvEy2Z24NTVjo34YEALDF8A2y/gekgQYk iHcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DZiNPXXu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si511404ejb.97.2020.04.20.05.54.26; Mon, 20 Apr 2020 05:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DZiNPXXu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729534AbgDTMui (ORCPT + 99 others); Mon, 20 Apr 2020 08:50:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:46170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728836AbgDTMtP (ORCPT ); Mon, 20 Apr 2020 08:49:15 -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 BB8E320747; Mon, 20 Apr 2020 12:49:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587386955; bh=CYFVsBxgywRzUEvwk2dikz2au/dAN3WcLNWOf1HanAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DZiNPXXuEX8OM5NnN1sRrLWXHhTYW+C3AGa2prJcsAKbWPVc4t5pi3RkyK4li74C5 Cmk2Y+cFix9DtEc6qrQqFK8g0/jzSIIyojKhR3cdCVQgzywp4sb7hwED4RTXckBg9j SHvQDPdAqH9lCDTpg63FY2iIn05tqSmnfyC9Cwu8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sai Praneeth Prakhya , Reinette Chatre , Borislav Petkov Subject: [PATCH 4.19 34/40] x86/resctrl: Fix invalid attempt at removing the default resource group Date: Mon, 20 Apr 2020 14:39:44 +0200 Message-Id: <20200420121505.792530801@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420121444.178150063@linuxfoundation.org> References: <20200420121444.178150063@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 From: Reinette Chatre commit b0151da52a6d4f3951ea24c083e7a95977621436 upstream. The default resource group ("rdtgroup_default") is associated with the root of the resctrl filesystem and should never be removed. New resource groups can be created as subdirectories of the resctrl filesystem and they can be removed from user space. There exists a safeguard in the directory removal code (rdtgroup_rmdir()) that ensures that only subdirectories can be removed by testing that the directory to be removed has to be a child of the root directory. A possible deadlock was recently fixed with 334b0f4e9b1b ("x86/resctrl: Fix a deadlock due to inaccurate reference"). This fix involved associating the private data of the "mon_groups" and "mon_data" directories to the resource group to which they belong instead of NULL as before. A consequence of this change was that the original safeguard code preventing removal of "mon_groups" and "mon_data" found in the root directory failed resulting in attempts to remove the default resource group that ends in a BUG: kernel BUG at mm/slub.c:3969! invalid opcode: 0000 [#1] SMP PTI Call Trace: rdtgroup_rmdir+0x16b/0x2c0 kernfs_iop_rmdir+0x5c/0x90 vfs_rmdir+0x7a/0x160 do_rmdir+0x17d/0x1e0 do_syscall_64+0x55/0x1d0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fix this by improving the directory removal safeguard to ensure that subdirectories of the resctrl root directory can only be removed if they are a child of the resctrl filesystem's root _and_ not associated with the default resource group. Fixes: 334b0f4e9b1b ("x86/resctrl: Fix a deadlock due to inaccurate reference") Reported-by: Sai Praneeth Prakhya Signed-off-by: Reinette Chatre Signed-off-by: Borislav Petkov Tested-by: Sai Praneeth Prakhya Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/884cbe1773496b5dbec1b6bd11bb50cffa83603d.1584461853.git.reinette.chatre@intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -2923,7 +2923,8 @@ static int rdtgroup_rmdir(struct kernfs_ * If the rdtgroup is a mon group and parent directory * is a valid "mon_groups" directory, remove the mon group. */ - if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn) { + if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn && + rdtgrp != &rdtgroup_default) { if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP || rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) { ret = rdtgroup_ctrl_remove(kn, rdtgrp);