From mboxrd@z Thu Jan 1 00:00:00 1970 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 8AE90C433FE for ; Tue, 11 Oct 2022 21:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbiJKV1R (ORCPT ); Tue, 11 Oct 2022 17:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229790AbiJKV05 (ORCPT ); Tue, 11 Oct 2022 17:26:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4C101F9F8 for ; Tue, 11 Oct 2022 14:26:49 -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 952E3B80749 for ; Tue, 11 Oct 2022 21:26:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5889DC433C1; Tue, 11 Oct 2022 21:26:47 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1oiMmE-003PwC-03; Tue, 11 Oct 2022 17:27:02 -0400 Message-ID: <20221011212501.773319898@goodmis.org> User-Agent: quilt/0.66 Date: Tue, 11 Oct 2022 17:25:01 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton Subject: [PATCH 0/2] tracing: Fix synthetic event bug Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The follow commands caused a crash: # cd /sys/kernel/tracing # echo 's:open char file[]' > dynamic_events # echo 'hist:keys=common_pid:file=filename:onchange($file).trace(open,$file)' > events/syscalls/sys_enter_openat/trigger' # echo 1 > events/synthetic/open/enable BOOM! The problem is that the synthetic event field "char file[]" will read the value given to it as a string without any memory checks to make sure the address is valid. The above example will pass in the user space address and the sythetic event code will happily call strlen() on it and then strscpy() where either one will cause an oops when accessing user space addresses. Steven Rostedt (Google) (2): tracing: Move duplicate code of trace_kprobe/eprobe.c into header tracing: Fix reading strings from synthetic events ---- kernel/trace/trace_eprobe.c | 60 ++---------------------- kernel/trace/trace_events_synth.c | 28 +++++++++--- kernel/trace/trace_kprobe.c | 60 ++---------------------- kernel/trace/trace_probe_kernel.h | 96 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 117 deletions(-) create mode 100644 kernel/trace/trace_probe_kernel.h