Received: by 10.223.185.116 with SMTP id b49csp1049143wrg; Fri, 23 Feb 2018 11:00:16 -0800 (PST) X-Google-Smtp-Source: AH8x227UbJac/9PqebJorSYyw91ogQ0bELP7RhoKhf3ic4okYNzPIx3/51GHNuuWWTQMptXSs8wa X-Received: by 10.98.37.198 with SMTP id l189mr2729724pfl.103.1519412416374; Fri, 23 Feb 2018 11:00:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412416; cv=none; d=google.com; s=arc-20160816; b=KdSxg/0DITo8UN2S9xNKQ76nSCZGojqHMAEnzrIbL+SK1qg6OlyTEmVIchHnNonSH/ Dm0+MuSDb/opBfuEvkWzqqHWBKSa00KSodUhUDAjlPkwn0G78kf4y26L+N8yi5ARareY gf3oZZQhUrUIeEQYQCiCdszp4stKUih/dg4BsBBBYg20g8+rUw9RDKhcS1xsDC1bCtTY GBpmKXVTcj27wcfdSmRrZAIg+j2yruT/aCYn37bn+6L+P746KCMtWaYtXhhka/NOWR8L VYilOac6D8vpWiEQLpgaNdh0SXx9jbUTsN1ISJb7SxGIlnwdVVH1pfV3F7KNzVNqxfAK CVRg== 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=lLmyjGkZ2Xi1g8eGi/E2ELJRbSWfOf2eEMLCkF8tziw=; b=ETZ+IQP3Li+GY5vY6PRiq9/q1mVE/c7FrgMyM6ncIxY7hiCJOc/sPGGRcuyb1jO8Mo /txjuCfOC3MwW1MhN63QUN04lkBsIhragxWPOCjTgeuW3fMi5rqgr+jSWaDAvSTEOb7h f0caeIhFR+e+uGHPPfYmVXB3X0XAQeUPFWkrZLZfEsfvLcUm7e6r2n/esZtKXzdLaM2P /1TVcPyDSf87ODYHSTWKYs3MKxvKyjJOEmzMjqlyszRxb1XWSYRfv3EFhJC4EUmZOHFw 2gcd7ZJhZ1BdvbmbCc0ybC6sdtU6wD5OcBKhw5m9JeoSfeZvFIBBTYv8KXr+hHXMSMEk Pmtw== 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 33-v6si2144964ply.512.2018.02.23.11.00.02; Fri, 23 Feb 2018 11:00:16 -0800 (PST) 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 S965532AbeBWS6H (ORCPT + 99 others); Fri, 23 Feb 2018 13:58:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50404 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965252AbeBWS6D (ORCPT ); Fri, 23 Feb 2018 13:58:03 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C7F2D107C; Fri, 23 Feb 2018 18:58:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Mauro Carvalho Chehab Subject: [PATCH 4.15 06/45] media: pvrusb2: properly check endpoint types Date: Fri, 23 Feb 2018 19:28:45 +0100 Message-Id: <20180223170716.269633850@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrey Konovalov commit 72c27a68a2a3f650f0dc7891ee98f02283fc11af upstream. As syzkaller detected, pvrusb2 driver submits bulk urb withount checking the the endpoint type is actually blunk. Add a check. usb 1-1: BOGUS urb xfer, pipe 3 != type 1 ------------[ cut here ]------------ WARNING: CPU: 1 PID: 2713 at drivers/usb/core/urb.c:449 usb_submit_urb+0xf8a/0x11d0 Modules linked in: CPU: 1 PID: 2713 Comm: pvrusb2-context Not tainted 4.14.0-rc1-42251-gebb2c2437d80 #210 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff88006b7a18c0 task.stack: ffff880069978000 RIP: 0010:usb_submit_urb+0xf8a/0x11d0 drivers/usb/core/urb.c:448 RSP: 0018:ffff88006997f990 EFLAGS: 00010286 RAX: 0000000000000029 RBX: ffff880063661900 RCX: 0000000000000000 RDX: 0000000000000029 RSI: ffffffff86876d60 RDI: ffffed000d32ff24 RBP: ffff88006997fa90 R08: 1ffff1000d32fdca R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff1000d32ff39 R13: 0000000000000001 R14: 0000000000000003 R15: ffff880068bbed68 FS: 0000000000000000(0000) GS:ffff88006c600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000001032000 CR3: 000000006a0ff000 CR4: 00000000000006f0 Call Trace: pvr2_send_request_ex+0xa57/0x1d80 drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3645 pvr2_hdw_check_firmware drivers/media/usb/pvrusb2/pvrusb2-hdw.c:1812 pvr2_hdw_setup_low drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2107 pvr2_hdw_setup drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2250 pvr2_hdw_initialize+0x548/0x3c10 drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2327 pvr2_context_check drivers/media/usb/pvrusb2/pvrusb2-context.c:118 pvr2_context_thread_func+0x361/0x8c0 drivers/media/usb/pvrusb2/pvrusb2-context.c:167 kthread+0x3a1/0x470 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 Code: 48 8b 85 30 ff ff ff 48 8d b8 98 00 00 00 e8 ee 82 89 fe 45 89 e8 44 89 f1 4c 89 fa 48 89 c6 48 c7 c7 40 c0 ea 86 e8 30 1b dc fc <0f> ff e9 9b f7 ff ff e8 aa 95 25 fd e9 80 f7 ff ff e8 50 74 f3 ---[ end trace 6919030503719da6 ]--- Signed-off-by: Andrey Konovalov Signed-off-by: Greg Kroah-Hartman Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -3648,6 +3648,12 @@ static int pvr2_send_request_ex(struct p hdw); hdw->ctl_write_urb->actual_length = 0; hdw->ctl_write_pend_flag = !0; + if (usb_urb_ep_type_check(hdw->ctl_write_urb)) { + pvr2_trace( + PVR2_TRACE_ERROR_LEGS, + "Invalid write control endpoint"); + return -EINVAL; + } status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); if (status < 0) { pvr2_trace(PVR2_TRACE_ERROR_LEGS, @@ -3672,6 +3678,12 @@ status); hdw); hdw->ctl_read_urb->actual_length = 0; hdw->ctl_read_pend_flag = !0; + if (usb_urb_ep_type_check(hdw->ctl_read_urb)) { + pvr2_trace( + PVR2_TRACE_ERROR_LEGS, + "Invalid read control endpoint"); + return -EINVAL; + } status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); if (status < 0) { pvr2_trace(PVR2_TRACE_ERROR_LEGS,