Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3524287pxj; Mon, 24 May 2021 08:37:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk181+Xa1izyjQ6JJh+sNbMXKhzEpOnRpcIBzjJ2/FDd4S3qHgjLVe5xh43ZbYxQw2O2xf X-Received: by 2002:aa7:d455:: with SMTP id q21mr26232428edr.2.1621870657371; Mon, 24 May 2021 08:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870657; cv=none; d=google.com; s=arc-20160816; b=aDiMl53yilcmo9In7BRQe6njqXFn6HmQ7/+tA0FA1uO2MaC6o6eFn4rsrhQ/RDD5p5 +uqMFaGSB3idC/RfHvLVtB2/DwMzm+KQLb2yCdBwZofhsFBJaunGecr3LSwwb9DDzq/w 0+9drjvUeihJfkfFEcEMB9LVGmkNnPv60Hel5MQdfrmMDenLjiLyWS08Vd+paC2IKxXj arabiGBC390AvliY7BVh9n8CH6s1lQ0qg+jho0hD/g7UDvdkosCQreT/w2NuwInAkBhL jFJzpYyJvksd51qr60h5v/Adh+kQAYhyT9HHz1qGmXkgqQUsv67xhfAD9QJUdRzO7ffo DvwA== 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=Kqq1pc50oD4gyETX0RadDFcd0Td/ZjOC1VfkCChNxbPQSf4Gpno7VaAPxjepeba9AA ofNeH5yqXMQv6ANGWg1LxxRk3Icezeyk+WYR/6B1rgHI33FumPv+gRwu66txbqRNSGM/ 8asROu8Tr9Hu5D4f6ygrwVbIbX7F5N4MH5csRqFfD2sPr0r3J9EtGEhEcGYZ3V4XDxWT MgUJ0NUgTQXYz+jWH3iTwXlsEtcn6yeveactYEok+/yNHLwb3ZJTA3i4BKLRkW781V5J lPVMwF0+5iKg0sMQCZt9no00/yiDXKYTpyIq1Bsfm3c6ZOIZZ5xopc1a+5bDpNEyoRfv VV1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RqVRDTwm; 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 mp18si13121749ejc.543.2021.05.24.08.37.14; Mon, 24 May 2021 08:37:37 -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=RqVRDTwm; 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 S233629AbhEXPhi (ORCPT + 99 others); Mon, 24 May 2021 11:37:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:51356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233878AbhEXPec (ORCPT ); Mon, 24 May 2021 11:34:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E360F61405; Mon, 24 May 2021 15:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870316; bh=Nw8V2DfsiF3lunap2Awy8h9mfGQg0ElLDoFn4mNSw8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RqVRDTwmxNLgecvDpt2xYZnN+CM+6vcL/IQgUl70mj5z8zsJ2dg19nNP5u/iYb8vo +MMnkNiqZXM1vatBGuB3ctOC+wpK8Tzbbr6r/eWu31Ud3pIP8rqkN9regn5re15XhU ynGf2/mM4z9eFBDyiHS9MdZ3Mby0CQO3gXcpLb7w= 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.9 07/36] ALSA: usb-audio: Validate MS endpoint descriptors Date: Mon, 24 May 2021 17:24:52 +0200 Message-Id: <20210524152324.400120947@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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) {