> In the coredump case, I'm not sure - but in general it's because
> there's a race condition. Someone can put the 'evil' symlink in
> place between the stat() and the open().
No, indeed you are correct - there is a race. Doh! Need more coffee.
> Even in the coredump case there's a race, but presumably there's a
> lock somewhere that we can use to make it seem atomic.
How does this look (still a race, but much harder to exploit):
if(fd = (open("core",O_CREAT | O_EXCL)) == -1)
goto end_dump;
lstat("core",&fs1);
fstat(fd,&fs2);
/* compare stat results - don't sump if bad */
Better?
-cw
We _really_ do need O_NOFOLLOW semantics. Anyone looked at how hard
this would be to implement?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/