Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
317d9a05
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
317d9a05
编写于
6月 09, 2017
作者:
J
John Johansen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
apparmor: update query interface to support label queries
Signed-off-by:
N
John Johansen
<
john.johansen@canonical.com
>
上级
76a1d263
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
7 deletion
+39
-7
security/apparmor/apparmorfs.c
security/apparmor/apparmorfs.c
+39
-7
未找到文件。
security/apparmor/apparmorfs.c
浏览文件 @
317d9a05
...
...
@@ -33,6 +33,7 @@
#include "include/context.h"
#include "include/crypto.h"
#include "include/policy_ns.h"
#include "include/label.h"
#include "include/policy.h"
#include "include/policy_ns.h"
#include "include/resource.h"
...
...
@@ -629,6 +630,7 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
tmp
=
nullperms
;
}
aa_apply_modes_to_perms
(
profile
,
&
tmp
);
aa_perms_accum_raw
(
perms
,
&
tmp
);
}
...
...
@@ -655,7 +657,9 @@ static ssize_t query_data(char *buf, size_t buf_len,
{
char
*
out
;
const
char
*
key
;
struct
label_it
i
;
struct
aa_label
*
label
,
*
curr
;
struct
aa_profile
*
profile
;
struct
aa_data
*
data
;
u32
bytes
,
blocks
;
__le32
outle32
;
...
...
@@ -690,13 +694,16 @@ static ssize_t query_data(char *buf, size_t buf_len,
out
=
buf
+
sizeof
(
bytes
)
+
sizeof
(
blocks
);
blocks
=
0
;
if
(
labels_profile
(
label
)
->
data
)
{
data
=
rhashtable_lookup_fast
(
labels_profile
(
label
)
->
data
,
&
key
,
labels_profile
(
label
)
->
data
->
p
);
label_for_each_confined
(
i
,
label
,
profile
)
{
if
(
!
profile
->
data
)
continue
;
data
=
rhashtable_lookup_fast
(
profile
->
data
,
&
key
,
profile
->
data
->
p
);
if
(
data
)
{
if
(
out
+
sizeof
(
outle32
)
+
data
->
size
>
buf
+
buf
_len
)
{
if
(
out
+
sizeof
(
outle32
)
+
data
->
size
>
buf
+
buf_len
)
{
aa_put_label
(
label
);
return
-
EINVAL
;
/* not enough space */
}
...
...
@@ -741,10 +748,12 @@ static ssize_t query_data(char *buf, size_t buf_len,
static
ssize_t
query_label
(
char
*
buf
,
size_t
buf_len
,
char
*
query
,
size_t
query_len
,
bool
view_only
)
{
struct
aa_profile
*
profile
;
struct
aa_label
*
label
,
*
curr
;
char
*
label_name
,
*
match_str
;
size_t
label_name_len
,
match_len
;
struct
aa_perms
perms
;
struct
label_it
i
;
if
(
!
query_len
)
return
-
EINVAL
;
...
...
@@ -770,7 +779,16 @@ static ssize_t query_label(char *buf, size_t buf_len,
return
PTR_ERR
(
label
);
perms
=
allperms
;
profile_query_cb
(
labels_profile
(
label
),
&
perms
,
match_str
,
match_len
);
if
(
view_only
)
{
label_for_each_in_ns
(
i
,
labels_ns
(
label
),
label
,
profile
)
{
profile_query_cb
(
profile
,
&
perms
,
match_str
,
match_len
);
}
}
else
{
label_for_each
(
i
,
label
,
profile
)
{
profile_query_cb
(
profile
,
&
perms
,
match_str
,
match_len
);
}
}
aa_put_label
(
label
);
return
scnprintf
(
buf
,
buf_len
,
"allow 0x%08x
\n
deny 0x%08x
\n
audit 0x%08x
\n
quiet 0x%08x
\n
"
,
...
...
@@ -877,9 +895,12 @@ static int multi_transaction_release(struct inode *inode, struct file *file)
return
0
;
}
#define QUERY_CMD_LABEL "label\0"
#define QUERY_CMD_LABEL_LEN 6
#define QUERY_CMD_PROFILE "profile\0"
#define QUERY_CMD_PROFILE_LEN 8
#define QUERY_CMD_LABELALL "labelall\0"
#define QUERY_CMD_LABELALL_LEN 9
#define QUERY_CMD_DATA "data\0"
#define QUERY_CMD_DATA_LEN 5
...
...
@@ -922,6 +943,17 @@ static ssize_t aa_write_access(struct file *file, const char __user *ubuf,
len
=
query_label
(
t
->
data
,
MULTI_TRANSACTION_LIMIT
,
t
->
data
+
QUERY_CMD_PROFILE_LEN
,
count
-
QUERY_CMD_PROFILE_LEN
,
true
);
}
else
if
(
count
>
QUERY_CMD_LABEL_LEN
&&
!
memcmp
(
t
->
data
,
QUERY_CMD_LABEL
,
QUERY_CMD_LABEL_LEN
))
{
len
=
query_label
(
t
->
data
,
MULTI_TRANSACTION_LIMIT
,
t
->
data
+
QUERY_CMD_LABEL_LEN
,
count
-
QUERY_CMD_LABEL_LEN
,
true
);
}
else
if
(
count
>
QUERY_CMD_LABELALL_LEN
&&
!
memcmp
(
t
->
data
,
QUERY_CMD_LABELALL
,
QUERY_CMD_LABELALL_LEN
))
{
len
=
query_label
(
t
->
data
,
MULTI_TRANSACTION_LIMIT
,
t
->
data
+
QUERY_CMD_LABELALL_LEN
,
count
-
QUERY_CMD_LABELALL_LEN
,
false
);
}
else
if
(
count
>
QUERY_CMD_DATA_LEN
&&
!
memcmp
(
t
->
data
,
QUERY_CMD_DATA
,
QUERY_CMD_DATA_LEN
))
{
len
=
query_data
(
t
->
data
,
MULTI_TRANSACTION_LIMIT
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录