Bug 19513 - procps incorrectly accesses kernel headers
Summary: procps incorrectly accesses kernel headers
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: procps   
(Show other bugs)
Version: 7.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Preston Brown
QA Contact: Aaron Brown
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-10-21 17:09 UTC by Need Real Name
Modified: 2007-04-18 16:29 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-02-01 20:17:31 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Need Real Name 2000-10-21 17:09:31 UTC
According to folks on libc-alpha any program that accesses kernel headers
(asm)
in userland are broken and should be fixed. Our maintainer for Linux 2.4 
(Paul Mackerras <paulus@linuxcare.com>) has wrapped all of our asm-ppc
kernel headers in #ifdef __KERNEL__/#endif wrappers to prevent userland
programs from accessing their contents. This has revealed that procps is
broken
in that it repeatedly access PAGE_SIZE and PAGE_SHIFT from asm/page.h.
On linuxppc, we believe the following test program demonstrates that these
values can be obtained for procps without resorting to the current broken
behavior 
of accessing kernel headers...

----------------------------------------------------------
#include <stdio.h>
#include <sys/shm.h>

#define PAGE_SHIFT	12
#define PAGE_SIZE	(1UL << PAGE_SHIFT)

int i,pagesize,pageshift;

main()
{
pagesize=__getpagesize();

for(i=1; i <= 8*sizeof(int); i++) {
  if( pagesize & (1UL << i)) {
    pageshift += i;
  }
}

printf("pagesize is %d\n",pagesize);
printf("pagesize is %d\n",PAGE_SIZE);
printf("pageshift is %d\n",pageshift);
printf("pageshift is %d\n",PAGE_SHIFT);

---------------------------------------------
This code works fine on Linuxppc running glibc 2.1.95/Linux 2.4-testpre3
/gcc 2.95.3. Below is the output I get from it here...

pagesize is 4096
pagesize is 4096
pageshift is 12
pageshift is 12

Please fix procps in rawhide so we can test the fixed version before Linux
2.4
is released.

Comment 1 Preston Brown 2001-02-01 20:17:26 UTC
but, you have redefined these internal kernel constants.  How can you be sure
they won't change?

I believe that procps needs to intrinsically depend on the kernel headers. 
Michael?

Comment 2 Preston Brown 2001-03-10 06:54:17 UTC
the assumption that userspace programs shouldn't access kernel constants and
data structures is a good general rule, but it doesn't _always_ apply.  procps
is a case where it doesn't.


Note You need to log in before you can comment on or make changes to this bug.