lkml.org 
[lkml]   [1999]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 2.2.5 - O_DIRECTORY|O_NOFOLLOW erroneously opens non-directories
(cc Alan since Linus is on holiday)

Dear Linus,

Enclosed is a bug fix for 2.2.5.

The open() flag O_DIRECTORY is supposed to refuse to open
non-directories. However due to a logic error, with O_NOFOLLOW it will
open files and other things.

O_DIRECTORY|O_NOFOLLOW is not such a weird combination. In fact it's
the only conceivable use for O_DIRECTORY since you can use a trailing
slash instead if you want the link-following behaviour.

Patch, thoroughly tested, enclosed.

Enjoy,
-- Jamie

--- linux-2.2.5/fs/namei.c.o_dir Mon Jan 25 06:48:39 1999
+++ linux-2.2.5/fs/namei.c Wed Mar 31 18:25:50 1999
@@ -279,7 +279,8 @@
{
struct inode * inode = dentry->d_inode;

- if (inode && inode->i_op && inode->i_op->follow_link) {
+ if ((follow & LOOKUP_FOLLOW)
+ && inode && inode->i_op && inode->i_op->follow_link) {
if (current->link_count < 5) {
struct dentry * result;

@@ -402,9 +403,6 @@

/* Check mountpoints.. */
dentry = follow_mount(dentry);
-
- if (!(flags & LOOKUP_FOLLOW))
- break;

base = do_follow_link(base, dentry, flags);
if (IS_ERR(base))
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:2.128 / U:1.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site