Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2567430pxb; Sat, 6 Feb 2021 00:34:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIppwnpYF4B3XAzlhIe+KtHmeO7MAhN2qUgHoD7CzBPeKmCSvF1+I/L3a/82QUgH6jYCn1 X-Received: by 2002:a17:906:a2d2:: with SMTP id by18mr7767440ejb.262.1612600492739; Sat, 06 Feb 2021 00:34:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612600492; cv=none; d=google.com; s=arc-20160816; b=OSs6bE7Twm5V3CPhTmQ4EluvhLjgsGuLo0GKxac7b7cZtUB05hFqKYdn/pZjfUaCL6 QtFai9PGsKKRUkfqcf94VRHx4mY6CblTZsLySrFqNO22cMWiiURyyJiJfHbuWSqSFWxI fPXajFH83phiROhdRuXGeRyPZ5knd0NlELBetK/NxSa+wuhdQ+y3tjn1GF8UCK5vu0S7 YmaiMI//CxcrizaQ8Xay511k/e6u5qNYRbNAgQaHXl6c0fB5SWyylqW/lu6eXWj5Kt9f VZA2QOahrFCwbnpLkl8JzQBchM4z/W3juguvehTbdOtHNPwtJyffxlejEVtlwLQ34nDT 845w== 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=q0SMI769coz5Mj7hhHqMOjF/KRI3GQHSIX27QhIelAY=; b=erQT4fMgeWhHs7c2VY7V3cAvQOEVG1CRHmhFAxcZKM7I0Wnm55ozGWA3Bh+Ss9RJQN zTJgEJuMKqa0Q7r+LKe/VetwOKIrkP4N+Lu5E0oM56u53F8T4j9SrXukzveP3PFU78UH nUJ7GISPnTuEuToWXRVvDpYe4ZFlrCQ4LxPv/cI4OE8jGWB7xHpShkA6Rf2K7hcKfFYq YIAtGMgtFmKM7kT6/0wg2s3rCeWIHlMXSwjkOWagXnMlwz9SnUJsqWHSSVch69moJha6 Zxvst2GM+UJzEtYfUZOwUpjHd970mgNS5oYMDIlqPzo17xygSCDUM+Yn2gxtYZzfhTMh OAkg== 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 cs10si6712151ejc.200.2021.02.06.00.34.27; Sat, 06 Feb 2021 00:34:52 -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 S229707AbhBFI3f (ORCPT + 99 others); Sat, 6 Feb 2021 03:29:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:57974 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbhBFI3e (ORCPT ); Sat, 6 Feb 2021 03:29:34 -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 EAAA7AC88; Sat, 6 Feb 2021 08:28:51 +0000 (UTC) Date: Sat, 06 Feb 2021 09:28:51 +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 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? Takashi