Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934225AbbLPXsf (ORCPT ); Wed, 16 Dec 2015 18:48:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932125AbbLPXsd (ORCPT ); Wed, 16 Dec 2015 18:48:33 -0500 Date: Wed, 16 Dec 2015 18:48:28 -0500 From: Jessica Yu To: Miroslav Benes Cc: Rusty Russell , Josh Poimboeuf , Seth Jennings , Jiri Kosina , Vojtech Pavlik , Jonathan Corbet , linux-api@vger.kernel.org, live-patching@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: module: s390: keep mod_arch_specific for livepatch modules Message-ID: <20151216234828.GB29092@packer-debian-8-amd64.digitalocean.com> References: <1448943679-3412-1-git-send-email-jeyu@redhat.com> <1448943679-3412-4-git-send-email-jeyu@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-OS: Linux eisen.io 3.16.0-4-amd64 x86_64 User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2184 Lines: 52 +++ Miroslav Benes [16/12/15 13:02 +0100]: >On Mon, 30 Nov 2015, Jessica Yu wrote: > >> Livepatch needs to utilize the symbol information contained in the >> mod_arch_specific struct in order to be able to call the s390 >> apply_relocate_add() function to apply relocations. Remove the redundant >> vfree() in module_finalize() since module_arch_freeing_init() (which also frees >> said structures) is called in do_init_module(). Keep a reference to syminfo if >> the module is a livepatch module and free the structures in >> module_arch_cleanup(). If the module isn't a livepatch module, we free the >> structures in module_arch_freeing_init() as usual. >> >> Signed-off-by: Jessica Yu >> --- >> arch/s390/kernel/module.c | 13 +++++++++++-- >> 1 file changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c >> index 0c1a679..17a1979 100644 >> --- a/arch/s390/kernel/module.c >> +++ b/arch/s390/kernel/module.c >> @@ -51,6 +51,9 @@ void *module_alloc(unsigned long size) >> >> void module_arch_freeing_init(struct module *mod) >> { >> + if (mod->klp) >> + return; >> + >> vfree(mod->arch.syminfo); >> mod->arch.syminfo = NULL; >> } > >Hm, this is problematic. module_arch_freeing_init() is called from >module_deallocate() and this is called in the error path in load_module(). >So if there was an error during load_module() of livepatch module which >led to free_modinfo label or behind mod->arch.syminfo would not be freed >at all. module_arch_cleanup() is called earlier under >free_arch_cleanup. Gah. Good catch. How about we add an additional check to see if mod->state is MODULE_STATE_LIVE? If so, we can return. This means we're coming from do_init_module(). If module_arch_freeing_init() was called and the module was in a state other than MODULE_STATE_LIVE (UNFORMED, GOING, COMING), we know we need to free. Think that would work? Jessica -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/