Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3556897rwi; Wed, 12 Oct 2022 03:56:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM489OxWdYkqCnKJ63Cmu+l4hxa3T01zseSbgbT6YlMrlZJdZsQMXrI3Pg8htbtXNTHKIehn X-Received: by 2002:a05:6a00:2446:b0:528:5da9:cc7 with SMTP id d6-20020a056a00244600b005285da90cc7mr30578021pfj.51.1665572164659; Wed, 12 Oct 2022 03:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665572164; cv=none; d=google.com; s=arc-20160816; b=gs8QA6YYCxjHyXxHAM8jDBG77JMpBJMwfRcW9ajeHLAqnI3YuBnN/5/AfwmtEyoc/O oeazR8btMnjQwU+ifpIY5A47KSSddiJlrpv3A9dsSoB2mcEdvVkA3pUlFN9ogPmsK2DH JI37wks6alEjXm8cd5ftrLhmiPkuLEYpeDRDLx4hHOh7tlV3s1BvKn9s7uAHvoDY91ul xd1vLg6dG3QQ52jRjLk+WB/2ZMv0mm77ya4yuuRPWtycmhgjN3UK24VqDJCHZAM5BtJb /L6rWoINeb4DJQ17IbNrQpCNtAmlkf0lXZDILiFKcmQvNb0L6mWiDsmLqUVEgzLwIfbu FMdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:user-agent:message-id; bh=m8JJW6pHN+8PkDYWqte//TlByVozIkSZkRNDyHcvydc=; b=0kONYmRprUc+1dk9de8RyycVYw9jWOn7sBjnHbGcxoiOrxvNulDVFJUtcfYECpa4cE zGY2mSZfxmoiLucdr9zqgnQBIWMDNGTldHSUPq1+A7Ew5uCEW55XEMCPcmxR9ZxbZB6v o4Pfb3XKS8gSGcKF0JrSLiYtQiglsNbMEwJbpCH2M3k3DHSJqukBFkB3scaF2JMzqTMe dqiDP947Vml0EFmghdYY2KpPVdTMucDcYhoefpCK0Js0l/qMSVmo7KPC23zZp2uhRrBl LhaOhjS6849d0NucdilxecrJUtmHuTblZDel6FNq5iJkP2DZBHcLOADWDGxns5/G1Q57 RwKw== 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 a71-20020a63904a000000b00461399560e5si12716309pge.524.2022.10.12.03.55.50; Wed, 12 Oct 2022 03:56:04 -0700 (PDT) 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 S229828AbiJLKp0 (ORCPT + 99 others); Wed, 12 Oct 2022 06:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbiJLKpW (ORCPT ); Wed, 12 Oct 2022 06:45:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BFAB4E609 for ; Wed, 12 Oct 2022 03:45:20 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D0682614A1 for ; Wed, 12 Oct 2022 10:45:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38164C43143; Wed, 12 Oct 2022 10:45:19 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1oiZF0-0047RC-1Q; Wed, 12 Oct 2022 06:45:34 -0400 Message-ID: <20221012104055.421393330@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 12 Oct 2022 06:40:55 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Tom Zanussi Subject: [PATCH v2 0/3] tracing: Fix synthetic event bug 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 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. Changes since v1: https://lore.kernel.org/all/20221011212501.773319898@goodmis.org/ - Handle "(fault)" printing when there's a fault Steven Rostedt (Google) (3): tracing: Move duplicate code of trace_kprobe/eprobe.c into header tracing: Add "(fault)" name injection to kernel probes tracing: Fix reading strings from synthetic events ---- kernel/trace/trace_eprobe.c | 60 ++------------------ kernel/trace/trace_events_synth.c | 23 ++++++-- kernel/trace/trace_kprobe.c | 60 ++------------------ kernel/trace/trace_probe_kernel.h | 115 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 116 deletions(-) create mode 100644 kernel/trace/trace_probe_kernel.h