You are not logged in.

#1 2014-09-24 14:10:36

Truc
Member
Registered: 2014-03-06
Posts: 15

Gcc errors. Where is asm/page.h?

Hi,
I'm trying to compile some code using gcc. The code does include asm/page.h but I don't have thad header in /usr/include/asm or asm-generic. Linux headers are installed.

x.c:30:22: fatal error: asm/page.h: No such file or directory
 #include <asm/page.h>
                      ^
compilation terminated.

Any idea how to fix this?

Last edited by Truc (2014-09-24 14:15:29)

Offline

#2 2014-09-24 14:15:06

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

Re: Gcc errors. Where is asm/page.h?

Are you sure it shouldn't be asm/page.h? Not that that one is present.

Last edited by Marcel- (2014-09-24 14:15:21)

Offline

#3 2014-09-24 14:17:54

Truc
Member
Registered: 2014-03-06
Posts: 15

Re: Gcc errors. Where is asm/page.h?

Indeed Marcel-. I edited my post also included error message.

▶ ls /usr/include/asm-generic/
auxvec.h       int-ll64.h     mman.h         sembuf.h       signal.h   termbits.h
bitsperlong.h  ioctl.h        msgbuf.h       setup.h        socket.h   termios.h
errno-base.h   ioctls.h       param.h        shmbuf.h       sockios.h  types.h
errno.h        ipcbuf.h       poll.h         shmparam.h     stat.h     ucontext.h
fcntl.h        kvm_para.h     posix_types.h  siginfo.h      statfs.h   unistd.h
int-l64.h      mman-common.h  resource.h     signal-defs.h  swab.h

▶ ls /usr/include/asm
a.out.h          hyperv.h    msr-index.h        processor-flags.h  socket.h    unistd_32.h
auxvec.h         ioctl.h     msr.h              ptrace-abi.h       sockios.h   unistd_64.h
bitsperlong.h    ioctls.h    mtrr.h             ptrace.h           stat.h      unistd_x32.h
boot.h           ipcbuf.h    param.h            resource.h         statfs.h    vm86.h
bootparam.h      ist.h       perf_regs.h        sembuf.h           svm.h       vmx.h
byteorder.h      kvm.h       poll.h             setup.h            swab.h      vsyscall.h
debugreg.h       kvm_para.h  posix_types.h      shmbuf.h           termbits.h
e820.h           ldt.h       posix_types_32.h   sigcontext.h       termios.h
errno.h          mce.h       posix_types_64.h   sigcontext32.h     types.h
fcntl.h          mman.h      posix_types_x32.h  siginfo.h          ucontext.h
hw_breakpoint.h  msgbuf.h    prctl.h            signal.h           unistd.h

Offline

#4 2014-09-24 14:26:24

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

Re: Gcc errors. Where is asm/page.h?

This file seems to be present in the Linux kernel.

Offline

#5 2014-09-24 14:29:01

Msegade
Member
Registered: 2013-10-15
Posts: 7

Re: Gcc errors. Where is asm/page.h?

 $ pacman -Ql linux-headers | grep asm/page.h 

Offline

#6 2014-09-24 14:30:42

Truc
Member
Registered: 2014-03-06
Posts: 15

Re: Gcc errors. Where is asm/page.h?

Oh thanks... I located it. Now I'm facing this error..

x.c: In function ‘main’:
x.c:211:36: error: ‘PAGE_SIZE’ undeclared (first use in this function)
x.c:211:36: note: each undeclared identifier is reported only once for each function it appears in

sad

Offline

#7 2014-09-24 14:36:00

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

Re: Gcc errors. Where is asm/page.h?

Msegade wrote:
 $ pacman -Ql linux-headers | grep asm/page.h 

The result of that command is another page.h then the one in the Linux kernel (in include/asm-generic/, downloaded from [core]'s PKGBUILD). The latter contains PAGE_SIZE.

Last edited by Marcel- (2014-09-24 14:36:52)

Offline

#8 2014-09-24 14:43:06

Marcel-
Member
From: Utrecht, NL
Registered: 2006-12-03
Posts: 266

Re: Gcc errors. Where is asm/page.h?

You'll have to use <asm-generic/page.h> to use the file from linux-headers.

Offline

#9 2014-09-24 14:52:37

Truc
Member
Registered: 2014-03-06
Posts: 15

Re: Gcc errors. Where is asm/page.h?

The pacman command didn't return anything actualy... But I found it in /usr/lib/modules/3.16.2-1-ARCH/build/arch/x86/include/asm/ and created a link for page.h
Tried with the one from asm-generic too. Including asm-generic/page.h instead didn't seem to change anything. I still get the no such file error

Thanks for helping

edit: btw I'm trying on both arch and debian 3.12. Looks like on debian I get the PAGE_SIZE issue and on arch it still the no such file

Last edited by Truc (2014-09-24 14:54:37)

Offline

#10 2014-09-24 15:32:42

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Gcc errors. Where is asm/page.h?

Where does this code come from? What do you need out of that header? If you need the page size, PAGE_SIZE is a kernel only symbol. You more likely want to be calling getpagesize() from unistd.h.

As a general rule, you should never be directly importing any header that starts with 'asm' unless you know what you're doing (and don't care about discarding portability).

Offline

#11 2014-09-24 15:49:20

Truc
Member
Registered: 2014-03-06
Posts: 15

Re: Gcc errors. Where is asm/page.h?

It's this exploit http://www.exploit-db.com/exploits/5092/
I need it to (maybe) escalate privilege on some machine in my lab

Offline

#12 2014-09-24 16:17:29

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Gcc errors. Where is asm/page.h?

This is quite old code and I had to rewrite it to even compile.

No kidding. And that comment appears to be at least 6 years old....

Since this is a learning exercise for you, I'll stop here. I think I've already given you sufficient hinting on how to solve this for yourself.

Offline

Board footer

Powered by FluxBB