Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp930055pxk; Mon, 31 Aug 2020 05:28:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlLAqQHM3/gZZA6PuyWs+NHxzWm8BGLm4eqBKJn0AxixnkgoDfGLlczoEYyxRiZ95+gOAU X-Received: by 2002:a17:906:7204:: with SMTP id m4mr924490ejk.342.1598876925750; Mon, 31 Aug 2020 05:28:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598876925; cv=none; d=google.com; s=arc-20160816; b=0KHtJ6PlEK/9yVvyd/1B7/23xn9J0/rOTLsqg8WjjzVFsYq2FLlJ+aBIQ0lNkT06/b b00muPihD29MyQ5W7EhLaIIKXqivaDDWKnpjuKRrO4nlUd82wPL0IFYT1sZS47g1OXMp PfUHTg2V+H6r7TwaBB+yreFIJfz63NA+/BJ3Ezi0916I4S+OuVVgqMMEko1GHBHU0CG9 y7msKiaJ+nhiU/E62kkk1glgrITruRD/8GNTQfHN4/JjYkQT2KC0+Nq26ncwTsvAxKls j3wfgfv9Tv/OUmOn+ChCq+9X9wMmf0TDWa0gr1glrgudWx930edLrxGkq/2vQvP/hI6R iTRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EQ8nQ7cr792+rycHJMTYHZdtvi9AQq7S6GS4Y6opAhc=; b=ZKpA4CB1MTSwhntjgnrK5XsNv1ARBXE9nx8Hu/d7kTHbi7Dt1ksB1gDHNgdZNa6DZ6 ZWnM8eOaJse2IVqEFTBYZWFFo4ErzJbrYiAlBJ42It/9C/oiNfk3/5dwXCcKE4WqESwV JbxM9g/fp+O9FWnz9eL2p17i9V7zJUk7pznmi+APZL+0uzg8+SeibJGzos+oddrTfRJl ouVDk5HJWhhHao93W9LGvQgLA2DLzk+bIsv/++mUhTOOmR5NUpo8rK0ZuFQ0kYH7fD8x TXiEEUnG89Pdi9BB4Xy674KMgSoJOLnDQkfZ6Pg4huEMTWm0b6OL5QQaiAY0SHe440rj hyLQ== 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 j18si4861372ejb.50.2020.08.31.05.28.23; Mon, 31 Aug 2020 05:28:45 -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 S1727799AbgHaM0y (ORCPT + 99 others); Mon, 31 Aug 2020 08:26:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:35808 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbgHaM0e (ORCPT ); Mon, 31 Aug 2020 08:26:34 -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 67098B7DB; Mon, 31 Aug 2020 12:26:33 +0000 (UTC) From: Miroslav Benes To: rostedt@goodmis.org, mingo@redhat.com Cc: peterz@infradead.org, adrian.hunter@intel.com, masami.hiramatsu.pt@hitachi.com, linux-kernel@vger.kernel.org, Miroslav Benes Subject: [PATCH] ftrace: Free the trampoline when ftrace_startup() fails Date: Mon, 31 Aug 2020 14:26:31 +0200 Message-Id: <20200831122631.28057-1-mbenes@suse.cz> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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