Re: patch for 2.1.48 autofs race

Linus Torvalds (torvalds@transmeta.com)
Fri, 8 Aug 1997 09:58:10 -0700 (PDT)


On Fri, 8 Aug 1997, Bill Hawes wrote:
>
> I've found a race condition in autofs that could explain some of the
> recent oops reports. In autofs/root.c, after doing a d_add(dentry,NULL)
> there's a nice long pause for revalidation. But since the dentry hasn't
> had its use count incremented, it may be possible for it to be released,
> and after the lookup returns the trashed dentry might get used.
>
> The attached patch bumps d_count around the revalidation to protect the
> dentry.

You're correct.

However, I think it actually would be better to do this at the VFS layer,
and not have the low-level filesystems every know about "dentry counts".
It's bad form by the VFS layer anyway to let dentries with a zero count be
around (except when holding the name lookup spinlock, which I still
haven't gotten around to actually create yet although it should be trivial
to do as the code has been designed with the spinlock in mind).

Linus