Skip to contentSkip to conversation

selinux: use kernel linux/socket.h definitions for PF_MAX

PATCH Applied Paulo Alcantara 3 participants 6 messages Feb 25, 2019 – Mar 18, 2019 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: use kernel linux/socket.h definitions for PF_MAX

When compiling genheaders and mdp from a newer host kernel, the following error happens:

In file included from scripts/selinux/genheaders/genheaders.c:18:
./security/selinux/include/classmap.h:238:2: error: #error New address family defined, please update secclass_map. #error New address family defined, please update secclass_map. ^~~~~ make[3]: *** [scripts/Makefile.host:107:
scripts/selinux/genheaders/genheaders] Error 1 make[2]: *** [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2 make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2 make[1]: *** Waiting for unfinished jobs....

Instead of relying on the host definition, include linux/socket.h in classmap.h to have PF_MAX.

---
 scripts/selinux/genheaders/genheaders.c | 1 -
 scripts/selinux/mdp/mdp.c               | 1 -
 security/selinux/include/classmap.h     | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)
scripts/selinux/genheaders/genheaders.c +0 -1
index 1ceedea847dd..544ca126a8a8 100644
@@ -9,7 +9,6 @@
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
-#include <sys/socket.h>
 
 struct security_class_mapping {
 	const char *name;
scripts/selinux/mdp/mdp.c +0 -1
index 073fe7537f6c..6d51b74bc679 100644
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <sys/socket.h>
 
 static void usage(char *name)
 {
security/selinux/include/classmap.h +1 -0
index bd5fe0d3204a..201f7e588a29 100644
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/capability.h>
+#include <linux/socket.h>
 
 #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", \
     "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map"
Signature · 1 line
2.20.1
#1 lore raw
Quoted 16 lines · Paulo Alcantara

When compiling genheaders and mdp from a newer host kernel, the following error happens:

In file included from scripts/selinux/genheaders/genheaders.c:18:
./security/selinux/include/classmap.h:238:2: error: #error New address family defined, please update secclass_map. #error New address family defined, please update secclass_map. ^~~~~ make[3]: *** [scripts/Makefile.host:107:
scripts/selinux/genheaders/genheaders] Error 1 make[2]: *** [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2 make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2 make[1]: *** Waiting for unfinished jobs....

Instead of relying on the host definition, include linux/socket.h in classmap.h to have PF_MAX.

Quoted 6 lines
---
 scripts/selinux/genheaders/genheaders.c | 1 -
 scripts/selinux/mdp/mdp.c               | 1 -
 security/selinux/include/classmap.h     | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)

Ping?

Could someone please take a look at this issue?

It's quite easy to reproduce on my host (4.20+) when building an unpatched 4.14 kernel[1]:

    $ make defconfig
    *** Default configuration is based on 'x86_64_defconfig'
    #
    # configuration written to .config
    #
    $ make scripts
    scripts/kconfig/conf  --silentoldconfig Kconfig
      WRAP    arch/x86/include/generated/asm/clkdev.h
      WRAP    arch/x86/include/generated/asm/dma-contiguous.h
      WRAP    arch/x86/include/generated/asm/early_ioremap.h
      WRAP    arch/x86/include/generated/asm/mcs_spinlock.h
      WRAP    arch/x86/include/generated/asm/mm-arch-hooks.h
      CC      scripts/mod/empty.o
      HOSTCC  scripts/mod/mk_elfconfig
      MKELF   scripts/mod/elfconfig.h
      HOSTCC  scripts/mod/modpost.o
      CC      scripts/mod/devicetable-offsets.s
      CHK     scripts/mod/devicetable-offsets.h
      UPD     scripts/mod/devicetable-offsets.h
      HOSTCC  scripts/mod/file2alias.o
      HOSTCC  scripts/mod/sumversion.o
      HOSTLD  scripts/mod/modpost
      HOSTCC  scripts/selinux/genheaders/genheaders
    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.
     #error New address family defined, please update secclass_map.
      ^~~~~
    make[3]: *** [scripts/Makefile.host:102: scripts/selinux/genheaders/genheaders] Error 1
    make[2]: *** [scripts/Makefile.build:585: scripts/selinux/genheaders] Error 2
    make[1]: *** [scripts/Makefile.build:585: scripts/selinux] Error 2
    make: *** [Makefile:572: scripts] Error 2

Thanks
Paulo

[1] https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.104.tar.xz

Quoted 38 lines
scripts/selinux/genheaders/genheaders.c +0 -1
index 1ceedea847dd..544ca126a8a8 100644
@@ -9,7 +9,6 @@
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
-#include <sys/socket.h>
 
 struct security_class_mapping {
 	const char *name;
scripts/selinux/mdp/mdp.c +0 -1
index 073fe7537f6c..6d51b74bc679 100644
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <sys/socket.h>
 
 static void usage(char *name)
 {
security/selinux/include/classmap.h +1 -0
index bd5fe0d3204a..201f7e588a29 100644
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/capability.h>
+#include <linux/socket.h>
 
 #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", \
     "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map"
Signature · 1 line
2.20.1
maintainer
#2 lore raw
Quoted 24 lines · Paulo Alcantara
Quoted 16 lines · Paulo Alcantara

When compiling genheaders and mdp from a newer host kernel, the following error happens:

In file included from scripts/selinux/genheaders/genheaders.c:18:
./security/selinux/include/classmap.h:238:2: error: #error New address family defined, please update secclass_map. #error New address family defined, please update secclass_map. ^~~~~ make[3]: *** [scripts/Makefile.host:107:
scripts/selinux/genheaders/genheaders] Error 1 make[2]: *** [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2 make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2 make[1]: *** Waiting for unfinished jobs....

Instead of relying on the host definition, include linux/socket.h in classmap.h to have PF_MAX.

Quoted 6 lines
---
 scripts/selinux/genheaders/genheaders.c | 1 -
 scripts/selinux/mdp/mdp.c               | 1 -
 security/selinux/include/classmap.h     | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)
Quoted 3 lines

Ping?

Could someone please take a look at this issue?

It looks fine to me, but I typically don't merge patches this late in the development window (we are at -rc8), unless it is a serious bug fix.

Quoted 2 lines

It's quite easy to reproduce on my host (4.20+) when building an unpatched 4.14 kernel ...

While this is a good patch that does fix a real but, the fact that it has been broken for several releases tells me this is not a serious bug and not likely worth the risk for the upcoming merge window (however small it may be). There has been a lot of good work put into mdp very recently, and I expect to merge that, as well as your fix, once the upcoming merge window closes.

Signature · 2 lines
paul moore
www.paul-moore.com
#3 lore raw
Quoted 25 lines · Paul Moore
Quoted 24 lines · Paulo Alcantara
Quoted 22 lines · Paulo Alcantara

When compiling genheaders and mdp from a newer host kernel, the following error happens:

In file included from scripts/selinux/genheaders/genheaders.c:18:
./security/selinux/include/classmap.h:238:2: error: #error New address family defined, please update secclass_map. #error New address family defined, please update secclass_map. ^~~~~ make[3]: *** [scripts/Makefile.host:107:
scripts/selinux/genheaders/genheaders] Error 1 make[2]: *** [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2 make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2 make[1]: *** Waiting for unfinished jobs....

Instead of relying on the host definition, include linux/socket.h in classmap.h to have PF_MAX.

---
 scripts/selinux/genheaders/genheaders.c | 1 -
 scripts/selinux/mdp/mdp.c               | 1 -
 security/selinux/include/classmap.h     | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)
Quoted 7 lines
Quoted 3 lines

Ping?

Could someone please take a look at this issue?

It looks fine to me, but I typically don't merge patches this late in the development window (we are at -rc8), unless it is a serious bug fix.

Fair enough.

Quoted 9 lines
Quoted 2 lines

It's quite easy to reproduce on my host (4.20+) when building an unpatched 4.14 kernel ...

While this is a good patch that does fix a real but, the fact that it has been broken for several releases tells me this is not a serious bug and not likely worth the risk for the upcoming merge window (however small it may be). There has been a lot of good work put into mdp very recently, and I expect to merge that, as well as your fix, once the upcoming merge window closes.

Looks good to me. Thanks!

Paulo

maintainer Applied
#4 lore raw
Quoted 40 lines · Paulo Alcantara
Quoted 25 lines · Paul Moore
Quoted 24 lines · Paulo Alcantara
Quoted 22 lines · Paulo Alcantara

When compiling genheaders and mdp from a newer host kernel, the following error happens:

In file included from scripts/selinux/genheaders/genheaders.c:18:
./security/selinux/include/classmap.h:238:2: error: #error New address family defined, please update secclass_map. #error New address family defined, please update secclass_map. ^~~~~ make[3]: *** [scripts/Makefile.host:107:
scripts/selinux/genheaders/genheaders] Error 1 make[2]: *** [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2 make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2 make[1]: *** Waiting for unfinished jobs....

Instead of relying on the host definition, include linux/socket.h in classmap.h to have PF_MAX.

---
 scripts/selinux/genheaders/genheaders.c | 1 -
 scripts/selinux/mdp/mdp.c               | 1 -
 security/selinux/include/classmap.h     | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)
