• Nicolas Iooss's avatar
    selinux: include sys/socket.h in host programs to have PF_MAX · c017c71c
    Nicolas Iooss authored
    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: default avatarNicolas Iooss <nicolas.iooss@m4x.org>
    Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
    c017c71c
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...