# Can't build any modules... permission denied.

## siknasa9

EDIT: Ok, I got it to build on the current version (had to eselect kernel set version I chmodded... durrp), but every time I install a new or updated kernel, I have to chmod 755 it. Anyone know why that could be?

```
odenheim linux # emerge app-emulation/virtualbox-modules

Calculating dependencies ... done!                            

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) app-emulation/virtualbox-modules-4.3.20::gentoo

 * vbox-kernel-module-src-4.3.20.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                    [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/3.17.0-pf2/build

 * Found sources for kernel version:

 *     3.17.0-pf2

>>> Unpacking source...

>>> Unpacking vbox-kernel-module-src-4.3.20.tar.xz to /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work

>>> Source unpacked in /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work

>>> Preparing source in /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work ...

>>> Source prepared.

>>> Configuring source in /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work ...

>>> Source configured.

>>> Compiling source in /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work ...

ln: failed to create symbolic link ‘Module.symvers’: File exists

 * Preparing vboxdrv module

make -j5 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' KERN_DIR=/usr/src/linux KERNOUT=/lib/modules/3.17.0-pf2/build all 

*** Building 'vboxdrv' module ***

make[1]: Entering directory '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv'

make KBUILD_VERBOSE= SUBDIRS=/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv SRCROOT=/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv CONFIG_MODULE_SIG= -C /usr/src/linux modules

make[2]: Entering directory '/usr/src/linux-3.17_p2-pf'

Makefile:1571: .vmlinux.cmd: Permission denied

  ERROR: Kernel configuration is invalid.

         include/generated/autoconf.h or include/config/auto.conf are missing.

         Run 'make oldconfig && make prepare' on kernel src to fix it.

make[3]: stat: include/config/auto.conf: Permission denied

  CC [M]  /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/linux/SUPDrv-linux.o

  CC [M]  /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrvSem.o

  CC [M]  /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrv.o

  CC [M]  /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrvTracer.o

  CC [M]  /var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/r0drv/alloc-r0drv.o

cc1: error: arch/x86/include/generated/uapi: Permission denied

cc1: error: include/generated/uapi: Permission denied

scripts/Makefile.build:257: recipe for target '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/linux/SUPDrv-linux.o' failed

make[3]: *** [/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/linux/SUPDrv-linux.o] Error 1

make[3]: *** Waiting for unfinished jobs....

cc1: error: arch/x86/include/generated/uapi: Permission denied

cc1: error: arch/x86/include/generated/uapi: Permission denied

cc1: error: arch/x86/include/generated/uapi: Permission denied

cc1: error: include/generated/uapi: Permission denied

cc1: error: include/generated/uapi: Permission denied

cc1: error: arch/x86/include/generated/uapi: Permission denied

cc1: error: include/generated/uapi: Permission denied

cc1: error: include/generated/uapi: Permission denied

scripts/Makefile.build:257: recipe for target '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrvSem.o' failed

make[3]: *** [/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrvSem.o] Error 1

scripts/Makefile.build:257: recipe for target '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/r0drv/alloc-r0drv.o' failed

make[3]: *** [/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/r0drv/alloc-r0drv.o] Error 1

scripts/Makefile.build:257: recipe for target '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrvTracer.o' failed

make[3]: *** [/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrvTracer.o] Error 1

scripts/Makefile.build:257: recipe for target '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrv.o' failed

make[3]: *** [/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv/SUPDrv.o] Error 1

Makefile:1373: recipe for target '_module_/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv' failed

make[2]: *** [_module_/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv] Error 2

make[2]: Leaving directory '/usr/src/linux-3.17_p2-pf'

Makefile:289: recipe for target 'vboxdrv' failed

make[1]: *** [vboxdrv] Error 2

make[1]: Leaving directory '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work/vboxdrv'

Makefile:39: recipe for target 'all' failed

make: *** [all] Error 2

 * ERROR: app-emulation/virtualbox-modules-4.3.20::gentoo failed (compile phase):

 *   emake failed

 * 

 * If you need support, post the output of `emerge --info '=app-emulation/virtualbox-modules-4.3.20::gentoo'`,

 * the complete build log and the output of `emerge -pqv '=app-emulation/virtualbox-modules-4.3.20::gentoo'`.

 * The complete build log is located at '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/temp/environment'.

 * Working directory: '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work'

 * S: '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/work'

>>> Failed to emerge app-emulation/virtualbox-modules-4.3.20, Log file:

>>>  '/var/tmp/portage/app-emulation/virtualbox-modules-4.3.20/temp/build.log'
```

