From patchwork Wed Jun 28 11:53:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13295627 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 31BF0EB64DC for ; Wed, 28 Jun 2023 11:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229747AbjF1Lxy (ORCPT ); Wed, 28 Jun 2023 07:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbjF1Lxo (ORCPT ); Wed, 28 Jun 2023 07:53:44 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCD32D58; Wed, 28 Jun 2023 04:53:43 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5577900c06bso4234312a12.2; Wed, 28 Jun 2023 04:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687953223; x=1690545223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wle0DCHQl+P6X6ELLOmsgvAcyzgK2/Inf7FHrehVpkk=; b=aYHg22W/nHRQs6gRBAdXQ8vNOcs4HhCU8F9lDxQhcVeg9uw0nQYWIcrI6KcQ3lCCN7 ucG+Kvoyb89Grr8sheVQ8HrTjXK5criTrpQ0KvVjorOXbuPOCFKQhRyyQ6HVv4QOx+kj 0CtvfVnLRXBiHUykkTEcuA6UArGyoxsxvhyxiwTDEe0GuJV2HTEAxhP5T1yx85Uwv1J+ FI9o+xq59KhgEvQYdJN0WHZJb2FVDBniQqTL+8WbhIl+qKLgQFmNNZmlxmKd7vX9K4LP +jPKOXFPgAOMrr7eiEa4/lyFElKjsPG0zOYwDYwI7RRSJ8fJklUEd24CAe5ZMzU4rEuZ GLJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687953223; x=1690545223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wle0DCHQl+P6X6ELLOmsgvAcyzgK2/Inf7FHrehVpkk=; b=O77feaM9t+oVSSuJUn2aQWLMRqxoEMVLbGSOagfj7MsVLjcP4pc4g1mG19M44QeKs0 2IQ5+otbR1hkjQDH1hKaA/y1UTOQiNEiUbUrfkHd/920B/R6Ba+n4cqKL7n/Xjup4E10 i2bBrY/9vnxq7zH4db3I89Ds2qpG4JREzIpaYVfwTn6BOopdr3HkCvM7YEMcuaL35P27 YWDlHqAQjMTHrgcWz+2w8IXGNIxVG28VffU8TFEQRzQ27/UTWEcBZOkYcfqHf4Vf/UsG r5ndwQ9z/B68SrCsMWxmtM4ZWGNKwpTqQR5W9yHt81sngckzhSvYWFYIJ3KKabSQmYgr AnqA== X-Gm-Message-State: AC+VfDw5sow5k9rfzhCL8snHNxKVNu68IbtsM0qE12wOLuYDGz22XGs/ NK7itfYNw3jTQ9DH4AccAsc= X-Google-Smtp-Source: ACHHUZ4+bJfT4J/NPrUMEFcEGeGkkWq7flOehtrRc+a4Lpg3WHd2u81WDR8/LYIQa5NL+L/oaOlpIw== X-Received: by 2002:a17:90a:a386:b0:261:875:c2be with SMTP id x6-20020a17090aa38600b002610875c2bemr18174261pjp.29.1687953223146; Wed, 28 Jun 2023 04:53:43 -0700 (PDT) Received: from vultr.guest ([2001:19f0:ac02:b79:5400:4ff:fe7d:3e26]) by smtp.gmail.com with ESMTPSA id n91-20020a17090a5ae400b002471deb13fcsm8000504pji.6.2023.06.28.04.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 04:53:42 -0700 (PDT) From: Yafang Shao To: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, quentin@isovalent.com, rostedt@goodmis.org, mhiramat@kernel.org Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH v6 bpf-next 05/11] bpf: Clear the probe_addr for uprobe Date: Wed, 28 Jun 2023 11:53:23 +0000 Message-Id: <20230628115329.248450-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230628115329.248450-1-laoar.shao@gmail.com> References: <20230628115329.248450-1-laoar.shao@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org To avoid returning uninitialized or random values when querying the file descriptor (fd) and accessing probe_addr, it is necessary to clear the variable prior to its use. Fixes: 41bdc4b40ed6 ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY") Signed-off-by: Yafang Shao Acked-by: Yonghong Song --- kernel/trace/bpf_trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 1f9f78e1992f..ac9958907a7c 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -2382,10 +2382,12 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id, event->attr.type == PERF_TYPE_TRACEPOINT); #endif #ifdef CONFIG_UPROBE_EVENTS - if (flags & TRACE_EVENT_FL_UPROBE) + if (flags & TRACE_EVENT_FL_UPROBE) { err = bpf_get_uprobe_info(event, fd_type, buf, probe_offset, event->attr.type == PERF_TYPE_TRACEPOINT); + *probe_addr = 0x0; + } #endif }