From patchwork Sat Sep 22 13:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10611415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80544913 for ; Sat, 22 Sep 2018 13:39:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F1A62B1A5 for ; Sat, 22 Sep 2018 13:39:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62F282B1B7; Sat, 22 Sep 2018 13:39:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09E862B1A5 for ; Sat, 22 Sep 2018 13:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730207AbeIVTcu (ORCPT ); Sat, 22 Sep 2018 15:32:50 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59066 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730087AbeIVTcu (ORCPT ); Sat, 22 Sep 2018 15:32:50 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8MDZg8k058704; Sat, 22 Sep 2018 13:38:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=WIr8lP/6uJM6No6kV1SvWr17gzV0QmaRzAxG2hFzZQo=; b=fL2qFz6LYtH621vK+SlH6NqYOGLD3EORac/S3CTtf8BZLDrNEJKyr36Zx7ijrXEGhV4m iLd1nUfQJU383VOSq7Vgs4fVlzGpJ/eyH7l2W11Dlww9sBOEtdVMbhx194rbU/jju/G6 TVg7pfHvcqvM1xzIAWvnNaXdtwC+T865d34XmBfPf9sjzIJ9tLvbHYckCchWMJUwYOvw ixh0LqTTYpPW2gEDX4RAy+hcz9VJS2WL0zTZx6Qqnn4LkEzIMxrFPFn8aQTAjrmE5JSJ Wn7K3RLIaEVoRdva1IFTKegd8M5T9IEHGGSMS/iu5Y5XQYN4lxDT3A6NwW46REVqOGGf qQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mndpp0tte-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 22 Sep 2018 13:38:46 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8MDciXk003212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 22 Sep 2018 13:38:44 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w8MDcd74018197; Sat, 22 Sep 2018 13:38:41 GMT Received: from mwanda (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 22 Sep 2018 06:38:39 -0700 Date: Sat, 22 Sep 2018 16:38:32 +0300 From: Dan Carpenter To: Jaroslav Kysela , Ruslan Bilovol Cc: Takashi Iwai , Jorge Sanjuan , Greg Kroah-Hartman , Michael Drake , alsa-devel@alsa-project.org, linux-usb@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ALSA: usb-audio: ensure that cluster header size is enough Message-ID: <20180922133831.GA6792@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9023 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=909 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809220144 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I think we need a check to make sure that "hc_header.wLength" is large enough for a struct struct uac3_cluster_header_descriptor. Fixes: 9a2fe9b801f5 ("ALSA: usb: initial USB Audio Device Class 3.0 support") Signed-off-by: Dan Carpenter diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 67cf849aa16b..f7179ce39a19 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -968,6 +968,12 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip, * and request Cluster Descriptor */ wLength = le16_to_cpu(hc_header.wLength); + if (wLength < sizeof(*cluster)) { + dev_err(&dev->dev, + "%u:%d : cluster header size too small %d\n", + iface_no, altno, wLength); + return ERR_PTR(-EIO); + } cluster = kzalloc(wLength, GFP_KERNEL); if (!cluster) return ERR_PTR(-ENOMEM);