All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: Linux Audit <linux-audit@redhat.com>
Subject: [PATCH] name_count array overrun
Date: Thu, 7 Sep 2006 14:00:06 -0400	[thread overview]
Message-ID: <200609071400.06853.sgrubb@redhat.com> (raw)

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

             reply	other threads:[~2006-09-07 17:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-07 18:00 Steve Grubb [this message]
2006-09-07 20:43 ` [PATCH] name_count array overrun Amy Griffis
2006-09-07 20:53   ` Steve Grubb
2006-09-24 12:56   ` Steve Grubb
2006-09-27 21:04     ` Amy Griffis
  -- strict thread matches above, loose matches on Subject: below --
2006-09-28 18:31 Steve Grubb
2006-09-29 12:46 ` Alexander Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200609071400.06853.sgrubb@redhat.com \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.