Re: Linux 2.1.125 doesn't dump core on SIGSEGV

Chris Wedgwood (chris@cybernet.co.nz)
Wed, 21 Oct 1998 11:01:05 +1300


On Tue, Oct 20, 1998 at 10:55:27PM +0100, David Woodhouse wrote:

> 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/