Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3951366ybh; Tue, 17 Mar 2020 09:27:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuMhyoKbd91BTzzM4/aquDAm+FZ8DMZJVY/6ENxNyCnQq/JP20C2u+3TPqc66ufRsMCdNfc X-Received: by 2002:aca:474e:: with SMTP id u75mr139358oia.52.1584462446958; Tue, 17 Mar 2020 09:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584462446; cv=none; d=google.com; s=arc-20160816; b=ClZJHPSGK7BGVVf/kdYJ4O10g5Vxw9L7HsAAhulggoRBlfpcbpWNJq993je6I06XnU Cy8eFfQQ2XSIzTEHJnvbYp14asj25MwWZn5ctRzbSFeELhBYayeNATYmtR9/2UjPrX+l kfD+jWGUBO5icON+Ub9Y8Aj26ZBPttf1T0LVN9V56pUvkir8uVsIO+g7GDgwnSai1P6y XH/xgMwhK4+hNnr6UUoK/t5D8oR10RUrF18XGmZQbJMj3XDpF3LsriUL0eB5/HsE+0wP MpFINeT5JFyV0DBUyK14Wl4neZPDFRZ/P+M6iJ0H4hoNoDAy7VuJqtl9/qWmyiIQxynx 8unQ== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=yEKUKAdBx0q625VXnGRBfkWQV3hph1wDMMiwOYsiF9M=; b=En15DBTSsOpk6oglfB3YESbfXdvlS8eJVATFKA9KynJ4xeTl6ZMt3T05wZXwP3LSiY kohRaXDqbNIPp2zRnkJAd+fTR/ZpiRQClOx6GMv/t+OjDOiCpYYcCl6RyEOZYMI7VawI R3UDw+AGEM9lQ3J0R5rY61Aj6ZZ5SFZjw4JpUl9dXrgfd1JnDFQzHL60qwT1OtraSry5 sC3l2/KwWcPWA9vFSD7Y23eABddGWmuFL6V0gJezAMxXzwbhPOYBz4jR3yvGtFqgZyDW djJ8/6ohGMDReQAq53au0B3OIEOA/2GTx/0Ol2vpS0ZVwHeBIKFLuHztjpmHeeZTGILb hdbQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si1936947otq.72.2020.03.17.09.27.12; Tue, 17 Mar 2020 09:27:26 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726643AbgCQQ0x (ORCPT + 99 others); Tue, 17 Mar 2020 12:26:53 -0400 Received: from mga17.intel.com ([192.55.52.151]:60668 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgCQQ0x (ORCPT ); Tue, 17 Mar 2020 12:26:53 -0400 IronPort-SDR: wxM5gfHesnbqJyCURgpd/4lOq+yGbC4GIcGGOLobnUF8NbMzyvumHBs88jhFS6lqUt4t0BDD8t XPM/DJpD4jeQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 09:26:52 -0700 IronPort-SDR: 5sJQC8mpecwiXgdj9P9ed5N2YqvExySFjwF6A6vuCxy0XtwABcdBjxLZRM95CuAtsPEOiSVE/W z9Aoh8NsX2QA== X-IronPort-AV: E=Sophos;i="5.70,565,1574150400"; d="scan'208";a="443814680" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 09:26:52 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: mingo@redhat.com, hpa@zytor.com, kuo-lang.tseng@intel.com, xiaochen.shen@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , stable@vger.kernel.org, Sai Praneeth Prakhya Subject: [PATCH] x86/resctrl: Fix invalid attempt at removing default resource group Date: Tue, 17 Mar 2020 09:26:45 -0700 Message-Id: <884cbe1773496b5dbec1b6bd11bb50cffa83603d.1584461853.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 commit 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") Cc: stable@vger.kernel.org Reported-by: Sai Praneeth Prakhya Tested-by: Sai Praneeth Prakhya Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 064e9ef44cd6..9d4e73a9b5a9 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3072,7 +3072,8 @@ static int rdtgroup_rmdir(struct kernfs_node *kn) * 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); -- 2.21.0