Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3527797pxj; Mon, 24 May 2021 08:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1NHASynhd8VZbkmD/2TRmQgQ0WoFm093bHdjEJku/iTEjAaVgr/7xdStvbYhrd9P49aoy X-Received: by 2002:a05:6638:cc9:: with SMTP id e9mr25538602jak.46.1621870942546; Mon, 24 May 2021 08:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870942; cv=none; d=google.com; s=arc-20160816; b=B+M/Xf9v0cwwu3v2tRuShvmi9LlzetDMg0BXfNmYdtg5EvV0fSIrRP8LXHhp7PENe8 +/GhnND855G7lUjFbc0ctCg+k0cftXAG1/n3/oaHI5n6j1Hu5CYVoPu5bIdNrqRt7tdF JY/bYsUvteLlQ9V6MpRRyOmIhRv0fMQ8ge35serVYsuSj3Np9f/IWPcElVHeZO7e8fIU v/yKO8KCjoTMKv82UM1qRL8Jf29umLQ9CCKzuVna9mKPpgTDuWLcA/m/pqa+2QaY7gfA BYWnkNqjI9d3AXDLy5Zyre5GkCafqzQOEyWZDAAiBfKaloeXbB9+RXQL++zjC4RI9qwa VP9w== 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=uuC8v/rJIeilwX5CFD3fLawFpAVuYbmfVuoMmaL3A9I=; b=gO1V8d2OSgAalq2AREaXJjgE6qItSuMenVCv6K6EFOI4pqvpI803NuN0WTMliLvX8K e5I6aHxZk1GBlNfhsL4u/Q6AmMBjV0kT1JkfGVO4wLVYIAI/B68AMBxa6ZI/NTKWQrBx fJ9AQUL+O839VVHHSDjC3QyIe3nIw0frBiLMsvXRfHDDvgoYTyZ8iD6HfIwQJl2yizzU JZRxbkh7wKEBLRf+D7L7NM88nYeTm0fcsf0cL7bhwPr49Ztao+DIpCk96jv3gyDJna6v Fk1YYvXVDjdF5VD5uqPxCAIL4gCty3eqvzaWKqIkdTQJuugN5UbLqMxYAoAapDJc18P0 lhsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z1WeHUA5; 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 h13si6636451iop.97.2021.05.24.08.42.09; Mon, 24 May 2021 08:42:22 -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=z1WeHUA5; 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 S233175AbhEXPlo (ORCPT + 99 others); Mon, 24 May 2021 11:41:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:56096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233787AbhEXPiQ (ORCPT ); Mon, 24 May 2021 11:38:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D6936141F; Mon, 24 May 2021 15:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870396; bh=Nw8V2DfsiF3lunap2Awy8h9mfGQg0ElLDoFn4mNSw8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z1WeHUA5XEC9bmZ3SCrNarzAfNbJZIcxBDDg6F3JA+Nrdef+EjhJq7cRWXFJiekn+ 22FOoqlBJfsjwxOIOu+S5fo4B3Y8g0VXbMHG5vF94IJnlKk/jsoTEOFVD5iuZfW4r5 FRNNHSnG8VIK74S8ipW1jRWERgEPYTys7kKgovWY= 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 4.14 07/37] ALSA: usb-audio: Validate MS endpoint descriptors Date: Mon, 24 May 2021 17:25:11 +0200 Message-Id: <20210524152324.439740582@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@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 @@ -1867,8 +1867,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) {