代码拉取完成,页面将自动刷新
同步操作将从 openEuler/itrustee_tzdriver 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* ko_adapt.c
*
* function for find symbols not exported
*
* Copyright (c) 2012-2021 Huawei Technologies Co., Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ko_adapt.h"
#include <linux/types.h>
#include <linux/mm_types.h>
#include <linux/stddef.h>
#include <linux/cred.h>
#include <linux/version.h>
#if (KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE)
#include <linux/sched/task.h>
#endif
#include <linux/cpumask.h>
#include <linux/syscalls.h>
#include <linux/fs.h>
#include "tc_ns_log.h"
typedef const struct cred *(get_task_cred_func)(struct task_struct *);
typedef void (kthread_bind_mask_func)(struct task_struct *, const struct cpumask *);
typedef long (sys_chown_func)(const char __user *filename,
uid_t user, gid_t group);
typedef ssize_t (vfs_write_func)(struct file *file, const char __user *buf,
size_t count, loff_t *pos);
typedef ssize_t (vfs_read_func)(struct file *file, char __user *buf,
size_t count, loff_t *pos);
typedef struct page *(alloc_pages_func)(gfp_t gfp_mask, unsigned int order);
typedef struct workqueue_attrs *(alloc_workqueue_attrs_func)(gfp_t gfp_mask);
typedef void (free_workqueue_attrs_func)(struct workqueue_attrs *attrs);
const struct cred *koadpt_get_task_cred(struct task_struct *task)
{
static get_task_cred_func *get_task_cred_pt = NULL;
if (!task)
return NULL;
if (!get_task_cred_pt) {
get_task_cred_pt = (get_task_cred_func *)
(uintptr_t)kallsyms_lookup_name("get_task_cred");
if (IS_ERR_OR_NULL(get_task_cred_pt)) {
tloge("fail to find symbol get task cred\n");
return NULL;
}
}
return get_task_cred_pt(task);
}
void koadpt_kthread_bind_mask(struct task_struct *task,
const struct cpumask *mask)
{
static kthread_bind_mask_func *kthread_bind_mask_pt = NULL;
if (!task || !mask)
return;
if (!kthread_bind_mask_pt) {
kthread_bind_mask_pt = (kthread_bind_mask_func *)
(uintptr_t)kallsyms_lookup_name("kthread_bind_mask");
if (IS_ERR_OR_NULL(kthread_bind_mask_pt)) {
tloge("fail to find symbol kthread bind mask\n");
return;
}
}
kthread_bind_mask_pt(task, mask);
}
long koadpt_sys_chown(const char __user *filename, uid_t user, gid_t group)
{
static sys_chown_func *sys_chown_pt = NULL;
if (!filename)
return -EINVAL;
if (!sys_chown_pt) {
sys_chown_pt = (sys_chown_func *)
(uintptr_t)kallsyms_lookup_name("sys_chown");
if (IS_ERR_OR_NULL(sys_chown_pt)) {
tloge("fail to find symbol kthread bind mask\n");
return -EINVAL;
}
}
return sys_chown_pt(filename, user, group);
}
ssize_t koadpt_vfs_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 116))
static vfs_write_func *vfs_write_pt = NULL;
if (!file || !buf || !pos)
return -EINVAL;
if (!vfs_write_pt) {
vfs_write_pt = (vfs_write_func *)
(uintptr_t)kallsyms_lookup_name("vfs_write");
if (IS_ERR_OR_NULL(vfs_write_pt)) {
tloge("fail to find symbol vfs write\n");
return -EINVAL;
}
}
return vfs_write_pt(file, buf, count, pos);
#else
return vfs_write(file, buf, count, pos);
#endif
}
ssize_t koadpt_vfs_read(struct file *file, char __user *buf,
size_t count, loff_t *pos)
{
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 19, 116))
static vfs_read_func *vfs_read_pt = NULL;
if (!file || !buf || !pos)
return -EINVAL;
if (!vfs_read_pt) {
vfs_read_pt = (vfs_read_func *)
(uintptr_t)kallsyms_lookup_name("vfs_read");
if (IS_ERR_OR_NULL(vfs_read_pt)) {
tloge("fail to find symbol vfs read\n");
return -EINVAL;
}
}
return vfs_read_pt(file, buf, count, pos);
#else
return vfs_read(file, buf, count, pos);
#endif
}
struct page *koadpt_alloc_pages(gfp_t gfp_mask, unsigned int order)
{
#ifdef CONFIG_NUMA
static alloc_pages_func *alloc_pages_pt = NULL;
if (!alloc_pages_pt) {
alloc_pages_pt = (alloc_pages_func *)
(uintptr_t)kallsyms_lookup_name("alloc_pages_current");
if (IS_ERR_OR_NULL(alloc_pages_pt)) {
tloge("fail to find symbol alloc pages current\n");
return NULL;
}
}
return alloc_pages_pt(gfp_mask, order);
#else
return alloc_pages(gfp_mask, order);
#endif
}
struct workqueue_attrs *koadpt_alloc_workqueue_attrs(gfp_t gfp_mask)
{
static alloc_workqueue_attrs_func *alloc_workqueue_attrs_pt = NULL;
if (!alloc_workqueue_attrs_pt) {
alloc_workqueue_attrs_pt = (alloc_workqueue_attrs_func *)
(uintptr_t)kallsyms_lookup_name("alloc_workqueue_attrs");
if (IS_ERR_OR_NULL(alloc_workqueue_attrs_pt)) {
tloge("fail to find symbol alloc workqueue attrs\n");
return NULL;
}
}
return alloc_workqueue_attrs_pt(gfp_mask);
}
void koadpt_free_workqueue_attrs(struct workqueue_attrs *attrs)
{
static free_workqueue_attrs_func *free_workqueue_attrs_pt = NULL;
if (!attrs)
return;
if (!free_workqueue_attrs_pt) {
free_workqueue_attrs_pt = (free_workqueue_attrs_func *)
(uintptr_t)kallsyms_lookup_name("free_workqueue_attrs");
if (IS_ERR_OR_NULL(free_workqueue_attrs_pt)) {
tloge("fail to find symbol free workqueue attrs\n");
return;
}
}
free_workqueue_attrs_pt(attrs);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。