Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3532817pxj; Mon, 24 May 2021 08:49:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQTje0ueaw+CXtesrSBKLvDArbaN7rVri2kcwd5J1J0pHdBxvdzLjgRFHw0C55Y8PDrg0x X-Received: by 2002:a02:8787:: with SMTP id t7mr24636746jai.53.1621871370799; Mon, 24 May 2021 08:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871370; cv=none; d=google.com; s=arc-20160816; b=cKJ+swn6b4JndUo0MNU4jmt85A5x5AVwR3gTN6M4nBeL/YD/WhBmCn40xii1hhHA78 tN615EEUwB35W54GYiRRm9v0VY40OhkFZ+zx5uXEmxG2LXSxUyjMngfgHjV0Sx6BlRSH 6HfMrCASo4AWCr5W4YYN2y1nzEreEIpzOcZ6Ag3PhWruPqoO53RD8vNeYn35LzBWhKu4 s4n8SNgesiuiBZmcu4oViWmpwlHPvVUk6C4+idjQ+eHSXjZLqqdU+ELZOpW4WNHgv8VH KkxAX/dFCgTlwMBl8rrxQEC2p6XOL6kUpxlGUW+8Ql5cbC6xtrhIntoSUZWHOm9OoSWe GZXQ== 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=IiqURytPA8UvTSKbGknRJIhMzM8l+qG/RhnVpY0x9lg=; b=X88tkuU3KE4EVsyT7nt6ytIq34tNfqEwoApYkWVQDSsaKSdT0wQ7Fk0ofqy+NMVu4B +B//dtqumLaqlBM0diuFg4pLXrEvc/NYdVWRzqn8s5INURoGIwxA5AKMomhw1aElcBZ8 6gAE39MfZcDSNegO+1BX9mYcqO8xDM/ilieMvauEsY1rNPEOpffyT5zoY3tsvqxVT0oh jFfp2RwDSZg2abQrWcjNb0OtoJ7N1Y4EYGwOTWVlGGjh69sYupLzSqOj9+vkwHulFhan qQL/DbvNBUdLgz/lcurjkOeCk36QzjUEMCT0LS24X8DWfW1L+2geb9Q8TdBsoVRpppYS Rj0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dmYIZ8T4; 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 o13si12937158ilt.118.2021.05.24.08.49.08; Mon, 24 May 2021 08:49:30 -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=dmYIZ8T4; 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 S234326AbhEXPtA (ORCPT + 99 others); Mon, 24 May 2021 11:49:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233156AbhEXPnF (ORCPT ); Mon, 24 May 2021 11:43:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A6406144A; Mon, 24 May 2021 15:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870516; bh=0JyQG+hDlPaL4XMSDJgc9c5o+b1VXag7VKaC6Ne/OXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dmYIZ8T43U+oQBpXUqR7G+umM6uG5XaEoOF8uTnd65nudYF8LjfLOM0QSHpSrpoXH 2M2T4YuVQMcbPlxS5n01s+eaDCKoZDvfuW4D5vVOEJrJeamNE0ujuXknKt61TqHY1G KnviuVYMvnnIkLoNV0tav4JGypyIM1lqIEsiWeTQ= 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.19 14/49] ALSA: usb-audio: Validate MS endpoint descriptors Date: Mon, 24 May 2021 17:25:25 +0200 Message-Id: <20210524152324.844154998@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.382084875@linuxfoundation.org> References: <20210524152324.382084875@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 @@ -1890,8 +1890,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) {