Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3656085ybz; Mon, 20 Apr 2020 07:07:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJdi+f8MCOtOQXBcKHKdjWsknE5A856WjIUrlRxnj30bn7GB9RXZYAcnQ1VtWYq1KyC69xk X-Received: by 2002:a17:906:328f:: with SMTP id 15mr3902929ejw.33.1587391629221; Mon, 20 Apr 2020 07:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587391629; cv=none; d=google.com; s=arc-20160816; b=tlzz9J9LFqmXS+teMWNpRRpy018zdR4GLfyOa8Jr5rCFG2v1lPyBLbrGzelfxFNhRb cKFw/vMUpTfIMhbGUwDm+oBIJK/wWGalM3jd/WjiJvFWoiblwSKwZT/IxaOXUfy7+W00 k6Fchko962XP7bYpvUq7CaODse1LaKTFmCs0wBWxpL43R28yzZ/6PpC0ZEyOucXxK/lI anJ5rQ/bSk3JmlRKhMfZ33nBIF3cm8XD36oxJ1NsJkLha/+Pa6h3O4EmiOCGfExW2UfT N3nu4krEWwEq/oK4fFxZMZE6AhLmTDytP9XnkIU9sjBvqhpE5b3nKb1CixEGaxcffO4r m6Jg== 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=NByS1bHzgPOzkyA6ANHcuHxT3T/g9fONY5bwv737TbU=; b=YfIqKG8+tlE3IpEx7hiF7UQ/Tb1NP8yrtin2H9XJYww6woh/R2+84vWiEmvdpiuvof ZG83s4oWsR962dkuNKJWvCceHi/cKUFEzWlhPuaRNwvwlIkVKvCA5Is8zEC769/AYwvW ZOKiKkZ+KwchkKgiT480Y36bjySpv0SxLd8D+zKRDBu9k7kVh97Q09FROliXVFZwVrCu +9XxEfXgGp2D8qPumg0O41xHiJIUQi5iHorNqPL8zpuiLUdic0FpVtzG1l25aXknQ8Wu 7rgyfc0QyFThseqkNzC/6XQjVrTT/UuzbKBe2hNkcMAGhrwAj7RynaqTw784FPGfyWrh U98A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R8wQKVrK; 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 p16si594400ejx.212.2020.04.20.07.06.36; Mon, 20 Apr 2020 07:07:09 -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=R8wQKVrK; 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 S1728699AbgDTMpQ (ORCPT + 99 others); Mon, 20 Apr 2020 08:45:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728694AbgDTMpO (ORCPT ); Mon, 20 Apr 2020 08:45:14 -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 68D81206DD; Mon, 20 Apr 2020 12:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587386713; bh=cl3Wc5b4Ov99KYv9DZbIOVytmV0JrM/M92OF8LxKvL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R8wQKVrKB5iHvPR9n6nTeYIj9EEZ5/XG0lQU8w0DbK07vjnwO5XPOH+7Gk+eOds2O 8+E6v37kIjaFQbpv9tNyfFKofrWnEGyBql42iVIxlgv+oFaW0RNP6i/TSO8Qn/MqwM vf7mWqPYBWT/wKAbY3kQn2lF0cpZjWdLerwI6BOw= 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.6 69/71] x86/resctrl: Fix invalid attempt at removing the default resource group Date: Mon, 20 Apr 2020 14:39:23 +0200 Message-Id: <20200420121522.593903305@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420121508.491252919@linuxfoundation.org> References: <20200420121508.491252919@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 @@ -3085,7 +3085,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);