From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753195AbcIBMfK (ORCPT ); Fri, 2 Sep 2016 08:35:10 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:43352 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbcIBMfI (ORCPT ); Fri, 2 Sep 2016 08:35:08 -0400 Subject: Re: [PATCH 1/3] ALSA: timer: fix NULL pointer dereference in read()/ioctl() race To: Takashi Iwai References: <20160828223351.32489-1-vegard.nossum@oracle.com> <0560accf-2461-8205-6377-32b464bfce7e@oracle.com> Cc: Jaroslav Kysela , alsa-devel@alsa-project.org, syzkaller , linux-kernel@vger.kernel.org From: Vegard Nossum Message-ID: <14739ff0-b415-08e5-5f5c-a29a99fe473e@oracle.com> Date: Fri, 2 Sep 2016 14:34:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <0560accf-2461-8205-6377-32b464bfce7e@oracle.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/29/2016 09:14 AM, Vegard Nossum wrote: > On 08/29/2016 09:02 AM, Takashi Iwai wrote: >> On Mon, 29 Aug 2016 00:33:49 +0200, >> Vegard Nossum wrote: >>> @@ -1602,15 +1602,25 @@ static int snd_timer_user_tselect(struct file >>> *file, >>> kfree(tu->tqueue); >>> tu->tqueue = NULL; >>> if (tu->tread) { >>> - tu->tqueue = kmalloc(tu->queue_size * sizeof(struct >>> snd_timer_tread), >>> + struct snd_timer_tread *ttr; >>> + ttr = kmalloc(tu->queue_size * sizeof(struct snd_timer_tread), >>> GFP_KERNEL); >>> - if (tu->tqueue == NULL) >>> + if (ttr) { >>> + kfree(tu->tqueue); >>> + tu->tqueue = ttr; >> >> This looks like the double-tree, as you didn't remove the kfree() call >> in the above. But, I guess this change is superfluous when you >> introduce the mutex at... > > You're right, this hunk is garbage. > > Please see the new patch (attached), I also changed the patch > description slightly to match the changes. > > I'll start running some tests on the new patch. I tested the new patch (from the email I'm replying to). It seems to work for me. Thanks, Vegard