All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Atsushi Katagiri" <a-katagiri@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] [PATCH] Buffer over flow in /proc/xenomai/stat
Date: Mon, 4 Aug 2008 16:02:22 +0900	[thread overview]
Message-ID: <001b01c8f600$0c5a5a60$09201fac@domain.hid> (raw)

Hello all.

This is a small patch that fixes a serious bug.

When we open /proc/xenomai/stat, function stat_seq_open kmalloc the area, write the data and increment iter->nentries.
The last increment of this value reaches "count",
and at the next iteration "stat_info->cpu = cpu;"  overwrites zero on illegal address!

Here is my proposal of the fix..

=====patch start=====>
diff -Nur xenomai-2.4.4-org/ksrc/nucleus/module.c xenomai-2.4.4/ksrc/nucleus/module.c
--- xenomai-2.4.4-org/ksrc/nucleus/module.c 2008-06-02 00:44:48.000000000 +0900
+++ xenomai-2.4.4/ksrc/nucleus/module.c 2008-07-29 09:46:45.000000000 +0900
@@ -443,6 +443,9 @@
   int cpu = 0;
   int err;
 
+  if (iter->nentries >= count)
+   break;
+
   /* ...over all shared IRQs on all CPUs */
   while (1) {
    stat_info = &iter->stat_info[iter->nentries];
@@ -464,7 +467,9 @@
    stat_info->pf = 0;
 
    iter->nentries++;
-  };
+   if (iter->nentries >= count)
+    break;
+  }
  }
 
  seq = file->private_data;
<=====patch end=====

I hope someone who knows this function well will solve the problem.

Regards,

Atsushi KATAGIRI
Software Engineer
A&D Company, Limited
Tokyo, Japan



             reply	other threads:[~2008-08-04  7:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-04  7:02 Atsushi Katagiri [this message]
2008-08-04  7:49 ` [Xenomai-core] [PATCH] Buffer over flow in /proc/xenomai/stat Philippe Gerum
2008-08-04  9:38   ` Atsushi Katagiri
2008-08-04 10:15     ` Philippe Gerum
2008-08-04 10:22       ` Philippe Gerum
2008-08-04 11:42         ` Atsushi Katagiri
2008-08-13 10:53         ` Jan Kiszka
2008-08-13 13:06           ` Philippe Gerum
2008-08-18 19:11             ` [Xenomai-core] [PATCH] rework xnintr_query (was: [PATCH] Buffer over flow in /proc/xenomai/stat) Jan Kiszka
2008-08-19  9:01               ` [Xenomai-core] [PATCH] rework xnintr_query Philippe Gerum
2008-08-19  9:06                 ` Gilles Chanteperdrix
2008-08-19 19:31                   ` Jan Kiszka

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='001b01c8f600$0c5a5a60$09201fac@domain.hid' \
    --to=a-katagiri@domain.hid \
    --cc=xenomai@xenomai.org \
    /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.