Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757015AbcJ3Q3e (ORCPT ); Sun, 30 Oct 2016 12:29:34 -0400 Received: from mail-ua0-f169.google.com ([209.85.217.169]:36812 "EHLO mail-ua0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755498AbcJ3Q3c (ORCPT ); Sun, 30 Oct 2016 12:29:32 -0400 MIME-Version: 1.0 In-Reply-To: <1477842248-2234-1-git-send-email-jann@thejh.net> References: <1477842248-2234-1-git-send-email-jann@thejh.net> From: Andy Lutomirski Date: Sun, 30 Oct 2016 09:29:10 -0700 Message-ID: Subject: Re: [PATCH] ppdev: fix double-free of pp->pdev->name To: Jann Horn Cc: Arnd Bergmann , Greg Kroah-Hartman , Sudip Mukherjee , "linux-kernel@vger.kernel.org" , linux-parport@lists.infradead.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1397 Lines: 32 On Sun, Oct 30, 2016 at 8:44 AM, Jann Horn wrote: > free_pardevice() is called by parport_unregister_device() and already frees > pp->pdev->name, don't try to do it again. > > This bug causes kernel crashes. > > I found and verified this with KASAN and some added pr_emerg()s: > > [ 60.316568] pp_release: pp->pdev->name == ffff88039cb264c0 > [ 60.316692] free_pardevice: freeing par_dev->name at ffff88039cb264c0 > [ 60.316706] pp_release: kfree(ffff88039cb264c0) > [ 60.316714] ========================================================== > [ 60.316722] BUG: Double free or freeing an invalid pointer > [ 60.316731] Unexpected shadow byte: 0xFB > [ 60.316801] Object at ffff88039cb264c0, in cache kmalloc-32 size: 32 > [ 60.316813] Allocated: > [ 60.316824] PID = 1695 > [ 60.316869] Freed: > [ 60.316880] PID = 1695 > [ 60.316935] ========================================================== > > CCing Andy Lutomirski because I think this is what broke vmapped stacks > for me - after applying this patch, vmapped stacks worked for me. > Previously, I got oopses (and lockups) caused by area->pages[0] being > 0x400000000 in __vunmap(), with area->pages being allocated in the kmalloc > area. That's an odd symptom. I assume that what's happening is that the pages array is being freed early by the extra kfree in here and then getting corrupted. --Andy