Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
a4a0683f
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a4a0683f
编写于
12月 01, 2017
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bpf_obj_do_pin(): switch to vfs_mkobj(), quit abusing ->mknod()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
8e6c848e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
28 deletion
+22
-28
kernel/bpf/inode.c
kernel/bpf/inode.c
+22
-28
未找到文件。
kernel/bpf/inode.c
浏览文件 @
a4a0683f
...
@@ -150,39 +150,29 @@ static int bpf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
...
@@ -150,39 +150,29 @@ static int bpf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
return
0
;
return
0
;
}
}
static
int
bpf_mkobj_ops
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
static
int
bpf_mkobj_ops
(
struct
dentry
*
dentry
,
umode_t
mode
,
void
*
raw
,
umode_t
mode
,
const
struct
inode_operations
*
iops
)
const
struct
inode_operations
*
iops
)
{
{
struct
inode
*
inode
;
struct
inode
*
dir
=
dentry
->
d_parent
->
d_inode
;
struct
inode
*
inode
=
bpf_get_inode
(
dir
->
i_sb
,
dir
,
mode
);
inode
=
bpf_get_inode
(
dir
->
i_sb
,
dir
,
mode
|
S_IFREG
);
if
(
IS_ERR
(
inode
))
if
(
IS_ERR
(
inode
))
return
PTR_ERR
(
inode
);
return
PTR_ERR
(
inode
);
inode
->
i_op
=
iops
;
inode
->
i_op
=
iops
;
inode
->
i_private
=
dentry
->
d_fsdata
;
inode
->
i_private
=
raw
;
bpf_dentry_finalize
(
dentry
,
inode
,
dir
);
bpf_dentry_finalize
(
dentry
,
inode
,
dir
);
return
0
;
return
0
;
}
}
static
int
bpf_mkobj
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
,
static
int
bpf_mkprog
(
struct
dentry
*
dentry
,
umode_t
mode
,
void
*
arg
)
dev_t
devt
)
{
{
enum
bpf_type
type
=
MINOR
(
devt
);
return
bpf_mkobj_ops
(
dentry
,
mode
,
arg
,
&
bpf_prog_iops
);
}
if
(
MAJOR
(
devt
)
!=
UNNAMED_MAJOR
||
!
S_ISREG
(
mode
)
||
dentry
->
d_fsdata
==
NULL
)
return
-
EPERM
;
switch
(
type
)
{
static
int
bpf_mkmap
(
struct
dentry
*
dentry
,
umode_t
mode
,
void
*
arg
)
case
BPF_TYPE_PROG
:
{
return
bpf_mkobj_ops
(
dir
,
dentry
,
mode
,
&
bpf_prog_iops
);
return
bpf_mkobj_ops
(
dentry
,
mode
,
arg
,
&
bpf_map_iops
);
case
BPF_TYPE_MAP
:
return
bpf_mkobj_ops
(
dir
,
dentry
,
mode
,
&
bpf_map_iops
);
default:
return
-
EPERM
;
}
}
}
static
struct
dentry
*
static
struct
dentry
*
...
@@ -218,7 +208,6 @@ static int bpf_symlink(struct inode *dir, struct dentry *dentry,
...
@@ -218,7 +208,6 @@ static int bpf_symlink(struct inode *dir, struct dentry *dentry,
static
const
struct
inode_operations
bpf_dir_iops
=
{
static
const
struct
inode_operations
bpf_dir_iops
=
{
.
lookup
=
bpf_lookup
,
.
lookup
=
bpf_lookup
,
.
mknod
=
bpf_mkobj
,
.
mkdir
=
bpf_mkdir
,
.
mkdir
=
bpf_mkdir
,
.
symlink
=
bpf_symlink
,
.
symlink
=
bpf_symlink
,
.
rmdir
=
simple_rmdir
,
.
rmdir
=
simple_rmdir
,
...
@@ -234,7 +223,6 @@ static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
...
@@ -234,7 +223,6 @@ static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
struct
inode
*
dir
;
struct
inode
*
dir
;
struct
path
path
;
struct
path
path
;
umode_t
mode
;
umode_t
mode
;
dev_t
devt
;
int
ret
;
int
ret
;
dentry
=
kern_path_create
(
AT_FDCWD
,
pathname
->
name
,
&
path
,
0
);
dentry
=
kern_path_create
(
AT_FDCWD
,
pathname
->
name
,
&
path
,
0
);
...
@@ -242,9 +230,8 @@ static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
...
@@ -242,9 +230,8 @@ static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
return
PTR_ERR
(
dentry
);
return
PTR_ERR
(
dentry
);
mode
=
S_IFREG
|
((
S_IRUSR
|
S_IWUSR
)
&
~
current_umask
());
mode
=
S_IFREG
|
((
S_IRUSR
|
S_IWUSR
)
&
~
current_umask
());
devt
=
MKDEV
(
UNNAMED_MAJOR
,
type
);
ret
=
security_path_mknod
(
&
path
,
dentry
,
mode
,
devt
);
ret
=
security_path_mknod
(
&
path
,
dentry
,
mode
,
0
);
if
(
ret
)
if
(
ret
)
goto
out
;
goto
out
;
...
@@ -254,9 +241,16 @@ static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
...
@@ -254,9 +241,16 @@ static int bpf_obj_do_pin(const struct filename *pathname, void *raw,
goto
out
;
goto
out
;
}
}
dentry
->
d_fsdata
=
raw
;
switch
(
type
)
{
ret
=
vfs_mknod
(
dir
,
dentry
,
mode
,
devt
);
case
BPF_TYPE_PROG
:
dentry
->
d_fsdata
=
NULL
;
ret
=
vfs_mkobj
(
dentry
,
mode
,
bpf_mkprog
,
raw
);
break
;
case
BPF_TYPE_MAP
:
ret
=
vfs_mkobj
(
dentry
,
mode
,
bpf_mkmap
,
raw
);
break
;
default:
ret
=
-
EPERM
;
}
out:
out:
done_path_create
(
&
path
,
dentry
);
done_path_create
(
&
path
,
dentry
);
return
ret
;
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录