Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp946456pxk; Mon, 31 Aug 2020 05:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfeOXjbrgSCKpomIP+gdfqtAo8xJ0LGLgkOrAmovJWme2xzJH0wnsh0GBaojgRsbG1jPth X-Received: by 2002:a50:b2a5:: with SMTP id p34mr1139218edd.385.1598878685909; Mon, 31 Aug 2020 05:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598878685; cv=none; d=google.com; s=arc-20160816; b=MHOm4Fl7vwQ/yu+tFtyRxTlMPo6/z0LNmbCRRgWlxlHsY3Nd5OnBijd6rV4xPSciZW CFTR680Vd79wxilvFRdtLzXCObbFMgG7nfGVCNqFSKi9EjjzB9AEClXBrdHqD4LDgH6+ Pa9v4GAfyTENca4PdsImU6cl5thkW26UrAG358GYcAiuS9dtj3mNkTGpX5Me08afvWj7 RBjhinyOvl4JvSF9EEWIwe5FMaf771dv51F6Vc5BUM/uACwVsUNY793ubxLXH5zaRyLg 7jwAxUQyd+xc3utsu7q3ZAum1OD1TQ+Xh/YnxTbg1s3Bo2yxfMaJD6suBtajx5XnaboB kpYg== 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=0NNhnRDctUcPja/h83W1chLgCMD4xegOSEPnGkNzDPU=; b=DU/Z9Q7mJ85lMdvDUlqHKutOZccMak7a6E7tqqfw9zr0wjHqE5dRQG19RFQGQ7X9Ud +KVaLgQhFbaNFPYnJkKIFbUhqj/W+AevDhdiig6Ze7RKS2zytNjwXIrwHi8q+s7rvkIr Ffx/hrAksN+Mxo8pZP04k0nOE0hrRdzg4Y4L1nn9ddy3a/0tkcNJV88ZWap53is/C+nD 0Zd/kFoJ7ob0zHlEArVgpAhC3aWFb0s8vVl7x5T+jRYKahX01+E4btAMtUG19gwBmxl3 Dh830okuFB+A36h637OEdGCLbFnLD3beUiZ6p4ed6+Y/CrtkaC3OJFbmSKGtqKfTLEIR ZAxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df8si5067519edb.237.2020.08.31.05.57.42; Mon, 31 Aug 2020 05:58:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbgHaM5A (ORCPT + 99 others); Mon, 31 Aug 2020 08:57:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:55366 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgHaM47 (ORCPT ); Mon, 31 Aug 2020 08:56:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 07FDDADCD; Mon, 31 Aug 2020 12:56:58 +0000 (UTC) Date: Mon, 31 Aug 2020 14:56:57 +0200 (CEST) From: Miroslav Benes To: rostedt@goodmis.org, mingo@redhat.com cc: peterz@infradead.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, mhiramat@kernel.org Subject: Re: [PATCH] ftrace: Free the trampoline when ftrace_startup() fails In-Reply-To: <20200831122631.28057-1-mbenes@suse.cz> Message-ID: References: <20200831122631.28057-1-mbenes@suse.cz> 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 I used Masami's address which did not work. Sorry about that. Should be ok now. On Mon, 31 Aug 2020, Miroslav Benes wrote: > Commit fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines") > missed to remove ops from new ftrace_ops_trampoline_list in > ftrace_startup() if ftrace_hash_ipmodify_enable() fails there. It may > lead to BUG if such ops come from a module which may be removed. > > Moreover, the trampoline itself is not freed in this case. > > Fix it by calling ftrace_trampoline_free() during the rollback. > > Fixes: fc0ea795f53c ("ftrace: Add symbols for ftrace trampolines") > Signed-off-by: Miroslav Benes > --- > > It would be fair to add > > Fixes: f8b8be8a310a ("ftrace, kprobes: Support IPMODIFY flag to find IP modify conflict") > > too. The situation was a bit more complicated back then though since > RCU-tasks support was missing. > > kernel/trace/ftrace.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 275441254bb5..656d7cb5a78c 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -2862,6 +2862,8 @@ int ftrace_startup(struct ftrace_ops *ops, int command) > __unregister_ftrace_function(ops); > ftrace_start_up--; > ops->flags &= ~FTRACE_OPS_FL_ENABLED; > + if (ops->flags & FTRACE_OPS_FL_DYNAMIC) > + ftrace_trampoline_free(ops); > return ret; > } > > -- > 2.28.0 >