Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409713rwa; Tue, 23 Aug 2022 04:25:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fc7/fUKK7bzsA0HHY8+n3k123Z5uoLcWoP6yr+aDWeTyFF7Ud+Udxqbjlv1oiQDTMR1CL X-Received: by 2002:a05:6a00:17a1:b0:536:783a:9c2e with SMTP id s33-20020a056a0017a100b00536783a9c2emr11769404pfg.76.1661253935501; Tue, 23 Aug 2022 04:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253935; cv=none; d=google.com; s=arc-20160816; b=FxqyK5xUv/dsTeLFi7kYosWKK97MeWAJ1y6Nc5eRRhbUizEqegFHfN6mZLEM8T7h5f sRYKXI9ZucJLtZS1GrcCMAxFc+DgBdn1bK4kK9IALzdaoL0tEmI/JHzj6Qb8ZtRNqaxO BP50xUy/KytxBcbTdRc+CVdo9GGG+2N9R1JBREIzKwaKqzGYWmnfBTEjOJukzKaL+o7X PzO1FSoUjbGoyDazJyv3bsr6xAad4ksRODGkdmhwk26dPhtyzVkuZF07RGmxG2TsNsxh fSlKympKl6sA5VJ0u9Jfh6sTrRnsHGlUom56Zm4k3CKqtc0C+NcrJ5n3wJFhplH6/fUv 7K2g== 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=ecs6ojiJ2Mn3Ux8RY7YX2DWJ8wJ/7lIK5j5LBIB+yFA=; b=lGcI2Ie3Ry3QtMTF9KnM5XVlGsstKEMWOoumhWAkJIb3udxLhVqtecNyjEDBZ3MAe0 qVN6ywB8WvY4C7fcTA7JTVFpoTycMn8qPF/GYUnYDa9sUDJ8E+HHtvw2WKK+v326lXBc 70fJ1lGhhzoGvmfvBxgWIzD7HHEvi3NtSQFS3Li/D52P9NEJM91q3CXii5Mdmy14oZ+w PFGPqRrluRVKW3z3194drLjfS5AgLd8XeETMrM9L+Vq9GBlZFEpy9EdvyrQpM5jpdX8a zAem/W0N+/ZpnjmFC9VK1DD2o2tRjr4OmYqvRqh4k5ryjq+t2putp6IjYaO8p2EusrIO hk+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zKXJDz3b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a17090a7e8100b001f2df5559dasi14025374pjl.115.2022.08.23.04.25.23; Tue, 23 Aug 2022 04:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zKXJDz3b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1355397AbiHWKb6 (ORCPT + 99 others); Tue, 23 Aug 2022 06:31:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353583AbiHWKPL (ORCPT ); Tue, 23 Aug 2022 06:15:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A50E6C748; Tue, 23 Aug 2022 02:00:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EAACC6123D; Tue, 23 Aug 2022 09:00:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF086C433D7; Tue, 23 Aug 2022 09:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245223; bh=XnKHTAqr4cw2+DZhxkmwjc8pnDzf654pxG/zleJA8kA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zKXJDz3bDSJ2pUiMm8ArgUZEPr0ccYHMCaB/Q+87BMNee1y3ywQeMuq5nH7+yoLNT RLu0wuILaXXXartp6wp1Tqe5wKZ40G4bV0b788vOTusKpS15uWLfO1eyPRorJlAFeK Ve79ynAzOpjNI/RxDKNBQGji87qfEPfp0H5uX7iY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Takashi Iwai Subject: [PATCH 4.19 003/287] ALSA: bcd2000: Fix a UAF bug on the error path of probing Date: Tue, 23 Aug 2022 10:22:52 +0200 Message-Id: <20220823080100.388540705@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma commit ffb2759df7efbc00187bfd9d1072434a13a54139 upstream. When the driver fails in snd_card_register() at probe time, it will free the 'bcd2k->midi_out_urb' before killing it, which may cause a UAF bug. The following log can reveal it: [ 50.727020] BUG: KASAN: use-after-free in bcd2000_input_complete+0x1f1/0x2e0 [snd_bcd2000] [ 50.727623] Read of size 8 at addr ffff88810fab0e88 by task swapper/4/0 [ 50.729530] Call Trace: [ 50.732899] bcd2000_input_complete+0x1f1/0x2e0 [snd_bcd2000] Fix this by adding usb_kill_urb() before usb_free_urb(). Fixes: b47a22290d58 ("ALSA: MIDI driver for Behringer BCD2000 USB device") Signed-off-by: Zheyu Ma Cc: Link: https://lore.kernel.org/r/20220715010515.2087925-1-zheyuma97@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/bcd2000/bcd2000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/usb/bcd2000/bcd2000.c +++ b/sound/usb/bcd2000/bcd2000.c @@ -357,7 +357,8 @@ static int bcd2000_init_midi(struct bcd2 static void bcd2000_free_usb_related_resources(struct bcd2000 *bcd2k, struct usb_interface *interface) { - /* usb_kill_urb not necessary, urb is aborted automatically */ + usb_kill_urb(bcd2k->midi_out_urb); + usb_kill_urb(bcd2k->midi_in_urb); usb_free_urb(bcd2k->midi_out_urb); usb_free_urb(bcd2k->midi_in_urb);