Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2165639iof; Tue, 7 Jun 2022 21:56:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyuyGqxvv85pEVpoEh3d3HHmTnyvFhzxotJiVWPAd2ymPbJXkWDQhvRFomYhDSX9VUKSZp X-Received: by 2002:a17:90b:4a4c:b0:1e4:da3a:9b07 with SMTP id lb12-20020a17090b4a4c00b001e4da3a9b07mr35519620pjb.242.1654664167601; Tue, 07 Jun 2022 21:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654664167; cv=none; d=google.com; s=arc-20160816; b=k7m7Qtp6mxCAXmkrcumxS7E4w6UwT0FU4jfduR/uFNI8rRa/Y17yzBZ7vlBsZoxbi1 XB3hIoJI0ubGPI7cEqruG0hdlUnGQ9bdPMFBKfgQbU2SjBLLdfG2gEwQJ5LBrAncjIJu SJYFeEL3wRnJ/5ezP7qBFK2dWWAb06a7pUf31Q5FjeldQNj6wiK3qkSFoEpbr1lGhzWK rvgq3JOU1PKonjPc+Kcd0Sa/DEZAL4GB5LaijVZR0vIEMEQ9Hxxc4Sji+I7/R/wzFgJX rFKP3/Orl4vUbPYgRaPgYDPnCIL7vALf/0/50nejBy+w2tr6oXg5NR8dcooY0NuUE4vm 2P7A== 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=QBg9Y+zE1rnFpKe/Ve+zYkrAC43efjU6aJLYPFVsuoI=; b=RW8dXRo5CItUpMJQTBV3m7UyvGFhyTynJKamEiW4Nqt3622vghjQ3dPwoSFxwsWcYw i2SQ3zvaWw19u8O0vIL7ibK9GQ7JUp0oVv7Eu+jvcHOOCnCp9gyBy1L6Q0k298Sx2chX ombkDwtcGADxyoOtrjPd1A0UIawyw0e0LYEtGuqycDa5hI8V12MslGFHnizVozgQwbu4 Dg5C5xsNj0XfWLnN5DDJnLijDGJjmQw/pxf8Lo9ravp1qhXRulBRll1uAsQYV/uds+yH QlC/CkduxQQXR/JQMkeuPwVC8oZJSR8MCXqOrmCP/eC5wVTE9gA/oTQwl4XkDFQgr0cC CwEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Svy5Cvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q12-20020a17090311cc00b001677e4d8420si3827396plh.467.2022.06.07.21.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:56:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Svy5Cvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C644942C408; Tue, 7 Jun 2022 21:33:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382202AbiFGWCm (ORCPT + 99 others); Tue, 7 Jun 2022 18:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378997AbiFGVB5 (ORCPT ); Tue, 7 Jun 2022 17:01:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF0E5187C35; Tue, 7 Jun 2022 11:46:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 85DF6B81FE1; Tue, 7 Jun 2022 18:46:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5EF5C385A5; Tue, 7 Jun 2022 18:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627565; bh=diPTJAlAYIKdCCWA3zqqCctkFNXEeBxcidPHNv1YQRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Svy5Cvc8pNCFvxOiB1Y41A8UFp9HaRceXonX+7c73W+cpONejjK72c8mUMLeGKLm g9w/lvuw0uaGLFIZOG6W/XSZQ6Gvadu2ODk4gc7pY2j6Py1h9K/j2dprKdw931B0ad ZSdN1KYIosO1/YEtkheLEFKCC6wTZ82QjyRdevy8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6912c9592caca7ca0e7d@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 5.18 014/879] ALSA: usb-audio: Cancel pending work at closing a MIDI substream Date: Tue, 7 Jun 2022 18:52:12 +0200 Message-Id: <20220607165003.085393918@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Takashi Iwai commit 0125de38122f0f66bf61336158d12a1aabfe6425 upstream. At closing a USB MIDI output substream, there might be still a pending work, which would eventually access the rawmidi runtime object that is being released. For fixing the race, make sure to cancel the pending work at closing. Reported-by: syzbot+6912c9592caca7ca0e7d@syzkaller.appspotmail.com Cc: Link: https://lore.kernel.org/r/000000000000e7e75005dfd07cf6@google.com Link: https://lore.kernel.org/r/20220525131203.11299-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/midi.c | 3 +++ 1 file changed, 3 insertions(+) --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -1145,6 +1145,9 @@ static int snd_usbmidi_output_open(struc static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) { + struct usbmidi_out_port *port = substream->runtime->private_data; + + cancel_work_sync(&port->ep->work); return substream_open(substream, 0, 0); }