From patchwork Sun Nov 8 17:24:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Krause X-Patchwork-Id: 7578871 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 39A529F1C2 for ; Sun, 8 Nov 2015 17:24:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B1692065E for ; Sun, 8 Nov 2015 17:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BF9B20650 for ; Sun, 8 Nov 2015 17:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751864AbbKHRYi (ORCPT ); Sun, 8 Nov 2015 12:24:38 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:36193 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677AbbKHRYh (ORCPT ); Sun, 8 Nov 2015 12:24:37 -0500 Received: by wmww144 with SMTP id w144so59756155wmw.1 for ; Sun, 08 Nov 2015 09:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=3UXB9uiNTI6Tpd0S/xA/TZ0xZt1/A6qFPa5ok4b/Epo=; b=XwH+TbiRp8p919cEQLaY+Jo71joAn3vai9cEUu/WiiFcRLEOQs7bE4Ls20JfDePYex ghg7UWyRgRy0n1FIl0fWxvmH5fr99rp4XEspvfTsxO7G0IPYsHQlLiw1EfCfXWitry/2 B7TCH9kRasTJxrL/wO1KOtqCVrpKqZ1swvZTXoZepqZoeeywim+uIdvXmUJn3ftErCmE yO7pKOjuz7jlTdIvauRDVmeQvsv3wLBJ3yd0mpjF+Z+OqYnExT2sox7ev5C3c/tM5GTj Y+rbWGZ5b8nCmM65tHoTbzI15tqGjfSPF6NbsNnJ2mZj15o3biuMJs3DvPnKFidXAk8f zMHg== X-Received: by 10.28.212.8 with SMTP id l8mr22539032wmg.32.1447003476677; Sun, 08 Nov 2015 09:24:36 -0800 (PST) Received: from jig.fritz.box (p54B301AE.dip0.t-ipconnect.de. [84.179.1.174]) by smtp.gmail.com with ESMTPSA id kr10sm10881786wjc.25.2015.11.08.09.24.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2015 09:24:36 -0800 (PST) From: Mathias Krause To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Mathias Krause , Sasha Levin , Prarit Bhargava Subject: [PATCH] PCI: Prevent out of bounds access in numa_node override - part 2 Date: Sun, 8 Nov 2015 18:24:04 +0100 Message-Id: <1447003444-27108-1-git-send-email-minipli@googlemail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Commit 1266963170f5 ("PCI: Prevent out of bounds access in numa_node override") missed that the user provided node could also be negative. Handle this case as well to really avoid out-of-bounds accesses to the node_states[] array. Fixes: 1266963170f5 ("PCI: Prevent out of bounds access in numa_node...") Signed-off-by: Mathias Krause Cc: Sasha Levin Cc: Prarit Bhargava CC: stable@vger.kernel.org # v3.19+ --- drivers/pci/pci-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 92618686604c..87835d50b927 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -216,7 +216,7 @@ static ssize_t numa_node_store(struct device *dev, if (ret) return ret; - if (node >= MAX_NUMNODES || !node_online(node)) + if (node < 0 || node >= MAX_NUMNODES || !node_online(node)) return -EINVAL; add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);