Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2874236rwb; Mon, 15 Aug 2022 13:04:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6hF4JtSqh2piG6BFi1x7nHSBHgOmydZdzF3TqVE9vRvj8DbOhTs4lm6AEwfU6kuHiq7Vtm X-Received: by 2002:a05:6402:550c:b0:443:7d15:d57f with SMTP id fi12-20020a056402550c00b004437d15d57fmr9979964edb.147.1660593896098; Mon, 15 Aug 2022 13:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593896; cv=none; d=google.com; s=arc-20160816; b=iXqCM5UytAcauGnDw/7/+zfFCuNxdYhIuEMhajaTa+J1GmQj8n/akYqkuWf/5sHt+1 SBrsed1aQwSL0+tYlU6CzYlC0QRklL1Sst5Huk60KtBmkX2xMBeUOAadSavjHdGo+ROW yHeThsYrpBoo9ckwY8sxU6Z1b+0ySnh59iMKXOApuOysk78ROC4ZyAZ2m/KmGELWmRbU 7Gkbz7HvU5BCQkAVvTZ95zAWJiRSKBbSuk05X0oibPwi8yJoXGmJ6JWMpST0i2DC5C8d B+tFv70arOcV/Y5BJRYXI5S5XBAuFeiHuGcrCO71rgKL9vFHogcfRHByJuC5xUbUrAcb GPYw== 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=k3i07mkI8XSg3jg9QObrPPP6r/bZPedz6wTQEIbXVeh3KDQvF6TJ+ZJReWdaWrgwpo lwnjsL2GR5yX4RR1IT8JOvefwCLMlkRXYy1Kjr/KkGSNT3DQ7oxJcjRqprO1+FQke3N3 GEap4QZkW388KjY+LNFsRPzs0cBi0z/4/M8ujDvHUdULTnv/eJNdAD2ubcGB27XOJl+a Lmpw2KqTTviqW0A+mybmjVFM00AWRshVXsLIT6f9ObJERrMu7DtLUfwQAokCG4ESY/Gy BSgHy+TcBPGbQDnnZMMIpFJqYhPBaKL6yM+SctSYGBwUOQbkyzZRpcxz/UrgtJMLzCx1 ZCjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JPs3UMnx; 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 nb39-20020a1709071ca700b0072b0f6f1456si8286328ejc.612.2022.08.15.13.04.30; Mon, 15 Aug 2022 13:04:56 -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=JPs3UMnx; 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 S233234AbiHOSPC (ORCPT + 99 others); Mon, 15 Aug 2022 14:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233396AbiHOSOY (ORCPT ); Mon, 15 Aug 2022 14:14:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F57B2A426; Mon, 15 Aug 2022 11:14:06 -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 C05F461281; Mon, 15 Aug 2022 18:14:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C92C7C433C1; Mon, 15 Aug 2022 18:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587245; bh=bIhvwJ0cO3l3RJdTOuGmzssh9wbYGfWA10vvMIuUm+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JPs3UMnxPZynqcjMDHZeTE3eHptg1ToVNMLgWpTMfRBqWqdk76sUnjROZtQ7+uMth 6R6wB6HMrf8jiB7YpExzxFxk2jSPeKV3G/q+fuCK4uNQMeu/lURyhF0XK6kxYa7++t kjpD4AKZaLlq/+SEUxJk+9pvrAYEdgDO135WOuFc= 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.15 009/779] ALSA: bcd2000: Fix a UAF bug on the error path of probing Date: Mon, 15 Aug 2022 19:54:13 +0200 Message-Id: <20220815180337.577966557@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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);