Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2685272rwb; Thu, 17 Nov 2022 14:37:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xq67Psuma6AvFzhQ2vQ0LhxN1Qwsf7p7/VxDmZWi+81s74olye0n19ErIV+MahcrhejOl X-Received: by 2002:a17:902:f606:b0:188:f42e:6aa1 with SMTP id n6-20020a170902f60600b00188f42e6aa1mr3757602plg.26.1668724653469; Thu, 17 Nov 2022 14:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668724653; cv=none; d=google.com; s=arc-20160816; b=o03v/klgY+cKekTTcEiBuLBnWTomHPyVYo0CITNRmaaYC8/2X441l1XugL0pzWVb7t a5ght39bf7bEaqPGd6CdIWuBPQ/ck+4h6mTpN3D5/C+uerIDdA1RJAXdk6JODnGiZaaZ /xH5YUHB/dcPtF8/Zy1Z4Ql2Sb9otbcVTf2SLqLjrUGg50vuYcoPeXmu4AnO4EQseSHg A7FG0zQpa6Kmzyo7Kd/+OHLWlys69WNlYysaDL+S/RQf1iBhzHBzoig7WC2tUkJUOV58 iTC/eDLeRYuH0N+2wgSbZf1Ta3vph5+hTU7NH2VE0ajmScQnqsb0ahbtzGI+DNPvncH0 j5hQ== 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=7GkeBy1BGJWodZQ9voQcGZASwdm/vV7N1ZFgLT/UnIQ=; b=ZWOnjNQcyeVIPPcPhBRZ6NGIQ8GgiD6hkAxJqQho2Kl+FK3f03GF7dtEqDEraQ39oP Sq0MJWAukHHe2sI4bts6V6lkUv1tifQDY1Ygsvgr0sSWMFCIg2+CDzC1egV1FPeaU51b aAnLTo8zk68Ap6itTX0KPJfA92p5QOisuFHNyzpYNvBUtx6+cJFGnQkeifO+E+oPTLzl YRUNg9rfX+oDyTh6sYi3uNakwHHaDOM7/UTOnttWEWIkYz2iVyOBUnh39G562TQ6BDJu KmlpkubibuhU1YTZBtWJOO9LvGCREOoR2IqIc8Qygm4nMkM1zt2vZzaXt+9CGY8r/sHL zXnQ== 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 e14-20020a6558ce000000b0046f5ffcfc1dsi2299894pgu.324.2022.11.17.14.37.22; Thu, 17 Nov 2022 14:37:33 -0800 (PST) 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 S240558AbiKQWRt (ORCPT + 92 others); Thu, 17 Nov 2022 17:17:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240359AbiKQWRg (ORCPT ); Thu, 17 Nov 2022 17:17:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2763278D55 for ; Thu, 17 Nov 2022 14:17:35 -0800 (PST) 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 97D9BB821FA for ; Thu, 17 Nov 2022 22:17:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B98FBC433D6; Thu, 17 Nov 2022 22:17:31 +0000 (UTC) Date: Thu, 17 Nov 2022 17:17:30 -0500 From: Steven Rostedt To: Xiu Jianfeng Cc: , , Subject: Re: [PATCH] ftrace: Fix null pointer dereference in ftrace_add_mod() Message-ID: <20221117171730.023c8472@gandalf.local.home> In-Reply-To: <20221116015207.30858-1-xiujianfeng@huawei.com> References: <20221116015207.30858-1-xiujianfeng@huawei.com> 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 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 Wed, 16 Nov 2022 09:52:07 +0800 Xiu Jianfeng wrote: > The @ftrace_mod is allocated by kzalloc(), so both the members {prev,next} > of @ftrace_mode->list are NULL, it's not a valid state to call list_del(). > If kstrdup() for @ftrace_mod->{func|module} fails, it goes to @out_free > tag and calls free_ftrace_mod() to destroy @ftrace_mod, then list_del() > will write prev->next and next->prev, where null pointer dereference > happens. > > BUG: kernel NULL pointer dereference, address: 0000000000000008 > Oops: 0002 [#1] PREEMPT SMP NOPTI > Call Trace: > > ftrace_mod_callback+0x20d/0x220 > ? do_filp_open+0xd9/0x140 > ftrace_process_regex.isra.51+0xbf/0x130 > ftrace_regex_write.isra.52.part.53+0x6e/0x90 > vfs_write+0xee/0x3a0 > ? __audit_filter_op+0xb1/0x100 > ? auditd_test_task+0x38/0x50 > ksys_write+0xa5/0xe0 > do_syscall_64+0x3a/0x90 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > Kernel panic - not syncing: Fatal exception > > So call INIT_LIST_HEAD() to initialize the list member to fix this issue. > > Fixes: 673feb9d76ab ("ftrace: Add :mod: caching infrastructure to trace_array") > Signed-off-by: Xiu Jianfeng > --- Queued. Thanks Xiu! -- Steve