Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1687506ybh; Mon, 20 Jul 2020 04:54:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVBWW0n70zMiDCk+aQOGIzwmPcVMJGwGAoB+rPQqTWYMbCSHpM9HM4cy07ibIABRD/vHR/ X-Received: by 2002:a05:6402:c06:: with SMTP id co6mr21112577edb.142.1595246093627; Mon, 20 Jul 2020 04:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595246093; cv=none; d=google.com; s=arc-20160816; b=nLpetBfbWJhL8Q8Nkgj8pSd16FFxiVFMPOkMoNLGroWQlg6D8H/wHgjL0VxgO5IfWh TjWD/scw8xyS5k6kw5NSrXCIho2qyUCb4G6ny2CPxauUspsn9beMnvtoGfPW1hpeniIV j/4Dfu3n7B/tlBQU6gz+54sSTkjuN5VBWaT1K1ePpIAmdmW8/lTWvIeZLQ9TxrXaqOy0 6wFcAPjOCI8REsKL3sugfI5xhimbN/sUyvKeA2n6/olUbV9s6zZp5pBSIOPRJBh+JgW6 mSQggH9KRjbsWiJz0T7Mnqzmt+jBgYZ562kG/p2ePYUcsDQ3PD7jNnsGo/e6pqJF11S4 CN0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/YXYJgmTLLawI09r+e1//mSAR/9LYPumoks746wreuI=; b=bdlI/FtwqKN+U2W9OJ2/i/wR2yQY+RUIPffHnIB7CCcpRhKz5R1XBb4dwDe9MtdHJf g5Hub8B44gvUncKrT3AB7sfAs+6xV0tlH2C5ImRtGlmVelXjNM9QKdZ8+Mb0888F9030 V30IdcPtz1GMFve9W2cdqTAHIwsU5MKdyALLcmlHpwEVKrg8aguWwRHl7gyn50fyaHOY azTDm/fyUkTOw6BK2C+WS5BUVTD53kSayUP63YoaED0GikuSjvh6KXopbFMeu+x0YPH3 b82dIcbMHD1rS+5o9Z1Y8/78X1Eapo1fQPAlaliU05ERW2lN2beeI9IQaxwWRZGeKcIb fhKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=EGDNMaDL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q22si9955837ejx.87.2020.07.20.04.54.30; Mon, 20 Jul 2020 04:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=EGDNMaDL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728578AbgGTLyR (ORCPT + 99 others); Mon, 20 Jul 2020 07:54:17 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:59368 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728449AbgGTLyR (ORCPT ); Mon, 20 Jul 2020 07:54:17 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06KBgE1W113693; Mon, 20 Jul 2020 11:54:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=/YXYJgmTLLawI09r+e1//mSAR/9LYPumoks746wreuI=; b=EGDNMaDLd+galPObfcvba4RicKEZv8G9eN7N1NBumwkfvVN7uJ+yRjA0Fh8l7szyr6Do Azhg98EboiE3x6X3KmL25ZCG78NC0WfHCZKRLJc9/pyKR+jop8Fig/j0khw+2N0lrfBS iCkzwtqW+dC8tnhKBfJ9P4Dk7eNFchp0MoguJUW2+uDukzx3zRMol3xxbi4M6BB5Z9sh xOfdEoaQ52l2AgL1H2n03CQuiGUpZ4HhssbEZiZQVZlKMkCdZSGBCN85u4v5Cbz4H6HP /Tg3RVc5VIoO55h706SXCeq+BWhjf/olPX6HAPKWBBLfbWil+gJ0ouSZAY542GUdSPe1 uA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 32bpkaxnh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Jul 2020 11:54:10 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06KBi7Gm143755; Mon, 20 Jul 2020 11:54:09 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 32d9wb2np4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jul 2020 11:54:09 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06KBs8fI012686; Mon, 20 Jul 2020 11:54:08 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Jul 2020 04:54:08 -0700 Date: Mon, 20 Jul 2020 14:54:01 +0300 From: Dan Carpenter To: Peilin Ye Cc: Jiri Kosina , Benjamin Tissoires , Greg Kroah-Hartman , syzkaller-bugs@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [Linux-kernel-mentees] [PATCH v1] usbhid: Fix slab-out-of-bounds write in hiddev_ioctl_usage() Message-ID: <20200720115400.GI2549@kadam> References: <20200718231218.170730-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200718231218.170730-1-yepeilin.cs@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9687 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007200082 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9687 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007200082 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 18, 2020 at 07:12:18PM -0400, Peilin Ye wrote: > `uref->usage_index` is not always being properly checked, causing > hiddev_ioctl_usage() to go out of bounds under some cases. Fix it. > Yeah. This code is not obvious. It doesn't come from the user directly so we don't have to worry about nospec. It comes from hiddev_lookup_usage() where we set: uref->usage_index = j; We know that j is less than field->maxusage but we do need to check against field->report_count like your patch does... The two arrays are allocated in hid_register_field(). I don't know the code well enough to say how these arrays are used or why the one is larger than the other so I can't give a proper reviewed-by. But the patch looks reasonable and doesn't introduce any bugs which weren't there in the original code. regards, dan carpenter