Received: by 10.223.185.116 with SMTP id b49csp1084887wrg; Fri, 23 Feb 2018 11:39:16 -0800 (PST) X-Google-Smtp-Source: AH8x226GIXiDpRBko0hsS519JS+U+a8FBaWQVTAKbu+mdHG1mrEkAg+WdVpOEp28W7QUSa0io3c4 X-Received: by 2002:a17:902:5596:: with SMTP id g22-v6mr2625445pli.4.1519414756405; Fri, 23 Feb 2018 11:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414756; cv=none; d=google.com; s=arc-20160816; b=FYicU+H336+n1s/sOq5hZP7rndX0cOvzdfcQgBwrxb5mLIWM0hkwrsXkUR3fxx5i/5 aSynEv02krESmXDiCD2Pk0cKJP6pVS4oagOtXBZFh41EoZAtwJPI0Jh1v7WAiozkLmSw nDMD4/XNCLm+ULoOQb3v7X99+aT/roFb/oxKuZ56vY/Q5iAwDGU2NPuadgpyMbPkO99l eMvT/YQ3KAbfSgfDZIlL2XtXlmyi8a8QdX/wmTTt6FkTu3JcMMiLeRstZCjP/mwKV8C8 mPsd+ROaiRISZVUIexaTN/dKMBR55F6GYiaad2y0NCR4o7aGzeE5fSObdZd7uTvw5UUF VFvQ== 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=2MAtqfklvjbghIMgLzFkMCdI6m0UF92EQ7c6BOjHbO4=; b=bloqNizLldKmTUimgBmlOCx4HcQhDtrWDQ5f76GQczyX/zxGPNJer5tvWsSRZKgxv8 Z+E8Jr1UcfbPm9kLzH/MjnYM5UYq5wV7qNv1h80rc34/x8wXGJb3p/osdfI3FxhNiqlC 0CMQsmkqVaGfxB5mbtf1B9kIa1EZHofKMRFb8Z/Knj0lNerK5qWgA0ZnLT9zt3oqAlF/ YVB50Q/SaszPDVpKVWqIzqcxxqG+QIbTKj86Uek1VpNu774UDJGoNoJL7b2CZXkSw3H2 gqoA3Hn4yIw5wvNu9JQ1Mv7kJtOorf7h44LxJ9cfCDHlbdaGSXEE9wch+IRHlHRIq9T8 XKCg== 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 x3-v6si1309184plo.608.2018.02.23.11.39.02; Fri, 23 Feb 2018 11:39: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 S934657AbeBWSuH (ORCPT + 99 others); Fri, 23 Feb 2018 13:50:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45508 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934413AbeBWSuF (ORCPT ); Fri, 23 Feb 2018 13:50:05 -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 3654F11B5; Fri, 23 Feb 2018 18:50:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Takashi Iwai Subject: [PATCH 4.14 023/159] ALSA: bcd2000: Add a sanity check for invalid EPs Date: Fri, 23 Feb 2018 19:25:31 +0100 Message-Id: <20180223170745.997497718@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@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: Takashi Iwai commit 6815a0b444572527256f0d0efd8efe3ddede6018 upstream. As syzkaller spotted, currently bcd2000 driver submits a URB with the fixed EP without checking whether it's actually available, which may result in a kernel warning like: usb 1-1: BOGUS urb xfer, pipe 1 != type 3 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1846 at drivers/usb/core/urb.c:449 usb_submit_urb+0xf8a/0x11d0 Modules linked in: CPU: 0 PID: 1846 Comm: kworker/0:2 Not tainted 4.14.0-rc2-42613-g1488251d1a98 #238 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: bcd2000_init_device sound/usb/bcd2000/bcd2000.c:289 bcd2000_init_midi sound/usb/bcd2000/bcd2000.c:345 bcd2000_probe+0xe64/0x19e0 sound/usb/bcd2000/bcd2000.c:406 usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361 .... This patch adds a sanity check of validity of EPs at the device initialization phase for avoiding the call with an invalid EP. Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/bcd2000/bcd2000.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/sound/usb/bcd2000/bcd2000.c +++ b/sound/usb/bcd2000/bcd2000.c @@ -342,6 +342,13 @@ static int bcd2000_init_midi(struct bcd2 bcd2k->midi_out_buf, BUFSIZE, bcd2000_output_complete, bcd2k, 1); + /* sanity checks of EPs before actually submitting */ + if (usb_urb_ep_type_check(bcd2k->midi_in_urb) || + usb_urb_ep_type_check(bcd2k->midi_out_urb)) { + dev_err(&bcd2k->dev->dev, "invalid MIDI EP\n"); + return -EINVAL; + } + bcd2000_init_device(bcd2k); return 0;