From patchwork Wed Nov 23 08:51:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 13053320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 977A7C43219 for ; Wed, 23 Nov 2022 09:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238014AbiKWJhl (ORCPT ); Wed, 23 Nov 2022 04:37:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238047AbiKWJhM (ORCPT ); Wed, 23 Nov 2022 04:37:12 -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 2C58745091; Wed, 23 Nov 2022 01:34:43 -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 BE8E861B29; Wed, 23 Nov 2022 09:34:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B31FC433C1; Wed, 23 Nov 2022 09:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669196082; bh=UOCS9MkiyXy/QeITiO/Q5A/jXZCqlXLe2lkOogRGYdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V0Y0//Rdy5+WBWkVa3ddw/uS8Mxo2A9bTvfzmVsQuRd64R0YNMJmVB8zp3wW67u/m igJJEp/eXIDxzhp+GxSmnX8ZY7sNG0BRiZYX7TXEliCLYDDpbIhoSkmTldvuRvBKM6 5HogTTdyIn6T4PPuSM824By2Alst3687suFg+sq4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Linux Trace Kernel , Tzvetomir Stoyanov , Tom Zanussi , "Masami Hiramatsu (Google)" , Rafael Mendonca , "Steven Rostedt (Google)" Subject: [PATCH 5.15 114/181] tracing: Fix race where eprobes can be called before the event Date: Wed, 23 Nov 2022 09:51:17 +0100 Message-Id: <20221123084607.274462055@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123084602.707860461@linuxfoundation.org> References: <20221123084602.707860461@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org From: Steven Rostedt (Google) commit 94eedf3dded5fb472ce97bfaf3ac1c6c29c35d26 upstream. The flag that tells the event to call its triggers after reading the event is set for eprobes after the eprobe is enabled. This leads to a race where the eprobe may be triggered at the beginning of the event where the record information is NULL. The eprobe then dereferences the NULL record causing a NULL kernel pointer bug. Test for a NULL record to keep this from happening. Link: https://lore.kernel.org/linux-trace-kernel/20221116192552.1066630-1-rafaelmendsr@gmail.com/ Link: https://lore.kernel.org/linux-trace-kernel/20221117214249.2addbe10@gandalf.local.home Cc: Linux Trace Kernel Cc: Tzvetomir Stoyanov Cc: Tom Zanussi Cc: stable@vger.kernel.org Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events") Acked-by: Masami Hiramatsu (Google) Reported-by: Rafael Mendonca Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_eprobe.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -567,6 +567,9 @@ static void eprobe_trigger_func(struct e { struct eprobe_data *edata = data->private_data; + if (unlikely(!rec)) + return; + __eprobe_trace_func(edata, rec); }