Quoted 7 lines
Quoted 3 lines

Ping?

Could someone please take a look at this issue?

It looks fine to me, but I typically don't merge patches this late in the development window (we are at -rc8), unless it is a serious bug fix.

Fair enough.

Quoted 3 lines
Quoted 2 lines

It's quite easy to reproduce on my host (4.20+) when building an unpatched 4.14 kernel ...

Quoted 8 lines
Quoted 6 lines

While this is a good patch that does fix a real but, the fact that it has been broken for several releases tells me this is not a serious bug and not likely worth the risk for the upcoming merge window (however small it may be). There has been a lot of good work put into mdp very recently, and I expect to merge that, as well as your fix, once the upcoming merge window closes.

Looks good to me. Thanks!

Merged into selinux/next, thanks for the patch and your patience.

Signature · 2 lines
paul moore
www.paul-moore.com
Acked-by on v1 1/1
#5 lore raw
In reply to Paulo Alcantara
Quoted 13 lines · Paulo Alcantara

When compiling genheaders and mdp from a newer host kernel, the following error happens:

In file included from scripts/selinux/genheaders/genheaders.c:18:
./security/selinux/include/classmap.h:238:2: error: #error New address family defined, please update secclass_map. #error New address family defined, please update secclass_map. ^~~~~ make[3]: *** [scripts/Makefile.host:107:
scripts/selinux/genheaders/genheaders] Error 1 make[2]: *** [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2 make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2 make[1]: *** Waiting for unfinished jobs....

Quoted 4 lines

Instead of relying on the host definition, include linux/socket.h in classmap.h to have PF_MAX.

Quoted 42 lines
---
  scripts/selinux/genheaders/genheaders.c | 1 -
  scripts/selinux/mdp/mdp.c               | 1 -
  security/selinux/include/classmap.h     | 1 +
  3 files changed, 1 insertion(+), 2 deletions(-)
scripts/selinux/genheaders/genheaders.c +0 -1
index 1ceedea847dd..544ca126a8a8 100644
@@ -9,7 +9,6 @@
  #include <string.h>
  #include <errno.h>
  #include <ctype.h>
-#include <sys/socket.h>
 
  struct security_class_mapping {
  	const char *name;
scripts/selinux/mdp/mdp.c +0 -1
index 073fe7537f6c..6d51b74bc679 100644
@@ -32,7 +32,6 @@
  #include <stdlib.h>
  #include <unistd.h>
  #include <string.h>
-#include <sys/socket.h>
 
  static void usage(char *name)
  {
security/selinux/include/classmap.h +1 -0
index bd5fe0d3204a..201f7e588a29 100644
@@ -1,5 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0 */
  #include <linux/capability.h>
+#include <linux/socket.h>
 
  #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", \
      "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map"