Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5514806rwb; Wed, 17 Aug 2022 20:11:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6R1H0NcT4rbPuJaVutfUgBAEbaM+AJw3JK7GRwpmhD/+u7YQsX2BFbqXuL3MUbywX3mH7U X-Received: by 2002:a65:494b:0:b0:428:d68c:35bf with SMTP id q11-20020a65494b000000b00428d68c35bfmr912431pgs.509.1660792309555; Wed, 17 Aug 2022 20:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660792309; cv=none; d=google.com; s=arc-20160816; b=sGhF3kW/sdsLHwL9imPu6BQ2ElDQlroZairVym3wKkgdk+K/j3aCodzjC+ioe9sre4 FkKgyEHG7Fk8oWLfnhWMa1fx6joQxL6+QYZj2XUE/uHDeqYouKGqaHUlUNkFe02jyQcX 82iNBPuh6EqVBYX4tf7TgX2Unly7OjweWROnyHx3lOvT6tsAcCCmi/o8kloCzvgUNi7h jNo9ajKKfJZaV3NpiOyEXE0t3XB7AVzVdNG4NCcoSmG2Wx+M5+H4AYstniaV2+paFqJ1 zhm0dwZEYa/eAVNJ34XZ54OauuFVKNEk7ku4L8ll4Rt2Z32ww3nbj2AUmsYqrnnNj7VJ rhbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=JL8RfK2ADkj7/B7uvRfkQU3Q/3z1GnDTSbGvGol6nfM=; b=ixanEfPSiNNbvli/mzr89FF0TVWXmPOHnncDg0WbBYSJq86KUoluN3FJMgg+ixt5J9 eMg07tFuh8s0YscJhoz7FwW+8uFDHVHTEhJFLhJTNACyDygMitpGDxPvT1bzruspKYNu MHAfHFalGWiHZdIvWgH1bKGVoTRPqsSh/+lGQpE4Y434LZiNUbCUWh8/skAiLqGzxHLa MuDhbjkLbgLrO/Bo+2KCQJyhyCRxbN6HAQUDYXoHwdM2OR08ucmkaBpg0VHr0gfOxt7F 9Hk1gjySZHv++qYb6EHZ8XYNW+RLdi2YQO2wZF/6yS7jvw/ro/6DkoY9scHvxRM4eDI/ E7Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a170902c94200b00172ae8bb61bsi353806pla.101.2022.08.17.20.11.38; Wed, 17 Aug 2022 20:11:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242563AbiHRCOT (ORCPT + 99 others); Wed, 17 Aug 2022 22:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234593AbiHRCOS (ORCPT ); Wed, 17 Aug 2022 22:14:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABBEC59245 for ; Wed, 17 Aug 2022 19:14:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4C1C2B82003 for ; Thu, 18 Aug 2022 02:14:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A76BFC433D7; Thu, 18 Aug 2022 02:14:12 +0000 (UTC) Date: Wed, 17 Aug 2022 22:14:22 -0400 From: Steven Rostedt To: Yang Jihong Cc: , Subject: Re: [PATCH] ftrace: Fix NULL pointer dereference in is_ftrace_trampoline when ftrace is dead Message-ID: <20220817221422.295db316@gandalf.local.home> In-Reply-To: References: <20220804021610.209791-1-yangjihong1@huawei.com> <20220817104115.0ec6b90b@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Aug 2022 09:50:40 +0800 Yang Jihong wrote: > Thanks for the detailed explanation. > If panic_on_warn is not set, FTRACE_WARN_ON{_ONCE} only sets > ftrace_disabled, but will not reboot. Correct. But whenever there's a WARN_ON() the administrator of the machine should think about rebooting it ASAP. That's because all WARN_ON()s are suppose to only happen when the system does something that was not expected, putting it into an inconsistent state. And could be a dangerous one. This is why all WARN_ON()s that are triggered are considered bugs and must be fixed. > I think this is to limit the problem to ftrace itself and not spread to > other subsystems(I don't know if that's right. If it's not right, please > correct it). Yes, the ftrace_disable means that ftrace just found itself in a situation that it does not understand, and nothing can be trusted. As ftrace modifies kernel code, it basically stops everything and WARNs about it. Because anything else it does can make things worse. > Because is_ftrace_trampoline is a common and public interface (This > interface is called in many places in the kernel). > If is_ftrace_trampoline interface is not restricted (for example, just > return true if ftrace_disabled is set), the preceding Syzkaller scenario > may be triggered when this interface is called. If ftrace_disabled is set, then any operations should fail, and any tests should fail with it. > > Therefore, my idea is to restrict the is_ftrace_trampoline or roll back > _unregister_ftrace_function when ftrace_disabled is set, so that the > interface can be invoked normally. Or keep the current code and do not > modify. Once ftrace_disabled is set, none of its interfaces should perform normally. But you reported that you could hit a NULL pointer from the is_ftrace_trampoline() which was caused by the failure adding the dynamic trampoline, and then the ops is on the list but later freed. My suggestion above is to just call _unregister_ftrace_function(ops) to take it off the list and prevent the NULL pointer. Doesn't that fix the bug? I don't want to totally roll it back and free the trampoline, because those actions could cause further damage, depending on the failed state ftrace is in. -- Steve