Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1859812rwb; Fri, 19 Aug 2022 10:34:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7K7laoGBZy2Vv6BO//zRs+cvtMqmV4Jgw4Q5VHlD5i7GCfIffYIQ1o5cnqbgWFe3icjTSO X-Received: by 2002:a17:902:bcc7:b0:172:bb9d:d6ce with SMTP id o7-20020a170902bcc700b00172bb9dd6cemr6222358pls.3.1660930474563; Fri, 19 Aug 2022 10:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930474; cv=none; d=google.com; s=arc-20160816; b=xO4z7nyhkZjG7MlOvwlofJ6zbkL5Gz9i14XONsbXnz1b5/a1b7C/O87W0d3LVbr/5F BoRShiguyPkPU/t7o7TLLLUTe7SKqpfyHrTqpQtrmMdPgtavL24aI7B4S+ehbsfU86m8 E34xhauWb0CmEmk8brJAL4rm0trs46GwD5tWvrxcFBO7eGFKdgVMk1k2e9/Lz3e/BfxW n13gg68MAstnDJdfJVxmhn6prqJnapXZDLYNTXStaJqEqhtSqonyfpSTFlCaakcrOxyL hYCP+9xdllY2ipx1wMX3QLdObDhYsnXEKIs+CVedovlG3VrJ2gfs/l3L7ezGq3f7t0GD VVTQ== 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=7Pe86Q7SQSsIuvxUZX9PUCPMBXk33imXvMkEAjhy9BU=; b=cJO0ALvTiwWjtWjcbWnDaJiU2JzlEPO3kvfwr/+hLeVlBtzh4afjjtVNZENj1/XvsP QyaKrYCx23e78WyC7VpMGyeFyIuDk619FTZm/EtNA90VLk/V/MVi2fqWI4Ho3Klatru/ IYB4nzF3pRF0Dp4IqaqbosSlaHzuKIOy1j0s3NFtJfuWmw9nqqAZ60q7ib6Htc5HW3bQ mJAS7jDM+KYPC1fwWn/27UU71jSSULX4ivGRVhRKWRi1DoJHIybOX0e4NlktLwcJybOq Rk+gYEX57XDFyrQysa+900Ye/gcklHq2HhtvNuFXLdOUpqKStCpjCXvfXfAj//ONRb9j Sbkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SBa9GDrV; 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 69-20020a630048000000b0041bbc3a52b6si4297950pga.812.2022.08.19.10.34.23; Fri, 19 Aug 2022 10:34:34 -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=SBa9GDrV; 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 S1350144AbiHSPrH (ORCPT + 99 others); Fri, 19 Aug 2022 11:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350135AbiHSPqe (ORCPT ); Fri, 19 Aug 2022 11:46:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2201429803; Fri, 19 Aug 2022 08:46:28 -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 9D00D615E9; Fri, 19 Aug 2022 15:46:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5D88C433C1; Fri, 19 Aug 2022 15:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660923987; bh=bIhvwJ0cO3l3RJdTOuGmzssh9wbYGfWA10vvMIuUm+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SBa9GDrV8qhqaHFIcXu1R4CTDAyAf7rResmY0T5Jvn7NbwwMy84Q3T3BZyE9UazpM cKMQh8KLitI6V5DdM2eI5EdKZjni1DvtCNhEXzaWq7g8eVJlKr4kdyKTNbGO8I+SzR GgpSfnEJT1vf07CQEek1oqASv1q8rtbZSbzyPDoQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Takashi Iwai Subject: [PATCH 5.10 005/545] ALSA: bcd2000: Fix a UAF bug on the error path of probing Date: Fri, 19 Aug 2022 17:36:15 +0200 Message-Id: <20220819153829.408974468@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 @@ -348,7 +348,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);