/** * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread. * * Returns pointer to "struct tomoyo_domain_info" for current thread.
*/ struct tomoyo_domain_info *tomoyo_domain(void)
{ struct tomoyo_task *s = tomoyo_task(current);
#ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER /** * tomoyo_bprm_creds_for_exec - Target for security_bprm_creds_for_exec(). * * @bprm: Pointer to "struct linux_binprm". * * Returns 0.
*/ staticint tomoyo_bprm_creds_for_exec(struct linux_binprm *bprm)
{ /* * Load policy if /sbin/tomoyo-init exists and /sbin/init is requested * for the first time.
*/ if (!tomoyo_policy_loaded)
tomoyo_load_policy(bprm->filename); return 0;
} #endif
/** * tomoyo_bprm_check_security - Target for security_bprm_check(). * * @bprm: Pointer to "struct linux_binprm". * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_bprm_check_security(struct linux_binprm *bprm)
{ struct tomoyo_task *s = tomoyo_task(current);
/* * Execute permission is checked against pathname passed to execve() * using current domain.
*/ if (!s->old_domain_info) { constint idx = tomoyo_read_lock(); constint err = tomoyo_find_next_domain(bprm);
tomoyo_read_unlock(idx); return err;
} /* * Read permission is checked against interpreters using next domain.
*/ return tomoyo_check_open_permission(s->domain_info,
&bprm->file->f_path, O_RDONLY);
}
/** * tomoyo_inode_getattr - Target for security_inode_getattr(). * * @path: Pointer to "struct path". * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_inode_getattr(conststruct path *path)
{ return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, path, NULL);
}
/** * tomoyo_path_truncate - Target for security_path_truncate(). * * @path: Pointer to "struct path". * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_path_truncate(conststruct path *path)
{ return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path, NULL);
}
/** * tomoyo_file_truncate - Target for security_file_truncate(). * * @file: Pointer to "struct file". * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_file_truncate(struct file *file)
{ return tomoyo_path_truncate(&file->f_path);
}
/** * tomoyo_path_unlink - Target for security_path_unlink(). * * @parent: Pointer to "struct path". * @dentry: Pointer to "struct dentry". * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_path_unlink(conststruct path *parent, struct dentry *dentry)
{ struct path path = { .mnt = parent->mnt, .dentry = dentry };
if (err) return err;
} return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2);
}
/** * tomoyo_file_fcntl - Target for security_file_fcntl(). * * @file: Pointer to "struct file". * @cmd: Command for fcntl(). * @arg: Argument for @cmd. * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_file_fcntl(struct file *file, unsignedint cmd, unsignedlong arg)
{ if (!(cmd == F_SETFL && ((arg ^ file->f_flags) & O_APPEND))) return 0; return tomoyo_check_open_permission(tomoyo_domain(), &file->f_path,
O_WRONLY | (arg & O_APPEND));
}
/** * tomoyo_file_open - Target for security_file_open(). * * @f: Pointer to "struct file". * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_file_open(struct file *f)
{ /* Don't check read permission here if called from execve(). */ /* Illogically, FMODE_EXEC is in f_flags, not f_mode. */ if (f->f_flags & __FMODE_EXEC) return 0; return tomoyo_check_open_permission(tomoyo_domain(), &f->f_path,
f->f_flags);
}
/** * tomoyo_file_ioctl - Target for security_file_ioctl(). * * @file: Pointer to "struct file". * @cmd: Command for ioctl(). * @arg: Argument for @cmd. * * Returns 0 on success, negative value otherwise.
*/ staticint tomoyo_file_ioctl(struct file *file, unsignedint cmd, unsignedlong arg)
{ return tomoyo_path_number_perm(TOMOYO_TYPE_IOCTL, &file->f_path, cmd);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.