From patchwork Mon Sep 30 19:23:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13816884 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 ACFC919A281; Mon, 30 Sep 2024 19:26:34 +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=1727724396; cv=none; b=EiSds36MVR3/yuwBHzKXPqzRxypRjvuKWY7jkalurM0eeSB96+WBW9PqQHQHvSY88vviZCYe79hagJvzwvg1ylRIEO+2QfyUwFZb4LPYc6JI8D4+UbfPYGv6OhbeQWh3ILfPwCbvoS/j5JAfhjiB6jzsmC2Eb4Mn6eiZHhRwIWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727724396; c=relaxed/simple; bh=jzrIYZ+NCfJJx2hpaA2hpfIcWE+lBCRlUE3pqnCzPys=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oLK6nvZfhK1hWMF2Ykh06dxCu9BJaU5UsoPwSkHqWQxPmObJa67iBtb/LTqpMpXMDylnIEOMJ5wXwi5fH2NW+2efAVWV+khXXo8cl3oykFBNILIdVz1Kdk9zIyq1pDBehOVaHvwn8aEn67SPXtQNLtLtCW5TEszqql5SfrmZmJw= 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=LWz5TE/u; 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="LWz5TE/u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1727724392; bh=jzrIYZ+NCfJJx2hpaA2hpfIcWE+lBCRlUE3pqnCzPys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LWz5TE/uu1joLZFDkBoIS/ae2dUCXUzkKUPIX8yb4SwVsNnHJ2auB+5CLun7Ys3sl XV8MzJhRMar1LDpt8HCrnmZOnxCbzuayb8cE0JStneltc4I+3SQxb25g3dKEvi6nED uELjXD5DjrzLNYBi7BKkgQLa4bjMw/EdmTRW65IVvwHUTTMH2XapDIiUiemP9iVTiC EYPO1+8ERzz3ES1pcUoryYO1h7WlnDOryJM7iOIeJK4O+TSqgMtuxetxlSgZE5m8MZ MbTsPGTHvTs3ERDhC3dYsytqtkE6KQJ8waTQYoA4YnF5WrxleHJIR0wjoNSNTzh5Mb oJiAXgdN+4cIA== 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 4XHWK44Wv4zQgH; Mon, 30 Sep 2024 15:26:32 -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 resend 6/8] tracing/ftrace: Add might_fault check to syscall probes Date: Mon, 30 Sep 2024 15:23:55 -0400 Message-Id: <20240930192357.1154417-7-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240930192357.1154417-1-mathieu.desnoyers@efficios.com> References: <20240930192357.1154417-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 a3d8ac00793e..0430890cbb42 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)(); syscall_nr = trace_get_syscall_nr(current, regs); @@ -348,6 +349,7 @@ static void ftrace_syscall_exit(void *data, 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);