From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25635C43613 for ; Mon, 24 Jun 2019 09:24:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F16172089F for ; Mon, 24 Jun 2019 09:24:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pPZckTeX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727673AbfFXJYy (ORCPT ); Mon, 24 Jun 2019 05:24:54 -0400 Received: from merlin.infradead.org ([205.233.59.134]:42238 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727537AbfFXJYx (ORCPT ); Mon, 24 Jun 2019 05:24:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=t52uwsZ5CS16wjZkH/9lP0ZEe/KSj6WTDcY9RTylZiU=; b=pPZckTeXk7GUNaGNfbBK8q0PET Psm8el7YAywshXMcwevA7aur0wDPpnp4QcJ+KqJ1uwvD5z0H8AUlfcQVnD1GHLXxRvLJDT1LJpdF+ ArrXtpfxk76E2n8Y9P8oh/5r2UERyrrXl/s571fHUrdkz7DdsEVFgEQDYPshcUhoeRMWokvmtEIUi rV1OSQHDdsa9DeouIVSVaYHFlZRr+BHJiwf37wWPkUxGop+I4Gl+MVMNIGjW1SN4ZBSP9mBD+Jziz YZdsR77vZh1Wq7Q673JGai165+G3fDHIn4+Xk1z2UVtgN5RlURm45MF+2cWBzMWqVE6sTF8AKNA2u fK5uCIxA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfLCm-0006v0-M0; Mon, 24 Jun 2019 09:24:04 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 5518620A0EF24; Mon, 24 Jun 2019 11:24:02 +0200 (CEST) Message-Id: <20190624092109.805742823@infradead.org> User-Agent: quilt/0.65 Date: Mon, 24 Jun 2019 11:18:45 +0200 From: Peter Zijlstra To: Jessica Yu , linux-kernel@vger.kernel.org, jpoimboe@redhat.com, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com, ast@kernel.org, daniel@iogearbox.net, akpm@linux-foundation.org, peterz@infradead.org Cc: Robert Richter , Steven Rostedt , Ingo Molnar , Martin KaFai Lau , Song Liu , Yonghong Song , Mathieu Desnoyers , "Paul E. McKenney" , "Joel Fernandes (Google)" , Ard Biesheuvel , Thomas Gleixner , oprofile-list@lists.sf.net, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 2/3] module: Fix up module_notifier return values. References: <20190624091843.859714294@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While auditing all module notifiers I noticed a whole bunch of fail wrt the return value. Notifiers have a 'special' return semantics. Cc: Robert Richter Cc: Steven Rostedt Cc: Ingo Molnar Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Martin KaFai Lau Cc: Song Liu Cc: Yonghong Song Cc: Mathieu Desnoyers Cc: "Paul E. McKenney" Cc: "Joel Fernandes (Google)" Cc: Ard Biesheuvel Cc: Thomas Gleixner Cc: oprofile-list@lists.sf.net Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org Cc: bpf@vger.kernel.org Signed-off-by: Peter Zijlstra (Intel) --- drivers/oprofile/buffer_sync.c | 4 ++-- kernel/module.c | 9 +++++---- kernel/trace/bpf_trace.c | 8 ++++++-- kernel/trace/trace.c | 2 +- kernel/trace/trace_events.c | 2 +- kernel/trace/trace_printk.c | 4 ++-- kernel/tracepoint.c | 2 +- 7 files changed, 18 insertions(+), 13 deletions(-) --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c @@ -116,7 +116,7 @@ module_load_notify(struct notifier_block { #ifdef CONFIG_MODULES if (val != MODULE_STATE_COMING) - return 0; + return NOTIFY_DONE; /* FIXME: should we process all CPU buffers ? */ mutex_lock(&buffer_mutex); @@ -124,7 +124,7 @@ module_load_notify(struct notifier_block add_event_entry(MODULE_LOADED_CODE); mutex_unlock(&buffer_mutex); #endif - return 0; + return NOTIFY_OK; } --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1302,10 +1302,11 @@ static int bpf_event_notify(struct notif { struct bpf_trace_module *btm, *tmp; struct module *mod = module; + int ret = 0; if (mod->num_bpf_raw_events == 0 || (op != MODULE_STATE_COMING && op != MODULE_STATE_GOING)) - return 0; + goto out; mutex_lock(&bpf_module_mutex); @@ -1315,6 +1316,8 @@ static int bpf_event_notify(struct notif if (btm) { btm->module = module; list_add(&btm->list, &bpf_trace_modules); + } else { + ret = -ENOMEM; } break; case MODULE_STATE_GOING: @@ -1330,7 +1333,8 @@ static int bpf_event_notify(struct notif mutex_unlock(&bpf_module_mutex); - return 0; +out: + return notifier_from_errno(ret); } static struct notifier_block bpf_module_nb = { --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8685,7 +8685,7 @@ static int trace_module_notify(struct no break; } - return 0; + return NOTIFY_OK; } static struct notifier_block trace_module_nb = { --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2450,7 +2450,7 @@ static int trace_module_notify(struct no mutex_unlock(&trace_types_lock); mutex_unlock(&event_mutex); - return 0; + return NOTIFY_OK; } static struct notifier_block trace_module_nb = { --- a/kernel/trace/trace_printk.c +++ b/kernel/trace/trace_printk.c @@ -95,7 +95,7 @@ static int module_trace_bprintk_format_n if (val == MODULE_STATE_COMING) hold_module_trace_bprintk_format(start, end); } - return 0; + return NOTIFY_OK; } /* @@ -173,7 +173,7 @@ __init static int module_trace_bprintk_format_notify(struct notifier_block *self, unsigned long val, void *data) { - return 0; + return NOTIFY_OK; } static inline const char ** find_next_mod_format(int start_index, void *v, const char **fmt, loff_t *pos) --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c @@ -538,7 +538,7 @@ static int tracepoint_module_notify(stru case MODULE_STATE_UNFORMED: break; } - return ret; + return notifier_from_errno(ret); } static struct notifier_block tracepoint_module_nb = {