Bug 7420

Summary: [PATCH] Maximum socket buffer size (SB_MAX) could not go higher than 2^21
Product: Base System Reporter: ioannis <ioannis>
Component: i386Assignee: silby
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description ioannis 1998-07-28 02:40:00 UTC
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)

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.
Comment 1 Poul-Henning Kamp freebsd_committer freebsd_triage 1998-07-28 10:06:37 UTC
State Changed
From-To: open->suspended

awaiting review & comitter 
Comment 2 silby freebsd_committer freebsd_triage 2002-01-06 01:30:03 UTC
State Changed
From-To: suspended->analyzed

This change seems reasonable, I'll doublecheck the patch and 
get it committed. 


Comment 3 silby freebsd_committer freebsd_triage 2002-01-06 01:30:03 UTC
Responsible Changed
From-To: freebsd-bugs->silby
Comment 4 silby freebsd_committer freebsd_triage 2002-01-06 06:51:11 UTC
State Changed
From-To: analyzed->closed

A modified version of this change has been committed to -current, 
and it will be mfc'd to -stable in 3 weeks.