Bug 19513

Summary: procps incorrectly accesses kernel headers
Product: [Retired] Red Hat Linux Reporter: Need Real Name <howarth>
Component: procpsAssignee: Preston Brown <pbrown>
Status: CLOSED NOTABUG QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: ckjohnson, davem, dr, johnsonm
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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: --- Target Upstream Version:
Embargoed:

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>) 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.