Skip to contentSkip to conversation

EACCESS vs ENOENT for nonexistent files-within-files

DISCUSSION Joe Orton 6 participants 10 messages Sep 13, 2004 – Sep 16, 2004 VFS

lore
Share & tools
lore

Joe Orton

author
#0 lore raw

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

Can someone explain the justification behind reiser4's behaviour? httpd's assumption does not seem unreasonable, and EACCES seems to make little sense for this error case.

Regards,

joe

#1 lore raw

From: Joe Orton <[email protected]>

Quoted 4 lines

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

Thank you. I was just tracking down a similar problem with BitKeeper that is explained by this bug. You saved me some work.

-Wayne

#2 lore raw
In reply to Joe Orton
Quoted 8 lines

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

Can someone explain the justification behind reiser4's behaviour? httpd's assumption does not seem unreasonable, and EACCES seems to make little sense for this error case.

i think the problem would be "solved" by mounting the partition with the nopseudos option. of course, this is not the long-term solution.

regards,
michael

#3 lore raw
In reply to Joe Orton
Quoted 8 lines · Joe Orton

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

Can someone explain the justification behind reiser4's behaviour? httpd's assumption does not seem unreasonable, and EACCES seems to make little sense for this error case.

It is because open(name, O_DIRECTORY) is successful for regular files in reiser4. Once it succedes, Apache2 thinks that is a directory and tries to open .htaccess under it. It does not matter what error code is receives there, the problem is that apache2 has decided that the file is a directory.

There are two solutions:

