Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

sockets - Kernel compilation fails due to PF_MAX > 44

I have a QEMU VM running an image of the Linux kernel 4.14.78.

On the host machine (a server with 96 cores), I am trying to compile a new update for the kernel with some changes I have made. To make this process faster, I was using the host machine to compile for the target VM.

To do that I follow these steps:

  • copy the /boot/config-4.14.78 file from VM to host

  • put the copied file into the kernel source-code root directory, renaming it to .config in my

  • run make clean to clean it

  • run make menuconfig just to update the configs

  • run make -j$(nproc)

However, I am getting this error:

  AS      arch/x86/purgatory/setup-x86_64.o
  CC      arch/x86/purgatory/sha256.o
  AS      arch/x86/purgatory/entry64.o
  CC      arch/x86/purgatory/string.o
In file included from scripts/selinux/mdp/mdp.c:49:
./security/selinux/include/classmap.h:245:2: error: #error New address family defined, please update secclass_map.
  245 | #error New address family defined, please update secclass_map.
      |  ^~~~~
make[3]: *** [scripts/Makefile.host:102: scripts/selinux/mdp/mdp] Error 1
make[2]: *** [scripts/Makefile.build:587: scripts/selinux/mdp] Error 2
make[2]: *** Waiting for unfinished jobs....
In file included from scripts/selinux/genheaders/genheaders.c:19:
./security/selinux/include/classmap.h:245:2: error: #error New address family defined, please update secclass_map.
  245 | #error New address family defined, please update secclass_map.
      |  ^~~~~
  CHK     scripts/mod/devicetable-offsets.h
make[3]: *** [scripts/Makefile.host:102: scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/Makefile.build:587: scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/Makefile.build:587: scripts/selinux] Error 2
make[1]: *** Waiting for unfinished jobs....

I have checked what causes this, and turns out that it is because of the:

include/linux/socket.h:211:#define AF_MAX       44  /* For now.. */
include/linux/socket.h:260:#define PF_MAX       AF_MAX

Then, I followed this solution to print out the definition of PF_MAX at preprocessing time, and turns out that the PF_MAX is 45:

In file included from scripts/selinux/mdp/mdp.c:49:
./security/selinux/include/classmap.h:247:9: note: #pragma message: 45
  247 | #pragma message(STRING(PF_MAX))
      |         ^~~~~~~
./security/selinux/include/classmap.h:250:2: error: #error New address family defined, please update secclass_map.
  250 | #error New address family defined, please update secclass_map.
      |  ^~~~~

This 45 makes no sense for me, because I just checked that it is supposed to be 44.

I wonder if the build is considering the host machine instead of the target?

P.S.: These steps works fine on my local machine, which is a 8-cores machine, look the kernel version:

uname -a
Linux campes-note 5.4.86 #1 SMP Fri Jan 1 16:26:25 -03 2021 x86_64 x86_64 x86_64 GNU/Linux

UPDATE 1: I tried to compile the kernel without any of my changes, following th above steps mentioned, and it did not compile as well, I get the same error.

UPDATE 2: I found out that somehow, the compilation is looking at the host /usr/src/linux-headers-x.x.x files. Instead, it should point to the same version as the target.

For that, I tried to follow this tutorial but I did not success. I am having a problem in one of the steps stated on this tutorial.

question from:https://stackoverflow.com/questions/65672033/kernel-compilation-fails-due-to-pf-max-44

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

(Gathered from the now removed comments)

I have tried myself to build myself v4.14.78 followed by the latest available v4.14.214. I have found that former fails while the latter builds. So, I have bisected down to v4.14.116 that first builds correctly. Then I simple looked into the changes and found commit 760f8522ce08 ("selinux: use kernel linux/socket.h for genheaders and mdp") in the Linux stable tree which fixes the issue.

You may try to cherry-pick it to your branch and compile again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...