Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2741803pxb; Sat, 6 Feb 2021 06:22:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqOWbjdY/kGrAa0n5zlt72BUYZuZArNsuBnTstEgbZA7tNGmC9hr/KEzKdk6+9MjfYgITm X-Received: by 2002:a17:906:9ad3:: with SMTP id ah19mr9050794ejc.37.1612621363049; Sat, 06 Feb 2021 06:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612621363; cv=none; d=google.com; s=arc-20160816; b=FJAGy8I2ZMoPP4PCB+In6tvt8Ycc5wEhEw91ShUMesfdmYbVVOGqN0Ytwkj81XD/Z2 bYODOTG0QDnE//4oBokw3+ETy/BNyube7Kt+uG25bG8DClOTnd4e/4M8ThjOqArgETGA RhNf25Ad83YGrcxY9s1W+98PN4Wu9Wdqz3PauZLhUNyaXTOf6fxM3gsUdrEWpoIRVA1p o2PG8n/X2kGE5Hdv4Lqujhu3w5Qm8DsuuR7eVSBFf3X13Kqe8ta2dXbyXMM0xRibIwgc 8LkUwqvpa5IMm/pupII/E/nuWQgO0nJwZvnxmaMfzhO3FnG/GPiprjqvK6cSdVTrTACu qPCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=to3AxKYKszAj3XkWkxW/OTXbnw+NvU2FhdRiIoTn2QA=; b=vR+BXS0Q2uo4N3oejistpTHZQW84P2OP+qE8kefGmY16SsGFaRkVNONQt4ajGGGS0t 555v23/UjbR9LS9iJb+B+f9mfj82embdy7+3yiE3+JQ7ug+s9nZF+AfSwa0gQN1y0WDJ 03wp5Ci/r2d4pySL/chODcWuf749EtqEbzA2uFVkT1n8Yy66wQiNnOifJaDP/rOTyd2/ 0NwHoZAJMoAUbWghcfXE/ne81bhSniM6SCT3+fVTp8ln84ElJZdHyfJIzgcQv5Aaxe8y FX/p7ZIYWmV/OsAyrmrV+a3y9BeI3jjQ6TqMaOS/U04Eza1P8R9nCpWXfi3yzXz35Fri GiMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qp24si8509584ejb.563.2021.02.06.06.22.18; Sat, 06 Feb 2021 06:22:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbhBFMT4 (ORCPT + 99 others); Sat, 6 Feb 2021 07:19:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:45694 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBFMTx (ORCPT ); Sat, 6 Feb 2021 07:19:53 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C3EC0ACB7; Sat, 6 Feb 2021 12:19:11 +0000 (UTC) Date: Sat, 06 Feb 2021 13:19:11 +0100 Message-ID: From: Takashi Iwai To: Mikhail Gavrilov Cc: Hillf Danton , zonque@gmail.com, LKML , alsa-devel@alsa-project.org, linux-usb@vger.kernel.org Subject: Re: BUG: KASAN: use-after-free in snd_complete_urb+0x109e/0x1740 [snd_usb_audio] (5.11-rc6) In-Reply-To: References: <20210206054533.120-1-hdanton@sina.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 06 Feb 2021 09:28:51 +0100, Takashi Iwai wrote: > > On Sat, 06 Feb 2021 08:48:05 +0100, > Takashi Iwai wrote: > > > > On Sat, 06 Feb 2021 06:45:32 +0100, > > Hillf Danton wrote: > > > > > > Due to the reconnecting key word mentioned, no fix to > > > d0f09d1e4a88 ("ALSA: usb-audio: Refactoring endpoint URB deactivation") > > > will be added. > > > > > > What is added is to capture EP_FLAG_STOPPING and remove the one > > > second wait limit if the reconnecting acts may make it easier to > > > repro the uaf. The diff is only for idea show. > > > > If my understanding is right, this won't change. The problem is > > rather the lack of this function call itself, i.e. the missing > > synchronization for the stream stop. > > > > It worked casually in the past because the endpoint resource is > > released at a later point that is after all streams are really closed. > > Now it's released earlier and hitting the UAF. > > ... and reading the code in a closer look, my guess was also wrong. > The sync should have happened in snd_usb_endpoint_release(), and this > didn't change for quite some time. So my previous fix won't be > effective, too, I'm afraid. (And Hilif's patch won't help, either; if > it's effective, there must have been a timeout error in the original > case.) > > That said, I don't think this is a newly introduced regression, and > race the condition could be in a hairy detail. > > Mikhail, can you reproduce this bug reliably? And if you can reproduce the problem, please try the topic/pcm-sync-stop-fixes branch of my sound git tree git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git Takashi