diff options
| author | Nicolas Iooss <nicolas.iooss@m4x.org> | 2017-03-05 09:01:52 -0500 |
|---|---|---|
| committer | Paul Moore <paul@paul-moore.com> | 2017-03-10 15:09:27 -0500 |
| commit | c017c71ce09f4c7a5378fccbec6a3d7e96b0c5c2 (patch) | |
| tree | 5e39795da65b23adaa26cd82e417ab927380688e /scripts | |
| parent | 579fc0dc09111c1f8b94742a0ed5a0bb8fdddbb9 (diff) | |
selinux: include sys/socket.h in host programs to have PF_MAX
Compiling with clang and -Wundef makes the compiler report a usage of
undefined PF_MAX macro in security/selinux/include/classmap.h:
In file included from scripts/selinux/mdp/mdp.c:48:
security/selinux/include/classmap.h:37:31: warning: no previous
extern declaration for non-static variable 'secclass_map'
[-Wmissing-variable-declarations]
struct security_class_mapping secclass_map[] = {
^
security/selinux/include/classmap.h:235:5: error: 'PF_MAX' is not
defined, evaluates to 0 [-Werror,-Wundef]
#if PF_MAX > 43
^
In file included from scripts/selinux/genheaders/genheaders.c:17:
security/selinux/include/classmap.h:37:31: warning: no previous
extern declaration for non-static variable 'secclass_map'
[-Wmissing-variable-declarations]
struct security_class_mapping secclass_map[] = {
^
security/selinux/include/classmap.h:235:5: error: 'PF_MAX' is not
defined, evaluates to 0 [-Werror,-Wundef]
#if PF_MAX > 43
^
PF_MAX is defined in include/linux/socket.h but not in
include/uapi/linux/socket.h. Therefore host programs have to rely on the
definition from libc's /usr/include/bits/socket.h, included by
<sys/socket.h>.
Fix the issue by using sys/socket.h in mdp and genheaders. When
classmap.h is included by security/selinux/avc.c, it uses the kernel
definition of PF_MAX, which makes the test consistent.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/selinux/genheaders/genheaders.c | 1 | ||||
| -rw-r--r-- | scripts/selinux/mdp/mdp.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c index f4dd41f900d5..6a24569c3578 100644 --- a/scripts/selinux/genheaders/genheaders.c +++ b/scripts/selinux/genheaders/genheaders.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <errno.h> | 9 | #include <errno.h> |
| 10 | #include <ctype.h> | 10 | #include <ctype.h> |
| 11 | #include <sys/socket.h> | ||
| 11 | 12 | ||
| 12 | struct security_class_mapping { | 13 | struct security_class_mapping { |
| 13 | const char *name; | 14 | const char *name; |
diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c index c29fa4a6228d..ffe8179f5d41 100644 --- a/scripts/selinux/mdp/mdp.c +++ b/scripts/selinux/mdp/mdp.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
| 33 | #include <unistd.h> | 33 | #include <unistd.h> |
| 34 | #include <string.h> | 34 | #include <string.h> |
| 35 | #include <sys/socket.h> | ||
| 35 | 36 | ||
| 36 | static void usage(char *name) | 37 | static void usage(char *name) |
| 37 | { | 38 | { |
