TOMOYO: Remove unneeded parameter.

tomoyo_path_perm() tomoyo_path2_perm() and tomoyo_check_rewrite_permission()
always receive tomoyo_domain(). We can move it from caller to callee.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
Tetsuo Handa 2010-02-16 09:46:15 +09:00 committed by James Morris
parent 7ef612331f
commit 97d6931ead
3 changed files with 27 additions and 38 deletions

View file

@ -637,12 +637,10 @@ int tomoyo_check_exec_perm(struct tomoyo_domain_info *domain,
const struct tomoyo_path_info *filename); const struct tomoyo_path_info *filename);
int tomoyo_check_open_permission(struct tomoyo_domain_info *domain, int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
struct path *path, const int flag); struct path *path, const int flag);
int tomoyo_path_perm(struct tomoyo_domain_info *domain, const u8 operation, int tomoyo_path_perm(const u8 operation, struct path *path);
struct path *path); int tomoyo_path2_perm(const u8 operation, struct path *path1,
int tomoyo_path2_perm(struct tomoyo_domain_info *domain, const u8 operation, struct path *path2);
struct path *path1, struct path *path2); int tomoyo_check_rewrite_permission(struct file *filp);
int tomoyo_check_rewrite_permission(struct tomoyo_domain_info *domain,
struct file *filp);
int tomoyo_find_next_domain(struct linux_binprm *bprm); int tomoyo_find_next_domain(struct linux_binprm *bprm);
/* Run garbage collector. */ /* Run garbage collector. */

View file

