Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2795246ybd; Mon, 24 Jun 2019 12:49:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzW2Q/lEvGFVt4wdLgAwSw/rGV3DEaA/bMSa+UuxHtbBlXpUQ4C9DskbYS3wYuhogu4WgA7 X-Received: by 2002:a63:1d5:: with SMTP id 204mr35717147pgb.207.1561405788584; Mon, 24 Jun 2019 12:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561405788; cv=none; d=google.com; s=arc-20160816; b=v0nSf+iGXKqurTyieqXRu008YETJ4VNeWkLMp9CvYwW2rykjvVKDLCOa6u6K1CiGC8 phNEDnGL4tZL6jsCHig+rNBtCgwRj9KHWWLyxZDZbTM6BwkEIUdN2gTW3nWg/VwXiJRi X87gpd6+MkEpquaV1BYgzf+mG3eNfDZifYkR5M9DNIflHlm3zhOKzTM3FfL2xsUoATOJ kf1BO2B2JUjgf2BImk9iHObJY1Y4wIAHAa/leeo1dqvgD52xTxmHLv9C9zkAVmHlYQMj TflOe79j1tNbqb8voVKpZah2YRz+lnTMwY3v+wtLithjYuxdWVcFn7T7PPBlRHH19+yG JASw== 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:dkim-signature; bh=Px55vsxlWUa+5ZAUavHWxhk2yXQs9ETqoP8b6WxOkms=; b=CpRtskPdOupVJ1tWOtpWtJy5vs/Klxj87QUqnQUBkmPbT+O4TgfvyRuoKdziqF9aNA 4shO1JsobBRlPWlb2xVsxkdpcKZ4RYH32nv/xOaEGNU+kfQZmyAuV+/knu5mhWUTQ2gu b0r/DwajWh0XRo1XrRTN6QGx/b/2CAB2+8nsLvNI8TH3fzJfoFyRCHyCCIa+B9Xzce6X R6tsvcQnb2OJ+DSkyLRcSL7fZ37wz/aPM1SNuwCxrZT5aq0PofVvlSO2aVoQjjD1NwtC ss+p/6pOWEjSq6qtLK1jPZLfDnw+Ly4A48hL3I8So5k2hB5S4cbr6as1tZo4bBwV//dV Psnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=nMVpZ6t6; 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 z5si11113555pgj.213.2019.06.24.12.49.33; Mon, 24 Jun 2019 12:49:48 -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=@joelfernandes.org header.s=google header.b=nMVpZ6t6; 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 S1729346AbfFXPwR (ORCPT + 99 others); Mon, 24 Jun 2019 11:52:17 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:45109 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728725AbfFXPwQ (ORCPT ); Mon, 24 Jun 2019 11:52:16 -0400 Received: by mail-qk1-f194.google.com with SMTP id s22so10084654qkj.12 for ; Mon, 24 Jun 2019 08:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Px55vsxlWUa+5ZAUavHWxhk2yXQs9ETqoP8b6WxOkms=; b=nMVpZ6t6yvkRI8JTB2fGMerawDsRhL0/iqvwIvHdoVXopMnMqU5PI/pn1syMvLqGms Rw2EcKCOL3MuPgQ97OgUvIP4Ut8lxtGkmBXc55ysvSxoamyi1P4HLcsx39d+QMyY81xQ 2PQDgpcf2DGfbHVXO4YLvpkFB0G8WZeBEyQNI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Px55vsxlWUa+5ZAUavHWxhk2yXQs9ETqoP8b6WxOkms=; b=Bbk/Uh9X2J5VDbMrUPT5/thkaJbcy+MTiZWW3toBIWW5p865RxumNUrbgeLDcn6rmc nIot73xnZk3djpyCQJ5qiMTr1KU3A1p0mPrUr1OSsiF7tmsQ0kqnedKWaIKZ5rHlo5s5 vxEhASkKXhGAjqmsbTlcz9ynBN1maulkg/FCvLdtDbQx7qpMMHr2vOGIU257HS9Dl5W1 WQes1z9w0FVYshdNkMa20Q/Lxs/XY7AKj1XU+19JlETZJWA5BzfDfpfbcAumIdF9aRxY +YyceX1dxIS6MpUvyeEYv2CX5K6xfh+aCApNjiYfIiiXtP/6WOg5l2FvGn7B5h7fSLyE LI8Q== X-Gm-Message-State: APjAAAVhnm1j7gTufiWYNqAgs2CuX2zdaTKfX5SIXh0yBaolT3xA0fRm EQtMEkBLrLXIy2w18jrR87KYig== X-Received: by 2002:a37:ac14:: with SMTP id e20mr120205143qkm.243.1561391535368; Mon, 24 Jun 2019 08:52:15 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id k58sm7173879qtc.38.2019.06.24.08.52.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 08:52:14 -0700 (PDT) Date: Mon, 24 Jun 2019 11:52:13 -0400 From: Joel Fernandes To: Mathieu Desnoyers Cc: Peter Zijlstra , "Frank Ch. Eigler" , 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 , Ard Biesheuvel , Thomas Gleixner , oprofile-list@lists.sf.net, netdev , bpf@vger.kernel.org Subject: Re: [PATCH 2/3] module: Fix up module_notifier return values. Message-ID: <20190624155213.GB261936@google.com> References: <20190624091843.859714294@infradead.org> <20190624092109.805742823@infradead.org> <320564860.243.1561384864186.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <320564860.243.1561384864186.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 10:01:04AM -0400, Mathieu Desnoyers wrote: > ----- 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 ? Could you elaborate? Do you mean there is no MODULE_STATE_GOING notifier check? If that's what you mean then I agree, there should be some place where the format structures are freed when the module is unloaded no? > > With respect to your changes: > Reviewed-by: Mathieu Desnoyers Looks good to me too. Reviewed-by: Joel Fernandes (Google) Could we CC stable so that the fix is propagated to older kernels? thanks, - Joel > 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