Received: by 10.223.185.116 with SMTP id b49csp1041381wrg; Fri, 23 Feb 2018 10:51:06 -0800 (PST) X-Google-Smtp-Source: AH8x226CU1z6YppT+WeH7SaV3Gjj4oU4DZhypwua1eTmCBBbhoRfaiTYzN4rH9A8Bi1biUG2D2b2 X-Received: by 10.99.110.133 with SMTP id j127mr2181951pgc.79.1519411865896; Fri, 23 Feb 2018 10:51:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411865; cv=none; d=google.com; s=arc-20160816; b=zdXi6Y26T0QYVCHv4rO2HsxDhRcgjJqn3K5nERMysGw6JQ26Yn8KRA8KN7iPyl1LFS 52KiTAvkO/gNEnr+WavodEMxy2g2WS2V92hSYB3XWoBFbrLftU1uH++GPTSXXHs8++oU XIJToj0Xov5A9XPp3qP1zkLe8yB+BsoVAdoEMqKvXSj3U/YCCwOYmFUCFbKT+alcmfz6 X3qfC9MVZ5PHgd2DVXVCzLYmd+0L3334iy7eyCRkhC8iKHTJYeBhE4oZmusp0tMPkBxR 2jIpNTDGiV2o6jkSJTY66p//CHtbN8nUHxUpuODk8WLgRdm96eAOCloF1z+YxlY8Ie2t TqNw== 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=Z50b7ryVLe51Efola3Q6/DREUR67iyJQ94a1j8f4HFs=; b=fivXbIrKyjUCcjsPKW0RD/2mKScMR0cZ3Nxubh0QaRaUJfTjx3ciVS7xvyvVaFR8gW 3ROELUw6njdzkYoDH7aZ6P8oiahLksH/cBzEfkCgMEy/0JpfpLd1eQZaBBJrk4WHgZXg 5gIUcWpe+KoEptK3otNSNjW2jh88j9rhi0XtBQbMRS8eDmx7M1uQRuZhlVtJ79jXZaOF u6mn/tpYW+LJNu7jglpBHAcHu7hkhOMhm+CKtXd78vDcGWreOWIvHA84NFmNXak+FEjm 253GDwbKoCZn8MaMDf1ZI/wq5AHXeftxJeyx7ckVClVVGc5D9IGTvxYWXTMW8tIGEJ4x QchA== 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 y190si1844463pgd.177.2018.02.23.10.50.51; Fri, 23 Feb 2018 10:51:05 -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 S934642AbeBWSuC (ORCPT + 99 others); Fri, 23 Feb 2018 13:50:02 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45480 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934602AbeBWSuA (ORCPT ); Fri, 23 Feb 2018 13:50:00 -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 980571195; Fri, 23 Feb 2018 18:49:59 +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 022/159] ALSA: caiaq: Add a sanity check for invalid EPs Date: Fri, 23 Feb 2018 19:25:30 +0100 Message-Id: <20180223170745.876499330@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 58fc7f73a85d45a47057dad2af53502fdf6cf778 upstream. As syzkaller spotted, currently caiaq 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 3 != type 1 ------------[ cut here ]------------ WARNING: CPU: 1 PID: 1150 at drivers/usb/core/urb.c:449 usb_submit_urb+0xf8a/0x11d0 Modules linked in: CPU: 1 PID: 1150 Comm: kworker/1:1 Not tainted 4.14.0-rc2-42660-g24b7bd59eec0 #277 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: init_card sound/usb/caiaq/device.c:467 snd_probe+0x81c/0x1150 sound/usb/caiaq/device.c:525 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/caiaq/device.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c @@ -461,6 +461,13 @@ static int init_card(struct snd_usb_caia cdev->midi_out_buf, EP1_BUFSIZE, snd_usb_caiaq_midi_output_done, cdev); + /* sanity checks of EPs before actually submitting */ + if (usb_urb_ep_type_check(&cdev->ep1_in_urb) || + usb_urb_ep_type_check(&cdev->midi_out_urb)) { + dev_err(dev, "invalid EPs\n"); + return -EINVAL; + } + init_waitqueue_head(&cdev->ep1_wait_queue); init_waitqueue_head(&cdev->prepare_wait_queue);