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

  • 0 posts edited
  • 0 helpful flags
  • 40 votes cast
2d
comment Why pipe to cat only to redirect?
@IstvanChung: They're not equivalent. wc < file1 causes wc to run with stdin being a file descriptor for a regular seekable, mmappable file, file1. cat file1 | wc causes wc to run with a non-seekable pipe on stdin.
Jul
9
comment Why are UNIX/POSIX system call namings so illegible?
You might as well ask why they're not written in German, because that's about the closest natural-language approximation I can think of for the over-long monstrosities Java has taught programmers to accept...
Jun
8
comment Deleting files with spaces in their names
No need for xargs. Just use -exec rm -i '{}' +
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?
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
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.
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.
Aug
9
comment Why does ls accept duplicate switches?
@kasperd: Yes. Although putting -l in your ls alias seems like a bad idea, the same issue is likely to arise with options that are nice in an interactive ls alias like -p or --color=auto.
Aug
3
comment Can GPL software be bought by a company and still released as GPL?
The license part of the question is actually irrelevant, since the people producing the malware-infected files advertised on sourceforge with ads that look like a legitimate download button have little reason to care if what they're doing is illegal. I think the important part of OP's question, even though it wasn't stated as such, is how this happened.
Jun
10
comment Will Linux start killing my processes without asking me if memory gets short?
Citation: kernel.org/doc/Documentation/vm/overcommit-accounting
Jun
10
comment Will Linux start killing my processes without asking me if memory gets short?
Your understanding of the different values is wrong. 2 turns off overcommit off completely. 0 is the traditional "off" setting that doesn't really turn it off. 1 allows unlimited overcommit.