1) mount reiser4 partition with "nopseudo" mount option. it makes /metas/* files unaccessible.

2) apply the patch:

===== fs/namei.c 1.104 vs edited =====

fs/namei.c +1 -1
@@ -816,7 +816,7 @@
 			break;
 		if (lookup_flags & LOOKUP_DIRECTORY) {
 			err = -ENOTDIR; 
-			if (!inode->i_op || !inode->i_op->lookup)
+			if (!S_ISDIR(inode->i_mode))
 				break;
 		}
 		goto return_base;

===============================

Quoted 3 lines

Regards,

joe

Signature · 1 line
Alex.
author
#4 lore raw
Quoted 6 lines · Alex Zarochentsev
Quoted 5 lines · Joe Orton

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

Quoted 7 lines
Quoted 3 lines

Can someone explain the justification behind reiser4's behaviour? httpd's assumption does not seem unreasonable, and EACCES seems to make little sense for this error case.

It is because open(name, O_DIRECTORY) is successful for regular files in reiser4. Once it succedes, Apache2 thinks that is a directory and tries to open .htaccess under it.

I don't think that has anything to do with it. It's a simple open() without O_DIRECTORY which is failing with EACCES. The reporter confirmed this with the simplest of tests:

$ touch newfile.txt
$ cat newfile.txt/.htaccess
cat: newfile.txt/.htaccess: Permission denied

this is the behaviour I'm trying to find the justification for.

Quoted 4 lines

There are two solutions:

1) mount reiser4 partition with "nopseudo" mount option. it makes /metas/* files unaccessible.

If this is broken by default, our users will continue to complain, so that doesn't really help.

Quoted 1 line

2) apply the patch:

OK, does this mean you do consider this a bug in reiser4 which will be fixed in future releases, then?

Regards,

joe

#5 lore raw
Quoted 11 lines · Joe Orton
Quoted 10 lines · Alex Zarochentsev
Quoted 8 lines · Joe Orton

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

Can someone explain the justification behind reiser4's behaviour? httpd's assumption does not seem unreasonable, and EACCES seems to make little sense for this error case.

Quoted 7 lines
Quoted 3 lines

It is because open(name, O_DIRECTORY) is successful for regular files in reiser4. Once it succedes, Apache2 thinks that is a directory and tries to open .htaccess under it.

I don't think that has anything to do with it. It's a simple open() without O_DIRECTORY which is failing with EACCES. The reporter confirmed this with the simplest of tests:

The only reason Apache is trying to access "regular/.htaccess" is because previous open("regular", O_DIRECTORY) returned success.

Quoted 6 lines
$ touch newfile.txt
$ cat newfile.txt/.htaccess
cat: newfile.txt/.htaccess: Permission denied

this is the behaviour I'm trying to find the justification for.

If newfile.txt has no +x bit set, then justification is obvious: UNIX requires +x bit for lookup, and EACCES is returned when trying to lookup anything in a directory (or, in this case, a regular file) without +x bit:

$ mkdir zzz
$ chmod a-x zzz
$ cat zzz/.htaccess
cat: zzz/.htaccess: Permission denied

This is how things worked for almost 30 years.

If you observe EACCES on the file with +x bit---this is unknown bug and test-case is most welcome.

Quoted 9 lines
Quoted 5 lines

There are two solutions:

1) mount reiser4 partition with "nopseudo" mount option. it makes /metas/* files unaccessible.

If this is broken by default, our users will continue to complain, so that doesn't really help.

Quoted 8 lines
Quoted 1 line

2) apply the patch:

OK, does this mean you do consider this a bug in reiser4 which will be fixed in future releases, then?

Regards,

joe

Nikita.

#6 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 11 lines · Nikita Danilov

If newfile.txt has no +x bit set, then justification is obvious: UNIX requires +x bit for lookup, and EACCES is returned when trying to lookup anything in a directory (or, in this case, a regular file) without +x bit:

$ mkdir zzz
$ chmod a-x zzz
$ cat zzz/.htaccess
cat: zzz/.htaccess: Permission denied
Quoted 4 lines

This is how things worked for almost 30 years.

If you observe EACCES on the file with +x bit---this is unknown bug and test-case is most welcome.

at least on ext3 and nfs3 i have this:

evil@prinz:/tmp$ touch file.txt
evil@prinz:/tmp$ cat file.txt/.htaccess
cat: file.txt/.htaccess: Not a directory
evil@prinz:/tmp$ chmod +x file.txt
evil@prinz:/tmp$ cat file.txt/.htaccess
cat: file.txt/.htaccess: Not a directory

...which sounds *a bit* more reasonable than "permission denied", but
"cat: file.txt/: Not a directory"
or
"cat: file.txt/.htaccess: No such file or directory"

would make even more sense IMHO.

Christian.
- --
BOFH excuse #290:

The CPU has shifted, and become decentralized. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBSB+lC/PVm5+NVoYRAvslAJwLMd7VJlOOIJhkZmYMetspLeWYzQCgsUli SFgoAG3eMrHn1URscHeoGZM=
=yFbW
-----END PGP SIGNATURE-----

#7 lore raw
Quoted 2 lines · evilninja

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello, Christian evilninja :)

Quoted 18 lines
Quoted 11 lines · Nikita Danilov

If newfile.txt has no +x bit set, then justification is obvious: UNIX requires +x bit for lookup, and EACCES is returned when trying to lookup anything in a directory (or, in this case, a regular file) without +x bit:

$ mkdir zzz
$ chmod a-x zzz
$ cat zzz/.htaccess
cat: zzz/.htaccess: Permission denied
Quoted 4 lines

This is how things worked for almost 30 years.

If you observe EACCES on the file with +x bit---this is unknown bug and test-case is most welcome.

Quoted 8 lines

at least on ext3 and nfs3 i have this:

evil@prinz:/tmp$ touch file.txt
evil@prinz:/tmp$ cat file.txt/.htaccess
cat: file.txt/.htaccess: Not a directory
evil@prinz:/tmp$ chmod +x file.txt
evil@prinz:/tmp$ cat file.txt/.htaccess
cat: file.txt/.htaccess: Not a directory

But in reiser4 file.txt _is_ a directory. That's the whole point: it contains other objects inside.

Quoted 7 lines

...which sounds *a bit* more reasonable than "permission denied", but
"cat: file.txt/: Not a directory"
or
"cat: file.txt/.htaccess: No such file or directory"

would make even more sense IMHO.

This is very simple: do be able to do a lookup one needs +x bit. No +x bit--no lookup. No lookup---impossible to determine exists .htaccess or not.

Permission bits determine what operations are possible on object. Letting user to know that .htaccess doesn't exist while permission bits on parent explicitly disable lookups is a security hole.

Quoted 2 lines

Christian.

Nikita.

Quoted 12 lines

- --
BOFH excuse #290:

The CPU has shifted, and become decentralized. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBSB+lC/PVm5+NVoYRAvslAJwLMd7VJlOOIJhkZmYMetspLeWYzQCgsUli SFgoAG3eMrHn1URscHeoGZM=
=yFbW
-----END PGP SIGNATURE-----

#8 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 5 lines · Nikita Danilov
Quoted 2 lines · evilninja

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello, Christian evilninja :)

um, yes, it just sticks ;-)

Quoted 3 lines

But in reiser4 file.txt _is_ a directory. That's the whole point: it contains other objects inside.

[...]

Quoted 3 lines

This is very simple: do be able to do a lookup one needs +x bit. No +x bit--no lookup. No lookup---impossible to determine exists .htaccess or not.

ok, so things will be different when i'll try reiser4 on my box.

Quoted 4 lines

Permission bits determine what operations are possible on object. Letting user to know that .htaccess doesn't exist while permission bits on parent explicitly disable lookups is a security hole.

yes, i think i got i now. thanks for the explanation.

Christian.
- --
BOFH excuse #65:

system needs to be rebooted
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBSNerC/PVm5+NVoYRAuLsAJ99JCbKQ0ebl9xRPwwYK/un9OKRtgCg3nOu tlYw+GkQWwO2Kfk1pEVlivE=
=5iJg
-----END PGP SIGNATURE-----

#9 lore raw
In reply to Joe Orton
Quoted 6 lines · Joe Orton
Quoted 5 lines · Alex Zarochentsev
Quoted 4 lines · Joe Orton

Hi, we had a bug report that Apache httpd logs a spurious error for every file served from a reiser4 filesystem, because httpd assumes that /path/to/file/.htaccess (where /path/to/file is a normal file) returns ENOENT or ENOTDIR, but reiser4 returns EACCES in this case.

what does the user get in the browser?

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Can someone explain the justification behind reiser4's behaviour? httpd's assumption does not seem unreasonable, and EACCES seems to make little sense for this error case.

It is because open(name, O_DIRECTORY) is successful for regular files in reiser4. Once it succedes, Apache2 thinks that is a directory and tries to open .htaccess under it.

Quoted 7 lines

I don't think that has anything to do with it. It's a simple open() without O_DIRECTORY which is failing with EACCES. The reporter confirmed this with the simplest of tests:

$ touch newfile.txt
$ cat newfile.txt/.htaccess
cat: newfile.txt/.htaccess: Permission denied

But what is the reason why apache2 looks at <regular file>/.htaccess ?

can you ask the user to add execute permitions (just for test) to the file and see would apache2 work with the file.

Quoted 7 lines

this is the behaviour I'm trying to find the justification for.

Quoted 4 lines

There are two solutions:

1) mount reiser4 partition with "nopseudo" mount option. it makes /metas/* files unaccessible.

Quoted 7 lines

If this is broken by default, our users will continue to complain, so that doesn't really help.

Quoted 1 line

2) apply the patch:

OK, does this mean you do consider this a bug in reiser4 which will be fixed in future releases, then?

it requires Linux VFS changes, the changes are being discussed in LKML still.

Quoted 4 lines

Regards,

joe

Signature · 1 line
Alex.