From tejblum@purple.yandex.net  Fri Aug  1 11:42:46 2008
Return-Path: <tejblum@purple.yandex.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AAD9D106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Aug 2008 11:42:46 +0000 (UTC)
	(envelope-from tejblum@purple.yandex.net)
Received: from purple.yandex.net (purple.yandex.net [213.180.201.241])
	by mx1.freebsd.org (Postfix) with ESMTP id 331458FC08
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Aug 2008 11:42:45 +0000 (UTC)
	(envelope-from tejblum@purple.yandex.net)
Received: from purple.yandex.net (localhost [127.0.0.1])
	by purple.yandex.net (8.14.2/8.14.2) with ESMTP id m71BSk0G000785
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 1 Aug 2008 15:28:46 +0400 (MSD)
	(envelope-from tejblum@purple.yandex.net)
Received: (from tejblum@localhost)
	by purple.yandex.net (8.14.2/8.14.2/Submit) id m71BSjAu000784;
	Fri, 1 Aug 2008 15:28:45 +0400 (MSD)
	(envelope-from tejblum)
Message-Id: <200808011128.m71BSjAu000784@purple.yandex.net>
Date: Fri, 1 Aug 2008 15:28:45 +0400 (MSD)
From: Dmitry Tejblum <tejblum@yandex-team.ru>
Reply-To: Dmitry Tejblum <tejblum@yandex-team.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] [vm] integer overflow in vm_pageout.c
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         126158
>Category:       kern
>Synopsis:       [vm] [patch] integer overflow in vm_pageout.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    alc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 01 11:50:02 UTC 2008
>Closed-Date:    Fri Sep 26 03:08:20 UTC 2008
>Last-Modified:  Fri Sep 26 03:10:01 UTC 2008
>Originator:     Dmitry Tejblum
>Release:        FreeBSD 7.0-STABLE i386
>Organization:
OOO Yandex
>Environment:
System: FreeBSD purple.yandex.net 7.0-STABLE FreeBSD 7.0-STABLE #12: Fri Aug 1 15:11:21 MSD 2008 root@purple.yandex.net:/usr/src/sys/i386/compile/PURPLE i386


>Description:

The function vm_pageout_page_stats() compute 
(vm_pageout_stats_max * cnt.v_active_count) / cnt.v_page_count
at the start. The intention is to compute
(cnt.v_active_count / cnt.v_page_count) fraction of vm_pageout_stats_max.
But on machine with relatively large amount of memory,
vm_pageout_stats_max * cnt.v_active_count easily overflows 32-bit numbers.
Say, on some our machines with 16G RAM, cnt.v_active_count is about 3000000,
and default value of vm_pageout_stats_max is about 100000.

>How-To-Repeat:

>Fix:



--- sys/vm/vm_pageout.c	2008-07-28 19:15:05.000000000 +0400
+++ sys/vm/vm_pageout.c	2008-08-01 15:10:40.000000000 +0400
@@ -1284,7 +1284,7 @@
 	pcount = cnt.v_active_count;
 	fullintervalcount += vm_pageout_stats_interval;
 	if (fullintervalcount < vm_pageout_full_stats_interval) {
-		tpcount = (vm_pageout_stats_max * cnt.v_active_count) / cnt.v_page_count;
+		tpcount = ((int64_t)vm_pageout_stats_max * cnt.v_active_count) / cnt.v_page_count;
 		if (pcount > tpcount)
 			pcount = tpcount;
 	} else {
>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/126158: commit references a PR
Date: Sun, 21 Sep 2008 18:01:48 +0000 (UTC)

 alc         2008-09-21 18:01:34 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/vm               vm_pageout.c 
   Log:
   SVN rev 183236 on 2008-09-21 18:01:34Z by alc
   
   Prevent an integer overflow in vm_pageout_page_stats() on machines with a
   large number of physical pages.
   
   PR:             126158
   Submitted by:   Dmitry Tejblum
   MFC after:      3 days
   
   Revision  Changes    Path
   1.299     +2 -1      src/sys/vm/vm_pageout.c
 _______________________________________________
 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"
 
State-Changed-From-To: open->patched 
State-Changed-By: alc 
State-Changed-When: Sun Sep 21 20:53:47 UTC 2008 
State-Changed-Why:  
Patch applied to HEAD. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/126158: commit references a PR
Date: Thu, 25 Sep 2008 06:12:26 +0000 (UTC)

 alc         2008-09-25 06:11:58 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     sys/vm               vm_pageout.c 
   Log:
   SVN rev 183338 on 2008-09-25 06:11:58Z by alc
   
   MFC r183236
     Prevent an integer overflow in vm_pageout_page_stats() on machines with a
     large number of physical pages.
   
   PR:             126158
   Approved by:    re (kib)
   
   Revision   Changes    Path
   1.292.2.4  +2 -1      src/sys/vm/vm_pageout.c
 _______________________________________________
 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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: alc 
State-Changed-When: Fri Sep 26 03:06:52 UTC 2008 
State-Changed-Why:  
The patch has been applied to RELENG_6 and RELENG_7. 


Responsible-Changed-From-To: freebsd-bugs->alc 
Responsible-Changed-By: alc 
Responsible-Changed-When: Fri Sep 26 03:06:52 UTC 2008 
Responsible-Changed-Why:  
The patch has been applied to RELENG_6 and RELENG_7. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/126158: commit references a PR
Date: Fri, 26 Sep 2008 03:06:39 +0000 (UTC)

 alc         2008-09-26 03:06:08 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/vm               vm_pageout.c 
   Log:
   SVN rev 183369 on 2008-09-26 03:06:08Z by alc
   
   MFC r183236
     Prevent an integer overflow in vm_pageout_page_stats() on machines with a
     large number of physical pages.
   
   PR:             126158
   Approved by:    re (kib)
   
   Revision   Changes    Path
   1.268.2.6  +2 -1      src/sys/vm/vm_pageout.c
 _______________________________________________
 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:
