FAILED: patch "[PATCH] proc: protect ptrace_may_access() with exec_update_lock (part" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 6650527444dadc63d84aa939d14ecba4fadb2f69
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071445-ridden-persuader-5fac@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6650527444dadc63d84aa939d14ecba4fadb2f69 Mon Sep 17 00:00:00 2001
From: Jann Horn <[email protected]>
Date: Mon, 18 May 2026 18:35:15 +0200
Subject: [PATCH] proc: protect ptrace_may_access() with exec_update_lock (part
1)
Fix the easy cases where procfs currently calls ptrace_may_access() without exec_update_lock protection, where the fix is to simply add the extra lock or use mm_access():
- do_task_stat(): grab exec_update_lock
- proc_pid_wchan(): grab exec_update_lock
- proc_map_files_lookup(): use mm_access() instead of get_task_mm()
- proc_map_files_readdir(): use mm_access() instead of get_task_mm()
- proc_ns_get_link(): grab exec_update_lock
- proc_ns_readlink(): grab exec_update_lock
fs/proc/array.c +6 -0
@@ -482,6 +482,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,unsigned long flags;int exit_code = task->exit_code;struct signal_struct *sig = task->signal; +int ret; + + ret =down_read_killable (&task->signal->exec_update_lock); +if (ret) +return ret; state = *get_task_state (task); vsize = eip = esp =0 ;
@@ -657,6 +662,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,seq_puts (m," 0" );seq_putc (m,'\n' ); +up_read (&task->signal->exec_update_lock);if (mm)mmput (mm);return 0 ;
fs/proc/base.c +23 -20
103 lines not on this page · raw message
fs/proc/namespaces.c +12 -0
@@ -55,6 +55,10 @@ static const char *proc_ns_get_link(struct dentry *dentry,if (!task)return ERR_PTR (-EACCES ); + error =down_read_killable (&task->signal->exec_update_lock); +if (error) + goto out_put_task; +if (!ptrace_may_access (task,PTRACE_MODE_READ_FSCREDS )) goto out;
@@ -64,6 +68,8 @@ static const char *proc_ns_get_link(struct dentry *dentry, error =nd_jump_link (&ns_path); out: +up_read (&task->signal->exec_update_lock); +out_put_task:put_task_struct (task);return ERR_PTR (error); }
@@ -80,11 +86,17 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int buflif (!task)return res; + res =down_read_killable (&task->signal->exec_update_lock); +if (res) + goto out_put_task; +if (ptrace_may_access (task,PTRACE_MODE_READ_FSCREDS )) { res =ns_get_name (name,sizeof (name), task, ns_ops);if (res >=0 ) res =readlink_copy (buffer, buflen, name,strlen (name)); } +up_read (&task->signal->exec_update_lock); +out_put_task:put_task_struct (task);return res; }
Sasha Levin
maintainerPATCH 1/1 proc: protect ptrace_may_access() with exec_update_lock (part 1)
From: Jann Horn <[email protected]>
[ Upstream commit 6650527444dadc63d84aa939d14ecba4fadb2f69 ]
Fix the easy cases where procfs currently calls ptrace_may_access() without exec_update_lock protection, where the fix is to simply add the extra lock or use mm_access():
- do_task_stat(): grab exec_update_lock
- proc_pid_wchan(): grab exec_update_lock
- proc_map_files_lookup(): use mm_access() instead of get_task_mm()
- proc_map_files_readdir(): use mm_access() instead of get_task_mm()
- proc_ns_get_link(): grab exec_update_lock
- proc_ns_readlink(): grab exec_update_lock
--- fs/proc/array.c | 6 ++++++ fs/proc/base.c | 41 ++++++++++++++++++++++++----------------- fs/proc/namespaces.c | 12 ++++++++++++ 3 files changed, 42 insertions(+), 17 deletions(-)
fs/proc/array.c +6 -0
@@ -468,6 +468,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,unsigned long flags;struct signal_struct *sig = task->signal;unsigned int seq =1 ; +int ret; + + ret =down_read_killable (&task->signal->exec_update_lock); +if (ret) +return ret; state = *get_task_state (task); vsize = eip = esp =0 ;
@@ -642,6 +647,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,seq_puts (m," 0" );seq_putc (m,'\n' ); +up_read (&task->signal->exec_update_lock);if (mm)mmput (mm);return 0 ;
fs/proc/base.c +24 -17
103 lines not on this page · raw message
fs/proc/namespaces.c +12 -0
@@ -55,6 +55,10 @@ static const char *proc_ns_get_link(struct dentry *dentry,if (!task)return ERR_PTR (-EACCES ); + error =down_read_killable (&task->signal->exec_update_lock); +if (error) + goto out_put_task; +if (!ptrace_may_access (task,PTRACE_MODE_READ_FSCREDS )) goto out;
@@ -64,6 +68,8 @@ static const char *proc_ns_get_link(struct dentry *dentry, error =nd_jump_link (&ns_path); out: +up_read (&task->signal->exec_update_lock); +out_put_task:put_task_struct (task);return ERR_PTR (error); }
@@ -80,11 +86,17 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int buflif (!task)return res; + res =down_read_killable (&task->signal->exec_update_lock); +if (res) + goto out_put_task; +if (ptrace_may_access (task,PTRACE_MODE_READ_FSCREDS )) { res =ns_get_name (name,sizeof (name), task, ns_ops);if (res >=0 ) res =readlink_copy (buffer, buflen, name); } +up_read (&task->signal->exec_update_lock); +out_put_task:put_task_struct (task);return res; }
Signature · 1 line
2.53.0