Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5638337ybp; Tue, 8 Oct 2019 06:12:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqsmENjrzi5LLEdiwOc/FI59F92qjak1dRP78RlglTN+vsEt6xiZb3l+nyW2Bi335Cz/MU X-Received: by 2002:a17:906:1c5b:: with SMTP id l27mr29231141ejg.27.1570540335129; Tue, 08 Oct 2019 06:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570540335; cv=none; d=google.com; s=arc-20160816; b=FR7gm1GLlMOQoQcLfWzQmM4BacbgSsHiWzZNEiwHhZLrG+n/rJ8qLQJjcX+QvvbDyh UMt1aNyyti/ZV9sy2/cGRLad71zifj5B6eYevhtQHTnjA3M6UF2nnJFouSIeZltRZRqh e40q5FBRhvK3T8z7g0B52bm+sTy9KpPPN02E3yb/Idzd8GsE3gIv/mDzhLnQONKTiVj2 Ht0ESvSB0wtI/9NFBQC0yDK2v5bMvew73bS2686KeDCsUOvpylrntLgMBKIfQdNdhzmf 6//86HnT/doC4LLlzQdU6qpk9NuWFf9/jy1U+zra7QfJwCP+pd0fOeflP6fuqa5pJRoL 86HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=N35dzJqxrtZoGrnSIzazHZl27/UxomK80fTuoFr4enE=; b=IslNJnFNp2se+hhoMX37X7Ib7dq9bvhXDDs8lElZ4ha2NW2Nki35e8v7KOTy3O3I43 MN8dwPVJ4cVE2iIW6DYyvfOBetUUfgJ2TQQjVV8S26yCYMLW/m3XiUVEKJVsshYd+Yjh /bO4a2FozpSOoZ/xFqL9tnAFT7WDRkA0ct0Xqvb20LsmFR22sa0Xhb81fpwbSPo5lacv 1Bf7ScGw3UcpiHsGa1PZkTxaUuegzsvQO93Ipxf49zfoKj3P5WSn4pnm2okhJwwvYUBL cjiKLvEpHZGykCig/rbkyIFpkaxgngVf/4FHwLYrfUsHkqEo8fmDwImbHm11917exsJD lZyw== 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 b33si11104991edc.265.2019.10.08.06.11.45; Tue, 08 Oct 2019 06:12:15 -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 S1730583AbfJHNJ0 (ORCPT + 99 others); Tue, 8 Oct 2019 09:09:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:52902 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730301AbfJHNJ0 (ORCPT ); Tue, 8 Oct 2019 09:09:26 -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 AEE02B052; Tue, 8 Oct 2019 13:09:24 +0000 (UTC) Date: Tue, 8 Oct 2019 15:08:57 +0200 (CEST) From: Miroslav Benes To: Peter Zijlstra cc: x86@kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, bristot@redhat.com, jbaron@akamai.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, namit@vmware.com, hpa@zytor.com, luto@kernel.org, ard.biesheuvel@linaro.org, Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Song Liu , Jessica Yu , Martin KaFai Lau Subject: Re: [PATCH v2 3/4] module: Properly propagate MODULE_STATE_COMING failure In-Reply-To: <20191007082700.14428791.6@infradead.org> Message-ID: References: <20191007082541.64146933.7@infradead.org> <20191007082700.14428791.6@infradead.org> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Oct 2019, Peter Zijlstra wrote: > Now that notifiers got unbroken; use the proper interface to handle > notifier errors and propagate them. > > There were already MODULE_STATE_COMING notifiers that failed; notably: > > - jump_label_module_notifier() > - tracepoint_module_notify() > - bpf_event_notify() > > By propagating this error, we fix those users. > > Signed-off-by: Peter Zijlstra (Intel) > Cc: Yonghong Song > Cc: Alexei Starovoitov > Cc: Daniel Borkmann > Cc: Song Liu > Cc: Jessica Yu > Cc: Martin KaFai Lau > --- > kernel/module.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3751,9 +3751,13 @@ static int prepare_coming_module(struct > if (err) > return err; > > - blocking_notifier_call_chain(&module_notify_list, > - MODULE_STATE_COMING, mod); > - return 0; > + err = blocking_notifier_call_chain_robust(&module_notify_list, > + MODULE_STATE_COMING, MODULE_STATE_GOING, mod); > + err = notifier_to_errno(err); > + if (err) > + klp_module_going(mod); > + > + return err; > } It looks almost ok. At least klp_ error handling is correct now. I see only one possible problem. If there is an error in a MODULE_STATE_COMING notifier, all MODULE_STATE_GOING notifiers will be called with mod->state set to MODULE_STATE_COMING. Not nice. I don't think it is actually a problem, because all notifiers, that I checked, only use the correct value (MODULE_STATE_COMING or MODULE_STATE_GOING, coming from the function parameter) and not mod->state. Better to doublecheck though. However, mod->state is not set to MODULE_STATE_GOING anywhere under bug_cleanup label in load_module(). That is a bug and it is there regardless of this patch. Jessica? Regards Miroslav