home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
- From: torvalds@klaava.Helsinki.FI (Linus Torvalds)
- Subject: Re: BUG REPORT (strace -p 1 messes up process tree) under 0.98.6
- Message-ID: <1992Dec17.121735.23547@klaava.Helsinki.FI>
- Organization: University of Helsinki
- References: <of=iQIy00VBCA4IqYu@andrew.cmu.edu> <jpo.724582915@hrz.tu-chemnitz.de>
- Date: Thu, 17 Dec 1992 12:17:35 GMT
- Lines: 31
-
- In article <jpo.724582915@hrz.tu-chemnitz.de> jpo@my.informatik.tu-chemnitz.de (Joerg Pommnitz) writes:
- >I have mentioned this bug to Linus when 0.98.6 was out. It's still
- >in 0.99, just tried it yesterday. Hope someone who is familiar with
- >the kernel can fix this.
-
- Yes, sorry about forgetting about this bug. The fix is very simple:
- disallow tracing of init, even by root. Init is special in other ways
- anyway (you cannot kill init with any outside signal including SIGKILL
- etc), as it has to run so that zombies can be given to somebody. The fix
- is easy:
-
- in linux/kernel/ptrace.c, function sys_ptrace(), add these two lines to
- just after checking against PTRACE_TRACEME:
-
- ----- pseudo-patch -----
- /* set the ptrace bit in the proccess flags. */
- return 0;
- }
- + if (pid == 1)
- + return -EPERM;
- if (!(child = get_task(pid)))
- return -ESRCH;
- if (request == PTRACE_ATTACH) {
- ----- pseudo-patch -----
-
- That may not have been what people wanted, but it's consistent with how
- the rest of the kernel handles the init task. So no, you won't be able
- to trace init, but on the other hand you won't be able to mess with the
- internal kernel process pointers either..
-
- Linus
-