Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106371
b: refs/heads/master
c: e56b6a5
h: refs/heads/master
i:
  106369: 128b55f
  106367: 736060b
v: v3
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Jul 27, 2008
1 parent e84e1ff commit e6aa0b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: beb29e058c35ab69e96e455a12ccf7505f6de425
refs/heads/master: e56b6a5dda1a36ffaa532df6f975ea324298fa4d
58 changes: 30 additions & 28 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,38 +656,40 @@ EXPORT_SYMBOL(setup_arg_pages);
struct file *open_exec(const char *name)
{
struct nameidata nd;
int err;
struct file *file;
int err;

err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
file = ERR_PTR(err);

if (!err) {
struct inode *inode = nd.path.dentry->d_inode;
file = ERR_PTR(-EACCES);
if (S_ISREG(inode->i_mode)) {
int err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN);
file = ERR_PTR(err);
if (!err) {
file = nameidata_to_filp(&nd,
O_RDONLY|O_LARGEFILE);
if (!IS_ERR(file)) {
err = deny_write_access(file);
if (err) {
fput(file);
file = ERR_PTR(err);
}
}
out:
return file;
}
}
release_open_intent(&nd);
path_put(&nd.path);
err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd,
FMODE_READ|FMODE_EXEC);
if (err)
goto out;

err = -EACCES;
if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
goto out_path_put;

err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN);
if (err)
goto out_path_put;

file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
if (IS_ERR(file))
return file;

err = deny_write_access(file);
if (err) {
fput(file);
goto out;
}
goto out;
}

return file;

out_path_put:
release_open_intent(&nd);
path_put(&nd.path);
out:
return ERR_PTR(err);
}
EXPORT_SYMBOL(open_exec);

int kernel_read(struct file *file, unsigned long offset,
Expand Down

0 comments on commit e6aa0b0

Please sign in to comment.