Received: by 10.192.165.156 with SMTP id m28csp226087imm; Tue, 17 Apr 2018 09:07:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx489O/Cz21HioZmLu0/5M4YsRCqfSmsyL0vh06vBD4ShjYXpd5Yj08M3+bZ+7TFJ6BQ3kSZR X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr2594651plg.23.1523981252010; Tue, 17 Apr 2018 09:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523981251; cv=none; d=google.com; s=arc-20160816; b=SEgad65pSi3avhWF/bZr8tEBmpXXQAmDU3ahOSPZGp5DK+agdcguSEy2AWgirmVKCr UAt6Mfg6S2XXYGMqO7yuEcA1xaVZKJSAH0DZl07rs8AG1oO15xYUhG6CzxLDz+QaqzU4 Iec9nnAuVLjj6HjdJllk/fb6H2/7tqt/TtttVIQ2K2IAhc/agPigh5D/9cXDouDFpy7z Qcdy0jPWzIovYlEM5Z73/cAIQzC9UEY6WK5BAdUuumX0zOfeJ10+hCTXL0jkTp9zGuEW VMTscRKF1izHEczqEes1vv4LnQ66+s5tac438ANoODknegB4OxYfIykHzCELwa0kWN0T kewQ== 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=+n1vXMQcTarUiKFWvHIwQqmOtn7SArdBdMlHCIT+2k8=; b=y2ukAjbejWRgWeiRwoIy9FGsBh6FlQCuzouXDW5eQD249YU9t086iipG0eSJRFuHHR 2iv9O8cuWf7mnEDN/WyHtwp8AZZjIJj/Kw7zgZdLRQwQdicECq//D0bhTV1jb69o4JPe tphz17NT8eZ8zcp2TMG2VUEiiEmyeHgqWqDwQeFeKFRUnn1uYhwWLoFDYq2G7Vxvyq5K DjAmNzctwmulUqB/L8dVYjiU9jc0zie7UbxKGDMMQUknN/1jj7hFaXh+RShhASWigoHO JhT73FfAvHBkD5nmQRvlqb7F7sUunFvkdOBfVkyby/019IZ98PKBhBJEpU79nd3zLz/z UHfQ== 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 d1-v6si14728370plo.328.2018.04.17.09.07.16; Tue, 17 Apr 2018 09:07:31 -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 S1754299AbeDQQFu (ORCPT + 99 others); Tue, 17 Apr 2018 12:05:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34640 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754739AbeDQQFq (ORCPT ); Tue, 17 Apr 2018 12:05:46 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DB296E56; Tue, 17 Apr 2018 16:05:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 4.14 10/49] parisc: Fix out of array access in match_pci_device() Date: Tue, 17 Apr 2018 17:58:49 +0200 Message-Id: <20180417155715.503525252@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155715.032245882@linuxfoundation.org> References: <20180417155715.032245882@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 4.14-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 @@ -651,6 +651,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); }