[DRBD-cvs] r1494 - trunk/drbd
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Fri, 20 Aug 2004 15:07:27 +0200 (CEST)
Author: lars
Date: 2004-08-20 15:07:22 +0200 (Fri, 20 Aug 2004)
New Revision: 1494
Modified:
trunk/drbd/drbd_main.c
trunk/drbd/drbd_proc.c
trunk/drbd/drbd_worker.c
Log:
prevent in-kernel buffer overflow in drbd_proc.c
add some missing include linux/version.h
Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c 2004-08-19 08:48:25 UTC (rev 1493)
+++ trunk/drbd/drbd_main.c 2004-08-20 13:07:22 UTC (rev 1494)
@@ -35,6 +35,7 @@
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/version.h>
#include <asm/uaccess.h>
#include <asm/types.h>
Modified: trunk/drbd/drbd_proc.c
===================================================================
--- trunk/drbd/drbd_proc.c 2004-08-19 08:48:25 UTC (rev 1493)
+++ trunk/drbd/drbd_proc.c 2004-08-20 13:07:22 UTC (rev 1494)
@@ -66,11 +66,18 @@
/* note: both rs_total and rs_left are in bits, i.e. in
* units of BM_BLOCK_SIZE.
* for the percentage, we don't care. */
+
rs_left = drbd_bm_total_weight(mdev);
- D_ASSERT(rs_left < mdev->rs_total);
/* >> 10 to prevent overflow,
* +1 to prevent division by zero */
- res = (rs_left >> 10)*1000/((mdev->rs_total >> 10) + 1);
+ ERR_IF(rs_left > mdev->rs_total) {
+ /* doh. logic bug somewhere.
+ * for now, just try to prevent in-kernel buffer overflow.
+ */
+ res = 1000;
+ } else {
+ res = (rs_left >> 10)*1000/((mdev->rs_total >> 10) + 1);
+ }
{
int i, y = res/50, x = 20-y;
sz += sprintf(buf + sz, "\t[");
Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c 2004-08-19 08:48:25 UTC (rev 1493)
+++ trunk/drbd/drbd_worker.c 2004-08-20 13:07:22 UTC (rev 1494)
@@ -27,6 +27,7 @@
#include <linux/config.h>
#include <linux/module.h>
+#include <linux/version.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>