Skip to contentSkip to conversation

sig_info: use standard template for log messages

PATCH Superseded Richard Guy Briggs 2 participants 7 messages Apr 15, 2019 – Apr 16, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sig_info: use standard template for log messages

Records that are triggered by an AUDIT_SIGNAL_INFO message including AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

See: https://github.com/linux-audit/audit-userspace/issues/90

---
 docs/audit_request_signal_info.3 |  2 +-
 lib/libaudit.c                   | 12 +++++++++
 lib/libaudit.h                   |  1 +
 src/auditd-reconfig.c            |  9 +++----
 src/auditd.c                     | 54 ++++++++++++++--------------------------
 5 files changed, 36 insertions(+), 42 deletions(-)
docs/audit_request_signal_info.3 +1 -1
index 873deb58bef3..b68d7bbefeed 100644
@@ -8,7 +8,7 @@ int audit_request_signal_info(int fd);
 
 .SH "DESCRIPTION"
 
-audit_request_signal_info requests that the kernel send information about the sender of a signal to the audit daemon. The sinal info structure is as follows:
+audit_request_signal_info requests that the kernel send information about the sender of a signal to the audit daemon. The signal info structure is as follows:
 
 .nf
 struct audit_sig_info {
lib/libaudit.c +12 -0
index 2af017a0e520..e9c4f9cad6df 100644
@@ -674,6 +674,18 @@ int audit_request_signal_info(int fd)
 	return rc;
 }
 
