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?
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.
May
29
comment Is there a way in Linux to have one non root user check if another non root user has permissions to a folder / file?
Indeed, access is almost always a bug. It's subject to TOCTOU races and it uses the real uid/gid rather than the effective (or, if it's set differently, the Linux-specific fsuid/fsgid) uid/gid to determine permissions, which is almost never what you want unless they all happen to be equal.
May
26
comment Can the /home folder in Linux contain anything else but user folders?
@JamesN: If the other HD is formatted for use by windows, the problem is not going to be what it contains, but the fact that it's unsuitable for many uses that applications might expect to work. For instance, lacking symlink and hardlink support, case-sensitive filenames, fifos, unix sockets, ...
May
13
comment Why *not* parse `ls`?
@mikeserv: Then tell me what you want me to demonstrate. Patrick already gave you examples of directory contents which your method fails to parse (because they are indistinguishable by it). For any method you're using (please pick one for the sake of being specific) I'm happy to provide you a trivial example of a directory it fails to properly parse. The fact that you can construct specific examples which you think are "hard" and successfully parse them has no bearing on whether your method works in general.