3 ms·
In a similar family, note also that setuid() can fail! If you try to setuid() to a user that has has reached their ulimit for number of processes, then setuid(
by jwise0 12y ago
In a similar family, note also that setuid() can fail! If you try to setuid() to a user that has has reached their ulimit for number of processes, then setuid() will fail, just like fork() would for that user.
This is a classic way to get your application exploited. Google did it (at least) twice in Android: once in ADB [1], and once in Zygote [2]. Both resulted in escalation.
Check your return values! All of them!
[1] http://thesnkchrmr.wordpress.com/2011/03/24/rageagainstthecage/ http://thesnkchrmr.wordpress.com/2011/03/24/rageagainsttheca...
[2] https://github.com/unrevoked/zysploit https://github.com/unrevoked/zysploit
- agwa 12y agoThankfully, setuid() no longer fails on Linux because of RLIMIT_NPROC, as of 2011[1]. Still, I agree with you 100%: check your syscall return values, especially security-critical syscalls like setuid! [1] http://lwn.net/Articles/451985/ http://lwn.net/Articles/451985/ and http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=72fa59970f8698023045ab0713d66f3f4f96945c http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.g...