Bug 19513 - procps incorrectly accesses kernel headers
procps incorrectly accesses kernel headers
Product: Red Hat Linux
Classification: Retired
Component: procps (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Preston Brown
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2000-10-21 13:09 EDT by Need Real Name
Modified: 2007-04-18 12:29 EDT (History)
4 users (show)

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

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2000-10-21 13:09:31 EDT
According to folks on libc-alpha any program that accesses kernel headers
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
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
of accessing kernel headers...

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

#define PAGE_SHIFT	12

int i,pagesize,pageshift;


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
is released.
Comment 1 Preston Brown 2001-02-01 15:17:26 EST
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. 
Comment 2 Preston Brown 2001-03-10 01:54:17 EST
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.