Re: silent semantic changes with reiser4

From: Linus Torvalds
Date: Thu Aug 26 2004 - 12:46:13 EST




On Thu, 26 Aug 2004, Jamie Lokier wrote:
>
> run_setuid_program
>
> -> calls pwd
> pwd opens("."), (".."), ("../..") etc.

Ehh.. Not only does pwd not do that..

(hint: there's a getcwd() system call)

> -> the setuid program thus ends up opening a device or fifo,
> when it does pwd's path walk. Yes it could use the getcwd
> syscall, but some programs do their own path walk.

.. but even if it did that, it should use O_DIRECTORY when it did so. If
it doesn't, it's broken.

So no, it would _not_ open the device or fifo when it did so.

The fact is, anything that expects to open a directory should already be
opening it with O_DIRECTORY.

That said, ".." and "." are special already inside the kernel, and it
migth be worth making them automatically imply O_DIRECTORY, since nothing
else makes sense anyway. That would fix the case where somebody uses ".."
_without_ using O_DIRECTORY.

> It also fits the container idea very well:
>
> /dev/hda/part1/ <- the filesystem inside partition 1

I don't think you can do that. The kernel has no idea how to mount the
filesystem.

If it's already mounted somewhere else, that's a different issue.
Although it might be mounted in several places (as a bind mount) with
different writability, I guess, so even then it might be "interesting".

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/