Message ID | 20221120200734.707886372@goodmis.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1250518wrr; Sun, 20 Nov 2022 12:09:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf4qeQogg+LkymjKEGbIZVt3sZ42Ot04HP67Li04D3W3ZnBFlr197aIuz5lKrRgIUkM8A7Iy X-Received: by 2002:a17:902:6943:b0:188:ab16:2393 with SMTP id k3-20020a170902694300b00188ab162393mr8815418plt.87.1668974940429; Sun, 20 Nov 2022 12:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668974940; cv=none; d=google.com; s=arc-20160816; b=jsMP0rHQrrhdFo8mH7ChPVaRMXCwINfkRr5lmqM/0nfJQRApBakhjjkwo6eP6Y5y/O Y24fL5rnLgmDQzXaMdSuryCeViZokWEKSRxryETY3lRYU7mR8mXsaDSuk9vwcl3vzS9E anavp+UmsEV5MXuxIOeQIs9Z+Eq4Y5a09qy+GonwP25AVRfayRGW9Zv2p8i+ODVPiE5X KrWjcyo6dw1NYXiFDm4Uz+2sr10UdX9qxAqBAxwOeGt5yKXH83r825KhGcCAXBp+eEVO bDIkvvUgff6wd9YLoZMbGJ+kQaIZ4g4TM0R3Gp5Da+RYRZSO7Gh5HLsurAiYPbwGRXbX s0mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=Cf8ecPiixsn80T8GXthOSISQnHB4AeknvvFDiWB8xkQ=; b=y1aPqBaUh2phppw6fWoFdi1uKFMg1af0Qzkoor53yYuaW4e5BYIIKoep+d1no/mNty LILJuqjhKs+QEAf0h8zci3626tYDToq/BOZPOgumTMme/udd3BVPyZCrQkzptO8HnO1n D4Pv4DYguhpSp3CGND6DtKtwoW6PHKyOTDWfce+34pLbLZ9ZYIqmws7nP5AzskbK/32I FGXUVlpE1jU72Bq8jwyVEEftpuIUnHbTGL++wOwGzvOLFhSWYH3qMSl0dhdeTTsLcczG e5HEwl8h09jsriQsStXyHmVhIQPx9qoKRMjyS4cGVOyHktL+pLiHMJi6PFmvPRkKdEMF mkSw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw6-20020a17090b180600b0020d65f31df8si15795489pjb.143.2022.11.20.12.08.47; Sun, 20 Nov 2022 12:09:00 -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 S229834AbiKTUHs (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Sun, 20 Nov 2022 15:07:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiKTUHi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 20 Nov 2022 15:07:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 135391AF27; Sun, 20 Nov 2022 12:07:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1B99A60D30; Sun, 20 Nov 2022 20:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E99B3C43147; Sun, 20 Nov 2022 20:07:35 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from <rostedt@goodmis.org>) id 1owqbG-00Di7E-2n; Sun, 20 Nov 2022 15:07:34 -0500 Message-ID: <20221120200734.707886372@goodmis.org> User-Agent: quilt/0.66 Date: Sun, 20 Nov 2022 15:07:08 -0500 From: Steven Rostedt <rostedt@goodmis.org> To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, stable@vger.kernel.org, Xiu Jianfeng <xiujianfeng@huawei.com> Subject: [for-linus][PATCH 08/13] ftrace: Fix null pointer dereference in ftrace_add_mod() References: <20221120200700.725968899@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750047067246567160?= X-GMAIL-MSGID: =?utf-8?q?1750047067246567160?= |
Series |
tracing: Fixes for 6.1
|
|
Commit Message
Steven Rostedt
Nov. 20, 2022, 8:07 p.m. UTC
From: Xiu Jianfeng <xiujianfeng@huawei.com> 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: <TASK> 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. Link: https://lkml.kernel.org/r/20221116015207.30858-1-xiujianfeng@huawei.com Cc: stable@vger.kernel.org Fixes: 673feb9d76ab ("ftrace: Add :mod: caching infrastructure to trace_array") Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- kernel/trace/ftrace.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 56a168121bfc..33236241f236 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1289,6 +1289,7 @@ static int ftrace_add_mod(struct trace_array *tr, if (!ftrace_mod) return -ENOMEM; + INIT_LIST_HEAD(&ftrace_mod->list); ftrace_mod->func = kstrdup(func, GFP_KERNEL); ftrace_mod->module = kstrdup(module, GFP_KERNEL); ftrace_mod->enable = enable;