Not sure what else I can do.

----------

## siknasa9

Now it won't load the modules. Just says not found. They live in /lib/modules/3.17.4-gentoo/misc which is my kernel version, but nothing. I've rebuilt the kernel and the modules a few times. Not sure if this might be related to the strange permissions of newly installed kernels. Any help would be appreciated.

----------

## Hu

Virtualbox appears to be building for 3.17.0-pf2, not 3.17.4.  As for your permissions problems, you will need to provide more detail.  You should never need to change permissions on files installed by Portage.

----------

## siknasa9

Yeah, that's why I was calling it strange. Yet, I have to change permissions in order to build any modules, else I get permission denied. The pf kernel thing was a typo. I am running that kernel. I was running 3.17.4, but now 3.17.0-pf. Regardless, I've built the modules, after changing the permissions of the kernel source, for both kernels now and it says not found.

----------

## Hu

Something else is wrong with your environment, then.  I suggest you undo the permissions changes you have made and solve that problem the right way, then deal with the other problem, whatever it turns out to be.

----------

## siknasa9

Well, thanks for the replies anyway... Not even sure where to start on the permissions thing. Guess I know how my weekend will be spent.

----------

## Hu

Start by posting the permissions and ownership of a denied resource and all the parents of that resource.

----------

## Watcom

I had the same problem, same error with emerging virtualbox-modules.

I think the issue is that I always compile the kernel using 

```
su -c make
```

etc, which in turn uses my normal user's environment and that means my umask, which happens to be 027 instead of 022.

So many of the files created when compiling the kernel are not world-readable because of this but I've never had any problems related to this before.

----------

## Goingtobecrazy

Hie, I'm sorry to up this topic, but I have the exact same issue: 

