From patchwork Tue Jul 11 14:15:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 118569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp525189vqm; Tue, 11 Jul 2023 07:35:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFYW5uwe4mR7o7t9TIfmF9q+WLUoXBwBdCMy9ae9ky4fYxpIsnITv/jv297kjR5M5+Ovh/h X-Received: by 2002:a17:906:74d8:b0:988:57b4:2853 with SMTP id z24-20020a17090674d800b0098857b42853mr18227968ejl.25.1689086101755; Tue, 11 Jul 2023 07:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689086101; cv=none; d=google.com; s=arc-20160816; b=Z1xX+f/JQSNb0tumCg+Gga712KgG/ItzHQhkcfVIP7fjnxyacRHDzPjPcN7tau/bby PrkUiYqGoCE590f/ZgShDKxFZUper/4ccS/k+YX4ZFGfhk2UyhvrnVzPK/c/xkzSfyip Nbwvi7o5kpp+kwYkcmrq5xry14iOG0uw1Y/TSRwFhzc5Q0uLGGQNLvwKnzUfP1R4lwPt Xeu1QRS+xIlLm84hhrUa3cpwwvdtBAlHw6pN2BeuwUdyIYg9/YKdnhbNwJx9pcRaPIdB bzP7BBgH3MGPcgQ8MpWXsHq9DIXncdXMwynxVX0Hvo0s0+Mw+2ofsxZCZxc4odqAZCAC 7dZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VFoKItDzYCaOWn4fgODDX8b+SEBOBqzdSJDV3zBHSYA=; fh=hf24JvveL55vCfzfv0agRHDWsuhzZqIeZ7dfs5kcUjQ=; b=U/XYCnXu03mR7YwTTqi0m3Ce+ZTDHkYeG4Lb2muvkpL+EJkReJxXS+D6esgSR4r8l1 Xq39nCGpW4IxVNoUpm2y4LdwZLmjTrE1YkLx4Ak4TmCgaep1FL+O+mQV1p+uWiSPzAR5 oRiYzySoM7sxbf0hU8+k6JSf0ZhXCXwcdCcWX8Ul1m4puhi29YL8L/BTTcl3d35677HB fq4XMiFAt2JzsXzCam004/0Q0g8U7OD1R6v8jkdtBIlVWRfvXaJryvw6fIc9R+i5jC73 Lr4zjbfWf8/ScMFgZt9Wr6vxuHiv/zRGc1Nm6AlUa+h9QKde0OgGRT5NRN4tv69Cvlq7 WtZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYHmYYZt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a1709062e8f00b009787b15aa51si2105630eji.713.2023.07.11.07.34.38; Tue, 11 Jul 2023 07:35:01 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYHmYYZt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232101AbjGKOQN (ORCPT + 99 others); Tue, 11 Jul 2023 10:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233484AbjGKOQG (ORCPT ); Tue, 11 Jul 2023 10:16:06 -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 B50FF1708; Tue, 11 Jul 2023 07:16:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1487F614E2; Tue, 11 Jul 2023 14:16:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FB75C433C9; Tue, 11 Jul 2023 14:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689084961; bh=LOMI4wDzsq/hXAQmAMNQ62g25jda2U1iBQmNIJ7a+L8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XYHmYYZtT9DWZF9d0bff3fSO3KXst8iYe5u/AyxO+3aKqfGuNsE4/ihcXTYjwXxPx 3aa9a3hL1//H/yyyNqTEMBy3YTZPMJ2KwuSjX9I6Fk/7HrNXpE+icCGRokFsH+BPY1 +PAN87G7p16i7VECnrs71be8M2bMGTffjNocZwQyD1J/ssIt4YIoGCMHB67U2Q05QA w1sLS0LOxXwA0n3wOCApwFca6rXUruLfxD/EUISDEVzDA43qxKjqOS19nmvZ5Gml9l ft2ZZ7MKL8ilVno+SARlP+TwK+WYrB+DncCyjTHy46S0i7wOhaz9fC/AAFumEtZb1t aDz+ax7OfMICg== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Dan Carpenter , linux-trace-kernel@vger.kernel.org, LKML , Masami Hiramatsu Subject: [PATCH v5 4/5] Revert "tracing: Add "(fault)" name injection to kernel probes" Date: Tue, 11 Jul 2023 23:15:57 +0900 Message-Id: <168908495772.123124.1250788051922100079.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <168908491977.123124.16583481716284477889.stgit@devnote2> References: <168908491977.123124.16583481716284477889.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771135148078608564 X-GMAIL-MSGID: 1771135148078608564 From: Masami Hiramatsu (Google) This reverts commit 2e9906f84fc7c99388bb7123ade167250d50f1c0. It was turned out that commit 2e9906f84fc7 ("tracing: Add "(fault)" name injection to kernel probes") did not work correctly and probe events still show just '(fault)' (instead of '"(fault)"'). Also, current '(fault)' is more explicit that it faulted. This also moves FAULT_STRING macro to trace.h so that synthetic event can keep using it, and uses it in trace_probe.c too. Link: https://lore.kernel.org/all/20230706230642.3793a593@rorschach.local.home/ Cc: stable@vger.kernel.org Cc: Andrew Morton Cc: Tom Zanussi Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) --- kernel/trace/trace.h | 2 ++ kernel/trace/trace_probe.c | 2 +- kernel/trace/trace_probe_kernel.h | 31 ++++++------------------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 79bdefe9261b..eee1f3ca4749 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -113,6 +113,8 @@ enum trace_type { #define MEM_FAIL(condition, fmt, ...) \ DO_ONCE_LITE_IF(condition, pr_err, "ERROR: " fmt, ##__VA_ARGS__) +#define FAULT_STRING "(fault)" + #define HIST_STACKTRACE_DEPTH 16 #define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long)) #define HIST_STACKTRACE_SKIP 5 diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 2d2616678295..591399ddcee5 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -65,7 +65,7 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent) int len = *(u32 *)data >> 16; if (!len) - trace_seq_puts(s, "(fault)"); + trace_seq_puts(s, FAULT_STRING); else trace_seq_printf(s, "\"%s\"", (const char *)get_loc_data(data, ent)); diff --git a/kernel/trace/trace_probe_kernel.h b/kernel/trace/trace_probe_kernel.h index c4e1d4c03a85..6deae2ce34f8 100644 --- a/kernel/trace/trace_probe_kernel.h +++ b/kernel/trace/trace_probe_kernel.h @@ -2,8 +2,6 @@ #ifndef __TRACE_PROBE_KERNEL_H_ #define __TRACE_PROBE_KERNEL_H_ -#define FAULT_STRING "(fault)" - /* * This depends on trace_probe.h, but can not include it due to * the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c. @@ -15,16 +13,8 @@ static nokprobe_inline int fetch_store_strlen_user(unsigned long addr) { const void __user *uaddr = (__force const void __user *)addr; - int ret; - ret = strnlen_user_nofault(uaddr, MAX_STRING_SIZE); - /* - * strnlen_user_nofault returns zero on fault, insert the - * FAULT_STRING when that occurs. - */ - if (ret <= 0) - return strlen(FAULT_STRING) + 1; - return ret; + return strnlen_user_nofault(uaddr, MAX_STRING_SIZE); } /* Return the length of string -- including null terminal byte */ @@ -44,18 +34,7 @@ fetch_store_strlen(unsigned long addr) len++; } while (c && ret == 0 && len < MAX_STRING_SIZE); - /* For faults, return enough to hold the FAULT_STRING */ - return (ret < 0) ? strlen(FAULT_STRING) + 1 : len; -} - -static nokprobe_inline void set_data_loc(int ret, void *dest, void *__dest, void *base, int len) -{ - if (ret >= 0) { - *(u32 *)dest = make_data_loc(ret, __dest - base); - } else { - strscpy(__dest, FAULT_STRING, len); - ret = strlen(__dest) + 1; - } + return (ret < 0) ? ret : len; } /* @@ -76,7 +55,8 @@ fetch_store_string_user(unsigned long addr, void *dest, void *base) __dest = get_loc_data(dest, base); ret = strncpy_from_user_nofault(__dest, uaddr, maxlen); - set_data_loc(ret, dest, __dest, base, maxlen); + if (ret >= 0) + *(u32 *)dest = make_data_loc(ret, __dest - base); return ret; } @@ -107,7 +87,8 @@ fetch_store_string(unsigned long addr, void *dest, void *base) * probing. */ ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); - set_data_loc(ret, dest, __dest, base, maxlen); + if (ret >= 0) + *(u32 *)dest = make_data_loc(ret, __dest - base); return ret; }