From nobody  Mon Jul 27 18:32:37 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id SAA04111;
          Mon, 27 Jul 1998 18:32:37 -0700 (PDT)
          (envelope-from nobody)
Message-Id: <199807280132.SAA04111@hub.freebsd.org>
Date: Mon, 27 Jul 1998 18:32:37 -0700 (PDT)
From: ioannis@andrew.cmu.edu, pnm@andrew.cmu.edu
To: freebsd-gnats-submit@freebsd.org
Subject: Maximum socket buffer size (SB_MAX) could not go higher than 2^21
X-Send-Pr-Version: www-1.0

>Number:         7420
>Category:       i386
>Synopsis:       [PATCH] Maximum socket buffer size (SB_MAX) could not go higher than 2^21
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    silby
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 27 18:40:00 PDT 1998
>Closed-Date:    Sat Jan 5 22:51:11 PST 2002
>Last-Modified:  Sat Jan 05 22:52:09 PST 2002
>Originator:     Yannis Pavlidis, Parag Manihar
>Release:        2.2.6
>Organization:
Carnegie Mellon University
>Environment:
FreeBSD z3.ini.cmu.edu 2.2.6-RELEASE FreeBSD 2.2.6-RELEASE #4: Mon Jul 27 21:07:57 EDT 1998     root@z3.ini.cmu.edu:/usr/src/sys/compile/Z3  i386

>Description:
Hi,

I was trying to increase the maximum socket buffer size (SB_MAX or kern.maxsockbuf)
in my kernel and I realized that the maximum I could go was: 2097151 (2^21 - 1).
If the SB_MAX was >= 2^21 I could not open any socket.

After spending a lot of time I realised that in the file:

kern/uipc_socket2.c in the sbreserve function there is the following line:

if (cc > sb_max * MCLBYTES / (MSIZE + MCLBYTES))

Taking into account that the highest number we can have is 2^32 -1 and that

MCLBYTES = 2048 = 2^11 it is obvious that if sb_max was 2^21 we would have
an overflow (sb_max * MCLBYTES = 2^21 * 2^11 = 2^32 overflow)


>How-To-Repeat:

>Fix:
The above can be easily corrected by replacing the above line with the 
following:

if (cc > (sb_max / (MSIZE + MCLBYTES)) * MCLBYTES)

In this case we can have SB_MAX with greater values.

Thanks.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Tue Jul 28 02:06:37 PDT 1998 
State-Changed-Why:  
awaiting review & comitter 
State-Changed-From-To: suspended->analyzed 
State-Changed-By: silby 
State-Changed-When: Sat Jan 5 17:30:03 PST 2002 
State-Changed-Why:  
This change seems reasonable, I'll doublecheck the patch and 
get it committed. 


Responsible-Changed-From-To: freebsd-bugs->silby 
Responsible-Changed-By: silby 
Responsible-Changed-When: Sat Jan 5 17:30:03 PST 2002 
Responsible-Changed-Why:  

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=7420 
State-Changed-From-To: analyzed->closed 
State-Changed-By: silby 
State-Changed-When: Sat Jan 5 22:51:11 PST 2002 
State-Changed-Why:  
A modified version of this change has been committed to -current, 
and it will be mfc'd to -stable in 3 weeks. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=7420 
>Unformatted:
