Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
55669bfa
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 2 年 前同步成功
通知
173
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看板
提交
55669bfa
编写于
8月 31, 2006
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PATCH] audit: AUDIT_PERM support
add support for AUDIT_PERM predicate Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
dc104fb3
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
236 addition
and
0 deletion
+236
-0
arch/i386/kernel/audit.c
arch/i386/kernel/audit.c
+16
-0
arch/ia64/ia32/audit.c
arch/ia64/ia32/audit.c
+16
-0
arch/ia64/kernel/audit.c
arch/ia64/kernel/audit.c
+19
-0
arch/powerpc/kernel/audit.c
arch/powerpc/kernel/audit.c
+21
-0
arch/powerpc/kernel/compat_audit.c
arch/powerpc/kernel/compat_audit.c
+16
-0
arch/s390/kernel/audit.c
arch/s390/kernel/audit.c
+21
-0
arch/s390/kernel/compat_audit.c
arch/s390/kernel/compat_audit.c
+16
-0
arch/x86_64/ia32/audit.c
arch/x86_64/ia32/audit.c
+16
-0
arch/x86_64/kernel/audit.c
arch/x86_64/kernel/audit.c
+19
-0
include/linux/audit.h
include/linux/audit.h
+7
-0
kernel/audit.h
kernel/audit.h
+1
-0
kernel/auditfilter.c
kernel/auditfilter.c
+17
-0
kernel/auditsc.c
kernel/auditsc.c
+51
-0
未找到文件。
arch/i386/kernel/audit.c
浏览文件 @
55669bfa
...
@@ -23,6 +23,22 @@ static unsigned chattr_class[] = {
...
@@ -23,6 +23,22 @@ static unsigned chattr_class[] = {
~
0U
~
0U
};
};
int
audit_classify_syscall
(
int
abi
,
unsigned
syscall
)
{
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
0
;
}
}
static
int
__init
audit_classes_init
(
void
)
static
int
__init
audit_classes_init
(
void
)
{
{
audit_register_class
(
AUDIT_CLASS_WRITE
,
write_class
);
audit_register_class
(
AUDIT_CLASS_WRITE
,
write_class
);
...
...
arch/ia64/ia32/audit.c
浏览文件 @
55669bfa
...
@@ -19,3 +19,19 @@ unsigned ia32_read_class[] = {
...
@@ -19,3 +19,19 @@ unsigned ia32_read_class[] = {
#include <asm-generic/audit_read.h>
#include <asm-generic/audit_read.h>
~
0U
~
0U
};
};
int
ia32_classify_syscall
(
unsigned
syscall
)
{
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
1
;
}
}
arch/ia64/kernel/audit.c
浏览文件 @
55669bfa
...
@@ -23,6 +23,25 @@ static unsigned chattr_class[] = {
...
@@ -23,6 +23,25 @@ static unsigned chattr_class[] = {
~
0U
~
0U
};
};
int
audit_classify_syscall
(
int
abi
,
unsigned
syscall
)
{
#ifdef CONFIG_IA32_SUPPORT
extern
int
ia32_classify_syscall
(
unsigned
);
if
(
abi
==
AUDIT_ARCH_I386
)
return
ia32_classify_syscall
(
syscall
);
#endif
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_execve
:
return
5
;
default:
return
0
;
}
}
static
int
__init
audit_classes_init
(
void
)
static
int
__init
audit_classes_init
(
void
)
{
{
#ifdef CONFIG_IA32_SUPPORT
#ifdef CONFIG_IA32_SUPPORT
...
...
arch/powerpc/kernel/audit.c
浏览文件 @
55669bfa
...
@@ -23,6 +23,27 @@ static unsigned chattr_class[] = {
...
@@ -23,6 +23,27 @@ static unsigned chattr_class[] = {
~
0U
~
0U
};
};
int
audit_classify_syscall
(
int
abi
,
unsigned
syscall
)
{
#ifdef CONFIG_PPC64
extern
int
ppc32_classify_syscall
(
unsigned
);
if
(
abi
==
AUDIT_ARCH_PPC
)
return
ppc32_classify_syscall
(
syscall
);
#endif
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
0
;
}
}
static
int
__init
audit_classes_init
(
void
)
static
int
__init
audit_classes_init
(
void
)
{
{
#ifdef CONFIG_PPC64
#ifdef CONFIG_PPC64
...
...
arch/powerpc/kernel/compat_audit.c
浏览文件 @
55669bfa
...
@@ -20,3 +20,19 @@ unsigned ppc32_read_class[] = {
...
@@ -20,3 +20,19 @@ unsigned ppc32_read_class[] = {
#include <asm-generic/audit_read.h>
#include <asm-generic/audit_read.h>
~
0U
~
0U
};
};
int
ppc32_classify_syscall
(
unsigned
syscall
)
{
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
1
;
}
}
arch/s390/kernel/audit.c
浏览文件 @
55669bfa
...
@@ -23,6 +23,27 @@ static unsigned chattr_class[] = {
...
@@ -23,6 +23,27 @@ static unsigned chattr_class[] = {
~
0U
~
0U
};
};
int
audit_classify_syscall
(
int
abi
,
unsigned
syscall
)
{
#ifdef CONFIG_COMPAT
extern
int
s390_classify_syscall
(
unsigned
);
if
(
abi
==
AUDIT_ARCH_S390
)
return
s390_classify_syscall
(
syscall
);
#endif
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
0
;
}
}
static
int
__init
audit_classes_init
(
void
)
static
int
__init
audit_classes_init
(
void
)
{
{
#ifdef CONFIG_COMPAT
#ifdef CONFIG_COMPAT
...
...
arch/s390/kernel/compat_audit.c
浏览文件 @
55669bfa
...
@@ -20,3 +20,19 @@ unsigned s390_read_class[] = {
...
@@ -20,3 +20,19 @@ unsigned s390_read_class[] = {
#include <asm-generic/audit_read.h>
#include <asm-generic/audit_read.h>
~
0U
~
0U
};
};
int
s390_classify_syscall
(
unsigned
syscall
)
{
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
1
;
}
}
arch/x86_64/ia32/audit.c
浏览文件 @
55669bfa
...
@@ -19,3 +19,19 @@ unsigned ia32_read_class[] = {
...
@@ -19,3 +19,19 @@ unsigned ia32_read_class[] = {
#include <asm-generic/audit_read.h>
#include <asm-generic/audit_read.h>
~
0U
~
0U
};
};
int
ia32_classify_syscall
(
unsigned
syscall
)
{
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_socketcall
:
return
4
;
case
__NR_execve
:
return
5
;
default:
return
1
;
}
}
arch/x86_64/kernel/audit.c
浏览文件 @
55669bfa
...
@@ -23,6 +23,25 @@ static unsigned chattr_class[] = {
...
@@ -23,6 +23,25 @@ static unsigned chattr_class[] = {
~
0U
~
0U
};
};
int
audit_classify_syscall
(
int
abi
,
unsigned
syscall
)
{
#ifdef CONFIG_IA32_EMULATION
extern
int
ia32_classify_syscall
(
unsigned
);
if
(
abi
==
AUDIT_ARCH_I386
)
return
ia32_classify_syscall
(
syscall
);
#endif
switch
(
syscall
)
{
case
__NR_open
:
return
2
;
case
__NR_openat
:
return
3
;
case
__NR_execve
:
return
5
;
default:
return
0
;
}
}
static
int
__init
audit_classes_init
(
void
)
static
int
__init
audit_classes_init
(
void
)
{
{
#ifdef CONFIG_IA32_EMULATION
#ifdef CONFIG_IA32_EMULATION
...
...
include/linux/audit.h
浏览文件 @
55669bfa
...
@@ -181,6 +181,7 @@
...
@@ -181,6 +181,7 @@
#define AUDIT_EXIT 103
#define AUDIT_EXIT 103
#define AUDIT_SUCCESS 104
/* exit >= 0; value ignored */
#define AUDIT_SUCCESS 104
/* exit >= 0; value ignored */
#define AUDIT_WATCH 105
#define AUDIT_WATCH 105
#define AUDIT_PERM 106
#define AUDIT_ARG0 200
#define AUDIT_ARG0 200
#define AUDIT_ARG1 (AUDIT_ARG0+1)
#define AUDIT_ARG1 (AUDIT_ARG0+1)
...
@@ -256,6 +257,11 @@
...
@@ -256,6 +257,11 @@
#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE)
#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE)
#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
#define AUDIT_PERM_EXEC 1
#define AUDIT_PERM_WRITE 2
#define AUDIT_PERM_READ 4
#define AUDIT_PERM_ATTR 8
struct
audit_status
{
struct
audit_status
{
__u32
mask
;
/* Bit mask for valid entries */
__u32
mask
;
/* Bit mask for valid entries */
__u32
enabled
;
/* 1 = enabled, 0 = disabled */
__u32
enabled
;
/* 1 = enabled, 0 = disabled */
...
@@ -318,6 +324,7 @@ struct mqstat;
...
@@ -318,6 +324,7 @@ struct mqstat;
#define AUDITSC_FAILURE 2
#define AUDITSC_FAILURE 2
#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
extern
int
__init
audit_register_class
(
int
class
,
unsigned
*
list
);
extern
int
__init
audit_register_class
(
int
class
,
unsigned
*
list
);
extern
int
audit_classify_syscall
(
int
abi
,
unsigned
syscall
);
#ifdef CONFIG_AUDITSYSCALL
#ifdef CONFIG_AUDITSYSCALL
/* These are defined in auditsc.c */
/* These are defined in auditsc.c */
/* Public API */
/* Public API */
...
...
kernel/audit.h
浏览文件 @
55669bfa
...
@@ -104,6 +104,7 @@ static inline int audit_hash_ino(u32 ino)
...
@@ -104,6 +104,7 @@ static inline int audit_hash_ino(u32 ino)
return
(
ino
&
(
AUDIT_INODE_BUCKETS
-
1
));
return
(
ino
&
(
AUDIT_INODE_BUCKETS
-
1
));
}
}
extern
int
audit_match_class
(
int
class
,
unsigned
syscall
);
extern
int
audit_comparator
(
const
u32
left
,
const
u32
op
,
const
u32
right
);
extern
int
audit_comparator
(
const
u32
left
,
const
u32
op
,
const
u32
right
);
extern
int
audit_compare_dname_path
(
const
char
*
dname
,
const
char
*
path
,
extern
int
audit_compare_dname_path
(
const
char
*
dname
,
const
char
*
path
,
int
*
dirlen
);
int
*
dirlen
);
...
...
kernel/auditfilter.c
浏览文件 @
55669bfa
...
@@ -302,6 +302,15 @@ int __init audit_register_class(int class, unsigned *list)
...
@@ -302,6 +302,15 @@ int __init audit_register_class(int class, unsigned *list)
return
0
;
return
0
;
}
}
int
audit_match_class
(
int
class
,
unsigned
syscall
)
{
if
(
unlikely
(
syscall
>=
AUDIT_BITMASK_SIZE
*
sizeof
(
__u32
)))
return
0
;
if
(
unlikely
(
class
>=
AUDIT_SYSCALL_CLASSES
||
!
classes
[
class
]))
return
0
;
return
classes
[
class
][
AUDIT_WORD
(
syscall
)]
&
AUDIT_BIT
(
syscall
);
}
/* Common user-space to kernel rule translation. */
/* Common user-space to kernel rule translation. */
static
inline
struct
audit_entry
*
audit_to_entry_common
(
struct
audit_rule
*
rule
)
static
inline
struct
audit_entry
*
audit_to_entry_common
(
struct
audit_rule
*
rule
)
{
{
...
@@ -414,6 +423,10 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
...
@@ -414,6 +423,10 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
case
AUDIT_ARG2
:
case
AUDIT_ARG2
:
case
AUDIT_ARG3
:
case
AUDIT_ARG3
:
break
;
break
;
case
AUDIT_PERM
:
if
(
f
->
val
&
~
15
)
goto
exit_free
;
break
;
case
AUDIT_INODE
:
case
AUDIT_INODE
:
err
=
audit_to_inode
(
&
entry
->
rule
,
f
);
err
=
audit_to_inode
(
&
entry
->
rule
,
f
);
if
(
err
)
if
(
err
)
...
@@ -568,6 +581,10 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
...
@@ -568,6 +581,10 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
entry
->
rule
.
buflen
+=
f
->
val
;
entry
->
rule
.
buflen
+=
f
->
val
;
entry
->
rule
.
filterkey
=
str
;
entry
->
rule
.
filterkey
=
str
;
break
;
break
;
case
AUDIT_PERM
:
if
(
f
->
val
&
~
15
)
goto
exit_free
;
break
;
default:
default:
goto
exit_free
;
goto
exit_free
;
}
}
...
...
kernel/auditsc.c
浏览文件 @
55669bfa
...
@@ -209,6 +209,54 @@ struct audit_context {
...
@@ -209,6 +209,54 @@ struct audit_context {
#endif
#endif
};
};
#define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
static
inline
int
open_arg
(
int
flags
,
int
mask
)
{
int
n
=
ACC_MODE
(
flags
);
if
(
flags
&
(
O_TRUNC
|
O_CREAT
))
n
|=
AUDIT_PERM_WRITE
;
return
n
&
mask
;
}
static
int
audit_match_perm
(
struct
audit_context
*
ctx
,
int
mask
)
{
unsigned
n
=
ctx
->
major
;
switch
(
audit_classify_syscall
(
ctx
->
arch
,
n
))
{
case
0
:
/* native */
if
((
mask
&
AUDIT_PERM_WRITE
)
&&
audit_match_class
(
AUDIT_CLASS_WRITE
,
n
))
return
1
;
if
((
mask
&
AUDIT_PERM_READ
)
&&
audit_match_class
(
AUDIT_CLASS_READ
,
n
))
return
1
;
if
((
mask
&
AUDIT_PERM_ATTR
)
&&
audit_match_class
(
AUDIT_CLASS_CHATTR
,
n
))
return
1
;
return
0
;
case
1
:
/* 32bit on biarch */
if
((
mask
&
AUDIT_PERM_WRITE
)
&&
audit_match_class
(
AUDIT_CLASS_WRITE_32
,
n
))
return
1
;
if
((
mask
&
AUDIT_PERM_READ
)
&&
audit_match_class
(
AUDIT_CLASS_READ_32
,
n
))
return
1
;
if
((
mask
&
AUDIT_PERM_ATTR
)
&&
audit_match_class
(
AUDIT_CLASS_CHATTR_32
,
n
))
return
1
;
return
0
;
case
2
:
/* open */
return
mask
&
ACC_MODE
(
ctx
->
argv
[
1
]);
case
3
:
/* openat */
return
mask
&
ACC_MODE
(
ctx
->
argv
[
2
]);
case
4
:
/* socketcall */
return
((
mask
&
AUDIT_PERM_WRITE
)
&&
ctx
->
argv
[
0
]
==
SYS_BIND
);
case
5
:
/* execve */
return
mask
&
AUDIT_PERM_EXEC
;
default:
return
0
;
}
}
/* Determine if any context name data matches a rule's watch data */
/* Determine if any context name data matches a rule's watch data */
/* Compare a task_struct with an audit_rule. Return 1 on match, 0
/* Compare a task_struct with an audit_rule. Return 1 on match, 0
* otherwise. */
* otherwise. */
...
@@ -397,6 +445,9 @@ static int audit_filter_rules(struct task_struct *tsk,
...
@@ -397,6 +445,9 @@ static int audit_filter_rules(struct task_struct *tsk,
/* ignore this field for filtering */
/* ignore this field for filtering */
result
=
1
;
result
=
1
;
break
;
break
;
case
AUDIT_PERM
:
result
=
audit_match_perm
(
ctx
,
f
->
val
);
break
;
}
}
if
(
!
result
)
if
(
!
result
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录