home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / linux / 20807 < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.6 KB  |  42 lines

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