From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1A1B6FBB for ; Tue, 10 Jan 2023 18:27:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C193C433D2; Tue, 10 Jan 2023 18:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673375256; bh=jC7XFeqzHvj2cx56qPreKMGI+gItXLjN5SIWhtwX+Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wZFYT4gyfKFinY+SjyzI/Uy9LB8xETx3w3dXZ0hXtEDrsOfT4YGDSAfWBY+QKf15q TT/YiGSAePDLscDmc2fVQMemXGxPtf5AVeqW5xx7puiLrN062tytsSfKuH8JVoh6LF NsSU0Mfg6t8KUsPGQQw3tMRQIweLFfF9/0uEJe0Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rafael Mendonca , "Steven Rostedt (Google)" , "Masami Hiramatsu (Google)" Subject: [PATCH 5.15 100/290] tracing: Fix race where eprobes can be called before the event Date: Tue, 10 Jan 2023 19:03:12 +0100 Message-Id: <20230110180035.080501945@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110180031.620810905@linuxfoundation.org> References: <20230110180031.620810905@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Steven Rostedt (Google) commit d5f30a7da8ea8e6450250275cec5670cee3c4264 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/all/20221117214249.2addbe10@gandalf.local.home/ Cc: stable@vger.kernel.org Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events") Reported-by: Rafael Mendonca Signed-off-by: Steven Rostedt (Google) Acked-by: Masami Hiramatsu (Google) Signed-off-by: Masami Hiramatsu (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 @@ -570,6 +570,9 @@ static void eprobe_trigger_func(struct e if (unlikely(!rec)) return; + if (unlikely(!rec)) + return; + __eprobe_trace_func(edata, rec); }