[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240906112345.GA17874@redhat.com>
Date: Fri, 6 Sep 2024 13:24:17 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Roman Kisel <romank@...ux.microsoft.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, apais@...rosoft.com,
benhill@...rosoft.com, ssengar@...rosoft.com,
sunilmut@...rosoft.com, vdso@...bites.dev
Subject: Re: [PATCH 1/1] ptrace: Get tracer PID without reliance on the proc
FS
Add cc's. Perhaps someone else can ack/nack the intent...
This (trivial) patch is obviously buggy, but fixable. I won't argue
if it can help userspace.
On 09/05, Roman Kisel wrote:
>
> For debugging, it might be useful to run the debug trap
> instruction to break into the debugger. To detect the debugger
> presence, the kernel provides the `/proc/self/status` pseudo-file
> that needs to be searched for the "TracerPid:" string.
>
> Provide a prctl command that returns the PID of the tracer if any.
prctl?
> That allows for much simpler logic in the user land, and makes it
> possible to detect tracer presence even if PROC_FS is not enabled.
You should probably move the links from 0/1 to the changelog to make
it more convincing.
> + if (request == PTRACE_TRACER) {
> + rcu_read_lock();
> + tracer = ptrace_parent(current);
> + ret = tracer ? task_pid_nr_ns(tracer,
> + task_active_pid_ns(current->parent)) : -ESRCH;
The namespace is wrong, we need task_active_pid_ns(current). So this
code should simply do task_tgid_vnr(tracer) like sys_getppid() does.
And to me it would be better to return 0 if !current->ptrace.
> + rcu_read_unlock();
> + goto out;
Wrong, this code runs after "child = find_get_task_by_vpid(pid);" above.
And why? perhaps the intent was to check if this child is traced, not
current?
Oleg.
Powered by blists - more mailing lists