From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-969494-1526508603-2-4105924129929609505 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.248, MAILING_LIST_MULTI -1, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='de', MailFrom='org' X-Spam-charsets: plain='UTF-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=fm2; t= 1526508602; b=RUGyYraDOJpthM51sU+KLnrkNt7HF1TU+ALwgLU1Z1lN6HxUsq 6j4199uMGN1q0we2N51i8eNRseDqIftnoDAjpF3wXb2EPaboYJxBBNccea6Qb6XV Rmcu95Z67KvOndOAdww5WJkh6787NBSHdhZOuWW4yxdHXGOTxkEc3Qc8a1uU96KY 9Tu6mYSHofwyqXdpg8PCrYrBIAWhfSMCPqASMGqPnrhXwLx8VG3fPFIfxIs0N4s8 Sp4OXa5PbF/HbhXuOLCHjX1FvO06Ec/T7j1fpGJtizjI9PIyGOIlS3W/Z1Maa4G2 H2K+4O+OL8gIUniIkIgurDMqQ2xOyNvVDpZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:message-id:from:to:cc:subject :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=fm2; t=1526508602; bh=FPU0jTWDEECRaVPYkQ64kSk5NOPdNHm53UTHlb6cfwc=; b=g2cEJEyFSJsw fW/FPolbNAVqlexf+bTYqtxRIhCzFedCg4MWA9YOciHDhrzCptBTI90mGZncLNsg AYQCjYC5R8ajOXfJS/F+ZErTcG0qu8g6nu+ZnMKs/mTIo67d+8UxTu41+zDJzK9q mM+yezEEiCSXpu17304jTHKu2Tro6hBGfB0eCWZpmSLmbzjoZftTNuqxd+2n3K8W DaWO4g2xgTouGeuAqK7qiInuwxQ424bliowT6dlXF4h0MBAqPei7F1hxDzWJgTjG NS3B5QLE5Wv4ODl07v6YS8sGYo1Nf8QjEBP0WINAiLzzBsW4/8SJujwSrIrYkJrb Sz8+yMM1NQ== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=suse.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-cm=none score=0; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=suse.de header.result=pass header_is_org_domain=yes; x-vs=clean score=-100 state=0 Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=suse.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-cm=none score=0; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=suse.de header.result=pass header_is_org_domain=yes; x-vs=clean score=-100 state=0 X-ME-VSCategory: clean X-CM-Envelope: MS4wfCwjLw1oiy/9pODT81EzGCmJS32/hpCzj6O5S0CZbPnfTrChJN/MQ24YfhPVyvv51XqQyx0VIgP89fjuegWK+YhdGrBOlxDIdmzNamzZxDG3LvYqCp5T FQVmXkEepX9bMJAqvlRVDnKY5mfYSUJk+v4cKL7r34tLyvJChBKHS07fDrEQy+/cPqoHSr+hQWh0dRhCb16hpDP7toihQr2RJgxGEsHyzgRoslbp+/VwhKPI X-CM-Analysis: v=2.3 cv=Tq3Iegfh c=1 sm=1 tr=0 a=UK1r566ZdBxH71SXbqIOeA==:117 a=UK1r566ZdBxH71SXbqIOeA==:17 a=IkcTkHD0fZMA:10 a=VUJBJC2UJ8kA:10 a=xAfncO3ikrIOfLjvVA0A:9 a=QEXdDO2ut3YA:10 X-ME-CMScore: 0 X-ME-CMCategory: none Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751153AbeEPWJ6 (ORCPT ); Wed, 16 May 2018 18:09:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:55473 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbeEPWJ6 (ORCPT ); Wed, 16 May 2018 18:09:58 -0400 Date: Thu, 17 May 2018 00:09:55 +0200 Message-ID: From: Takashi Iwai To: Ben Hutchings Cc: Greg Kroah-Hartman , 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 In-Reply-To: <1526503907.9159.150.camel@codethink.co.uk> References: <20180422135304.577223025@linuxfoundation.org> <20180422135308.244077643@linuxfoundation.org> <1526503907.9159.150.camel@codethink.co.uk> 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=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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.) Indeed, there seem more codes calling the callback without the lock. I'll send the fix patches. thanks, Takashi