Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169153
b: refs/heads/master
c: 8b8efb4
h: refs/heads/master
i:
  169151: 45e5d50
v: v3
  • Loading branch information
Tetsuo Handa authored and James Morris committed Oct 11, 2009
1 parent f15ebe6 commit 8c941e2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 89eda06837094ce9f34fae269b8773fcfd70f046
refs/heads/master: 8b8efb44033c7e86b3dc76f825c693ec92ae30e9
3 changes: 3 additions & 0 deletions trunk/fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
error = -EPERM;
if (!capable(CAP_SYS_CHROOT))
goto dput_and_out;
error = security_path_chroot(&path);
if (error)
goto dput_and_out;

set_fs_root(current->fs, &path);
error = 0;
Expand Down
11 changes: 11 additions & 0 deletions trunk/include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
* @uid contains new owner's ID.
* @gid contains new group's ID.
* Return 0 if permission is granted.
* @path_chroot:
* Check for permission to change root directory.
* @path contains the path structure.
* Return 0 if permission is granted.
* @inode_readlink:
* Check the permission to read the symbolic link.
* @dentry contains the dentry structure for the file link.
Expand Down Expand Up @@ -1503,6 +1507,7 @@ struct security_operations {
int (*path_chmod) (struct dentry *dentry, struct vfsmount *mnt,
mode_t mode);
int (*path_chown) (struct path *path, uid_t uid, gid_t gid);
int (*path_chroot) (struct path *path);
#endif

int (*inode_alloc_security) (struct inode *inode);
Expand Down Expand Up @@ -2970,6 +2975,7 @@ int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
mode_t mode);
int security_path_chown(struct path *path, uid_t uid, gid_t gid);
int security_path_chroot(struct path *path);
#else /* CONFIG_SECURITY_PATH */
static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
{
Expand Down Expand Up @@ -3031,6 +3037,11 @@ static inline int security_path_chown(struct path *path, uid_t uid, gid_t gid)
{
return 0;
}

static inline int security_path_chroot(struct path *path)
{
return 0;
}
#endif /* CONFIG_SECURITY_PATH */

#ifdef CONFIG_KEYS
Expand Down
6 changes: 6 additions & 0 deletions trunk/security/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ static int cap_path_chown(struct path *path, uid_t uid, gid_t gid)
{
return 0;
}

static int cap_path_chroot(struct path *root)
{
return 0;
}
#endif

static int cap_file_permission(struct file *file, int mask)
Expand Down Expand Up @@ -990,6 +995,7 @@ void security_fixup_ops(struct security_operations *ops)
set_to_cap_if_null(ops, path_truncate);
set_to_cap_if_null(ops, path_chmod);
set_to_cap_if_null(ops, path_chown);
set_to_cap_if_null(ops, path_chroot);
#endif
set_to_cap_if_null(ops, file_permission);
set_to_cap_if_null(ops, file_alloc_security);
Expand Down
5 changes: 5 additions & 0 deletions trunk/security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ int security_path_chown(struct path *path, uid_t uid, gid_t gid)
return 0;
return security_ops->path_chown(path, uid, gid);
}

int security_path_chroot(struct path *path)
{
return security_ops->path_chroot(path);
}
#endif

int security_inode_create(struct inode *dir, struct dentry *dentry, int mode)
Expand Down

0 comments on commit 8c941e2

Please sign in to comment.