






















On Tuesday 19 April 2005 11:23, Steve Grubb wrote:
I wanted to start a discussion about an old topic that we last discussed
back in December. The problem basically centers around the audit message
type being too coarse to be of any real use.
Attached is my current working patch for people to review and comment on. It
is not a final patch. I still need to review all messages to ensure we have
everything that its supposed to be. The patch is against the .31 kernel will
all my previous patches applied.
If there are no objections or concerns, I will finalize this patch and release
matching user space tools.
-Steve
diff -ur linux-2.6.9.orig/include/linux/audit.h linux-2.6.9/include/linux/audit.h
--- linux-2.6.9.orig/include/linux/audit.h 2005-05-10 08:24:41.000000000 -0400
+++ linux-2.6.9/include/linux/audit.h 2005-05-10 08:24:11.000000000 -0400
@@ -34,18 +34,52 @@
struct atomic_t;
-/* Request and reply types /
+/ The netlink messages for the audit system is divided into blocks:
-#define AUDIT_LOGIN 1006 /* Define the login id and information /
+#define AUDIT_LOGIN 1006 / /proc/pid/loginuid change event */
-#define AUDIT_SIGNAL_INFO 1010 /* Get information about sender of signal/
+#define AUDIT_SIGNAL_INFO 1010 / Get info about sender of signal/
+
+#define AUDIT_USER_AUTH 1100 / User space authentication /
+#define AUDIT_USER_ACCT 1101 / User space acct change /
+#define AUDIT_USER_MGMT 1102 / User space acct management /
+#define AUDIT_CRED_ACQ 1103 / User space credential acquired /
+#define AUDIT_CRED_DISP 1104 / User space credential disposed /
+#define AUDIT_USER_START 1105 / User space session start /
+#define AUDIT_USER_END 1106 / User space session end /
+
+#define AUDIT_DAEMON_START 1200 / Daemon startup record /
+#define AUDIT_DAEMON_END 1201 / Daemon normal stop record /
+#define AUDIT_DAEMON_ABORT 1202 / Daemon error stop record /
+#define AUDIT_DAEMON_CONFIG 1203 / Daemon config change /
+
+#define AUDIT_SYSCALL 1300 / Syscall event /
+#define AUDIT_FS_WATCH 1301 / Filesystem watch event /
+#define AUDIT_PATH 1302 / Filname path information /
+#define AUDIT_IPC 1303 / IPC record /
+#define AUDIT_SOCKET 1304 / Socket record /
+#define AUDIT_CONFIG_CHANGE 1305 / Audit system configuration change /
+
+#define AUDIT_AVC 1400 / SE Linux avc denial or grant /
+#define AUDIT_SELINUX_ERR 1401 / Internal SE Linux Errors */
@@ -284,11 +318,11 @@
/* These are defined in audit.c /
/ Public API */
-extern void audit_log(struct audit_context *ctx,
+extern void audit_log(struct audit_context *ctx, int type,
const char *fmt, ...)
-extern struct audit_buffer *audit_log_start(struct audit_context *ctx);
+extern struct audit_buffer *audit_log_start(struct audit_context *ctx,int type);
extern void audit_log_format(struct audit_buffer *ab,
const char *fmt, ...)
attribute((format(printf,2,3)));
@@ -314,8 +348,8 @@
void *payload, int size);
extern void audit_log_lost(const char *message);
-#define audit_log(t,f,...) do { ; } while (0)
-#define audit_log_start(t) ({ NULL; })
+#define audit_log(c,t,f,...) do { ; } while (0)
+#define audit_log_start(c,t) ({ NULL; })
diff -ur linux-2.6.9.orig/kernel/audit.c linux-2.6.9/kernel/audit.c
--- linux-2.6.9.orig/kernel/audit.c 2005-05-10 08:24:46.000000000 -0400
+++ linux-2.6.9/kernel/audit.c 2005-05-10 08:24:11.000000000 -0400
@@ -242,7 +242,8 @@
{
int old = audit_rate_limit;
audit_rate_limit = limit;
@@ -275,8 +278,9 @@
&& state != AUDIT_FAIL_PANIC)
return -EINVAL;
audit_failure = state;
@@ -387,7 +391,8 @@
if (status_get->mask & AUDIT_STATUS_PID) {
int old = audit_pid;
audit_pid = status_get->pid;
audit_set_type(ab, AUDIT_USER);
audit_set_pid(ab, pid);
audit_log_end(ab);
break;
@@ -538,7 +542,7 @@
audit_initialized = 1;
audit_enabled = audit_default;
audit_log(NULL, "initialized");
@@ -565,7 +569,7 @@
audit_initialized = 1;
audit_enabled = audit_default;
@@ -605,7 +609,7 @@
}
static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
int gfp_mask, int type)
{
unsigned long flags;
struct audit_buffer *ab = NULL;
@@ -633,7 +637,7 @@
ab->ctx = ctx;
nlh = (struct nlmsghdr *)skb_put(ab->skb, NLMSG_SPACE(0));
ab = audit_log_start(ctx, type);
if (ab) {
va_start(args, fmt);
audit_log_vformat(ab, fmt, args);
diff -ur linux-2.6.9.orig/kernel/auditfs.c linux-2.6.9/kernel/auditfs.c
--- linux-2.6.9.orig/kernel/auditfs.c 2005-05-10 08:24:46.000000000 -0400
+++ linux-2.6.9/kernel/auditfs.c 2005-05-10 08:24:11.000000000 -0400
@@ -384,7 +384,8 @@
/* __d_lookup will attach the audit data, if nd.last exists. */
dput(d_lookup(nd.dentry, &nd.last));
audit_insert_watch_release:
path_release(&nd);
@@ -418,7 +419,8 @@
audit_destroy_wentry(wentry);
audit_wentry_put(wentry);
write_unlock(&data->lock);
audit_log(NULL, AUDIT_CONFIG_CHANGE, "auid %u removed a watch\n",
loginuid);
ret = 0;
diff -ur linux-2.6.9.orig/kernel/auditsc.c linux-2.6.9/kernel/auditsc.c
--- linux-2.6.9.orig/kernel/auditsc.c 2005-05-10 08:24:46.000000000 -0400
+++ linux-2.6.9/kernel/auditsc.c 2005-05-10 08:24:11.000000000 -0400
@@ -298,7 +298,8 @@
err = audit_add_rule(entry, &audit_entlist);
if (!err && (flags & AUDIT_AT_EXIT))
err = audit_add_rule(entry, &audit_extlist);
+extern void audit_set_type(struct audit_buffer *ab, int type);
+
static void audit_log_exit(struct audit_context *context)
{
int i;
struct audit_buffer *ab;
@@ -705,6 +709,8 @@
switch (aux->type) {
case AUDIT_AUX_IPCPERM: {
struct audit_aux_data_ipcctl *axi = (void *)aux;
+
audit_set_type(ab, AUDIT_IPC);
audit_log_format(ab,
" qbytes=%lx uid=%d gid=%d mode=%x",
axi->qbytes, axi->uid, axi->gid, axi->mode);
@@ -713,6 +719,7 @@
case AUDIT_AUX_WATCH: {
struct audit_aux_data_watched *axi = (void *)aux;
audit_set_type(ab, AUDIT_FS_WATCH);
audit_log_format(ab, " watch=");
audit_log_untrustedstring(ab, axi->wentry->w_watch->name);
audit_log_format(ab,
@@ -733,7 +740,7 @@
}
for (i = 0; i < context->name_count; i++) {
int audit_set_loginuid(struct task_struct *task, uid_t loginuid)
{
if (task->audit_context) {
struct audit_buffer *ab;
audit_set_type(ab, AUDIT_LOGIN);
audit_log_end(ab);
}
task->audit_context->loginuid = loginuid;
diff -ur linux-2.6.9.orig/security/selinux/avc.c linux-2.6.9/security/selinux/avc.c
--- linux-2.6.9.orig/security/selinux/avc.c 2005-05-10 08:24:51.000000000 -0400
+++ linux-2.6.9/security/selinux/avc.c 2005-05-10 08:24:11.000000000 -0400
@@ -204,7 +204,7 @@
avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
0, SLAB_PANIC, NULL, NULL);
audit_log(current->audit_context, "AVC INITIALIZED\n");
int avc_get_hash_stats(char *page)
@@ -511,7 +511,7 @@
return;
}
diff -ur linux-2.6.9.orig/security/selinux/ss/services.c linux-2.6.9/security/selinux/ss/services.c
--- linux-2.6.9.orig/security/selinux/ss/services.c 2005-05-10 08:24:51.000000000 -0400
+++ linux-2.6.9/security/selinux/ss/services.c 2005-05-10 08:24:11.000000000 -0400
@@ -579,7 +579,7 @@
goto out;
if (context_struct_to_string(newcontext, &n, &nlen) < 0)
goto out;
------------------------------------------
除非特别声明,文章均为原创,版权与博客园共有,转载请保留出处
BUY ME COFFEE

此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。