Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
aeda4ac3
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aeda4ac3
编写于
1月 10, 2011
作者:
J
James Morris
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
git://git.infradead.org/users/eparis/selinux
into next
上级
d2e7ad19
350e4f31
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
944 addition
and
931 deletion
+944
-931
include/linux/flex_array.h
include/linux/flex_array.h
+1
-1
security/selinux/hooks.c
security/selinux/hooks.c
+4
-1
security/selinux/nlmsgtab.c
security/selinux/nlmsgtab.c
+2
-0
security/selinux/selinuxfs.c
security/selinux/selinuxfs.c
+311
-338
security/selinux/ss/conditional.c
security/selinux/ss/conditional.c
+5
-1
security/selinux/ss/mls.c
security/selinux/ss/mls.c
+13
-12
security/selinux/ss/policydb.c
security/selinux/ss/policydb.c
+351
-350
security/selinux/ss/policydb.h
security/selinux/ss/policydb.h
+9
-10
security/selinux/ss/services.c
security/selinux/ss/services.c
+209
-216
security/selinux/ss/sidtab.c
security/selinux/ss/sidtab.c
+37
-2
security/selinux/ss/sidtab.h
security/selinux/ss/sidtab.h
+2
-0
未找到文件。
include/linux/flex_array.h
浏览文件 @
aeda4ac3
...
...
@@ -71,7 +71,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr);
int
flex_array_shrink
(
struct
flex_array
*
fa
);
#define flex_array_put_ptr(fa, nr, src, gfp) \
flex_array_put(fa, nr,
&(void *)
(src), gfp)
flex_array_put(fa, nr,
(void *)&
(src), gfp)
void
*
flex_array_get_ptr
(
struct
flex_array
*
fa
,
unsigned
int
element_nr
);
...
...
security/selinux/hooks.c
浏览文件 @
aeda4ac3
...
...
@@ -2525,7 +2525,10 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
sid
=
tsec
->
sid
;
newsid
=
tsec
->
create_sid
;
if
(
!
newsid
||
!
(
sbsec
->
flags
&
SE_SBLABELSUPP
))
{
if
((
sbsec
->
flags
&
SE_SBINITIALIZED
)
&&
(
sbsec
->
behavior
==
SECURITY_FS_USE_MNTPOINT
))
newsid
=
sbsec
->
mntpoint_sid
;
else
if
(
!
newsid
||
!
(
sbsec
->
flags
&
SE_SBLABELSUPP
))
{
rc
=
security_transition_sid
(
sid
,
dsec
->
sid
,
inode_mode_to_security_class
(
inode
->
i_mode
),
&
newsid
);
...
...
security/selinux/nlmsgtab.c
浏览文件 @
aeda4ac3
...
...
@@ -65,6 +65,8 @@ static struct nlmsg_perm nlmsg_route_perms[] =
{
RTM_NEWADDRLABEL
,
NETLINK_ROUTE_SOCKET__NLMSG_WRITE
},
{
RTM_DELADDRLABEL
,
NETLINK_ROUTE_SOCKET__NLMSG_WRITE
},
{
RTM_GETADDRLABEL
,
NETLINK_ROUTE_SOCKET__NLMSG_READ
},
{
RTM_GETDCB
,
NETLINK_ROUTE_SOCKET__NLMSG_READ
},
{
RTM_SETDCB
,
NETLINK_ROUTE_SOCKET__NLMSG_WRITE
},
};
static
struct
nlmsg_perm
nlmsg_firewall_perms
[]
=
...
...
security/selinux/selinuxfs.c
浏览文件 @
aeda4ac3
此差异已折叠。
点击以展开。
security/selinux/ss/conditional.c
浏览文件 @
aeda4ac3
...
...
@@ -193,6 +193,7 @@ int cond_index_bool(void *key, void *datum, void *datap)
{
struct
policydb
*
p
;
struct
cond_bool_datum
*
booldatum
;
struct
flex_array
*
fa
;
booldatum
=
datum
;
p
=
datap
;
...
...
@@ -200,7 +201,10 @@ int cond_index_bool(void *key, void *datum, void *datap)
if
(
!
booldatum
->
value
||
booldatum
->
value
>
p
->
p_bools
.
nprim
)
return
-
EINVAL
;
p
->
p_bool_val_to_name
[
booldatum
->
value
-
1
]
=
key
;
fa
=
p
->
sym_val_to_name
[
SYM_BOOLS
];
if
(
flex_array_put_ptr
(
fa
,
booldatum
->
value
-
1
,
key
,
GFP_KERNEL
|
__GFP_ZERO
))
BUG
();
p
->
bool_val_to_struct
[
booldatum
->
value
-
1
]
=
booldatum
;
return
0
;
...
...
security/selinux/ss/mls.c
浏览文件 @
aeda4ac3
...
...
@@ -45,7 +45,7 @@ int mls_compute_context_len(struct context *context)
len
=
1
;
/* for the beginning ":" */
for
(
l
=
0
;
l
<
2
;
l
++
)
{
int
index_sens
=
context
->
range
.
level
[
l
].
sens
;
len
+=
strlen
(
policydb
.
p_sens_val_to_name
[
index_sens
-
1
]
);
len
+=
strlen
(
sym_name
(
&
policydb
,
SYM_LEVELS
,
index_sens
-
1
)
);
/* categories */
head
=
-
2
;
...
...
@@ -55,17 +55,17 @@ int mls_compute_context_len(struct context *context)
if
(
i
-
prev
>
1
)
{
/* one or more negative bits are skipped */
if
(
head
!=
prev
)
{
nm
=
policydb
.
p_cat_val_to_name
[
prev
]
;
nm
=
sym_name
(
&
policydb
,
SYM_CATS
,
prev
)
;
len
+=
strlen
(
nm
)
+
1
;
}
nm
=
policydb
.
p_cat_val_to_name
[
i
]
;
nm
=
sym_name
(
&
policydb
,
SYM_CATS
,
i
)
;
len
+=
strlen
(
nm
)
+
1
;
head
=
i
;
}
prev
=
i
;
}
if
(
prev
!=
head
)
{
nm
=
policydb
.
p_cat_val_to_name
[
prev
]
;
nm
=
sym_name
(
&
policydb
,
SYM_CATS
,
prev
)
;
len
+=
strlen
(
nm
)
+
1
;
}
if
(
l
==
0
)
{
...
...
@@ -102,8 +102,8 @@ void mls_sid_to_context(struct context *context,
scontextp
++
;
for
(
l
=
0
;
l
<
2
;
l
++
)
{
strcpy
(
scontextp
,
policydb
.
p_sens_val_to_name
[
context
->
range
.
level
[
l
].
sens
-
1
]
);
strcpy
(
scontextp
,
sym_name
(
&
policydb
,
SYM_LEVELS
,
context
->
range
.
level
[
l
].
sens
-
1
)
);
scontextp
+=
strlen
(
scontextp
);
/* categories */
...
...
@@ -118,7 +118,7 @@ void mls_sid_to_context(struct context *context,
*
scontextp
++
=
'.'
;
else
*
scontextp
++
=
','
;
nm
=
policydb
.
p_cat_val_to_name
[
prev
]
;
nm
=
sym_name
(
&
policydb
,
SYM_CATS
,
prev
)
;
strcpy
(
scontextp
,
nm
);
scontextp
+=
strlen
(
nm
);
}
...
...
@@ -126,7 +126,7 @@ void mls_sid_to_context(struct context *context,
*
scontextp
++
=
':'
;
else
*
scontextp
++
=
','
;
nm
=
policydb
.
p_cat_val_to_name
[
i
]
;
nm
=
sym_name
(
&
policydb
,
SYM_CATS
,
i
)
;
strcpy
(
scontextp
,
nm
);
scontextp
+=
strlen
(
nm
);
head
=
i
;
...
...
@@ -139,7 +139,7 @@ void mls_sid_to_context(struct context *context,
*
scontextp
++
=
'.'
;
else
*
scontextp
++
=
','
;
nm
=
policydb
.
p_cat_val_to_name
[
prev
]
;
nm
=
sym_name
(
&
policydb
,
SYM_CATS
,
prev
)
;
strcpy
(
scontextp
,
nm
);
scontextp
+=
strlen
(
nm
);
}
...
...
@@ -166,7 +166,7 @@ int mls_level_isvalid(struct policydb *p, struct mls_level *l)
if
(
!
l
->
sens
||
l
->
sens
>
p
->
p_levels
.
nprim
)
return
0
;
levdatum
=
hashtab_search
(
p
->
p_levels
.
table
,
p
->
p_sens_val_to_name
[
l
->
sens
-
1
]
);
sym_name
(
p
,
SYM_LEVELS
,
l
->
sens
-
1
)
);
if
(
!
levdatum
)
return
0
;
...
...
@@ -482,7 +482,8 @@ int mls_convert_context(struct policydb *oldp,
for
(
l
=
0
;
l
<
2
;
l
++
)
{
levdatum
=
hashtab_search
(
newp
->
p_levels
.
table
,
oldp
->
p_sens_val_to_name
[
c
->
range
.
level
[
l
].
sens
-
1
]);
sym_name
(
oldp
,
SYM_LEVELS
,
c
->
range
.
level
[
l
].
sens
-
1
));
if
(
!
levdatum
)
return
-
EINVAL
;
...
...
@@ -493,7 +494,7 @@ int mls_convert_context(struct policydb *oldp,
int
rc
;
catdatum
=
hashtab_search
(
newp
->
p_cats
.
table
,
oldp
->
p_cat_val_to_name
[
i
]
);
sym_name
(
oldp
,
SYM_CATS
,
i
)
);
if
(
!
catdatum
)
return
-
EINVAL
;
rc
=
ebitmap_set_bit
(
&
bitmap
,
catdatum
->
value
-
1
,
1
);
...
...
security/selinux/ss/policydb.c
浏览文件 @
aeda4ac3
此差异已折叠。
点击以展开。
security/selinux/ss/policydb.h
浏览文件 @
aeda4ac3
...
...
@@ -203,21 +203,13 @@ struct policydb {
#define p_cats symtab[SYM_CATS]
/* symbol names indexed by (value - 1) */
char
**
sym_val_to_name
[
SYM_NUM
];
#define p_common_val_to_name sym_val_to_name[SYM_COMMONS]
#define p_class_val_to_name sym_val_to_name[SYM_CLASSES]
#define p_role_val_to_name sym_val_to_name[SYM_ROLES]
#define p_type_val_to_name sym_val_to_name[SYM_TYPES]
#define p_user_val_to_name sym_val_to_name[SYM_USERS]
#define p_bool_val_to_name sym_val_to_name[SYM_BOOLS]
#define p_sens_val_to_name sym_val_to_name[SYM_LEVELS]
#define p_cat_val_to_name sym_val_to_name[SYM_CATS]
struct
flex_array
*
sym_val_to_name
[
SYM_NUM
];
/* class, role, and user attributes indexed by (value - 1) */
struct
class_datum
**
class_val_to_struct
;
struct
role_datum
**
role_val_to_struct
;
struct
user_datum
**
user_val_to_struct
;
struct
type_datum
**
type_val_to_struct
;
struct
flex_array
*
type_val_to_struct_array
;
/* type enforcement access vectors and transitions */
struct
avtab
te_avtab
;
...
...
@@ -321,6 +313,13 @@ static inline int put_entry(void *buf, size_t bytes, int num, struct policy_file
return
0
;
}
static
inline
char
*
sym_name
(
struct
policydb
*
p
,
unsigned
int
sym_num
,
unsigned
int
element_nr
)
{
struct
flex_array
*
fa
=
p
->
sym_val_to_name
[
sym_num
];
return
flex_array_get_ptr
(
fa
,
element_nr
);
}
extern
u16
string_to_security_class
(
struct
policydb
*
p
,
const
char
*
name
);
extern
u32
string_to_av_perm
(
struct
policydb
*
p
,
u16
tclass
,
const
char
*
name
);
...
...
security/selinux/ss/services.c
浏览文件 @
aeda4ac3
此差异已折叠。
点击以展开。
security/selinux/ss/sidtab.c
浏览文件 @
aeda4ac3
...
...
@@ -147,6 +147,17 @@ int sidtab_map(struct sidtab *s,
return
rc
;
}
static
void
sidtab_update_cache
(
struct
sidtab
*
s
,
struct
sidtab_node
*
n
,
int
loc
)
{
BUG_ON
(
loc
>=
SIDTAB_CACHE_LEN
);
while
(
loc
>
0
)
{
s
->
cache
[
loc
]
=
s
->
cache
[
loc
-
1
];
loc
--
;
}
s
->
cache
[
0
]
=
n
;
}
static
inline
u32
sidtab_search_context
(
struct
sidtab
*
s
,
struct
context
*
context
)
{
...
...
@@ -156,14 +167,33 @@ static inline u32 sidtab_search_context(struct sidtab *s,
for
(
i
=
0
;
i
<
SIDTAB_SIZE
;
i
++
)
{
cur
=
s
->
htable
[
i
];
while
(
cur
)
{
if
(
context_cmp
(
&
cur
->
context
,
context
))
if
(
context_cmp
(
&
cur
->
context
,
context
))
{
sidtab_update_cache
(
s
,
cur
,
SIDTAB_CACHE_LEN
-
1
);
return
cur
->
sid
;
}
cur
=
cur
->
next
;
}
}
return
0
;
}
static
inline
u32
sidtab_search_cache
(
struct
sidtab
*
s
,
struct
context
*
context
)
{
int
i
;
struct
sidtab_node
*
node
;
for
(
i
=
0
;
i
<
SIDTAB_CACHE_LEN
;
i
++
)
{
node
=
s
->
cache
[
i
];
if
(
unlikely
(
!
node
))
return
0
;
if
(
context_cmp
(
&
node
->
context
,
context
))
{
sidtab_update_cache
(
s
,
node
,
i
);
return
node
->
sid
;
}
}
return
0
;
}
int
sidtab_context_to_sid
(
struct
sidtab
*
s
,
struct
context
*
context
,
u32
*
out_sid
)
...
...
@@ -174,7 +204,9 @@ int sidtab_context_to_sid(struct sidtab *s,
*
out_sid
=
SECSID_NULL
;
sid
=
sidtab_search_context
(
s
,
context
);
sid
=
sidtab_search_cache
(
s
,
context
);
if
(
!
sid
)
sid
=
sidtab_search_context
(
s
,
context
);
if
(
!
sid
)
{
spin_lock_irqsave
(
&
s
->
lock
,
flags
);
/* Rescan now that we hold the lock. */
...
...
@@ -259,12 +291,15 @@ void sidtab_destroy(struct sidtab *s)
void
sidtab_set
(
struct
sidtab
*
dst
,
struct
sidtab
*
src
)
{
unsigned
long
flags
;
int
i
;
spin_lock_irqsave
(
&
src
->
lock
,
flags
);
dst
->
htable
=
src
->
htable
;
dst
->
nel
=
src
->
nel
;
dst
->
next_sid
=
src
->
next_sid
;
dst
->
shutdown
=
0
;
for
(
i
=
0
;
i
<
SIDTAB_CACHE_LEN
;
i
++
)
dst
->
cache
[
i
]
=
NULL
;
spin_unlock_irqrestore
(
&
src
->
lock
,
flags
);
}
...
...
security/selinux/ss/sidtab.h
浏览文件 @
aeda4ac3
...
...
@@ -26,6 +26,8 @@ struct sidtab {
unsigned
int
nel
;
/* number of elements */
unsigned
int
next_sid
;
/* next SID to allocate */
unsigned
char
shutdown
;
#define SIDTAB_CACHE_LEN 3
struct
sidtab_node
*
cache
[
SIDTAB_CACHE_LEN
];
spinlock_t
lock
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录