+char *audit_format_signal_info(char *buf, int len, char *op, struct audit_reply *rep, char *res)
+{
+	snprintf(buf, len,
+		 "op=%s auid=%u pid=%d subj=%s res=%s",
+		 op,
+		 rep->signal_info->uid, 
+		 rep->signal_info->pid,
+		 rep->len == 24 ? "?" : rep->signal_info->ctx,
+		 res);
+	return buf;
+}
+
 int audit_update_watch_perms(struct audit_rule_data *rule, int perms)
 {
 	unsigned int i, done=0;
lib/libaudit.h +1 -0
index ca7aa63e354e..63a5e948d00e 100644
@@ -562,6 +562,7 @@ extern int  audit_setloginuid(uid_t uid);
 extern uint32_t audit_get_session(void);
 extern int  audit_detect_machine(void);
 extern int audit_determine_machine(const char *arch);
+extern char *audit_format_signal_info(char *buf, int len, char *op, struct audit_reply *rep, char *res);
 
 /* Translation functions */
 extern int        audit_name_to_field(const char *field);
src/auditd-reconfig.c +3 -6
index a03e29aa57ab..f5b00e6d1dc7 100644
@@ -115,12 +115,9 @@ static void *config_thread_main(void *arg)
 	} else {
 		// need to send a failed event message
 		char txt[MAX_AUDIT_MESSAGE_LENGTH];
-		snprintf(txt, sizeof(txt),
-	    "op=reconfigure state=no-change auid=%u pid=%d subj=%s res=failed",
-			e->reply.signal_info->uid,
-			e->reply.signal_info->pid,
-			(e->reply.len > 24) ? 
-				e->reply.signal_info->ctx : "?");
+		audit_format_signal_info(txt, sizeof(txt),
+					 "reconfigure state=no-change",
+				         &e->reply, "failed");
 		// FIXME: need to figure out sending this
 		//send_audit_event(AUDIT_DAEMON_CONFIG, txt);
 		free_config(&new_config);
src/auditd.c +19 -35

97 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · EDT Richard Guy Briggs

Records that are triggered by an AUDIT_SIGNAL_INFO message including AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

This is crusty old code that has things in it that were for migrations with very old kernels. It's not readily obvious because those kernel transitions were quite some time ago. There was also a fake

Quoted 3 lines

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

How are you generating the events that trigger this? If this is based on reading the source code, I think its because of an ancient kernel change. If you can generate this condition, then I'd like to replicate the problem on my system to see what's happening.

Quoted 7 lines

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

See: https://github.com/linux-audit/audit-userspace/issues/90

I had made changes to the git repo Saturday. I suspect this patch does not apply. I like the op value changes. That part I can go along with. Shall I just make that adjustment in the upstream repo and we can talk more about how you are creating these events?

Thanks,
-Steve

Quoted 67 lines
---
 docs/audit_request_signal_info.3 |  2 +-
 lib/libaudit.c                   | 12 +++++++++
 lib/libaudit.h                   |  1 +
 src/auditd-reconfig.c            |  9 +++----
 src/auditd.c                     | 54

++++++++++++++-------------------------- 5 files changed, 36 insertions(+), 42 deletions(-)

(quoted diff) +0 -0

b/docs/audit_request_signal_info.3 index 873deb58bef3..b68d7bbefeed 100644

docs/audit_request_signal_info.3 +0 -1
@@ -8,7 +8,7 @@ int audit_request_signal_info(int fd);
 
 .SH "DESCRIPTION"
 
-audit_request_signal_info requests that the kernel send information about

the sender of a signal to the audit daemon. The sinal info structure is as
follows: +audit_request_signal_info requests that the kernel send information about the sender of a signal to the audit daemon. The signal info structure is as follows:

.nf
struct audit_sig_info {

lib/libaudit.c +11 -0
index 2af017a0e520..e9c4f9cad6df 100644
@@ -674,6 +674,18 @@ int audit_request_signal_info(int fd)
 	return rc;
 }
 
+char *audit_format_signal_info(char *buf, int len, char *op, struct
 audit_reply *rep, char *res) +{
+	snprintf(buf, len,
+		 "op=%s auid=%u pid=%d subj=%s res=%s",
+		 op,
+		 rep->signal_info->uid,
+		 rep->signal_info->pid,
+		 rep->len == 24 ? "?" : rep->signal_info->ctx,
+		 res);
+	return buf;
+}
+
 int audit_update_watch_perms(struct audit_rule_data *rule, int perms)
 {
 	unsigned int i, done=0;
lib/libaudit.h +1 -0
index ca7aa63e354e..63a5e948d00e 100644
@@ -562,6 +562,7 @@ extern int  audit_setloginuid(uid_t uid);
 extern uint32_t audit_get_session(void);
 extern int  audit_detect_machine(void);
 extern int audit_determine_machine(const char *arch);
+extern char *audit_format_signal_info(char *buf, int len, char *op, struct
 audit_reply *rep, char *res);
 
 /* Translation functions */

extern int audit_name_to_field(const char *field);

src/auditd-reconfig.c +0 -0
index a03e29aa57ab..f5b00e6d1dc7 100644

src/auditd-reconfig.c static void *config_thread_main(void *arg) · line 119

Quoted 5 lines
src/auditd-reconfig.c +0 -2
@@ -115,12 +115,9 @@ static void *config_thread_main(void *arg)
 	} else {
 		// need to send a failed event message
 		char txt[MAX_AUDIT_MESSAGE_LENGTH];
-		snprintf(txt, sizeof(txt),
-	    "op=reconfigure state=no-change auid=%u pid=%d subj=%s 

res=failed",

Quoted 15 lines
src/auditd-reconfig.c +3 -4
-			e->reply.signal_info->uid,
-			e->reply.signal_info->pid,
-			(e->reply.len > 24) ?
-				e->reply.signal_info->ctx : "?");
+		audit_format_signal_info(txt, sizeof(txt),
+					 "reconfigure state=no-change",
+				         &e->reply, "failed");
 		// FIXME: need to figure out sending this
 		//send_audit_event(AUDIT_DAEMON_CONFIG, txt);
 		free_config(&new_config);
src/auditd.c +0 -0
index c04a1c9ce93f..5c31583a49c6 100644

src/auditd.c static void hup_handler( struct ev_loop *loop, struct · line 134

Quoted 4 lines
src/auditd.c +0 -1
@@ -131,7 +131,7 @@ static void hup_handler( struct ev_loop *loop, struct
 ev_signal *sig, int revent rc = audit_request_signal_info(fd);
 	if (rc < 0)
 		send_audit_event(AUDIT_DAEMON_CONFIG,
-	  "op=hup-info state=request-siginfo auid=-1 pid=-1 subj=? 

res=failed");

Quoted 14 lines
src/auditd.c +2 -1
+	  "op=reconfigure state=no-change auid=-1 pid=-1 subj=? res=failed");
 	else
 		hup_info_requested = 1;
 }
@@ -147,7 +147,7 @@ static void user1_handler(struct ev_loop *loop, struct
 ev_signal *sig, rc = audit_request_signal_info(fd);
 	if (rc < 0)
 		send_audit_event(AUDIT_DAEMON_ROTATE,
-			 "op=usr1-info auid=-1 pid=-1 subj=? res=failed");
+			 "op=rotate-logs auid=-1 pid=-1 subj=? res=failed");
 	else
 		usr1_info_requested = 1;
 }

src/auditd.c static void user2_handler( struct ev_loop *loop, struct · line 166

Quoted 4 lines
src/auditd.c +0 -1
@@ -163,7 +163,7 @@ static void user2_handler( struct ev_loop *loop, struct
 ev_signal *sig, int reve if (rc < 0) {
 		resume_logging();
 		send_audit_event(AUDIT_DAEMON_RESUME,
-			 "op=resume-logging auid=-1 pid=-1 subj=? 

res=success");

Quoted 9 lines
src/auditd.c +2 -0
+			 "op=resume-logging auid=-1 pid=-1 subj=? res=failed");
 	} else
 		usr2_info_requested = 1;
 }
@@ -515,45 +515,33 @@ static void netlink_handler(struct ev_loop *loop,
 struct ev_io *io, break;
 		case AUDIT_SIGNAL_INFO:
 			if (hup_info_requested) {
+				char hup[MAX_AUDIT_MESSAGE_LENGTH];

src/auditd.c static void netlink_handler(struct ev_loop *loop, · line 524

Quoted 10 lines
src/auditd.c +2 -4
 				audit_msg(LOG_DEBUG,
 				    "HUP detected, starting config manager");
 				reconfig_ev = cur_event;
 				if (start_config_manager(cur_event)) {
-					send_audit_event(
-						AUDIT_DAEMON_CONFIG,
-				  "op=reconfigure state=no-change "
-				  "auid=-1 pid=-1 subj=? res=failed");
+					audit_format_signal_info(hup, sizeof(hup),
+								 "reconfigure 

state=no-change",

src/auditd.c static void netlink_handler(struct ev_loop *loop, struct ev_io *io,

Quoted 3 lines
src/auditd.c +3 -0
+								 &cur_event->reply,
+								 "failed");
+					send_audit_event(AUDIT_DAEMON_CONFIG, 

hup);

Quoted 57 lines
src/auditd.c +10 -28
 				}
 				cur_event = NULL;
 				hup_info_requested = 0;
 			} else if (usr1_info_requested) {
 				char usr1[MAX_AUDIT_MESSAGE_LENGTH];
-				if (cur_event->reply.len == 24) {
-					snprintf(usr1, sizeof(usr1),
-					"op=rotate-logs auid=-1 pid=-1 subj=?");
-				} else {
-					snprintf(usr1, sizeof(usr1),
-				 "op=rotate-logs auid=%u pid=%d subj=%s",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr1, sizeof(usr1),
+							 "rotate-logs",
+							 &cur_event->reply,
+							 "success");
 				send_audit_event(AUDIT_DAEMON_ROTATE, usr1);
 				usr1_info_requested = 0;
 			} else if (usr2_info_requested) {
 				char usr2[MAX_AUDIT_MESSAGE_LENGTH];
-				if (cur_event->reply.len == 24) {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging auid=-1 "
-						"pid=-1 subj=? res=success");
-				} else {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging "
-					"auid=%u pid=%d subj=%s res=success",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr2, sizeof(usr2),
+							 "resume-logging",
+							 &cur_event->reply,
+							 "success");
 				resume_logging();
 				libdisp_resume();
 				send_audit_event(AUDIT_DAEMON_RESUME, usr2);
@@ -993,12 +981,8 @@ int main(int argc, char *argv[])
 		rc = get_reply(fd, &trep, rc);
 		if (rc > 0) {
 			char txt[MAX_AUDIT_MESSAGE_LENGTH];
-			snprintf(txt, sizeof(txt),
-				"op=terminate auid=%u "
-				"pid=%d subj=%s res=success",
-				 trep.signal_info->uid,
-				 trep.signal_info->pid,
-				 trep.signal_info->ctx);
+			audit_format_signal_info(txt, sizeof(txt), "terminate",
+						 &trep, "success");
 			send_audit_event(AUDIT_DAEMON_END, txt);
 		}
 	}
#2 lore raw
Quoted 10 lines · Steve Grubb
Quoted 4 lines · EDT Richard Guy Briggs

Records that are triggered by an AUDIT_SIGNAL_INFO message including AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

This is crusty old code that has things in it that were for migrations with very old kernels. It's not readily obvious because those kernel transitions were quite some time ago. There was also a fake

Quoted 8 lines
Quoted 3 lines

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

How are you generating the events that trigger this? If this is based on reading the source code, I think its because of an ancient kernel change. If you can generate this condition, then I'd like to replicate the problem on my system to see what's happening.

I used a current audit/next kernel, compiled with AUDIT_CONFIG, but with and without AUDIT_CONFIGSYSCALL and simply signalled the audit daemon with the four signals and then ran ausearch on the most recent messages.

I did not generate errors, but I could have by creating a custom kernel that returned errors upon request for AUDIT_SIGNAL_INFO.

Quoted 6 lines
Quoted 6 lines

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

Quoted 6 lines
Quoted 1 line

See: https://github.com/linux-audit/audit-userspace/issues/90

I had made changes to the git repo Saturday. I suspect this patch does not apply. I like the op value changes. That part I can go along with. Shall I just make that adjustment in the upstream repo and we can talk more about how you are creating these events?

This patch was rebased on your patch so it is current.

I wanted it all in one function so that the format was consistent rather than open coded for anything that could use the AUDIT_SIGNAL_INFO contents. This will also help once there is also a cid (contid) to report.

Quoted 199 lines

-Steve

Quoted 67 lines
---
 docs/audit_request_signal_info.3 |  2 +-
 lib/libaudit.c                   | 12 +++++++++
 lib/libaudit.h                   |  1 +
 src/auditd-reconfig.c            |  9 +++----
 src/auditd.c                     | 54

++++++++++++++-------------------------- 5 files changed, 36 insertions(+), 42 deletions(-)

(quoted diff) +0 -0

b/docs/audit_request_signal_info.3 index 873deb58bef3..b68d7bbefeed 100644

docs/audit_request_signal_info.3 +0 -1
@@ -8,7 +8,7 @@ int audit_request_signal_info(int fd);
 
 .SH "DESCRIPTION"
 
-audit_request_signal_info requests that the kernel send information about

the sender of a signal to the audit daemon. The sinal info structure is as
follows: +audit_request_signal_info requests that the kernel send information about the sender of a signal to the audit daemon. The signal info structure is as follows:

.nf
struct audit_sig_info {

lib/libaudit.c +11 -0
index 2af017a0e520..e9c4f9cad6df 100644
@@ -674,6 +674,18 @@ int audit_request_signal_info(int fd)
 	return rc;
 }
 
+char *audit_format_signal_info(char *buf, int len, char *op, struct
 audit_reply *rep, char *res) +{
+	snprintf(buf, len,
+		 "op=%s auid=%u pid=%d subj=%s res=%s",
+		 op,
+		 rep->signal_info->uid,
+		 rep->signal_info->pid,
+		 rep->len == 24 ? "?" : rep->signal_info->ctx,
+		 res);
+	return buf;
+}
+
 int audit_update_watch_perms(struct audit_rule_data *rule, int perms)
 {
 	unsigned int i, done=0;
lib/libaudit.h +1 -0
index ca7aa63e354e..63a5e948d00e 100644
@@ -562,6 +562,7 @@ extern int  audit_setloginuid(uid_t uid);
 extern uint32_t audit_get_session(void);
 extern int  audit_detect_machine(void);
 extern int audit_determine_machine(const char *arch);
+extern char *audit_format_signal_info(char *buf, int len, char *op, struct
 audit_reply *rep, char *res);
 
 /* Translation functions */

extern int audit_name_to_field(const char *field);

src/auditd-reconfig.c +0 -0
index a03e29aa57ab..f5b00e6d1dc7 100644

src/auditd-reconfig.c static void *config_thread_main(void *arg) · line 119

Quoted 5 lines
src/auditd-reconfig.c +0 -2
@@ -115,12 +115,9 @@ static void *config_thread_main(void *arg)
 	} else {
 		// need to send a failed event message
 		char txt[MAX_AUDIT_MESSAGE_LENGTH];
-		snprintf(txt, sizeof(txt),
-	    "op=reconfigure state=no-change auid=%u pid=%d subj=%s 

res=failed",

Quoted 15 lines
src/auditd-reconfig.c +3 -4
-			e->reply.signal_info->uid,
-			e->reply.signal_info->pid,
-			(e->reply.len > 24) ?
-				e->reply.signal_info->ctx : "?");
+		audit_format_signal_info(txt, sizeof(txt),
+					 "reconfigure state=no-change",
+				         &e->reply, "failed");
 		// FIXME: need to figure out sending this
 		//send_audit_event(AUDIT_DAEMON_CONFIG, txt);
 		free_config(&new_config);
src/auditd.c +0 -0
index c04a1c9ce93f..5c31583a49c6 100644

src/auditd.c static void hup_handler( struct ev_loop *loop, struct · line 134

Quoted 4 lines
src/auditd.c +0 -1
@@ -131,7 +131,7 @@ static void hup_handler( struct ev_loop *loop, struct
 ev_signal *sig, int revent rc = audit_request_signal_info(fd);
 	if (rc < 0)
 		send_audit_event(AUDIT_DAEMON_CONFIG,
-	  "op=hup-info state=request-siginfo auid=-1 pid=-1 subj=? 

res=failed");

Quoted 14 lines
src/auditd.c +2 -1
+	  "op=reconfigure state=no-change auid=-1 pid=-1 subj=? res=failed");
 	else
 		hup_info_requested = 1;
 }
@@ -147,7 +147,7 @@ static void user1_handler(struct ev_loop *loop, struct
 ev_signal *sig, rc = audit_request_signal_info(fd);
 	if (rc < 0)
 		send_audit_event(AUDIT_DAEMON_ROTATE,
-			 "op=usr1-info auid=-1 pid=-1 subj=? res=failed");
+			 "op=rotate-logs auid=-1 pid=-1 subj=? res=failed");
 	else
 		usr1_info_requested = 1;
 }

src/auditd.c static void user2_handler( struct ev_loop *loop, struct · line 166

Quoted 4 lines
src/auditd.c +0 -1
@@ -163,7 +163,7 @@ static void user2_handler( struct ev_loop *loop, struct
 ev_signal *sig, int reve if (rc < 0) {
 		resume_logging();
 		send_audit_event(AUDIT_DAEMON_RESUME,
-			 "op=resume-logging auid=-1 pid=-1 subj=? 

res=success");

Quoted 9 lines
src/auditd.c +2 -0
+			 "op=resume-logging auid=-1 pid=-1 subj=? res=failed");
 	} else
 		usr2_info_requested = 1;
 }
@@ -515,45 +515,33 @@ static void netlink_handler(struct ev_loop *loop,
 struct ev_io *io, break;
 		case AUDIT_SIGNAL_INFO:
 			if (hup_info_requested) {
+				char hup[MAX_AUDIT_MESSAGE_LENGTH];

src/auditd.c static void netlink_handler(struct ev_loop *loop, · line 524

Quoted 10 lines
src/auditd.c +2 -4
 				audit_msg(LOG_DEBUG,
 				    "HUP detected, starting config manager");
 				reconfig_ev = cur_event;
 				if (start_config_manager(cur_event)) {
-					send_audit_event(
-						AUDIT_DAEMON_CONFIG,
-				  "op=reconfigure state=no-change "
-				  "auid=-1 pid=-1 subj=? res=failed");
+					audit_format_signal_info(hup, sizeof(hup),
+								 "reconfigure 

state=no-change",

src/auditd.c static void netlink_handler(struct ev_loop *loop, struct ev_io *io,

Quoted 3 lines
src/auditd.c +3 -0
+								 &cur_event->reply,
+								 "failed");
+					send_audit_event(AUDIT_DAEMON_CONFIG, 

hup);

Quoted 47 lines
src/auditd.c +8 -23
 				}
 				cur_event = NULL;
 				hup_info_requested = 0;
 			} else if (usr1_info_requested) {
 				char usr1[MAX_AUDIT_MESSAGE_LENGTH];
-				if (cur_event->reply.len == 24) {
-					snprintf(usr1, sizeof(usr1),
-					"op=rotate-logs auid=-1 pid=-1 subj=?");
-				} else {
-					snprintf(usr1, sizeof(usr1),
-				 "op=rotate-logs auid=%u pid=%d subj=%s",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr1, sizeof(usr1),
+							 "rotate-logs",
+							 &cur_event->reply,
+							 "success");
 				send_audit_event(AUDIT_DAEMON_ROTATE, usr1);
 				usr1_info_requested = 0;
 			} else if (usr2_info_requested) {
 				char usr2[MAX_AUDIT_MESSAGE_LENGTH];
-				if (cur_event->reply.len == 24) {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging auid=-1 "
-						"pid=-1 subj=? res=success");
-				} else {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging "
-					"auid=%u pid=%d subj=%s res=success",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr2, sizeof(usr2),
+							 "resume-logging",
+							 &cur_event->reply,
+							 "success");
 				resume_logging();
 				libdisp_resume();
 				send_audit_event(AUDIT_DAEMON_RESUME, usr2);
@@ -993,12 +981,8 @@ int main(int argc, char *argv[])
 		rc = get_reply(fd, &trep, rc);
 		if (rc > 0) {
 			char txt[MAX_AUDIT_MESSAGE_LENGTH];
-			snprintf(txt, sizeof(txt),

src/auditd.c int main(int argc, char *argv[]) · line 988

Quoted 10 lines
src/auditd.c +2 -5
-				"op=terminate auid=%u "
-				"pid=%d subj=%s res=success",
-				 trep.signal_info->uid,
-				 trep.signal_info->pid,
-				 trep.signal_info->ctx);
+			audit_format_signal_info(txt, sizeof(txt), "terminate",
+						 &trep, "success");
 			send_audit_event(AUDIT_DAEMON_END, txt);
 		}
 	}
Quoted 4 lines

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

#3 lore raw
Quoted 15 lines · EDT Richard Guy Briggs
Quoted 14 lines · Steve Grubb
Quoted 4 lines · EDT Richard Guy Briggs

Records that are triggered by an AUDIT_SIGNAL_INFO message including AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

This is crusty old code that has things in it that were for migrations with very old kernels. It's not readily obvious because those kernel transitions were quite some time ago. There was also a fake

Quoted 3 lines

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

Quoted 7 lines
Quoted 4 lines

How are you generating the events that trigger this? If this is based on reading the source code, I think its because of an ancient kernel change. If you can generate this condition, then I'd like to replicate the problem on my system to see what's happening.

I used a current audit/next kernel, compiled with AUDIT_CONFIG, but with and without AUDIT_CONFIGSYSCALL

Is this a configuration that we really want to support? :-) This really will not work as anything except for gathering AVC's or other LSM events. And I think those go to syslog anyways. I'd say that with this kernel configuration, they likely would not run auditd as there's no point in it.

Quoted 12 lines

and simply signalled the audit daemon with the four signals and then ran ausearch on the most recent messages.

I did not generate errors, but I could have by creating a custom kernel that returned errors upon request for AUDIT_SIGNAL_INFO.

Quoted 6 lines
Quoted 6 lines

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

See: https://github.com/linux-audit/audit-userspace/issues/90

I had made changes to the git repo Saturday. I suspect this patch does not apply. I like the op value changes. That part I can go along with. Shall I just make that adjustment in the upstream repo and we can talk more about how you are creating these events?

This patch was rebased on your patch so it is current.

One thing I should mention, the audit events are created with and without the subj field because for common criteria, a DAC based system should have no notion of MAC fields. This is why we alway branch on the "ctx" variables and create the event with or without subj.

Quoted 4 lines

I wanted it all in one function so that the format was consistent rather than open coded for anything that could use the AUDIT_SIGNAL_INFO contents. This will also help once there is also a cid (contid) to report.

OK.

-Steve

Quoted 149 lines
Quoted 149 lines
Quoted 82 lines

---

 docs/audit_request_signal_info.3 |  2 +-
 lib/libaudit.c                   | 12 +++++++++
 lib/libaudit.h                   |  1 +
 src/auditd-reconfig.c            |  9 +++----
 src/auditd.c                     | 54

++++++++++++++-------------------------- 5 files changed, 36 insertions(+), 42 deletions(-)

(quoted diff) +0 -0

b/docs/audit_request_signal_info.3 index 873deb58bef3..b68d7bbefeed 100644

docs/audit_request_signal_info.3 +0 -1
@@ -8,7 +8,7 @@ int audit_request_signal_info(int fd);
 
 .SH "DESCRIPTION"
 
-audit_request_signal_info requests that the kernel send information

about
the sender of a signal to the audit daemon. The sinal info structure is as
follows: +audit_request_signal_info requests that the kernel send information about the sender of a signal to the audit daemon. The signal

info structure is as follows:
.nf
struct audit_sig_info {

lib/libaudit.c +11 -0
index 2af017a0e520..e9c4f9cad6df 100644
@@ -674,6 +674,18 @@ int audit_request_signal_info(int fd)
 
 	return rc;
 
 }
 
+char *audit_format_signal_info(char *buf, int len, char *op, struct
 audit_reply *rep, char *res) +{
+	snprintf(buf, len,
+		 "op=%s auid=%u pid=%d subj=%s res=%s",
+		 op,
+		 rep->signal_info->uid,
+		 rep->signal_info->pid,
+		 rep->len == 24 ? "?" : rep->signal_info->ctx,
+		 res);
+	return buf;
+}
+
 
 int audit_update_watch_perms(struct audit_rule_data *rule, int perms)
 {
 
 	unsigned int i, done=0;
lib/libaudit.h +1 -0
index ca7aa63e354e..63a5e948d00e 100644
@@ -562,6 +562,7 @@ extern int  audit_setloginuid(uid_t uid);
 
 extern uint32_t audit_get_session(void);
 extern int  audit_detect_machine(void);
 extern int audit_determine_machine(const char *arch);
 
+extern char *audit_format_signal_info(char *buf, int len, char *op,
 struct audit_reply *rep, char *res);

/* Translation functions */
extern int audit_name_to_field(const char *field);

src/auditd-reconfig.c +0 -0
index a03e29aa57ab..f5b00e6d1dc7 100644

src/auditd-reconfig.c static void *config_thread_main(void *arg) · line 122

Quoted 8 lines
src/auditd-reconfig.c +0 -2
@@ -115,12 +115,9 @@ static void *config_thread_main(void *arg)
 
 	} else {
 
 		// need to send a failed event message
 		char txt[MAX_AUDIT_MESSAGE_LENGTH];
 
-		snprintf(txt, sizeof(txt),
-	    "op=reconfigure state=no-change auid=%u pid=%d subj=%s

res=failed",

Quoted 20 lines
src/auditd-reconfig.c +3 -4
-			e->reply.signal_info->uid,
-			e->reply.signal_info->pid,
-			(e->reply.len > 24) ?
-				e->reply.signal_info->ctx : "?");
+		audit_format_signal_info(txt, sizeof(txt),
+					 "reconfigure state=no-change",
+				         &e->reply, "failed");
src/auditd-reconfig.c +0 -0
 		// FIXME: need to figure out sending this
 		//send_audit_event(AUDIT_DAEMON_CONFIG, txt);
 		free_config(&new_config);
src/auditd.c +0 -0
index c04a1c9ce93f..5c31583a49c6 100644
@@ -131,7 +131,7 @@ static void hup_handler( struct ev_loop *loop,

struct
ev_signal *sig, int revent rc = audit_request_signal_info(fd);

src/auditd.c

Quoted 5 lines
src/auditd.c +0 -1
 	if (rc < 0)
 
 		send_audit_event(AUDIT_DAEMON_CONFIG,
 
-	  "op=hup-info state=request-siginfo auid=-1 pid=-1 subj=?

res=failed");

Quoted 28 lines
src/auditd.c +1 -0
+	  "op=reconfigure state=no-change auid=-1 pid=-1 subj=? res=failed");
 
 	else
 
 		hup_info_requested = 1;
 
 }
@@ -147,7 +147,7 @@ static void user1_handler(struct ev_loop *loop,

struct
ev_signal *sig, rc = audit_request_signal_info(fd);

src/auditd.c +1 -1
 	if (rc < 0)
 
 		send_audit_event(AUDIT_DAEMON_ROTATE,
 
-			 "op=usr1-info auid=-1 pid=-1 subj=? res=failed");
+			 "op=rotate-logs auid=-1 pid=-1 subj=? res=failed");
 
 	else
 
 		usr1_info_requested = 1;
 
 }
@@ -163,7 +163,7 @@ static void user2_handler( struct ev_loop *loop,
 struct ev_signal *sig, int reve if (rc < 0) {
 
Quoted 8 lines
Quoted 8 lines

src/auditd.c static void user2_handler( struct ev_loop *loop, struct ev_signal *sig, int reve

Quoted 4 lines
src/auditd.c +0 -1
 		resume_logging();
 		send_audit_event(AUDIT_DAEMON_RESUME,
 
-			 "op=resume-logging auid=-1 pid=-1 subj=?

res=success");

src/auditd.c static void user2_handler( struct ev_loop *loop, · line 168

Quoted 1 line
src/auditd.c +1 -0
+			 "op=resume-logging auid=-1 pid=-1 subj=? 

res=failed");

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
src/auditd.c +0 -0
 	} else
src/auditd.c +1 -0
 		usr2_info_requested = 1;
 
 }
@@ -515,45 +515,33 @@ static void netlink_handler(struct ev_loop *loop,
 struct ev_io *io, break;
 
 		case AUDIT_SIGNAL_INFO:
 			if (hup_info_requested) {
 
+				char hup[MAX_AUDIT_MESSAGE_LENGTH];
 
 				audit_msg(LOG_DEBUG,
 
 				    "HUP detected, starting config manager");
 
Quoted 8 lines
Quoted 8 lines

src/auditd.c static void netlink_handler(struct ev_loop *loop, struct ev_io *io,

Quoted 8 lines
src/auditd.c +1 -4
 				reconfig_ev = cur_event;
 				if (start_config_manager(cur_event)) {
 
-					send_audit_event(
-						AUDIT_DAEMON_CONFIG,
-				  "op=reconfigure state=no-change "
-				  "auid=-1 pid=-1 subj=? res=failed");
+					audit_format_signal_info(hup, 

sizeof(hup),

Quoted 68 lines
Quoted 68 lines

src/auditd.c static void netlink_handler(struct ev_loop *loop, · line 530

Quoted 1 line
src/auditd.c +1 -0
+								 "reconfigure

state=no-change",

src/auditd.c static void netlink_handler(struct ev_loop *loop, struct ev_io *io,

Quoted 3 lines
src/auditd.c +3 -0
+								 &cur_event->reply,
+								 "failed");
+					send_audit_event(AUDIT_DAEMON_CONFIG,

hup);

Quoted 58 lines
src/auditd.c +8 -22
 				}
 				cur_event = NULL;
 				hup_info_requested = 0;
 
 			} else if (usr1_info_requested) {
 
 				char usr1[MAX_AUDIT_MESSAGE_LENGTH];
 
-				if (cur_event->reply.len == 24) {
-					snprintf(usr1, sizeof(usr1),
-					"op=rotate-logs auid=-1 pid=-1 subj=?");
-				} else {
-					snprintf(usr1, sizeof(usr1),
-				 "op=rotate-logs auid=%u pid=%d subj=%s",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr1, sizeof(usr1),
+							 "rotate-logs",
+							 &cur_event->reply,
+							 "success");
 
 				send_audit_event(AUDIT_DAEMON_ROTATE, usr1);
 				usr1_info_requested = 0;
 
 			} else if (usr2_info_requested) {
 
 				char usr2[MAX_AUDIT_MESSAGE_LENGTH];
 
-				if (cur_event->reply.len == 24) {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging auid=-1 "
-						"pid=-1 subj=? res=success");
-				} else {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging "
-					"auid=%u pid=%d subj=%s res=success",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr2, sizeof(usr2),
+							 "resume-logging",
+							 &cur_event->reply,
+							 "success");
 
 				resume_logging();
 				libdisp_resume();
 				send_audit_event(AUDIT_DAEMON_RESUME, usr2);
@@ -993,12 +981,8 @@ int main(int argc, char *argv[])
 
 		rc = get_reply(fd, &trep, rc);
 		if (rc > 0) {
 
 			char txt[MAX_AUDIT_MESSAGE_LENGTH];
 
Quoted 7 lines
Quoted 7 lines

src/auditd.c int main(int argc, char *argv[])

Quoted 7 lines
src/auditd.c +1 -6
-			snprintf(txt, sizeof(txt),
-				"op=terminate auid=%u "
-				"pid=%d subj=%s res=success",
-				 trep.signal_info->uid,
-				 trep.signal_info->pid,
-				 trep.signal_info->ctx);
+			audit_format_signal_info(txt, sizeof(txt), 

"terminate",

Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
src/auditd.c +1 -0
+						 &trep, "success");

send_audit_event(AUDIT_DAEMON_END, txt);

Quoted 8 lines

src/auditd.c

Quoted 3 lines
src/auditd.c +0 -0
 		}
 
 	}

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

#4 lore raw
Quoted 21 lines · Steve Grubb
Quoted 20 lines · EDT Richard Guy Briggs
Quoted 18 lines · Steve Grubb
Quoted 4 lines · EDT Richard Guy Briggs

Records that are triggered by an AUDIT_SIGNAL_INFO message including AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

This is crusty old code that has things in it that were for migrations with very old kernels. It's not readily obvious because those kernel transitions were quite some time ago. There was also a fake

Quoted 3 lines

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

How are you generating the events that trigger this? If this is based on reading the source code, I think its because of an ancient kernel change. If you can generate this condition, then I'd like to replicate the problem on my system to see what's happening.

Quoted 7 lines
Quoted 2 lines

I used a current audit/next kernel, compiled with AUDIT_CONFIG, but with and without AUDIT_CONFIGSYSCALL

Is this a configuration that we really want to support? :-) This really will not work as anything except for gathering AVC's or other LSM events. And I think those go to syslog anyways. I'd say that with this kernel configuration, they likely would not run auditd as there's no point in it.

Audit still works without CONFIGSYSCALL but is more limited.

Quoted 19 lines
Quoted 19 lines

and simply signalled the audit daemon with the four signals and then ran ausearch on the most recent messages.

I did not generate errors, but I could have by creating a custom kernel that returned errors upon request for AUDIT_SIGNAL_INFO.

Quoted 12 lines
Quoted 7 lines

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

See: https://github.com/linux-audit/audit-userspace/issues/90

I had made changes to the git repo Saturday. I suspect this patch does not apply. I like the op value changes. That part I can go along with. Shall I just make that adjustment in the upstream repo and we can talk more about how you are creating these events?

Quoted 6 lines
Quoted 1 line

This patch was rebased on your patch so it is current.

One thing I should mention, the audit events are created with and without the subj field because for common criteria, a DAC based system should have no notion of MAC fields. This is why we alway branch on the "ctx" variables and create the event with or without subj.

The only branch is whether or not to print "?" for the subj field, so the field is still always there.

Quoted 263 lines
Quoted 4 lines

I wanted it all in one function so that the format was consistent rather than open coded for anything that could use the AUDIT_SIGNAL_INFO contents. This will also help once there is also a cid (contid) to report.

OK.

-Steve

Quoted 149 lines
Quoted 149 lines
Quoted 82 lines

---

 docs/audit_request_signal_info.3 |  2 +-
 lib/libaudit.c                   | 12 +++++++++
 lib/libaudit.h                   |  1 +
 src/auditd-reconfig.c            |  9 +++----
 src/auditd.c                     | 54

++++++++++++++-------------------------- 5 files changed, 36 insertions(+), 42 deletions(-)

(quoted diff) +0 -0

b/docs/audit_request_signal_info.3 index 873deb58bef3..b68d7bbefeed 100644

docs/audit_request_signal_info.3 +0 -1
@@ -8,7 +8,7 @@ int audit_request_signal_info(int fd);
 
 .SH "DESCRIPTION"
 
-audit_request_signal_info requests that the kernel send information

about
the sender of a signal to the audit daemon. The sinal info structure is as
follows: +audit_request_signal_info requests that the kernel send information about the sender of a signal to the audit daemon. The signal

info structure is as follows:
.nf
struct audit_sig_info {

lib/libaudit.c +11 -0
index 2af017a0e520..e9c4f9cad6df 100644
@@ -674,6 +674,18 @@ int audit_request_signal_info(int fd)
 
 	return rc;
 
 }
 
+char *audit_format_signal_info(char *buf, int len, char *op, struct
 audit_reply *rep, char *res) +{
+	snprintf(buf, len,
+		 "op=%s auid=%u pid=%d subj=%s res=%s",
+		 op,
+		 rep->signal_info->uid,
+		 rep->signal_info->pid,
+		 rep->len == 24 ? "?" : rep->signal_info->ctx,
+		 res);
+	return buf;
+}
+
 
 int audit_update_watch_perms(struct audit_rule_data *rule, int perms)
 {
 
 	unsigned int i, done=0;
lib/libaudit.h +1 -0
index ca7aa63e354e..63a5e948d00e 100644
@@ -562,6 +562,7 @@ extern int  audit_setloginuid(uid_t uid);
 
 extern uint32_t audit_get_session(void);
 extern int  audit_detect_machine(void);
 extern int audit_determine_machine(const char *arch);
 
+extern char *audit_format_signal_info(char *buf, int len, char *op,
 struct audit_reply *rep, char *res);

/* Translation functions */
extern int audit_name_to_field(const char *field);

src/auditd-reconfig.c +0 -0
index a03e29aa57ab..f5b00e6d1dc7 100644

src/auditd-reconfig.c static void *config_thread_main(void *arg) · line 122

Quoted 8 lines
src/auditd-reconfig.c +0 -2
@@ -115,12 +115,9 @@ static void *config_thread_main(void *arg)
 
 	} else {
 
 		// need to send a failed event message
 		char txt[MAX_AUDIT_MESSAGE_LENGTH];
 
-		snprintf(txt, sizeof(txt),
-	    "op=reconfigure state=no-change auid=%u pid=%d subj=%s

res=failed",

Quoted 20 lines
src/auditd-reconfig.c +3 -4
-			e->reply.signal_info->uid,
-			e->reply.signal_info->pid,
-			(e->reply.len > 24) ?
-				e->reply.signal_info->ctx : "?");
+		audit_format_signal_info(txt, sizeof(txt),
+					 "reconfigure state=no-change",
+				         &e->reply, "failed");
src/auditd-reconfig.c +0 -0
 		// FIXME: need to figure out sending this
 		//send_audit_event(AUDIT_DAEMON_CONFIG, txt);
 		free_config(&new_config);
src/auditd.c +0 -0
index c04a1c9ce93f..5c31583a49c6 100644
@@ -131,7 +131,7 @@ static void hup_handler( struct ev_loop *loop,

struct
ev_signal *sig, int revent rc = audit_request_signal_info(fd);

src/auditd.c

Quoted 5 lines
src/auditd.c +0 -1
 	if (rc < 0)
 
 		send_audit_event(AUDIT_DAEMON_CONFIG,
 
-	  "op=hup-info state=request-siginfo auid=-1 pid=-1 subj=?

res=failed");

Quoted 28 lines
src/auditd.c +1 -0
+	  "op=reconfigure state=no-change auid=-1 pid=-1 subj=? res=failed");
 
 	else
 
 		hup_info_requested = 1;
 
 }
@@ -147,7 +147,7 @@ static void user1_handler(struct ev_loop *loop,

struct
ev_signal *sig, rc = audit_request_signal_info(fd);

src/auditd.c +1 -1
 	if (rc < 0)
 
 		send_audit_event(AUDIT_DAEMON_ROTATE,
 
-			 "op=usr1-info auid=-1 pid=-1 subj=? res=failed");
+			 "op=rotate-logs auid=-1 pid=-1 subj=? res=failed");
 
 	else
 
 		usr1_info_requested = 1;
 
 }
@@ -163,7 +163,7 @@ static void user2_handler( struct ev_loop *loop,
 struct ev_signal *sig, int reve if (rc < 0) {
 
Quoted 8 lines
Quoted 8 lines

src/auditd.c static void user2_handler( struct ev_loop *loop, struct ev_signal *sig, int reve

Quoted 4 lines
src/auditd.c +0 -1
 		resume_logging();
 		send_audit_event(AUDIT_DAEMON_RESUME,
 
-			 "op=resume-logging auid=-1 pid=-1 subj=?

res=success");

src/auditd.c static void user2_handler( struct ev_loop *loop, · line 168

Quoted 1 line
src/auditd.c +1 -0
+			 "op=resume-logging auid=-1 pid=-1 subj=? 

res=failed");

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
src/auditd.c +0 -0
 	} else
src/auditd.c +1 -0
 		usr2_info_requested = 1;
 
 }
@@ -515,45 +515,33 @@ static void netlink_handler(struct ev_loop *loop,
 struct ev_io *io, break;
 
 		case AUDIT_SIGNAL_INFO:
 			if (hup_info_requested) {
 
+				char hup[MAX_AUDIT_MESSAGE_LENGTH];
 
 				audit_msg(LOG_DEBUG,
 
 				    "HUP detected, starting config manager");
 
Quoted 8 lines
Quoted 8 lines

src/auditd.c static void netlink_handler(struct ev_loop *loop, struct ev_io *io,

Quoted 8 lines
src/auditd.c +1 -4
 				reconfig_ev = cur_event;
 				if (start_config_manager(cur_event)) {
 
-					send_audit_event(
-						AUDIT_DAEMON_CONFIG,
-				  "op=reconfigure state=no-change "
-				  "auid=-1 pid=-1 subj=? res=failed");
+					audit_format_signal_info(hup, 

sizeof(hup),

Quoted 68 lines
Quoted 68 lines

src/auditd.c static void netlink_handler(struct ev_loop *loop, · line 530

Quoted 1 line
src/auditd.c +1 -0
+								 "reconfigure

state=no-change",

src/auditd.c static void netlink_handler(struct ev_loop *loop, struct ev_io *io,

Quoted 3 lines
src/auditd.c +3 -0
+								 &cur_event->reply,
+								 "failed");
+					send_audit_event(AUDIT_DAEMON_CONFIG,

hup);

Quoted 58 lines
src/auditd.c +8 -22
 				}
 				cur_event = NULL;
 				hup_info_requested = 0;
 
 			} else if (usr1_info_requested) {
 
 				char usr1[MAX_AUDIT_MESSAGE_LENGTH];
 
-				if (cur_event->reply.len == 24) {
-					snprintf(usr1, sizeof(usr1),
-					"op=rotate-logs auid=-1 pid=-1 subj=?");
-				} else {
-					snprintf(usr1, sizeof(usr1),
-				 "op=rotate-logs auid=%u pid=%d subj=%s",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr1, sizeof(usr1),
+							 "rotate-logs",
+							 &cur_event->reply,
+							 "success");
 
 				send_audit_event(AUDIT_DAEMON_ROTATE, usr1);
 				usr1_info_requested = 0;
 
 			} else if (usr2_info_requested) {
 
 				char usr2[MAX_AUDIT_MESSAGE_LENGTH];
 
-				if (cur_event->reply.len == 24) {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging auid=-1 "
-						"pid=-1 subj=? res=success");
-				} else {
-					snprintf(usr2, sizeof(usr2),
-						"op=resume-logging "
-					"auid=%u pid=%d subj=%s res=success",
-					 cur_event->reply.signal_info->uid,
-					 cur_event->reply.signal_info->pid,
-					 cur_event->reply.signal_info->ctx);
-				}
+				audit_format_signal_info(usr2, sizeof(usr2),
+							 "resume-logging",
+							 &cur_event->reply,
+							 "success");
 
 				resume_logging();
 				libdisp_resume();
 				send_audit_event(AUDIT_DAEMON_RESUME, usr2);
@@ -993,12 +981,8 @@ int main(int argc, char *argv[])
 
 		rc = get_reply(fd, &trep, rc);
 		if (rc > 0) {
 
 			char txt[MAX_AUDIT_MESSAGE_LENGTH];
 
Quoted 33 lines
Quoted 7 lines
Quoted 7 lines

src/auditd.c int main(int argc, char *argv[])

Quoted 7 lines
src/auditd.c +1 -6
-			snprintf(txt, sizeof(txt),
-				"op=terminate auid=%u "
-				"pid=%d subj=%s res=success",
-				 trep.signal_info->uid,
-				 trep.signal_info->pid,
-				 trep.signal_info->ctx);
+			audit_format_signal_info(txt, sizeof(txt), 

"terminate",

Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
src/auditd.c +1 -0
+						 &trep, "success");

send_audit_event(AUDIT_DAEMON_END, txt);

Quoted 8 lines

src/auditd.c

Quoted 3 lines
src/auditd.c +0 -0
 		}
 
 	}

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

#5 lore raw
Quoted 27 lines · EDT Richard Guy Briggs
Quoted 26 lines · Steve Grubb
Quoted 24 lines · EDT Richard Guy Briggs
Quoted 12 lines · Steve Grubb
Quoted 5 lines · EDT Richard Guy Briggs

Records that are triggered by an AUDIT_SIGNAL_INFO message including
AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

This is crusty old code that has things in it that were for migrations with very old kernels. It's not readily obvious because those kernel transitions were quite some time ago. There was also a fake

Quoted 8 lines
Quoted 3 lines

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

How are you generating the events that trigger this? If this is based on reading the source code, I think its because of an ancient kernel change. If you can generate this condition, then I'd like to replicate the problem on my system to see what's happening.

I used a current audit/next kernel, compiled with AUDIT_CONFIG, but with and without AUDIT_CONFIGSYSCALL

Quoted 7 lines
Quoted 5 lines

Is this a configuration that we really want to support? :-) This really will not work as anything except for gathering AVC's or other LSM events. And I think those go to syslog anyways. I'd say that with this kernel configuration, they likely would not run auditd as there's no point in it.

Audit still works without CONFIGSYSCALL but is more limited.

I really don't think we should cater to that use case. I am willing to go with a consolidated logging function. With the caveat below.

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines

and simply signalled the audit daemon with the four signals and then ran ausearch on the most recent messages.

I did not generate errors, but I could have by creating a custom kernel that returned errors upon request for AUDIT_SIGNAL_INFO.

Quoted 6 lines
Quoted 6 lines

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

Quoted 6 lines
Quoted 1 line

See: https://github.com/linux-audit/audit-userspace/issues/90

I had made changes to the git repo Saturday. I suspect this patch does not apply. I like the op value changes. That part I can go along with. Shall I just make that adjustment in the upstream repo and we can talk more about how you are creating these events?

This patch was rebased on your patch so it is current.

Quoted 7 lines
Quoted 4 lines

One thing I should mention, the audit events are created with and without the subj field because for common criteria, a DAC based system should have no notion of MAC fields. This is why we alway branch on the "ctx" variables and create the event with or without subj.

The only branch is whether or not to print "?" for the subj field, so the field is still always there.

But we don't want subj there at all if its a DAC only system.

-Steve

#6 lore raw
Quoted 34 lines · Steve Grubb
Quoted 33 lines · EDT Richard Guy Briggs
Quoted 31 lines · Steve Grubb
Quoted 17 lines · EDT Richard Guy Briggs
Quoted 16 lines · Steve Grubb
Quoted 5 lines · EDT Richard Guy Briggs

Records that are triggered by an AUDIT_SIGNAL_INFO message including
AUDIT_DAEMON_CONFIG (HUP), AUDIT_DAEMON_ROTATE (USR1), AUDIT_DAEMON_RESUME (USR2) and AUDIT_DAEMON_END (TERM) have inconsistent reporting of signal info and swinging field "state".

This is crusty old code that has things in it that were for migrations with very old kernels. It's not readily obvious because those kernel transitions were quite some time ago. There was also a fake

Quoted 3 lines

They also assume that an empty security context implies there is no other useful information in the AUDIT_SIGNAL_INFO message so don't use the information that is there.

Quoted 7 lines
Quoted 4 lines

How are you generating the events that trigger this? If this is based on reading the source code, I think its because of an ancient kernel change. If you can generate this condition, then I'd like to replicate the problem on my system to see what's happening.

I used a current audit/next kernel, compiled with AUDIT_CONFIG, but with and without AUDIT_CONFIGSYSCALL

Is this a configuration that we really want to support? :-) This really will not work as anything except for gathering AVC's or other LSM events. And I think those go to syslog anyways. I'd say that with this kernel configuration, they likely would not run auditd as there's no point in it.

Quoted 4 lines
Quoted 1 line

Audit still works without CONFIGSYSCALL but is more limited.

I really don't think we should cater to that use case. I am willing to go with a consolidated logging function. With the caveat below.

There are still 8 arches or so that are in this case.

Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 12 lines

and simply signalled the audit daemon with the four signals and then ran ausearch on the most recent messages.

I did not generate errors, but I could have by creating a custom kernel that returned errors upon request for AUDIT_SIGNAL_INFO.

Quoted 6 lines
Quoted 6 lines

Normalize AUDIT_DAEMON_CONFIG to use the value "reconfigure" and add the "state" field where missing.

Use audit_sig_info values when available, not making assumptions about their availability when the security context is absent.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

See: https://github.com/linux-audit/audit-userspace/issues/90

I had made changes to the git repo Saturday. I suspect this patch does not apply. I like the op value changes. That part I can go along with. Shall I just make that adjustment in the upstream repo and we can talk more about how you are creating these events?

This patch was rebased on your patch so it is current.

One thing I should mention, the audit events are created with and without the subj field because for common criteria, a DAC based system should have no notion of MAC fields. This is why we alway branch on the "ctx" variables and create the event with or without subj.

Quoted 4 lines
Quoted 2 lines

The only branch is whether or not to print "?" for the subj field, so the field is still always there.

But we don't want subj there at all if its a DAC only system.

Ok, so all of these messages I am fixing were needlessly printing the subj field anyways? This is easy to fix with this patch.

Quoted 1 line

-Steve

- RGB

--
Richard Guy Briggs <[email protected]>
Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635