public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
* [PATCH] name_count array overrun
@ 2006-09-28 18:31 Steve Grubb
  2006-09-29 12:46 ` Alexander Viro
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Grubb @ 2006-09-28 18:31 UTC (permalink / raw)
  To: Linux Audit

Hi,

This patch removes the rdev logging from the previous patch

The below patch closes an unbounded use of name_count. This can lead to oopses
in some new file systems.

Signed-off-by: Steve Grubb <sgrubb@redhat.com>


diff -urp linux-2.6.18.x86_64.orig/kernel/auditsc.c linux-2.6.18.x86_64/kernel/auditsc.c
--- linux-2.6.18.x86_64.orig/kernel/auditsc.c	2006-09-24 08:24:27.000000000 -0400
+++ linux-2.6.18.x86_64/kernel/auditsc.c	2006-09-24 08:42:01.000000000 -0400
@@ -1347,7 +1347,13 @@ void __audit_inode_child(const char *dna
 		}
 
 update_context:
-	idx = context->name_count++;
+	idx = context->name_count;
+	if (context->name_count == AUDIT_NAMES) {
+		printk(KERN_DEBUG "name_count maxed and losing %s\n",
+			found_name ?: "(null)");
+		return;
+	} 
+	context->name_count++;
 #if AUDIT_DEBUG
 	context->ino_count++;
 #endif
@@ -1365,7 +1371,18 @@ update_context:
 	/* A parent was not found in audit_names, so copy the inode data for the
 	 * provided parent. */
 	if (!found_name) {
-		idx = context->name_count++;
+		idx = context->name_count;
+		if (context->name_count == AUDIT_NAMES) {
+			printk(KERN_DEBUG 
+				"name_count maxed and losing parent inode data: dev=%02x:%02x, inode=%lu",
+				MAJOR(parent->i_sb->s_dev),
+				MINOR(parent->i_sb->s_dev),
+				parent->i_ino);
+			return;
+		}
+		context->name_count++;
 #if AUDIT_DEBUG
 		context->ino_count++;
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH] name_count array overrun
@ 2006-09-07 18:00 Steve Grubb
  2006-09-07 20:43 ` Amy Griffis
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Grubb @ 2006-09-07 18:00 UTC (permalink / raw)
  To: Linux Audit

Hello,

The below patch closes an unbounded use of name_count. This can lead to oopses
in some new file systems.

Signed-off-by: Steve Grubb <sgrubb@redhat.com>


diff -urp linux-2.6.17.x86_64.orig/kernel/auditsc.c linux-2.6.17.x86_64/kernel/auditsc.c
--- linux-2.6.17.x86_64.orig/kernel/auditsc.c	2006-08-29 11:21:20.000000000 -0400
+++ linux-2.6.17.x86_64/kernel/auditsc.c	2006-08-29 15:15:28.000000000 -0400
@@ -1281,7 +1281,15 @@ void __audit_inode(const char *name, con
 		 * associated name? */
 		if (context->name_count >= AUDIT_NAMES - AUDIT_NAMES_RESERVED)
 			return;
-		idx = context->name_count++;
+		idx = context->name_count;
+		if (context->name_count == (AUDIT_NAMES - 1)) {
+			printk(KERN_DEBUG
+				"name_count maxed and losing entry [%d]=%s\n",
+				context->name_count, 
+				context->names[context->name_count].name ?:
+				"(null)");
+		} else
+			context->name_count++;
 		context->names[idx].name = NULL;
 #if AUDIT_DEBUG
 		++context->ino_count;
@@ -1333,7 +1341,13 @@ void __audit_inode_child(const char *dna
 		}
 
 update_context:
-	idx = context->name_count++;
+	idx = context->name_count;
+	if (context->name_count == (AUDIT_NAMES - 1)) {
+		printk(KERN_DEBUG "name_count maxed and losing entry [%d]=%s\n",
+			context->name_count, 
+			context->names[context->name_count].name ?: "(null)");
+	} else
+		context->name_count++;
 #if AUDIT_DEBUG
 	context->ino_count++;
 #endif
@@ -1351,7 +1365,15 @@ update_context:
 	/* A parent was not found in audit_names, so copy the inode data for the
 	 * provided parent. */
 	if (!found_name) {
-		idx = context->name_count++;
+		idx = context->name_count;
+		if (context->name_count == (AUDIT_NAMES - 1)) {
+			printk(KERN_DEBUG 
+				"name_count maxed and losing entry [%d]=%s\n",
+				context->name_count, 
+				context->names[context->name_count].name ?:
+				"(null)");
+		} else
+			context->name_count++;
 #if AUDIT_DEBUG
 		context->ino_count++;
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-09-29 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-28 18:31 [PATCH] name_count array overrun Steve Grubb
2006-09-29 12:46 ` Alexander Viro
  -- strict thread matches above, loose matches on Subject: below --
2006-09-07 18:00 Steve Grubb
2006-09-07 20:43 ` Amy Griffis
2006-09-07 20:53   ` Steve Grubb
2006-09-24 12:56   ` Steve Grubb
2006-09-27 21:04     ` Amy Griffis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox