From nobody Thu Nov 28 05:46:53 2024 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 A5C491AA79C; Fri, 4 Oct 2024 15:00:26 +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=1728054029; cv=none; b=jhYDcfDzlfObyYwS3ZwRtXDjGGXjaW/XXg2i8FK35UgkndQuHudojdCSN2FIHO703UNA9M0ruGmiYJM243o6GRZ9QMok6RwjRALtxO87lOYIF+CAEHohFoCTzA24O/cxe6CIq16MB1KApYNwheGYLyP5ouY5K3JYKB4v8cTkosQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728054029; c=relaxed/simple; bh=wrJsydNsm7Eamjbe4sHKDboMTBocYGkFlr+a7R1zlbg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GkXovgbRRSZDEWxQHPP5bH/tVMO2iKExrDA+VQNpvZMr5rSI/sHob6U5xeXZLnNTbUDjKdR5QhQj9G4o3PTtIgbLAjkzq8QROkNHCl3j+nyYdlVrmiDoWk+ZKTwSx84QlQFP1wzjcdfkr+K+lAAzFsE3e24idts7oYlmBH97yMA= 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=P4i7owRH; 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="P4i7owRH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728054025; bh=wrJsydNsm7Eamjbe4sHKDboMTBocYGkFlr+a7R1zlbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4i7owRHyt1+SUttACTchjkI1Y1Ug3/uhVudMn8frH+LaQCPu+/Jp3k74SUF1Frhr 54Aid4hWhmuXnG0pzjKHAkYpBIZMCFcIyCaFdbACrRAraws8KtskHjD43/v3hFRblt mLKQC8E64nOnV7BPgu+G85qXmkAMrOKgUYf5J44+GG5Ku2YaotjqQ/SsYSuMc3Mvri yeH3SgLuiequu6HqKEm9vGHuMSwwqc1dDt2VeXEBQo/LgLa36KwLPSMxCfVG8GeM5Z B9pnnyJ6cxj+kiTaOEygNa0ncOv1dcX76PzeZJ9I5yyGjrih4VGhZY5zisw3IlcU79 XRlP9P4CYl4DQ== Received: from thinkos.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4XKsD924sdzLRx; Fri, 4 Oct 2024 11:00:25 -0400 (EDT) From: Mathieu Desnoyers To: Steven Rostedt , Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , 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 Subject: [PATCH v3 6/8] tracing/ftrace: Add might_fault check to syscall probes Date: Fri, 4 Oct 2024 10:58:16 -0400 Message-Id: <20241004145818.1726671-7-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241004145818.1726671-1-mathieu.desnoyers@efficios.com> References: <20241004145818.1726671-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a might_fault() check to validate that the ftrace sys_enter/sys_exit probe callbacks are indeed called from a context where page faults can be handled. Signed-off-by: Mathieu Desnoyers Acked-by: Masami Hiramatsu (Google) 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/trace_events.h | 1 + kernel/trace/trace_syscalls.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h index 0228d9ed94a3..e0d4850b0d77 100644 --- a/include/trace/trace_events.h +++ b/include/trace/trace_events.h @@ -446,6 +446,7 @@ __DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args)= , PARAMS(tstruct), \ static notrace void \ trace_event_raw_event_##call(void *__data, proto) \ { \ + might_fault(); \ guard(preempt_notrace)(); \ do_trace_event_raw_event_##call(__data, args); \ } diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index b1cc19806f3d..6d6bbd56ed92 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -303,6 +303,7 @@ static void ftrace_syscall_enter(void *data, 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)(); =20 syscall_nr =3D trace_get_syscall_nr(current, regs); @@ -348,6 +349,7 @@ static void ftrace_syscall_exit(void *data, struct pt_r= egs *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)(); =20 syscall_nr =3D trace_get_syscall_nr(current, regs); --=20 2.39.2