Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3021898imm; Thu, 17 May 2018 01:54:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrMe50fEt4XJOqLUTYXezWTD7M/ygVlsviwNjG9ZXhKJKXGrRbmE3UrHIAOdHe7bZGCevbE X-Received: by 2002:a17:902:1e3:: with SMTP id b90-v6mr4267048plb.273.1526547298139; Thu, 17 May 2018 01:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526547298; cv=none; d=google.com; s=arc-20160816; b=AEcncqj5Ft1IkFynnG9Its3po5Ung36Idvkf3AjUTizirexzzxdNJIvTkx8u7zEsum p7kqKE3clq/ixLLePj3BXbI0xdDyNgFVC73Gqd1tAryIQ8XUE/1yl7p66RB1NNQzSn13 pFB7437yT42qLR6NL5amy0Xrg4OhT0a22U6R5I5XfAwASTe20Ofe+wd60u0Gj8I724BK i1IBotDfTW6cXqppmERfhFU/U9wCUtBsSomZwLRSpXg3cw1xDWNvQLUAygH69orblI15 o2lQyqtZ1HkiM6yYQAwI33n+oyIg0kWKhWnu2MDMy5Q9qvNiA96sLZuNhHPnEQDKWoPJ /pGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=Qns+h1/fzVhCPUxZkTg8TzEry8ZoIKovfIbTRPu3ees=; b=e4Fxmi+AatUXmg4G6AzgeSMWNCa5Kz2aef8fle9/VTE3vNtslOow4DgJX1ECbo5Y2R DEKZbGlOX08xt26sCfwd10/fs8Ao21j6EYuRmFA2gece5RRQiJPoG7jZb3pyzZve96vb 8BKhoEhlXsJXm9VY35tMpbnBvL240XOVrVfW9i3R5OLScMfkD4UwWQkOaZ49sVzEqbWg T6rSNTw4R79om+gDXkRurKbwN0wg4tzxraIxbaKtEVxFbaxvSNiZlFs1DHPe1ry73jp5 QHllvN1+nBVft5ByAB0cHkEUlhoMK8uzt6Cw15jgZKZLdrm1KDwhisNXW1bXbnubroph /U7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vUSJqf/G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y34-v6si4699814plb.17.2018.05.17.01.54.42; Thu, 17 May 2018 01:54:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vUSJqf/G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbeEQIyY (ORCPT + 99 others); Thu, 17 May 2018 04:54:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:45806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751804AbeEQIyT (ORCPT ); Thu, 17 May 2018 04:54:19 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 883AC20858; Thu, 17 May 2018 08:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526547258; bh=4c/T5pmJ4dwOd004JfmurOj2gI7Kyy0I4NON96jLQXA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vUSJqf/GR1im5kaFm8ZZ3Odzo1uH9rkNfxyZL3NwDsKEsRhnBl84J6XHkTNlXHmlS OcKvlrB6HU2x9NZDR7y2oA2sWejboK5dfTR016yXT9C9orG75miSMSropnaPIKQGvj lOe47mBKea25yMUgHii9fpN1Bpj5n0zHOY0XTCAw= Date: Thu, 17 May 2018 10:54:00 +0200 From: Greg Kroah-Hartman To: Takashi Iwai Cc: Ben Hutchings , linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+8e62ff4e07aa2ce87826@syzkaller.appspotmail.com Subject: Re: [PATCH 4.4 53/97] ALSA: pcm: Fix UAF at PCM release via PCM timer access Message-ID: <20180517085400.GA25318@kroah.com> References: <20180422135304.577223025@linuxfoundation.org> <20180422135308.244077643@linuxfoundation.org> <1526503907.9159.150.camel@codethink.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 17, 2018 at 12:09:55AM +0200, Takashi Iwai wrote: > On Wed, 16 May 2018 22:51:47 +0200, > Ben Hutchings wrote: > > > > On Sun, 2018-04-22 at 15:53 +0200, Greg Kroah-Hartman wrote: > > > 4.4-stable review patch.??If anyone has any objections, please let me know. > > > > > > ------------------ > > > > > > From: Takashi Iwai > > > > > > commit a820ccbe21e8ce8e86c39cd1d3bc8c7d1cbb949b upstream. > > > > > > The PCM runtime object is created and freed dynamically at PCM stream > > > open / close time.??This is tracked via substream->runtime, and it's > > > cleared at snd_pcm_detach_substream(). > > > > > > The runtime object assignment is protected by PCM open_mutex, so for > > > all PCM operations, it's safely handled.??However, each PCM substream > > > provides also an ALSA timer interface, and user-space can access to > > > this while closing a PCM substream.??This may eventually lead to a > > > UAF, as snd_pcm_timer_resolution() tries to access the runtime while > > > clearing it in other side. > > > > > > Fortunately, it's the only concurrent access from the PCM timer, and > > > it merely reads runtime->timer_resolution field.??So, we can avoid the > > > race by reordering kfree() and wrapping the substream->runtime > > > clearance with the corresponding timer lock. > > [...] > > > > This seems to depend on: > > > > commit f65e0d299807d8a11812845c972493c3f9a18e10 > > Author: Takashi Iwai > > Date:???Wed Feb 10 12:47:03 2016 +0100 > > > > ????ALSA: timer: Call notifier in the same spinlock > > > > (But I'm not totally convinced that snd_pcm_timer_resolution() is > > always called with the timer lock held, even after that.) Good catch, I'll queue this up now, thanks. greg k-h