From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (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 1A424819; Fri, 4 Oct 2024 00:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728000855; cv=none; b=A8vEgL32p73Iq8tkdJiAy/OapUA9ZXEkP1AztSO5N2pbu2iXK/3/NxQu8MR1bOXhpNCepy5Wf+nDMheSvBrB51SIEtK0Yn2RkCKRXslhRdDl64EG4Izhgj/h27kCwm18ZtCFFAGOrDwMCjoD2jozGLGrw1ZptPerZ/zwb8DYQoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728000855; c=relaxed/simple; bh=UXhaRbYOaMta91c7QQfV1y9wIFiLHZ+klZnMfVmCt4c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nxLTc7DzaIMWAnq8zAYm4cbMbyAK+bt5CCSbvOJcOdu/rdLVi86l49hNHOaaTkaPoXxfzMHTXExI6mamSjjJFvlHr+VljFQQZZVU+Nj2OGlyG6in28KI3uXu09/aaeNtd6PLWypMVSz9oLIWU5ZAHH8O7WBkSXYtbRFBuoSQs5o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=eBqIM/6o; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="eBqIM/6o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728000853; bh=UXhaRbYOaMta91c7QQfV1y9wIFiLHZ+klZnMfVmCt4c=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eBqIM/6o3YuPyT4zu2URGxz34NtiiqQuv2FpiKJRTxvYwm0Ocl7zzdFMEsTf4F8ZV VN+PYCTto8bshdhu/7eG7e/8xd1Or88jm7rmpCnzGpKmHg/p8BDXn+Oj6M7imFtdN6 KdkK+sWa6+YDjfRVvHxkBCxPHRz67C408dhGd4SW+lj02Rct3ScpYhmMGvGsGp2EcT t7oVUuVjQm73u0OSi4LbStToUaozr8/e7WC85JQVYT3c/RIUl5Wcsh3xb4b6zddH8e KJgwdtQ4MmxSfy62SURgkR6E3B5dK5w2MHHSjuweuZh5KZgirWmxUENyJq5+zCVPH/ enwIedRJh3aUQ== Received: from [192.168.18.201] (unknown [198.16.233.254]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4XKTYc6nmCzBPT; Thu, 3 Oct 2024 20:14:12 -0400 (EDT) Message-ID: Date: Thu, 3 Oct 2024 20:12:12 -0400 Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 7/8] tracing/perf: Add might_fault check to syscall probes To: Steven Rostedt Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, Peter Zijlstra , Alexei Starovoitov , Yonghong Song , "Paul E . McKenney" , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , Andrii Nakryiko , bpf@vger.kernel.org, Joel Fernandes , linux-trace-kernel@vger.kernel.org, Michael Jeanson References: <20241003151638.1608537-1-mathieu.desnoyers@efficios.com> <20241003151638.1608537-8-mathieu.desnoyers@efficios.com> <20241003183738.4ebd97f9@gandalf.local.home> Content-Language: en-US From: Mathieu Desnoyers In-Reply-To: <20241003183738.4ebd97f9@gandalf.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-10-04 00:37, Steven Rostedt wrote: > On Thu, 3 Oct 2024 11:16:37 -0400 > Mathieu Desnoyers wrote: > >> Add a might_fault() check to validate that the perf sys_enter/sys_exit >> probe callbacks are indeed called from a context where page faults can >> be handled. >> >> Signed-off-by: Mathieu Desnoyers >> Cc: Michael Jeanson >> Cc: Steven Rostedt >> Cc: Masami Hiramatsu >> Cc: Peter Zijlstra >> Cc: Alexei Starovoitov >> Cc: Yonghong Song >> Cc: Paul E. McKenney >> Cc: Ingo Molnar >> Cc: Arnaldo Carvalho de Melo >> Cc: Mark Rutland >> Cc: Alexander Shishkin >> Cc: Namhyung Kim >> Cc: Andrii Nakryiko >> Cc: bpf@vger.kernel.org >> Cc: Joel Fernandes >> --- >> include/trace/perf.h | 1 + >> kernel/trace/trace_syscalls.c | 2 ++ >> 2 files changed, 3 insertions(+) >> >> diff --git a/include/trace/perf.h b/include/trace/perf.h >> index 5650c1bad088..321bfd7919f6 100644 >> --- a/include/trace/perf.h >> +++ b/include/trace/perf.h >> @@ -84,6 +84,7 @@ perf_trace_##call(void *__data, proto) \ >> u64 __count __attribute__((unused)); \ >> struct task_struct *__task __attribute__((unused)); \ >> \ >> + might_fault(); \ >> guard(preempt_notrace)(); \ >> do_perf_trace_##call(__data, args); \ > > Same for this. This is used for all tracepoints that perf hooks to. You're also missing the context: #undef DECLARE_EVENT_SYSCALL_CLASS #define DECLARE_EVENT_SYSCALL_CLASS(call, proto, args, tstruct, assign, print) \ __DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), PARAMS(tstruct), \ PARAMS(assign), PARAMS(print)) \ static notrace void \ perf_trace_##call(void *__data, proto) \ { \ u64 __count __attribute__((unused)); \ struct task_struct *__task __attribute__((unused)); \ \ might_fault(); \ guard(preempt_notrace)(); \ do_perf_trace_##call(__data, args); \ } Not an issue. Thanks, Mathieu > > -- Steve > >> } >> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c >> index 89d7e4c57b5b..0d42d6f293d6 100644 >> --- a/kernel/trace/trace_syscalls.c >> +++ b/kernel/trace/trace_syscalls.c >> @@ -602,6 +602,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id) >> * Syscall probe called with preemption enabled, but the ring >> * buffer and per-cpu data require preemption to be disabled. >> */ >> + might_fault(); >> guard(preempt_notrace)(); >> >> syscall_nr = trace_get_syscall_nr(current, regs); >> @@ -710,6 +711,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret) >> * Syscall probe called with preemption enabled, but the ring >> * buffer and per-cpu data require preemption to be disabled. >> */ >> + might_fault(); >> guard(preempt_notrace)(); >> >> syscall_nr = trace_get_syscall_nr(current, regs); > -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com