Received: by 10.192.165.148 with SMTP id m20csp2462916imm; Sun, 22 Apr 2018 07:33:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ydfmoj2sVAlJF0m7OjGbfynz+XATtFYK0okzPQXWoUm7no6XLiyqG3cuSznMd9jeKJS+5 X-Received: by 2002:a17:902:2f:: with SMTP id 44-v6mr17905125pla.187.1524407613424; Sun, 22 Apr 2018 07:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407613; cv=none; d=google.com; s=arc-20160816; b=NGdIlVgyFEFTmg2bmaE3Xo486/xqehTxL0gifT7Y03P+XWe6WMbD3Lag3EOtMxpMA5 Xosrh8kAA1qiDZLBy4fRpYVgu2BeBZegkaRNyDyqiawk+0bxyq8Y8LFxzqYv6y03pA8q f+Ntl4rxNvh5mUpzOrqET2a3icXCKZMiu0gpxJWbrDfCkfD7MVc0Kqa5B1SSHkxC7+Cw zevAl8Ghf+479ZtQqyJrtJPex7YR/kjBNQBszULXV0KvvUcorattDifZ0NG02VNi69Bc Xe0AxLdyVaoP+iMfSMeaUikxYuJevHRKCZMFUVUL7YoLqoZTiYTvugGO3SLirjOdktlg jcXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BxINKcR3zGoqj9mJZapRY+lHoHLANBnwJXwJyRycszw=; b=jptIYOlQOLx9c0JZtc2gzpu2SYe3lAXhr8waIrw/VpLUixXcjVa4NuDc3YKEW0GFQI l4Pw4KVwYSr9mwSI/oi3vxnaVOSemseWe2Sb9AF+S2ORnQbroVek7JzmX22S7WecxNdA sMztr6kpBZMtWO/RQq4jDjLYejZNZuqZuATfkSDj1Evg33qmGgTpPgqqiDJY6mJ5kUD2 ExpzJJsSVSBRUrq5n1HWq4FhMxEIlA7IjgFzb1IXDZRATracApG+bRsbiXDhcdQg4wdG AJcCHtOAWmqKa/MQjqt7cfyriEumCiaYmBD9RWAsM1AlIRoYFBO6p2cNwmv6o4/XZki6 vODQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n136si2836446pfd.312.2018.04.22.07.33.19; Sun, 22 Apr 2018 07:33:33 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757445AbeDVOUg (ORCPT + 99 others); Sun, 22 Apr 2018 10:20:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60424 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757377AbeDVOU0 (ORCPT ); Sun, 22 Apr 2018 10:20:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 07ED398C; Sun, 22 Apr 2018 14:20:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 3.18 02/52] parisc: Fix out of array access in match_pci_device() Date: Sun, 22 Apr 2018 15:53:35 +0200 Message-Id: <20180422135315.350623373@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Helge Deller commit 615b2665fd20c327b631ff1e79426775de748094 upstream. As found by the ubsan checker, the value of the 'index' variable can be out of range for the bc[] array: UBSAN: Undefined behaviour in arch/parisc/kernel/drivers.c:655:21 index 6 is out of range for type 'char [6]' Backtrace: [<104fa850>] __ubsan_handle_out_of_bounds+0x68/0x80 [<1019d83c>] check_parent+0xc0/0x170 [<1019d91c>] descend_children+0x30/0x6c [<1059e164>] device_for_each_child+0x60/0x98 [<1019cd54>] parse_tree_node+0x40/0x54 [<1019d86c>] check_parent+0xf0/0x170 [<1019d91c>] descend_children+0x30/0x6c [<1059e164>] device_for_each_child+0x60/0x98 [<1019d938>] descend_children+0x4c/0x6c [<1059e164>] device_for_each_child+0x60/0x98 [<1019cd54>] parse_tree_node+0x40/0x54 [<1019cffc>] hwpath_to_device+0xa4/0xc4 Signed-off-by: Helge Deller Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/parisc/kernel/drivers.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/parisc/kernel/drivers.c +++ b/arch/parisc/kernel/drivers.c @@ -648,6 +648,10 @@ static int match_pci_device(struct devic (modpath->mod == PCI_FUNC(devfn))); } + /* index might be out of bounds for bc[] */ + if (index >= 6) + return 0; + id = PCI_SLOT(pdev->devfn) | (PCI_FUNC(pdev->devfn) << 5); return (modpath->bc[index] == id); }