From smcho@tsp.korea.ac.kr  Thu Oct 12 21:09:05 2000
Return-Path: <smcho@tsp.korea.ac.kr>
Received: from tsp.korea.ac.kr (tsp.korea.ac.kr [163.152.18.252])
	by hub.freebsd.org (Postfix) with ESMTP
	id ACB0F37B66C; Thu, 12 Oct 2000 21:08:49 -0700 (PDT)
Received: from localhost (smcho@localhost)
	by tsp.korea.ac.kr (8.9.3/8.9.3) with ESMTP id NAA30630;
	Fri, 13 Oct 2000 13:04:39 +0900 (KST)
Message-Id: <Pine.BSO.4.10.10010131255420.20037-100000@tsp.korea.ac.kr>
Date: Fri, 13 Oct 2000 13:04:39 +0900 (KST)
From: <smcho@tsp.korea.ac.kr>
To: FreeBSD-gnats-submit@freebsd.org
Cc: freebsd-bugs@freebsd.org
Subject: smget(2) assumes the size in pages

>Number:         21947
>Category:       kern
>Synopsis:       shmget(2) takes 'size' in pages as opposed to bytes.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 12 21:10:01 PDT 2000
>Closed-Date:    Fri Oct 13 03:16:46 PDT 2000
>Last-Modified:  Fri Oct 13 03:17:49 PDT 2000
>Originator:     smcho@tsp.korea.ac.kr
>Release:        FreeBSD 3.5.1-RELEASE i386
>Organization:
>Environment:

	All branches supporting SYSV shared memory.

>Description:

	shmget(2) is described to take the second argument as 'the desired
	size of the new segment in bytes', but in reality, it takes the
	second argument as the size in _pages_.

>How-To-Repeat:

	Read the source:
		sys/kern/sysv_shm.c
		lib/libc/gen/shmget.c

>Fix:

	Attached is a patch to lib/libc/gen/shmget.c

*** /usr/src/lib/libc/gen/shmget.c.orig	Thu Oct 12 20:43:52 2000
--- /usr/src/lib/libc/gen/shmget.c	Thu Oct 12 20:47:36 2000
***************
*** 5,10 ****
--- 5,11 ----
  #include <sys/types.h>
  #include <sys/ipc.h>
  #include <sys/shm.h>
+ #include <sys/param.h>
  
  #if __STDC__
  int shmget(key_t key, int size, int shmflg)
***************
*** 15,19 ****
  	int shmflg;
  #endif
  {
! 	return (shmsys(3, key, size, shmflg));
  }
--- 16,25 ----
  	int shmflg;
  #endif
  {
! 	int page = size / PAGE_SIZE;
! 
! 	if (size % PAGE_SIZE > 0)
! 		page++;
! 
! 	return (shmsys(3, key, page, shmflg));
  }



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Fri Oct 13 03:16:46 PDT 2000 
State-Changed-Why:  
Closed at submitters request (probabal misreading of source code). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21947 
>Unformatted:
