NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/38109: Shared memory code can't handle > 4GB of memory



>Number:         38109
>Category:       kern
>Synopsis:       Shared memory code can't handle > 4GB of memory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 26 21:40:00 +0000 2008
>Originator:     Chris Brand
>Release:        3.0
>Organization:
Redback Networks
>Environment:
It's our own MIPS-based hardware.
>Description:
The shared memory code stores the total number of bytes available for use as 
shared memory in shminfo.shmmax. This is a uint32_t, so it overflows at 4GB 
(note that it's initially set to the max number of pages, but this is the 
multiplied by PAGE_SIZE).

>How-To-Repeat:
Try setting SHMMAX to 1024*1024 on a machine with 4KB PAGE_SIZE and then 
allocating any amount of shared memory.

>Fix:
Patch follows. It looks like the second change to sysv_shm.c isn't needed in 
HEAD, but the rest are.

Index: sys/kern/sysv_shm.c
===================================================================
RCS file: /cvsroot/pkt/sw/netbsd300/usr/src/sys/kern/Attic/sysv_shm.c,v
retrieving revision 1.1.6.5
diff -r1.1.6.5 sysv_shm.c
130c130,131
< static int    shm_last_free, shm_nused, shm_committed;
---
> static int    shm_last_free, shm_nused;
> static size_t shm_committed;
557c558,559
<       int i, segnum, shmid, size;
---
>       int i, segnum, shmid;
>       size_t size;
Index: sys/sys/shm.h
===================================================================
RCS file: /cvsroot/pkt/sw/netbsd300/usr/src/sys/sys/Attic/shm.h,v
retrieving revision 1.1.6.1
diff -r1.1.6.1 shm.h
197c197
<       int32_t shmmax;         /* max shared memory segment size (bytes) */
---
>       int64_t shmmax;         /* max shared memory segment size (bytes) */
217d216
<       int32_t pad;    /* shminfo not a multiple of 64 bits */
Index: usr.bin/ipcs/ipcs.c
===================================================================
RCS file: /cvsroot/pkt/sw/netbsd300/usr/src/usr.bin/ipcs/Attic/ipcs.c,v
retrieving revision 1.1.6.1
diff -r1.1.6.1 ipcs.c
257c257
<       printf("\tshmmax: %7d\t(max shared memory segment size)\n",
---
>       printf("\tshmmax: %7ld\t(max shared memory segment size)\n",



Home | Main Index | Thread Index | Old Index