Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3022147rwb; Mon, 15 Aug 2022 16:19:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR6R8HzW1zL5+1sWv9E+0XkftLmoDJ0nCD6R2DOU0muJ+ig4S31vloLHyRCwfXihQv7puKGm X-Received: by 2002:a17:906:ef90:b0:730:9af7:5702 with SMTP id ze16-20020a170906ef9000b007309af75702mr11846169ejb.107.1660605577009; Mon, 15 Aug 2022 16:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605577; cv=none; d=google.com; s=arc-20160816; b=TvHWo1gE1zfcjiuIEGZ3sRBT+ejk8sBW4j0b+psek/OWJOCTF922yqwE5z+4Oqqw1+ zL12oEolK0ZxEBKhNG90+Aabv7VDJwPVJPmto5PloN1hgXhACnxFj/sSoAKZb7L/gGBb WN7QyaKgTFgqTFRaiJOWiagn5jHPUK2gyBZwzHz9RL5iw+SqZWUlci7ffhKaJ+nxwBcg AK2dPHS/M2Pll9OXOyUxGgkbRYcCBovv4ewD+03bG8ovi14r1omd0l/lcqaXZDs6uji/ ZokUw7Sl1rwA++QJI2826nKm+a0bAB0Lo4DPGeoy15EK+at9U9VKbJF+3abZuUW+Ao7w M1hg== 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=NKKgfmLrE4rSXAaifNYBaAuGrS5ZhlEeGqcGmP/cDqgMvcQ9h4jlQAEiFRgidLtUi5 T54CpGu0vbMrykE5tR08I0fW+ZK0uaHnho/qplzJGfUnAIcZtW81568P5uGrSCI3qOTT Hd25v+YL78mCaIhSvYotzPcSgWY2yhDmAogObh/m2xOqz2P6jkYygZFldHeYOdgf/q0g mCKhsktB39EHKb/ElShOZGVr8OfTMrpMjnneSn+XgxTPfpdoXvnafApcB/Rat5wDEYAu 3ty8Kn8FchZMpso6NIvfkqDAxsPh1MwZTI/g/Fd7P5eWGydeNWE9fmJIlOaVWz6d7Agy Ryvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D+MzKyRw; 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 gu20-20020a170906f29400b00715867834e3si7422778ejb.506.2022.08.15.16.19.12; Mon, 15 Aug 2022 16:19:36 -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=D+MzKyRw; 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 S1349540AbiHOVsH (ORCPT + 99 others); Mon, 15 Aug 2022 17:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349348AbiHOVnP (ORCPT ); Mon, 15 Aug 2022 17:43:15 -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 DDFCB102288; Mon, 15 Aug 2022 12:29:44 -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 707B660FBE; Mon, 15 Aug 2022 19:29:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B05AC433D6; Mon, 15 Aug 2022 19:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591783; bh=bIhvwJ0cO3l3RJdTOuGmzssh9wbYGfWA10vvMIuUm+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+MzKyRwi5mw0h3YpBHzmn81muehnjaJIjbPZ/udZ2OJmgVoSRxWrhofTGDpRksLv x8Hy6N1ktXEt29Lhwacv3hxt/VUoHCb5v4QT/hmahKRXl5MXsri+AfoghNRGzxWeze ash3RexjTiBi3a9AgqQV8ZfkPSXGsfiT6EaJ4bVM= 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.19 0008/1157] ALSA: bcd2000: Fix a UAF bug on the error path of probing Date: Mon, 15 Aug 2022 19:49:24 +0200 Message-Id: <20220815180439.801019337@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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);