Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2493508ybd; Mon, 24 Jun 2019 07:23:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNVDHBnHewXRmXezoadlFgB56Vdic+KD7eVpcFJ0nyylpVAohtsL2/wbFLsJaaGmJorak3 X-Received: by 2002:a63:2cd1:: with SMTP id s200mr11269528pgs.439.1561386185318; Mon, 24 Jun 2019 07:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386185; cv=none; d=google.com; s=arc-20160816; b=czr3jBG0ObGZv4ZoTm07LjKYmoEmCXdIKMgNMzPvFUbPzrVx/dsqksQtOHqeaNYxI3 NKrnrqd/X+cS2CUwNXxhBtI/Hd6xWu/SjEPpp+7ODaBFdsNxp9pku2v07+7JvKNDMGHh 4Pk1qmfoItBtGYe+HaJKmwih9J6087npBaHXj1mEi9yNymuUvB7os4BdygJc6ThTN2Mr 8lRGcLcS6JR0vM/+PK+DJPdOFAfAJQ2RsX09DKM6CO6rnak8emCqSrwiERIF9JvqYUTA 5pSNlUzo9VlwaFa6DDLEwyKw9o9clxjtbMj3CgrrXvILSHVHnJ9OuCXFZcqFdl5g2EkM upjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=jc8emB4G4DxkJzWoVya72U2d4KhEjMEUsAUMMkYgQZg=; b=oDIdOWp9TQ9r2eaJTQpUx5kAlwfDP/HQKoz717tggJP9cLNuA+txh751TiyUYxbYu4 FR93mVb+6x/kGKbEseoJd+vqpSHqLHARHp2kmymlS6Y7yyokjCqmOVQOFXXX+RE1W+sC NvkTaaRm0spElOdTgb3dwa7kcTsbJ5dd5gXEsW93jIfmyAKJPiBj7Hr7Ep91yrqrDqya nhrg1G8L2OQ9amZnobdn1wJ7p7fz04tzvAPeOXF4QGF+3dSkINn7I7y2cW3JjbxuTWYl Z7aH6FCtLY8udgxZ1Na7ZrfUST3FQVnwBlnRM6Odo5AZvtYlDkd5kBh5oRrJ8It391l8 tE7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=VRVt6rcQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si6967492pff.262.2019.06.24.07.22.49; Mon, 24 Jun 2019 07:23:05 -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; dkim=pass header.i=@efficios.com header.s=default header.b=VRVt6rcQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731777AbfFXOBH (ORCPT + 99 others); Mon, 24 Jun 2019 10:01:07 -0400 Received: from mail.efficios.com ([167.114.142.138]:47618 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728052AbfFXOBG (ORCPT ); Mon, 24 Jun 2019 10:01:06 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 1F7B81E5846; Mon, 24 Jun 2019 10:01:05 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 30tAHu-OSvYj; Mon, 24 Jun 2019 10:01:04 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 8165B1E5831; Mon, 24 Jun 2019 10:01:04 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 8165B1E5831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1561384864; bh=jc8emB4G4DxkJzWoVya72U2d4KhEjMEUsAUMMkYgQZg=; h=Date:From:To:Message-ID:MIME-Version; b=VRVt6rcQHjCVHpY12SUnfvqlKUBvg1qfQjZJd0XJbcWX4BQjiksIwFvj7U9rk0k4w SDzLnSaHbDP1KXbm8Sh1yANLrmDpZpKiNFMIiLp+y9ZL24ctCzMDsacLQw5JaSVete VmnbGGquOkVhdsMO4gxWpT5mf2ItkyFKwn/RPXXJTfJn8/Bh+fXD7hqN3ldc3nfz3O xkzg2h9uAUKrUBuG2SlEmK0CGuYJAXyFrzwFA0sAHOBuhFX3mQB6tgAkvAjVOo69VE VavVADsPFOi8CSochiTy/3DU5WMMQp/aADvnBhVdpq9eYpNYb7U+67m9/jTd9JMepV HY/AvTjjRk+QA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id dJQ_J6pq8rdl; Mon, 24 Jun 2019 10:01:04 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 541671E582B; Mon, 24 Jun 2019 10:01:04 -0400 (EDT) Date: Mon, 24 Jun 2019 10:01:04 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Frank Ch. Eigler" Cc: Jessica Yu , linux-kernel , Josh Poimboeuf , jikos@kernel.org, mbenes@suse.cz, Petr Mladek , Alexei Starovoitov , Daniel Borkmann , Andrew Morton , Robert Richter , rostedt , Ingo Molnar , Martin KaFai Lau , Song Liu , Yonghong Song , paulmck , "Joel Fernandes, Google" , Ard Biesheuvel , Thomas Gleixner , oprofile-list@lists.sf.net, netdev , bpf@vger.kernel.org Message-ID: <320564860.243.1561384864186.JavaMail.zimbra@efficios.com> In-Reply-To: <20190624092109.805742823@infradead.org> References: <20190624091843.859714294@infradead.org> <20190624092109.805742823@infradead.org> Subject: Re: [PATCH 2/3] module: Fix up module_notifier return values. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.12_GA_3803 (ZimbraWebClient - FF67 (Linux)/8.8.12_GA_3794) Thread-Topic: module: Fix up module_notifier return values. Thread-Index: wEhc4w1xfyhyzFRK4s3Hnq/quVAuEQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jun 24, 2019, at 5:18 AM, Peter Zijlstra peterz@infradead.org wrote: > 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) Thanks Peter for looking into this, especially considering your endless love for kernel modules! ;) It's not directly related to your changes, but I notice that kernel/trace/trace_printk.c:hold_module_trace_bprintk_format() appears to leak memory. Am I missing something ? With respect to your changes: Reviewed-by: Mathieu Desnoyers I have a similar erroneous module notifier return value pattern in lttng-modules as well. I'll go fix it right away. CCing Frank Eigler from SystemTAP which AFAIK use a copy of lttng-tracepoint.c in their project, which should be fixed as well. I'm pasting the lttng-modules fix below. Thanks! Mathieu -- commit 5eac9d146a7d947f0f314c4f7103c92cbccaeaf3 Author: Mathieu Desnoyers Date: Mon Jun 24 09:43:45 2019 -0400 Fix: lttng-tracepoint module notifier should return NOTIFY_OK Module notifiers should return NOTIFY_OK on success rather than the value 0. The return value 0 does not seem to have any ill side-effects in the notifier chain caller, but it is preferable to respect the API requirements in case this changes in the future. Notifiers can encapsulate a negative errno value with notifier_from_errno(), but this is not needed by the LTTng tracepoint notifier. The approach taken in this notifier is to just print a console warning on error, because tracing failure should not prevent loading a module. So we definitely do not want to stop notifier iteration. Returning an error without stopping iteration is not really that useful, because only the return value of the last callback is returned to notifier chain caller. Signed-off-by: Mathieu Desnoyers diff --git a/lttng-tracepoint.c b/lttng-tracepoint.c index bbb2c7a4..8298b397 100644 --- a/lttng-tracepoint.c +++ b/lttng-tracepoint.c @@ -256,7 +256,7 @@ int lttng_tracepoint_coming(struct tp_module *tp_mod) } } mutex_unlock(<tng_tracepoint_mutex); - return 0; + return NOTIFY_OK; } static -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com