Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3595435ybz; Mon, 20 Apr 2020 06:01:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJiG0im3FtUtDfQr6O95/7pGqpSFAHHxKz3AtHUHOoirA3+AUDYD7InOSLgHlIx9CtD6225 X-Received: by 2002:adf:ce02:: with SMTP id p2mr18389460wrn.173.1587387705271; Mon, 20 Apr 2020 06:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587387705; cv=none; d=google.com; s=arc-20160816; b=heNA0u3sKJP/xHpyy1M90TVczTz4fN9b64qH/BvIKpYWxqgXbCNR0Yj04lgEH+qvNl GWV/weOROvyPLxrNPo/tztiw9eW2ISl52VTLezlEk1qQLAfViLPWAel83bfdvy1mTNIn d2WWcpnVN3TLWF9Qtzcz3fw0YhWLsl7eh+nIv84kPGAOCXXPdlOqCGQDMQg+IIKd7SS/ SbmTKzBpbsvmlbJjZ9LaLph6gTtFz0TjHn2kPIwpG/CuQfLnuUU8w3Tr1wklmt12nPg/ o4jaMzFTzBfpuD+f/RtW8yw5FNpBk/tkS8qZIhBfqV5G1h9VZIFXixH5NqpDe1ZpFtIC QPzA== 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=p4jRbej+6404JPMO+mXTHTI9ykPZLrcYo4+f7AlE0Zw=; b=0JAeySij747rFllTZnQZeQMjLdoHFPV8mJy3qXXfE1HFvsDy1D8gGNF+07IyFGjqg1 Zbgu3wv4qTsTjW5MH5peFj2OSIPFabPrzVZwhuQCbAhLJbrr9pEdNeeuYCYbEAaPs/Z5 Bws3Cq9nSQEIa9v5cPNG/yXhkKKViCJx3wUafhouj9ObfyTNTeLhDvKj5xBzEo0M2L4X 2lMf/u6ymJcOz+7fMmB74z64G59NNKCzbBciCTg74DA+hW2QqN7JqE386eV7Ojs29gQ6 ZsZBCZV6cWKqrp2Qww3j2CYEWaQQfkTA+9ZCRyVKgJqfXp1fgq61dOW1h1e8yvyQRw5L mIdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ieJ2H9i5; 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 v22si476365eds.78.2020.04.20.06.01.21; Mon, 20 Apr 2020 06:01:45 -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=ieJ2H9i5; 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 S1728211AbgDTM7C (ORCPT + 99 others); Mon, 20 Apr 2020 08:59:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:35204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbgDTMmQ (ORCPT ); Mon, 20 Apr 2020 08:42:16 -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 95A7920724; Mon, 20 Apr 2020 12:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587386536; bh=MvXeFa5FcNNRthXLPyxuyxLB4bd5gGS+Nh1stta1QhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieJ2H9i5brXLWE6KSzIiPserer8Yp0bpQs/j2k3qELLgT00IUD3eN4tuL0YLijgo7 IV/iOPGEpqXFSEDcb9CFrAeZURRubL0ajcqgKyUwVpe11icYuu8aa8wQFs3f2caIpH IxWZbf2zUU1y8fIWNm5F/NNYPKhPzx9/aSztz4Ww= 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 5.5 62/65] x86/resctrl: Fix invalid attempt at removing the default resource group Date: Mon, 20 Apr 2020 14:39:06 +0200 Message-Id: <20200420121519.851928584@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420121505.909671922@linuxfoundation.org> References: <20200420121505.909671922@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/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3006,7 +3006,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);