Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2814271pxb; Mon, 11 Jan 2021 22:02:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm7ZwWvDXc33Kc2Omd6Yx57hUO2q4nTfKOBCKSH5elQuc9vEBKckJ9QKMqaHIFFZppZQpl X-Received: by 2002:a17:906:3bcd:: with SMTP id v13mr2057486ejf.181.1610431339885; Mon, 11 Jan 2021 22:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610431339; cv=none; d=google.com; s=arc-20160816; b=J+CXXa8VdwXbLfzTn3wMc5ZukSRkqWi+ogBT0FB9EkYEdrQYXRqGp0JXXgP3wiJ722 7H4XS1GApqpoIqGTIT8ubZlavPUOEXTXe+7Td1TqIh2o04BAU4p5JGOZCi5E5r5tbJO0 uG+jU2sLcDqpOx1/f9LZrWrzbRbZB3FtFPajGEkJqnC/2tTHwsqEaEKDGXKmtz/22a2L 0a2vWuF2/vIjdmlUJosk9K4JzedemlFix4hzdW9MMeW+Xj2aYKmWsjqJksqk4H1tq1M9 UmHbyetOTBcZ5b5ymco2GGUVxQR4fnOii/xromvwvvb+HvO10mfbuT+NOs+R9ztTgoRX N81Q== 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=fRYHu4AJ3AuSkXacXgFDHutyXDolxtYOX45XRh8Mtgk=; b=K32yjvmIKv1s+qMydl267p952XbbrmoAvuxfIYQcf0Mo2K0VtCoj6PkUSy4WbsOFcH ckfAudloYRBUrJy+XzmghfvtOImjtto/fPlXyuMWJ0lDsfB92JYwLKRQqsqgX3LXFdqa /z/ANUaJX4Uo8FUsIouQsH0f/s/h94JXYldC6ZO2L8RYCo/NuMSl0FR+IlvAMZuj9IlP E98R+e1JEk5PPZMEuij0Ha3K0m4WCvMQlKM1gOo6QEfkq07aQyziyw5XwCmK0v29iqVZ nxehvXwQR4YGX48BTm5Av+EGS0hBLr4Zg8Vz9Uy+9HU+p887TVvL+bfxd1TaGb/Ufi8f I3iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GyqQO6Em; 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 e12si888203edc.322.2021.01.11.22.01.56; Mon, 11 Jan 2021 22:02:19 -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=GyqQO6Em; 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 S1733066AbhAKNhQ (ORCPT + 99 others); Mon, 11 Jan 2021 08:37:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:60132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731887AbhAKNNY (ORCPT ); Mon, 11 Jan 2021 08:13:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 099EF2225E; Mon, 11 Jan 2021 13:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370788; bh=vhFLJ8HdTM02dwPJ00wgNSQScS2zmm2Uyf30gja4WeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GyqQO6Em0HjMmzET7ohXO2Fl3H+6ROsD8anbw5Wmqbow2g4L6ANFgedqawEmbhHaK QLGzLyL1KGo2czES43dDvwkzOYPYkWt6+4X65IL72HJtFPllL6OclwgK6GKEBI3Ddc FtLX/OiJ2MMcyIvbQwUx7H4nowRiViM5UoOYNrOE= 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 5.4 66/92] ALSA: usb-audio: Fix UBSAN warnings for MIDI jacks Date: Mon, 11 Jan 2021 14:02:10 +0100 Message-Id: <20210111130042.330594103@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@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 @@ -1889,6 +1889,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) { @@ -2141,6 +2143,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);