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: 10611413 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 AD47A14DA for ; Sat, 22 Sep 2018 13:38:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 910E82B1A5 for ; Sat, 22 Sep 2018 13:38:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80ECE2B1B7; Sat, 22 Sep 2018 13:38:58 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10BCF2B1A5 for ; Sat, 22 Sep 2018 13:38:56 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 869E72676E6; Sat, 22 Sep 2018 15:38:54 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3ED8E2677BB; Sat, 22 Sep 2018 15:38:51 +0200 (CEST) Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by alsa0.perex.cz (Postfix) with ESMTP id 53F742673F4 for ; Sat, 22 Sep 2018 15:38:47 +0200 (CEST) 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 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 Cc: alsa-devel@alsa-project.org, Michael Drake , Greg Kroah-Hartman , linux-usb@vger.kernel.org, kernel-janitors@vger.kernel.org, Takashi Iwai , Jorge Sanjuan Subject: [alsa-devel] [PATCH] ALSA: usb-audio: ensure that cluster header size is enough X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.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);