From patchwork Mon Mar 13 10:50:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9620457 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 32FC760244 for ; Mon, 13 Mar 2017 10:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 263A8283F9 for ; Mon, 13 Mar 2017 10:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 195F728455; Mon, 13 Mar 2017 10:50:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 144B9283F9 for ; Mon, 13 Mar 2017 10:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbdCMKue (ORCPT ); Mon, 13 Mar 2017 06:50:34 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:37665 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751568AbdCMKud (ORCPT ); Mon, 13 Mar 2017 06:50:33 -0400 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v2DAoFbY019429 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Mar 2017 10:50:16 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v2DAoFqD018140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Mar 2017 10:50:15 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v2DAoDGs009682; Mon, 13 Mar 2017 10:50:14 GMT Received: from mwanda (/154.0.138.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 Mar 2017 03:50:13 -0700 Date: Mon, 13 Mar 2017 13:50:04 +0300 From: Dan Carpenter To: Kurt Schwemmer , Logan Gunthorpe Cc: Stephen Bates , Bjorn Helgaas , linux-pci@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/2] switchtec: off by one in ioctl_event_ctl() Message-ID: <20170313105004.GA24989@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The > should be >= SWITCHTEC_IOCTL_MAX_EVENTS. Otherwise we probably read one space beyond the end of the loop, hit a sanity check and return -EINVAL. This bug doesn't look super serious. Fixes: 61c2e02154a9 ("switchtec: Add IOCTLs to the Switchtec driver") Signed-off-by: Dan Carpenter Reviewed-by: Logan Gunthorpe diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 1f045c95dec6..82ae08956457 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -1049,7 +1049,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev, if (copy_from_user(&ctl, uctl, sizeof(ctl))) return -EFAULT; - if (ctl.event_id > SWITCHTEC_IOCTL_MAX_EVENTS) + if (ctl.event_id >= SWITCHTEC_IOCTL_MAX_EVENTS) return -EINVAL; if (ctl.flags & SWITCHTEC_IOCTL_EVENT_FLAG_UNUSED)