@ -1135,17 +1135,16 @@ int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
/** /**
* tomoyo_path_perm - Check permission for "create", "unlink", "mkdir", "rmdir", "mkfifo", "mksock", "mkblock", "mkchar", "truncate", "symlink", "ioctl", "chmod", "chown", "chgrp", "chroot", "mount" and "unmount". * tomoyo_path_perm - Check permission for "create", "unlink", "mkdir", "rmdir", "mkfifo", "mksock", "mkblock", "mkchar", "truncate", "symlink", "ioctl", "chmod", "chown", "chgrp", "chroot", "mount" and "unmount".
* *
* @domain: Pointer to "struct tomoyo_domain_info".
* @operation: Type of operation. * @operation: Type of operation.
* @path: Pointer to "struct path". * @path: Pointer to "struct path".
* *
* Returns 0 on success, negative value otherwise. * Returns 0 on success, negative value otherwise.
*/ */
int tomoyo_path_perm(struct tomoyo_domain_info *domain, int tomoyo_path_perm(const u8 operation, struct path *path)
const u8 operation, struct path *path)
{ {
int error = -ENOMEM; int error = -ENOMEM;
struct tomoyo_path_info *buf; struct tomoyo_path_info *buf;
struct tomoyo_domain_info *domain = tomoyo_domain();
const u8 mode = tomoyo_check_flags(domain, TOMOYO_MAC_FOR_FILE); const u8 mode = tomoyo_check_flags(domain, TOMOYO_MAC_FOR_FILE);
const bool is_enforce = (mode == 3); const bool is_enforce = (mode == 3);
int idx; int idx;
@ -1180,15 +1179,14 @@ int tomoyo_path_perm(struct tomoyo_domain_info *domain,
/** /**
* tomoyo_check_rewrite_permission - Check permission for "rewrite". * tomoyo_check_rewrite_permission - Check permission for "rewrite".
* *
* @domain: Pointer to "struct tomoyo_domain_info".
* @filp: Pointer to "struct file". * @filp: Pointer to "struct file".
* *
* Returns 0 on success, negative value otherwise. * Returns 0 on success, negative value otherwise.
*/ */
int tomoyo_check_rewrite_permission(struct tomoyo_domain_info *domain, int tomoyo_check_rewrite_permission(struct file *filp)
struct file *filp)
{ {
int error = -ENOMEM; int error = -ENOMEM;
struct tomoyo_domain_info *domain = tomoyo_domain();
const u8 mode = tomoyo_check_flags(domain, TOMOYO_MAC_FOR_FILE); const u8 mode = tomoyo_check_flags(domain, TOMOYO_MAC_FOR_FILE);
const bool is_enforce = (mode == 3); const bool is_enforce = (mode == 3);
struct tomoyo_path_info *buf; struct tomoyo_path_info *buf;
@ -1217,19 +1215,18 @@ int tomoyo_check_rewrite_permission(struct tomoyo_domain_info *domain,
/** /**
* tomoyo_path2_perm - Check permission for "rename", "link" and "pivot_root". * tomoyo_path2_perm - Check permission for "rename", "link" and "pivot_root".
* *
* @domain: Pointer to "struct tomoyo_domain_info".
* @operation: Type of operation. * @operation: Type of operation.
* @path1: Pointer to "struct path". * @path1: Pointer to "struct path".
* @path2: Pointer to "struct path". * @path2: Pointer to "struct path".
* *
* Returns 0 on success, negative value otherwise. * Returns 0 on success, negative value otherwise.
*/ */
int tomoyo_path2_perm(struct tomoyo_domain_info * const domain, int tomoyo_path2_perm(const u8 operation, struct path *path1,
const u8 operation, struct path *path1,
struct path *path2) struct path *path2)
{ {
int error = -ENOMEM; int error = -ENOMEM;
struct tomoyo_path_info *buf1, *buf2; struct tomoyo_path_info *buf1, *buf2;
struct tomoyo_domain_info *domain = tomoyo_domain();
const u8 mode = tomoyo_check_flags(domain, TOMOYO_MAC_FOR_FILE); const u8 mode = tomoyo_check_flags(domain, TOMOYO_MAC_FOR_FILE);
const bool is_enforce = (mode == 3); const bool is_enforce = (mode == 3);
const char *msg; const char *msg;

View file

@ -100,33 +100,33 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
static int tomoyo_path_truncate(struct path *path, loff_t length, static int tomoyo_path_truncate(struct path *path, loff_t length,
unsigned int time_attrs) unsigned int time_attrs)
{ {
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_TRUNCATE, path); return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path);
} }
static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry) static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry)
{ {
struct path path = { parent->mnt, dentry }; struct path path = { parent->mnt, dentry };
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_UNLINK, &path); return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path);
} }
static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry, static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry,
int mode) int mode)
{ {
struct path path = { parent->mnt, dentry }; struct path path = { parent->mnt, dentry };
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_MKDIR, &path); return tomoyo_path_perm(TOMOYO_TYPE_MKDIR, &path);
} }
static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry) static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry)
{ {
struct path path = { parent->mnt, dentry }; struct path path = { parent->mnt, dentry };
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_RMDIR, &path); return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path);
} }
static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry, static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry,
const char *old_name) const char *old_name)
{ {
struct path path = { parent->mnt, dentry }; struct path path = { parent->mnt, dentry };
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_SYMLINK, &path); return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path);
} }
static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry, static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
@ -149,7 +149,7 @@ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
type = TOMOYO_TYPE_MKSOCK; type = TOMOYO_TYPE_MKSOCK;
break; break;
} }
return tomoyo_path_perm(tomoyo_domain(), type, &path); return tomoyo_path_perm(type, &path);
} }
static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir, static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir,
@ -157,8 +157,7 @@ static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir,
{ {
struct path path1 = { new_dir->mnt, old_dentry }; struct path path1 = { new_dir->mnt, old_dentry };
struct path path2 = { new_dir->mnt, new_dentry }; struct path path2 = { new_dir->mnt, new_dentry };
return tomoyo_path2_perm(tomoyo_domain(), TOMOYO_TYPE_LINK, &path1, return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2);
&path2);
} }
static int tomoyo_path_rename(struct path *old_parent, static int tomoyo_path_rename(struct path *old_parent,
@ -168,15 +167,14 @@ static int tomoyo_path_rename(struct path *old_parent,
{ {
struct path path1 = { old_parent->mnt, old_dentry }; struct path path1 = { old_parent->mnt, old_dentry };
struct path path2 = { new_parent->mnt, new_dentry }; struct path path2 = { new_parent->mnt, new_dentry };
return tomoyo_path2_perm(tomoyo_domain(), TOMOYO_TYPE_RENAME, &path1, return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2);
&path2);
} }
static int tomoyo_file_fcntl(struct file *file, unsigned int cmd, static int tomoyo_file_fcntl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
if (cmd == F_SETFL && ((arg ^ file->f_flags) & O_APPEND)) if (cmd == F_SETFL && ((arg ^ file->f_flags) & O_APPEND))
return tomoyo_check_rewrite_permission(tomoyo_domain(), file); return tomoyo_check_rewrite_permission(file);
return 0; return 0;
} }
@ -196,50 +194,46 @@ static int tomoyo_dentry_open(struct file *f, const struct cred *cred)
static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, static int tomoyo_file_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_IOCTL, return tomoyo_path_perm(TOMOYO_TYPE_IOCTL, &file->f_path);
&file->f_path);
} }
static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
mode_t mode) mode_t mode)
{ {
struct path path = { mnt, dentry }; struct path path = { mnt, dentry };
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_CHMOD, &path); return tomoyo_path_perm(TOMOYO_TYPE_CHMOD, &path);
} }
static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid) static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid)
{ {
int error = 0; int error = 0;
if (uid != (uid_t) -1) if (uid != (uid_t) -1)
error = tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_CHOWN, error = tomoyo_path_perm(TOMOYO_TYPE_CHOWN, path);
path);
if (!error && gid != (gid_t) -1) if (!error && gid != (gid_t) -1)
error = tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_CHGRP, error = tomoyo_path_perm(TOMOYO_TYPE_CHGRP, path);
path);
return error; return error;
} }
static int tomoyo_path_chroot(struct path *path) static int tomoyo_path_chroot(struct path *path)
{ {
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_CHROOT, path); return tomoyo_path_perm(TOMOYO_TYPE_CHROOT, path);
} }
static int tomoyo_sb_mount(char *dev_name, struct path *path, static int tomoyo_sb_mount(char *dev_name, struct path *path,
char *type, unsigned long flags, void *data) char *type, unsigned long flags, void *data)
{ {
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_MOUNT, path); return tomoyo_path_perm(TOMOYO_TYPE_MOUNT, path);
} }
static int tomoyo_sb_umount(struct vfsmount *mnt, int flags) static int tomoyo_sb_umount(struct vfsmount *mnt, int flags)
{ {
struct path path = { mnt, mnt->mnt_root }; struct path path = { mnt, mnt->mnt_root };
return tomoyo_path_perm(tomoyo_domain(), TOMOYO_TYPE_UMOUNT, &path); return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path);
} }
static int tomoyo_sb_pivotroot(struct path *old_path, struct path *new_path) static int tomoyo_sb_pivotroot(struct path *old_path, struct path *new_path)
{ {
return tomoyo_path2_perm(tomoyo_domain(), TOMOYO_TYPE_PIVOT_ROOT, return tomoyo_path2_perm(TOMOYO_TYPE_PIVOT_ROOT, new_path, old_path);
new_path, old_path);
} }
/* /*