Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3546185pxj; Mon, 24 May 2021 09:05:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCGIsf3ud9XtbIkx6TlcWIx6llKLA2vS5flB1x9McpqJwnrM3xrii2hBib+gxu6piP8/bt X-Received: by 2002:a5d:8147:: with SMTP id f7mr16476222ioo.135.1621872335519; Mon, 24 May 2021 09:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872335; cv=none; d=google.com; s=arc-20160816; b=tSKwhTM2KXKxulkoqdhrREQ8WYfCSz+thGoZRVPSzFxTP+27QB5sOI7ReqTTjjR2sL fLsA6M0lYMZM/th0pkGLxYauPN87xiu4tfw9VVWO2+XgwHXTn+TNkRZf0CxLnW/8CQ4a 3ed6d9/SW850gdeWnFWHNjNBgMKgn61NOGFPOAWzLbtL72Asfyebyf3GG4Vc1WjPokr5 kD3mQ/plz1VqDWz6CGnyn5B0J6yU+f7CIoHyCOS4rzPYfiz2dpsFX9WDA+4aj7NS1axf mdhO+E05pZ8RlLoi2IjTmQEwGr62/GCC97BpWR624Jt+yxh1/w1Pj+MCa0/wJoFKyBF6 Jb0w== 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=sWaKUckUQ/S9boAPeM2YEqvBYb5PIWlWD2CYA9+Z0kIDg9LWroYmGBYd0AOfATJ1Hr JBH+HYeNrQvMcNzgvUPJQmOdEOxCh0mg4u6AXpB19GPY7tTMnTqGlVXxKEK8chbhXOrz padTuKXE9uRZV+CCvlg+lSbodp1lLcKzYC7z83ANLdM4n1mDnBYY0MnSo8jY6NUz7NkU tMJgStnq5AgNQxJQ/J11XcS38bGbxWMTT3NeIQOTl1/JmCDWIovtTl10lxoctKXApr/L /nU5ufLk8FeLEtu6bMoWBk9YN4LvfA0rcaO+TUEugY4EQbGY+IeTPZwPmg/XqccDzgOn Kg8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Wqvae/+p"; 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 a5si14589208ilh.94.2021.05.24.09.05.16; Mon, 24 May 2021 09:05:35 -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="Wqvae/+p"; 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 S237273AbhEXQFP (ORCPT + 99 others); Mon, 24 May 2021 12:05:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:40476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235408AbhEXP6r (ORCPT ); Mon, 24 May 2021 11:58:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18D456196C; Mon, 24 May 2021 15:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871072; bh=yiU8zdIvYxIC9N2pYR+ykiaGI3Da4dRhuRNqlvARqOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wqvae/+pqq3852i5BiCzCtOlmZ1/DrSm+9ZbEo+RFSCzdxWWrbyRxk/z6TWUFUQrD fnWTsdVFjf5TyykWl1WIvoyPEN96QFLKuvuISLRHq0ufxxqzI88fSC1xbrXnhOxR7T 19tuc4yxTGDFlbxB3Fb4jLD+2WKbHHip9zrYEyoY= 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.12 048/127] ALSA: usb-audio: Validate MS endpoint descriptors Date: Mon, 24 May 2021 17:26:05 +0200 Message-Id: <20210524152336.470419655@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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) {