Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2289205pxb; Mon, 11 Jan 2021 06:09:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJywp69CIFexFAm9Se9JbhVGKBWJCuZwNUqcImZNIW6GTDpCaiCppTEneymIFW3BcqWOUno6 X-Received: by 2002:a17:907:214d:: with SMTP id rk13mr11225867ejb.501.1610374165614; Mon, 11 Jan 2021 06:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610374165; cv=none; d=google.com; s=arc-20160816; b=RTTO7qdnNnuFxe2sg7Y5t7faFBdLOJr3kG/xQgPoZ6pTnbornh5tryH/T81VtP6oVI /zxgwaf+/8KQRaLIPjebcodH5jz/utvVGmns6DQyHRJJST8As5LjwgYudQ6Y2uCkOqaN vxSOBELsuY0osjQMwVWbuwS5gsII2xj76FOd24uWSjGNskSNs4tq6lgBuXzlw0Q6vnym ZLU/GAzM4oq2so8Y57xZWtr/48Jw3WKpYSL83BJ4AFuvxnG8oUSNQOUFHEDsI4b/uS9P w4QvVobwRx9hyj9W7VBEb8T29X4XbcPlXPgI6Wtlwvtmdp8OwdHuV/GA5720ARHyRMiK dnVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aIbYVvS5kkNf94nCdIxs43OW4gqaPV+gzSgh0CeA91k=; b=LE9Ind1aCbMpsDfkAgtYjQrBOp5O9M3ptx/T1aUwDszv61YDt5BbwPNbj773L4F4so huwibwrghQT6AyfqRxkBMsvztd/k3RCASapkJ8y8tVyaW0laWhKfAJXwE/tydESAdV1T K4Db1Lwl3vI0oHBKJRc8exPD6R/Dp0hbnWWFA7X58UfUaCjJC5KWe954uoqczj+s7yYj CkZxt1s3ydz4VzBg+5V6jUUj8EIuEbg2QaPfct3D2i/bnrNzOlQeq7mtnvyoxxguKN4c 1NJUpEAk8DH+0Hnuy8pPjp6UatrAtdkS7mlg+x4k+gRnSbOeMyI2wsaQe7N4NCabBoeF q+Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GgO3vK8y; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si6579716ejw.701.2021.01.11.06.08.56; Mon, 11 Jan 2021 06:09:25 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=GgO3vK8y; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388411AbhAKOGR (ORCPT + 99 others); Mon, 11 Jan 2021 09:06:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:50168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbhAKND5 (ORCPT ); Mon, 11 Jan 2021 08:03:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3612822527; Mon, 11 Jan 2021 13:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370221; bh=VedbmO/5/bZazH0fUPBlfrJlYbOrNDIrQEbwdNqIqQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgO3vK8yDX6y2z1u8yT4KolfzFn5NkxuVjF3NF3t9KrOFvPWS8WfXZvU2vLci3FsW Fpo9Qw8wZEFs4M/ikSct1IvZv5Obza4iigqyB6Ig9hAjuxY7iTA6dhCQ2kgXO+shvI U3Sx/HiheQUcfNsqiEMuPix1Hd7d9oSjOM7nJBuQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+92e45ae45543f89e8c88@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 4.9 31/45] ALSA: usb-audio: Fix UBSAN warnings for MIDI jacks Date: Mon, 11 Jan 2021 14:01:09 +0100 Message-Id: <20210111130035.151846078@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130033.676306636@linuxfoundation.org> References: <20210111130033.676306636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit c06ccf3ebb7503706ea49fd248e709287ef385a3 upstream. The calculation of in_cables and out_cables bitmaps are done with the bit shift by the value from the descriptor, which is an arbitrary value, and can lead to UBSAN shift-out-of-bounds warnings. Fix it by filtering the bad descriptor values with the check of the upper bound 0x10 (the cable bitmaps are 16 bits). Reported-by: syzbot+92e45ae45543f89e8c88@syzkaller.appspotmail.com Cc: Link: https://lore.kernel.org/r/20201223174557.10249-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/midi.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -1867,6 +1867,8 @@ static int snd_usbmidi_get_ms_info(struc ms_ep = find_usb_ms_endpoint_descriptor(hostep); if (!ms_ep) continue; + if (ms_ep->bNumEmbMIDIJack > 0x10) + continue; if (usb_endpoint_dir_out(ep)) { if (endpoints[epidx].out_ep) { if (++epidx >= MIDI_MAX_ENDPOINTS) { @@ -2119,6 +2121,8 @@ static int snd_usbmidi_detect_roland(str cs_desc[1] == USB_DT_CS_INTERFACE && cs_desc[2] == 0xf1 && cs_desc[3] == 0x02) { + if (cs_desc[4] > 0x10 || cs_desc[5] > 0x10) + continue; endpoint->in_cables = (1 << cs_desc[4]) - 1; endpoint->out_cables = (1 << cs_desc[5]) - 1; return snd_usbmidi_detect_endpoints(umidi, endpoint, 1);