[PATCH RFC v3 45/90] ptrace: keep everybody off an embryo

From: Josef Bacik

Date: Thu Nov 05 2026 - 10:32:23 EST


Between its creation and the end of its exec, an embryo is in an
intermediate state. It already has the credentials of the cell, and it
holds files that were placed from the outside. But it has not yet gone
through the exec that turns it into something the cell is meant to see.

Refuse all ptrace access to an embryo. That covers PTRACE_ATTACH and
PTRACE_SEIZE, and the files in /proc that are guarded by a ptrace access
check.

Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
kernel/ptrace.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 8024d80f82e3..c30e15d39c41 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -9,6 +9,7 @@
*/

#include <linux/capability.h>
+#include <linux/cell.h>
#include <linux/export.h>
#include <linux/sched.h>
#include <linux/sched/mm.h>
@@ -324,6 +325,9 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
/* Don't let security modules deny introspection */
if (same_thread_group(task, current))
return 0;
+ /* It is not yet what it will be. Nobody has any business with it. */
+ if (task_is_embryo(task))
+ return -EPERM;
rcu_read_lock();
if (mode & PTRACE_MODE_FSCREDS) {
caller_ids = CRED_IDS_FS;

--
2.55.0