Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3538605pxj; Mon, 24 May 2021 08:57:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzphmQD36P3+3I0fY0wg2EIGDePcTPaaIk8gQahHTBUwS+GR5ST/k/HCcZIYuVa8DV8hGR X-Received: by 2002:a92:c56a:: with SMTP id b10mr14730654ilj.17.1621871845686; Mon, 24 May 2021 08:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871845; cv=none; d=google.com; s=arc-20160816; b=ZfeleQJ6T3BJtLw9E138u6PIMWxK82Z28PI8ThM0X7sgDwnqt/scK477dQzzymGet1 mbfdMqnNKl3D3RWbJBlELXyQ4IULxipL/Exa8KePqM+pbHqPkLyAobEZ6k/oShERQoaL lAvip4lIXp/xkcohsGgfq6D6js65eb1FX/CBBv1gbPecBypn3pbjvC8/OVTAU/YyDhKy Krum47Mf+RLrsj6P0SjiV10d4qI9UrhDE4JzJzV41qs8gM+9Zbe56+Tym6fuaZMW5KG3 lZxpMYuqyDVgy5ROzGXXAjsav0IrF8BPW1b2gq5bJHWiK0RcmkUm8OFTUMvOURl8+7sD mS6w== 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=N571dPbtr7nfXOHspuxf95jOpcBmsjcKRpDeOs947rM=; b=rTCegD6RU6/podL3TZYL0amAZR8mDJDQNNdJWu7f9UnYCichd6VoGMcy4S7j3wgzGS Q6fN5ecxXrvQ4nWIrV5J0cZqkiUlGiml06YbvZf22HZV17RDba9mgkJX9gAjOdrEP8bl OE/5cwP3Jl5JiNsR/XwSLfVFLeg9VVHfN+PhNawMW9m78fV8JHnUpeWr00PXOdw5BeFB oaAt2blFi5GngIwerZX8LxdAaYoMPQkzY+MkdfuhaEhDP+43o8Ogdx/MhFX65rp67dkI 0RYqqbaVdEhFSDNrn2bMDGC4ftE4CKVlhPoIE9Z+VohPK7GNyxTX7BAqjvQlH0cc5Mcc vc5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aAAWoor8; 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 l126si19995444iof.101.2021.05.24.08.57.12; Mon, 24 May 2021 08:57:25 -0700 (PDT) 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=aAAWoor8; 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 S234539AbhEXP4e (ORCPT + 99 others); Mon, 24 May 2021 11:56:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:36504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234619AbhEXPtQ (ORCPT ); Mon, 24 May 2021 11:49:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76EA36141C; Mon, 24 May 2021 15:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870666; bh=yiU8zdIvYxIC9N2pYR+ykiaGI3Da4dRhuRNqlvARqOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAAWoor8HxFAjsEFVs35xoFuW6n9mr59YnnG62ZkbuBaOR30vu3Gw3+6pDm6nOD6/ Sq3FmErYcptc3PIQ2g110gv84IimR5J0IYlFoFHhiE6bmzuCs9tw/37uaB7yxgrUHS 2uCvL4DivoDowzwvNPJHW6ZffqNkRBQU8AQUlXuw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6bb23a5d5548b93c94aa@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 5.4 23/71] ALSA: usb-audio: Validate MS endpoint descriptors Date: Mon, 24 May 2021 17:25:29 +0200 Message-Id: <20210524152327.216071018@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152326.447759938@linuxfoundation.org> References: <20210524152326.447759938@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 e84749a78dc82bc545f12ce009e3dbcc2c5a8a91 upstream. snd_usbmidi_get_ms_info() may access beyond the border when a malformed descriptor is passed. This patch adds the sanity checks of the given MS endpoint descriptors, and skips invalid ones. Reported-by: syzbot+6bb23a5d5548b93c94aa@syzkaller.appspotmail.com Cc: Link: https://lore.kernel.org/r/20210510150659.17710-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,8 +1889,12 @@ static int snd_usbmidi_get_ms_info(struc ms_ep = find_usb_ms_endpoint_descriptor(hostep); if (!ms_ep) continue; + if (ms_ep->bLength <= sizeof(*ms_ep)) + continue; if (ms_ep->bNumEmbMIDIJack > 0x10) continue; + if (ms_ep->bLength < sizeof(*ms_ep) + ms_ep->bNumEmbMIDIJack) + continue; if (usb_endpoint_dir_out(ep)) { if (endpoints[epidx].out_ep) { if (++epidx >= MIDI_MAX_ENDPOINTS) {