```

[32;01m * [39;49;00mPackage:    app-emulation/virtualbox-modules-5.0.20

[32;01m * [39;49;00mRepository: gentoo

[32;01m * [39;49;00mMaintainer: polynomial-c@gentoo.org

[32;01m * [39;49;00mUSE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU

[32;01m * [39;49;00mFEATURES:   preserve-libs sandbox userpriv usersandbox

 [32;01m*[0m Determining the location of the kernel source code

 [32;01m*[0m Found kernel source directory:

 [32;01m*[0m     /usr/src/linux

 [32;01m*[0m Found kernel object directory:

 [32;01m*[0m     /lib/modules/4.6.0-gnu/build

 [32;01m*[0m Found sources for kernel version:

 [32;01m*[0m     4.6.0-gnu

>>> Unpacking source...

>>> Unpacking vbox-kernel-module-src-5.0.20.tar.xz to /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work

>>> Source unpacked in /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work

>>> Preparing source in /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work ...

>>> Source prepared.

>>> Configuring source in /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work ...

>>> Source configured.

>>> Compiling source in /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work ...

ln: failed to create symbolic link 'Module.symvers': File exists

 [32;01m*[0m Preparing vboxdrv module

make -j5 -l5 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' KERN_DIR=/usr/src/linux KERNOUT=/lib/modules/4.6.0-gnu/build V=1 KBUILD_VERBOSE=1 all 

*** Building 'vboxdrv' module ***

make[1]: Entering directory '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv'

make KBUILD_VERBOSE=1 SUBDIRS=/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv SRCROOT=/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv CONFIG_MODULE_SIG= -C /usr/src/linux modules

make[2]: Entering directory '/usr/src/linux-libre-4.6'

test -e include/generated/autoconf.h -a -e include/config/auto.conf || (      \

echo >&2;                     \

echo >&2 "  ERROR: Kernel configuration is invalid.";      \

echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\

echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";   \

echo >&2 ;                     \

/bin/false)

  ERROR: Kernel configuration is invalid.

         include/generated/autoconf.h or include/config/auto.conf are missing.

         Run 'make oldconfig && make prepare' on kernel src to fix it.

mkdir -p /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/.tmp_versions ; rm -f /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/.tmp_versions/*

make -f ./scripts/Makefile.build obj=/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv

make[3]: stat: include/config/auto.conf: Permission denied

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/linux/.SUPDrv-linux.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -include /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include/VBox/SUPDrvMangling.h -I/usr/src/linux/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/r0drv/linux -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(SUPDrv_linux)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxdrv)" -c -o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/linux/SUPDrv-linux.o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/linux/SUPDrv-linux.c

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/.SUPDrv.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -include /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include/VBox/SUPDrvMangling.h -I/usr/src/linux/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/r0drv/linux -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(SUPDrv)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxdrv)" -c -o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrv.o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrv.c

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/.SUPDrvSem.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -include /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include/VBox/SUPDrvMangling.h -I/usr/src/linux/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/r0drv/linux -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(SUPDrvSem)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxdrv)" -c -o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvSem.o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvSem.c

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/.SUPDrvTracer.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -include /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include/VBox/SUPDrvMangling.h -I/usr/src/linux/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/r0drv/linux -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(SUPDrvTracer)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxdrv)" -c -o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvTracer.o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvTracer.c

[01m[Kcc1:[m[K [01;31m[Kerror: [m[Kinclude/generated/uapi: Permission denied

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/.SUPDrvGip.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -include /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include/VBox/SUPDrvMangling.h -I/usr/src/linux/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/r0drv/linux -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/ -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/include -I/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -Wno-declaration-after-statement -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(SUPDrvGip)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxdrv)" -c -o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvGip.o /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvGip.c

make[3]: *** [scripts/Makefile.build:291: /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/linux/SUPDrv-linux.o] Error 1

make[3]: *** Waiting for unfinished jobs....

[01m[Kcc1:[m[K [01;31m[Kerror: [m[Kinclude/generated/uapi: Permission denied

make[3]: *** [scripts/Makefile.build:291: /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrv.o] Error 1

[01m[Kcc1:[m[K [01;31m[Kerror: [m[Kinclude/generated/uapi: Permission denied

[01m[Kcc1:[m[K [01;31m[Kerror: [m[Kinclude/generated/uapi: Permission denied

[01m[Kcc1:[m[K [01;31m[Kerror: [m[Kinclude/generated/uapi: Permission denied

make[3]: *** [scripts/Makefile.build:291: /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvGip.o] Error 1

make[3]: *** [scripts/Makefile.build:291: /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvSem.o] Error 1

make[3]: *** [scripts/Makefile.build:291: /var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv/SUPDrvTracer.o] Error 1

make[2]: *** [Makefile:1428: _module_/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv] Error 2

make[2]: Leaving directory '/usr/src/linux-libre-4.6'

make[1]: *** [Makefile:298: vboxdrv] Error 2

make[1]: Leaving directory '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work/vboxdrv'

make: *** [Makefile:40: all] Error 2

 [31;01m*[0m ERROR: app-emulation/virtualbox-modules-5.0.20::gentoo failed (compile phase):

 [31;01m*[0m   emake failed

 [31;01m*[0m 

 [31;01m*[0m If you need support, post the output of `emerge --info '=app-emulation/virtualbox-modules-5.0.20::gentoo'`,

 [31;01m*[0m the complete build log and the output of `emerge -pqv '=app-emulation/virtualbox-modules-5.0.20::gentoo'`.

 [31;01m*[0m The complete build log is located at '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/temp/build.log'.

 [31;01m*[0m The ebuild environment file is located at '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/temp/environment'.

 [31;01m*[0m Working directory: '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work'

 [31;01m*[0m S: '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.20/work'

```

I tried out the regular kernel (4.6.0, because I'm usually using linux-libre), and it's the exact same error. I really don't understand. I'm running emerge as root, in a directory (/usr/src/linux) when I've "chown -R root".

When I upgraded my kernel, i did: "make olddefconfig; make; make modules_install; make install".

Moreover, I have some trouble like 3 month ago around the portage installation. I had to reinstall it. Can the problem be around emerge?

I don't understand how a root user, running what so ever command it wants can show a "permission denied" error.

Thanks for the reading. I have to struggle right know with libvirt and try to make qemu work... Maybe am I doing it wrong, libvirt not being the simpler intermediate to use qemu.

----------

## Syl20

Did you change root's umask ? If set to 027 or 077, all the created files are not world-readable, so the portage user (used to compile the packages, because of the "userpriv" FEATURE) can't read them.

On my firewall box, because of the 077 umask, I have to set the "nouserpriv" FEATURE on net-firewall/xtables-addons to force emerge to compile it as root, and then be able to read the kernel sources files.

You can set that feature by adding this line to /etc/portage/package.env :

```
app-emulation/virtualbox-modules  nouserpriv
```

Perhaps there's a more secure way to do, that said...

----------

