From nobody@FreeBSD.org  Mon Mar  3 13:28:11 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C2A4C106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Mar 2008 13:28:11 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id BFEA78FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Mar 2008 13:28:11 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m23DPE2N080818
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 3 Mar 2008 13:25:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m23DPEjM080817;
	Mon, 3 Mar 2008 13:25:14 GMT
	(envelope-from nobody)
Message-Id: <200803031325.m23DPEjM080817@www.freebsd.org>
Date: Mon, 3 Mar 2008 13:25:14 GMT
From: MQ <antinvidia@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch]sysutils/xfce4-systemload-plugin integer multiplication overflow
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: thorsten.greiner@web.de

>Number:         121316
>Category:       ports
>Synopsis:       [patch]sysutils/xfce4-systemload-plugin integer multiplication overflow
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    miwi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 03 13:30:00 UTC 2008
>Closed-Date:    Sat Mar 29 23:56:33 UTC 2008
>Last-Modified:  Sun Mar 30 00:00:00 UTC 2008
>Originator:     MQ
>Release:        FreeBSD 7.0-RELEASE
>Organization:
>Environment:
FreeBSD q6600.macro 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 10:35:36 UTC 2008     root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
I've found an integer multiplication overflow in panel-plugin/memswap.c. When large memory is used, this bug will be triggered, causing the output of this plugin useless.
>How-To-Repeat:
Follow these steps when you have more than 3G memory (more than 2G must be enough to exploit this bug, but I have only tried installing 3G memory.)
1. cd /usr/ports/sysutils/xfce4-systemload-plugin && make install
2. Configure xfce4 to enable this plugin.
3. You will see that the output of the memory consumption is absolutely incorrect.
>Fix:
See my patch.

Patch attached with submission follows:

--- panel-plugin/memswap.c.orig	2007-01-18 02:01:09.000000000 +0800
+++ panel-plugin/memswap.c	2008-03-03 21:01:50.000000000 +0800
@@ -203,7 +203,7 @@
 gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST, gulong *SU)
 {
     int total_pages;
-    int free_pages;
+    u_int free_pages;
     int inactive_pages;
     int pagesize = getpagesize();
     int swap_avail;
@@ -222,8 +222,8 @@
         return -1;
     }
 
-    *MT = (total_pages*pagesize) >> 10;
-    *MU = ((total_pages-free_pages-inactive_pages) * pagesize) >> 10;
+    *MT = CONVERT(total_pages);
+    *MU = CONVERT(total_pages-free_pages-inactive_pages);
     *mem = *MU * 100 / *MT;
 
     if((*swap = swapmode(&swap_avail, &swap_free)) >= 0) {


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Mon Mar 3 13:30:08 UTC 2008 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121316 
Responsible-Changed-From-To: freebsd-ports-bugs->miwi 
Responsible-Changed-By: miwi 
Responsible-Changed-When: Fri Mar 7 13:31:47 UTC 2008 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121316 
State-Changed-From-To: feedback->closed 
State-Changed-By: miwi 
State-Changed-When: Sat Mar 29 23:56:32 UTC 2008 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121316 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/121316: commit references a PR
Date: Sat, 29 Mar 2008 23:56:32 +0000 (UTC)

 miwi        2008-03-29 23:56:27 UTC
 
   FreeBSD ports repository
 
   Modified files:
     sysutils/xfce4-systemload-plugin Makefile 
   Added files:
     sysutils/xfce4-systemload-plugin/files 
                                            patch-panel-plugin-memswap.c 
   Log:
   - Fix memory bug when you have more than 3 GB
   
   PR:             121316
   Submitted by:   MQ <antinvidia@gmail.com>
   Approved by:    maintainer timeout
   
   Revision  Changes    Path
   1.25      +1 -2      ports/sysutils/xfce4-systemload-plugin/Makefile
   1.1       +24 -0     ports/sysutils/xfce4-systemload-plugin/files/patch-panel-plugin-memswap.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
