Reputation
698
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
3 9
Newest
 Editor
Impact
~7k people reached

  • 0 posts edited
  • 0 helpful flags
  • 35 votes cast
May
12
comment Does bash open files in O_APPEND when using “>>” on linux?
In short, NFS is a load of bugs and should not be used.
Apr
7
comment What is the purpose of UEFI partition?
Why "unfortunately"? Does anyone actually want to use EFI to boot when there's an option not to?
Mar
17
awarded  Editor
Mar
17
revised Do I need swap space if I have more than enough amount of RAM?
added 281 characters in body
Mar
17
answered Do I need swap space if I have more than enough amount of RAM?
Jan
28
comment How can I kill a process and be sure the PID hasn't been reused
@MichaelMartinez: grsec has an option for it. See grsecurity.net/confighelp.php
Jan
28
comment How can I kill a process and be sure the PID hasn't been reused
The fact that you think it's unlikely to happen does not make it any less of a race. The potential amount of time between the stats read and the kill is unbounded; the code may lie in different pages, where one of the pages is resident and the other has been discarded and needs to be reloaded from a disk that's under high IO load. Als, hardened systems should assign pids randomly, not sequentially, and it's pretty easy for a malicious load source to run through the default pid space of 32k in a matter of seconds.
Jan
28
comment How can I kill a process and be sure the PID hasn't been reused
@MichaelMartinez: That does not help. There's still a TOCTOU race: first you check /proc/[pid]/stats then you use the pid to kill.
Jan
27
comment How can I kill a process and be sure the PID hasn't been reused
@kasperd: Indeed ptrace works, but it's not a good idea. It's not portable, it precludes debugging/strace (since there can usually only be one tracing process), and hardened systems sometimes have the ptrace syscall disabled entirely because of a history of vulns.
Jan
26
awarded  Yearling
Jan
26
awarded  Mortarboard
Jan
26
comment How can I kill a process and be sure the PID hasn't been reused
@peterph: "The race window is small" is not a solution. And the rarity of the race is dependent on sequential pid assignment. Bugs that cause something very bad to happen once in a year are much worse than bugs that happen all the time because they're virtually impossible to diagnose and fix.
Jan
26
comment How can I kill a process and be sure the PID hasn't been reused
@StéphaneChazelas: How do you prevent the shell from waiting on a pid of a background process that has exited? If you can do that, the problem is easily solvable in the case OP needs.
Jan
26
comment How can I kill a process and be sure the PID hasn't been reused
@peterph: In general, any use of a pid is a TOCTOU race -- no matter how you check whether it still refers to the same process you expect it to refer to, it could cease to refer to that process and refer to some new process in the interval before you use it (sending the signal). The only way to prevent this is to be able to block the freeing/reuse of the pid, and the only process that can do this is the direct parent.
Jan
26
awarded  Nice Answer
Jan
26
answered How can I kill a process and be sure the PID hasn't been reused
Oct
8
comment How do I delete all of a set of files in a random order?
This answer is unsafe as written, at least in general. find outputs literal strings separated by newlines, and xargs reads a shell-quoted, whitespace-delimited list of names as input. A malicious name in the input can trick it into deleting something very different from what you intended to delete.
Sep
11
comment why 'echo --help' doesn't give me help page of echo?
@Tyilo: Rather than re-explaining it I liked to a page where I already explained the answer to that question.
Sep
10
comment why 'echo --help' doesn't give me help page of echo?
@Tyilo: See the specification in POSIX, or my coverage of the issue here: etalabs.net/sh_tricks.html
Sep
5
comment why 'echo --help' doesn't give me help page of echo?
Note that production of a help message by echo --help is a bug. Imagine what happens if you do: printf "The option you entered is: " ; echo "$opt" and the shell variable opt happens to be contain the text --help. Per the POSIX standard, echo is not permitted to behave in this way, but the GNU echo is obnoxiously non-conforming.