Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2562206imm; Wed, 16 May 2018 15:10:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq+jeeaFA9MDUBYpdAAYXRcNTXcGbR8zZj4dBt97t3oV1QiagusnoDrQs1hL8fjzOd6qR+o X-Received: by 2002:a62:5050:: with SMTP id e77-v6mr2769037pfb.16.1526508636190; Wed, 16 May 2018 15:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526508636; cv=none; d=google.com; s=arc-20160816; b=uw9Q9E1OWpSQ+6IpH/C6OaHaSsczsurnBB9hGlNSIqRUvEYGqSa5cHyMFpkqgzeL0T M8v43oM3/EaG8DLA9bGXA0bt59Ls9Gys+h7UW0OSyJTXZlLVKZeBUZwErJ5Nn8Tv+17L K2iI3KogdBY+4SUYvbpAP0hm5U/BMR45/BvW8jaZ7ClSRRgVL1XEyWPffcRlLjtKBm3Y HDEakk4kSDqFJoSXeBE50qiSljlaYyuBQ1iZK+OMWIPYe4Wb8tFOB7y4dI4KG0TeRqYi nOtGfnv02iCOgsZ/aOPUsmn+ACf5gWm9VTgWlQmxMvyJGnQIwvKEcrjjaQeLDmoQwYvJ kg4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:arc-authentication-results; bh=FPU0jTWDEECRaVPYkQ64kSk5NOPdNHm53UTHlb6cfwc=; b=t/Kis1H4xuWI4tXIF3JwMax53atWIPOQEMv4kaSsMuV6a0H7VYMprtvtsrudyRiD0n x8qHLf/YgzURlQa9fbdBL5x8Q4czh1e2pVNXHwmtvgOiUHMjNff/Sw0+QpCcsjpMBqFP UXODUCxKLqwmUPWudinW/hbImPg7+qXkKL8rjCJLbfJ+iKuPjHmJpPJaZtzNFDPR/qX9 y1nPMOTp7SN9oHgwtO8lS5a6GTDKtbqPZsgWdG7Po8fo1TjWkWH59FXtufMpPRvkutHU K86IDTLuIAXGhM/B2WCbgz4pWQMUmYAaWZagIdc+FkI2KvhV4nJ0lxLvG2tAMg+KHTAB lsVA== ARC-Authentication-Results: i=1; mx.google.com; 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 s7-v6si2751778pgr.670.2018.05.16.15.10.21; Wed, 16 May 2018 15:10:36 -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; 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 S1751406AbeEPWJ7 (ORCPT + 99 others); Wed, 16 May 2018 18:09:59 -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 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 608AAACD5; Wed, 16 May 2018 22:09:56 +0000 (UTC) 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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