Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1265066pxb; Tue, 26 Oct 2021 05:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfyd0iSBmZMwtjLdqZ9nLoneviUZRzEsB89KG15O1Pm13WGnbwR8jDbHBlrushhaZBNBlb X-Received: by 2002:a62:5804:0:b0:44b:b75b:ec8f with SMTP id m4-20020a625804000000b0044bb75bec8fmr25464233pfb.63.1635253087888; Tue, 26 Oct 2021 05:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635253087; cv=none; d=google.com; s=arc-20160816; b=uhYkPAMrTDX9XOCwlboxEQZYs+XMGW96ENsFbq7TcTA7BiElmR/k32+g0zMJHkoIWT HfwCFMb7SF5HrgnzqMUk1BCkilnLn1EqZy9mcDDN0Un5jdMqvXvS5riJ8q2FvzFiZJxz 3xDVJ/y2Ie/ohv1/x4fwTH0PK6diRf7k3cux1r/vtgS1nkICS6Rn2Huhpps270TZsfOa eZKaOoJhvBlLrRMCcyAkyfNJTK0cw+HgUOVicZ6R+nQXR5HiGPkwr3P4MpOAUzEX909B FBY1UGtI/01ehgNo90nMnQX6hMzQEW5g8yPXF+YplPConmoN0Olkn/AOD3Ae1aRsFZzs KErQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=BmPWOmadXrSMszlxG6T/AKyqnHa3EKqXP0UcQqws2lM=; b=Sa0sOKcWo7W2VaMpg2867a2+lVY85XLtTTadPnKUqXGWnbnXxofw2DIBNztzaSrTWU 7RMzXPvG8W2rbh1Zl+utMIkwsPCgeguNdVXopU/AGmGNp0b4Mdi2BiU8V+Gs/nP1p5PK Z/0e+IF7YAXucmRanwhzNtyTpEfd1tasEaWhLkosaKKyjxL8B870B/i/e6Dp40dILGla asDlK6mD2kc0y9yS7m9OVVrR9A+lubuYjdecXyv5BrvnLCkWelBNV1whm4mBMvXTb5Ze QBPeLFjYdiRY3VOXL9qDnDRRVwmR99fqi1tJv5Kj9ATDTZNAt/n3PV7fTqVupcIiTZxv 4PJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IcCrcZA6; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g130si26598215pgc.216.2021.10.26.05.57.52; Tue, 26 Oct 2021 05:58:07 -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=@kernel.org header.s=k20201202 header.b=IcCrcZA6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232870AbhJZJ5F (ORCPT + 99 others); Tue, 26 Oct 2021 05:57:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:59062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbhJZJ5E (ORCPT ); Tue, 26 Oct 2021 05:57:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03A7D60F24; Tue, 26 Oct 2021 09:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635242081; bh=nyUiNsWaXu7J7EBCjgMBONE2lBGC6AijnH3+208gHk0=; h=From:To:Cc:Subject:Date:From; b=IcCrcZA6ot/XDbhxUd+ZROF+GVbjsIi9MGCTkO6xkTLTMrWzMPIMvHk4UN7tysl63 bxH75ZdPC3kMW433GIjN69XarQu5ic2SukukWUrfVH+r/KSgDpiKqMQL8kGzfYUGwr xKidZ4eZJ+7PhkdMPIdIbsYgw+C0Gy51P1VNLtMc2Um1/QshPAHvuGPW97v5vspN8B QA9y2RGbc+LV0xQKVzUW6EU8XkeKkJuaTyRmkYvH7Eg/izoy8RmsZ8fyI8Wkt3Iufw euwNO+WFOFl4jwQsrKfTg9NU3lGnkXLLxzVW827kUnKihjDoTw5gSEID1TAYHpUPhm 0YnwekDKkhszg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1mfJA0-0006uh-Kv; Tue, 26 Oct 2021 11:54:24 +0200 From: Johan Hovold To: Clemens Ladisch Cc: Takashi Iwai , Jaroslav Kysela , alsa-devel@alsa-project.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH] sound: ua101: fix division by zero at probe Date: Tue, 26 Oct 2021 11:54:01 +0200 Message-Id: <20211026095401.26522-1-johan@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the missing endpoint max-packet sanity check to probe() to avoid division by zero in alloc_stream_buffers() in case a malicious device has broken descriptors (or when doing descriptor fuzz testing). Note that USB core will reject URBs submitted for endpoints with zero wMaxPacketSize but that drivers doing packet-size calculations still need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip endpoint descriptors with maxpacket=0")). Fixes: 63978ab3e3e9 ("sound: add Edirol UA-101 support") Cc: stable@vger.kernel.org # 2.6.34 Signed-off-by: Johan Hovold --- sound/usb/misc/ua101.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index 5834d1dc317e..4f6b20ed29dd 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -1000,7 +1000,7 @@ static int detect_usb_format(struct ua101 *ua) fmt_playback->bSubframeSize * ua->playback.channels; epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc; - if (!usb_endpoint_is_isoc_in(epd)) { + if (!usb_endpoint_is_isoc_in(epd) || usb_endpoint_maxp(epd) == 0) { dev_err(&ua->dev->dev, "invalid capture endpoint\n"); return -ENXIO; } @@ -1008,7 +1008,7 @@ static int detect_usb_format(struct ua101 *ua) ua->capture.max_packet_bytes = usb_endpoint_maxp(epd); epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc; - if (!usb_endpoint_is_isoc_out(epd)) { + if (!usb_endpoint_is_isoc_out(epd) || usb_endpoint_maxp(epd) == 0) { dev_err(&ua->dev->dev, "invalid playback endpoint\n"); return -ENXIO; } -- 2.32.0