Bug 7420 - [PATCH] Maximum socket buffer size (SB_MAX) could not go higher than 2^21
Summary: [PATCH] Maximum socket buffer size (SB_MAX) could not go higher than 2^21
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: i386 (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: silby
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1998-07-28 02:40 UTC by ioannis
Modified: 2002-01-06 06:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.