Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp601427ybi; Wed, 19 Jun 2019 04:57:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfyEpCV83XbKob8GzfgesGcK5durrNkUp0UDSVR4BEAWXio4vawNU6AYEIOznAemFmNPNk X-Received: by 2002:a63:d415:: with SMTP id a21mr7233955pgh.229.1560945438949; Wed, 19 Jun 2019 04:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560945438; cv=none; d=google.com; s=arc-20160816; b=Uz4gLl4inhkCyQ9G6db54HX3WpJam/3uFA/HdaGf+c8bPdr+yJ2fiG0WLqJh7aP8cg zOkllPWS1PhX8QCZtDYea8fIKB9GFJmb5ZXWbv1nPpSJhVej1BIJuWV6/D95UVaniSNY r4iFhTRZMEBzjtDXecsnJZS1QHG6uGecH6gzilTD6t8INxCLRPZCOzmEzdGt0hH4xm6S 2JSnIoCE7tZ+7bRdW8hEIxcfGkU0B32GyxKG2WRpvWP89HXqj9925mN0pzFFIbRCTAM0 9qS50NkKPbOExtGUNrZs3IW5zFBj2oDMSQWO1lPc4S3j/TXFYNWFrzD2sfBXfN6ImH7E dl8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ksuupuy0f3r3Y8E8KjK2kXsdIb7aUSAXgjEnrLIYeB0=; b=VCTtvXX5u5i4w9MU7PA9UNJJtKbLZlxR55isgTbC4sml8C7zjfKdNG1aq/57qv6Hm7 ckdA2hKsEIQVZwSkl1p0ir9UA9uz1yfcIssVHfXPhAX0nwIfBA+nDciHXEf2jt/xIboj Cof1sV1J1Wkau1f5X+NFTP1eQPN8dRZaS4d8pwta8HAz76zM/X3iyKOTxtK91diiMfga gmNDyyg0/JSDgI9S/175XDiC5XhNhiWmuOf6TKUB4Ng2bBcPjckIim3ElN8PnBidBwdC bqCIjyDMRghuOS4Cqkg9Ivm4T85rrExaWmSHBPdDCgMPE1cOdSpCGlEEDrNhgnx2fuWK XW8Q== 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 d10si15924570pla.406.2019.06.19.04.57.03; Wed, 19 Jun 2019 04:57:18 -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 S1731587AbfFSL4o (ORCPT + 99 others); Wed, 19 Jun 2019 07:56:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:42246 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727067AbfFSL4o (ORCPT ); Wed, 19 Jun 2019 07:56:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 39582AF7C; Wed, 19 Jun 2019 11:56:43 +0000 (UTC) Date: Wed, 19 Jun 2019 13:56:42 +0200 From: Petr Mladek To: Miroslav Benes Cc: Peter Zijlstra , Jessica Yu , linux-kernel@vger.kernel.org, jpoimboe@redhat.com, jikos@kernel.org, rostedt@goodmis.org, ast@kernel.org, daniel@iogearbox.net Subject: Re: [RFC][PATCH] module: Propagate MODULE_STATE_COMING notifier errors Message-ID: <20190619115642.xzemjebbbl2llabu@pathway.suse.cz> References: <20190617090335.GX3436@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2019-06-19 13:12:12, Miroslav Benes wrote: > On Mon, 17 Jun 2019, Peter Zijlstra wrote: > > --- a/kernel/module.c > > +++ b/kernel/module.c > > @@ -3638,9 +3638,10 @@ static int prepare_coming_module(struct module *mod) > > if (err) > > return err; > > > > - blocking_notifier_call_chain(&module_notify_list, > > - MODULE_STATE_COMING, mod); > > - return 0; > > + ret = blocking_notifier_call_chain(&module_notify_list, > > + MODULE_STATE_COMING, mod); > > + ret = notifier_to_errno(ret); > > + return ret; > > } > > > > static int unknown_module_param_cb(char *param, char *val, const char *modname, > > @@ -3780,7 +3781,7 @@ static int load_module(struct load_info *info, const char __user *uargs, > > > > err = prepare_coming_module(mod); > > if (err) > > - goto bug_cleanup; > > + goto coming_cleanup; > > Not good. klp_module_going() is not prepared to be called without > klp_module_coming() succeeding. "Funny" things might happen. We have discussed it with Miroslav. The best solution seems to be to allow to call klp_module_going() even when klp_module_comming() failed. Something like: diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index c4ce08f43bd6..42d72b62edb2 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1188,6 +1188,10 @@ void klp_module_going(struct module *mod) return; mutex_lock(&klp_mutex); + + /* Nope when klp_module_comming failed */ + if (!mod->klp_alive) + goto out; /* * Each module has to know that klp_module_going() * has been called. We never know what module will @@ -1196,7 +1200,7 @@ void klp_module_going(struct module *mod) mod->klp_alive = false; klp_cleanup_module_patches_limited(mod, NULL); - +out: mutex_unlock(&klp_mutex); } Peter's patch actually allows to convert the klp hooks into proper module notifiers. But we could do it later once this patch is upstream or queued. Best Regards, Petr