From patchwork Tue Nov 24 15:08:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 7691871 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 967F49F4F5 for ; Tue, 24 Nov 2015 15:08:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1EDA2084B for ; Tue, 24 Nov 2015 15:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEB7620840 for ; Tue, 24 Nov 2015 15:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754520AbbKXPIL (ORCPT ); Tue, 24 Nov 2015 10:08:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56506 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753685AbbKXPIK (ORCPT ); Tue, 24 Nov 2015 10:08:10 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2F30BC075663; Tue, 24 Nov 2015 15:08:10 +0000 (UTC) Received: from praritdesktop.bos.redhat.com (prarit-guest.khw.lab.eng.bos.redhat.com [10.16.186.145]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAOF89cQ015113; Tue, 24 Nov 2015 10:08:09 -0500 From: Prarit Bhargava To: linux-pci@vger.kernel.org Cc: Prarit Bhargava , Sasha Levin , Bjorn Helgaas , stable@vger.kernel.org Subject: [PATCH] PCI: Fix NUMA bounds check Date: Tue, 24 Nov 2015 10:08:05 -0500 Message-Id: <1448377685-7515-1-git-send-email-prarit@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Suggested here: http://marc.info/?l=linux-pci&m=144706760307247&w=2 P. -----8<----- The fix for 1266963 ("PCI: Prevent out of bounds access in numa_node override") should allow for the setting of all valid NUMA states including NUMA_NO_NODE, which is also interpreted as "any node". This change splits the test into a range check, and then a separate check to see if the node is online. Fixes: 1266963 ("PCI: Prevent out of bounds access in numa_node override") Cc: Sasha Levin Cc: Bjorn Helgaas Cc: stable@vger.kernel.org Signed-off-by: Prarit Bhargava --- drivers/pci/pci-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 9261868..6e98182 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -216,7 +216,10 @@ static ssize_t numa_node_store(struct device *dev, if (ret) return ret; - if (node >= MAX_NUMNODES || !node_online(node)) + if (node < NUMA_NO_NODE || node >= MAX_NUMNODES) + return -EINVAL; + + if (node != NUMA_NO_NODE && !node_online(node)) return -EINVAL; add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);