Messages in this thread | | | Date | Mon, 11 Mar 2013 00:02:07 +0000 | From | Al Viro <> | Subject | Re: BUG_ON(nd->inode->i_op->follow_link); |
| |
On Thu, Mar 07, 2013 at 02:50:55PM -0800, Linus Torvalds wrote:
> and you get the oops, because when it follows that pseudo-symlink for > fd3, it will hit that symlink we just looked up. And trigger the > BUG_ON() you see. > > Al, I think the BUG_ON() is simply bogus. Should we just remove it? Or > is there some conceptual reason why we can't handle a symlink there?
BUG_ON() is bogus these days, but failing ->follow_link() is not. The thing is, what would you do with that sucker? Suppose you have ->follow_link() leaving you in a symlink. What would you do with it? Either you were not going to follow it (in which case you wouldn't have called ->follow_link() in the first place) *or* you need to know which directory it's in. Which we don't have in this case...
It really used to be an impossible case, until we'd introduced O_PATH. And IIRC, back when O_PATH had been developed, the plan was to fail attempts to follow these suckers with -ELOOP; looks like we forgot to do that. Mea culpa...
And no, just removing BUG_ON() is not enough - callers of follow_link() will do rather weird stuff (in nested symlink case it'll fail with ENOTDIR, in path_lookupat() with LOOKUP_FOLLOW it'll give you a symlink, in case of path_openat() with LOOKUP_FOLLOW fail with ELOOP).
See the patch I'd posted upthread. Let's make it fail consistently...
| |