From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753781AbcLHVRt (ORCPT ); Thu, 8 Dec 2016 16:17:49 -0500 Received: from mail-io0-f179.google.com ([209.85.223.179]:34183 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752854AbcLHVRr (ORCPT ); Thu, 8 Dec 2016 16:17:47 -0500 MIME-Version: 1.0 In-Reply-To: References: <20161208184801.1689-1-mcgrof@kernel.org> <20161208194802.2438-1-mcgrof@kernel.org> From: Kees Cook Date: Thu, 8 Dec 2016 13:17:45 -0800 X-Google-Sender-Auth: pr87V1LIrU_e84SA8wL-ir3d8UI Message-ID: Subject: Re: [RFC 02/10] module: fix memory leak on early load_module() failures To: "Luis R. Rodriguez" Cc: shuah@kernel.org, Jessica Yu , Rusty Russell , "Eric W. Biederman" , Dmitry Torokhov , Arnaldo Carvalho de Melo , Jonathan Corbet , martin.wilck@suse.com, Michal Marek , Petr Mladek , hare , rwright@hpe.com, Jeff Mahoney , DSterba@suse.com, Filipe Manana , NeilBrown , Guenter Roeck , rgoldwyn@suse.com, subashab@codeaurora.org, Heinrich Schuchardt , Aaron Tomlin , Miroslav Benes , "Paul E. McKenney" , Dan Williams , Josh Poimboeuf , "David S. Miller" , Ingo Molnar , Andrew Morton , Linus Torvalds , linux-kselftest@vger.kernel.org, "linux-doc@vger.kernel.org" , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 8, 2016 at 1:10 PM, Luis R. Rodriguez wrote: > On Thu, Dec 8, 2016 at 2:30 PM, Kees Cook wrote: >> On Thu, Dec 8, 2016 at 11:48 AM, Luis R. Rodriguez wrote: >>> While looking for early possible module loading failures I was >>> able to reproduce a memory leak possible with kmemleak. There >>> are a few rare ways to trigger a failure: >>> >>> o we've run into a failure while processing kernel parameters >>> (parse_args() returns an error) >>> o mod_sysfs_setup() fails >>> o we're a live patch module and copy_module_elf() fails >>> >>> Chances of running into this issue is really low. >>> >>> kmemleak splat: >>> >>> unreferenced object 0xffff9f2c4ada1b00 (size 32): >>> comm "kworker/u16:4", pid 82, jiffies 4294897636 (age 681.816s) >>> hex dump (first 32 bytes): >>> 6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0....... >>> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ >>> backtrace: >>> [] kmemleak_alloc+0x4a/0xa0 >>> [] __kmalloc_track_caller+0x126/0x230 >>> [] kstrdup+0x31/0x60 >>> [] kstrdup_const+0x24/0x30 >>> [] kvasprintf_const+0x7a/0x90 >>> [] kobject_set_name_vargs+0x21/0x90 >>> [] dev_set_name+0x47/0x50 >>> [] memstick_check+0x95/0x33c [memstick] >>> [] process_one_work+0x1f3/0x4b0 >>> [] worker_thread+0x48/0x4e0 >>> [] kthread+0xc9/0xe0 >>> [] ret_from_fork+0x1f/0x40 >>> [] 0xffffffffffffffff >>> >>> Signed-off-by: Luis R. Rodriguez >> >> Acked-by: Kees Cook >> >> Is this worth sending through -stable too? > > Yes, for some reason git-send e-mail complained to me about > stable@kernel.org not being a valid local address, so I had to remove > it, but indeed. I'll try to fix this e-mail issue later and add your > tag. Yup, you want stable@vger.kernel.org. :) -Kees -- Kees Cook Nexus Security