1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2016d825fSJohn Johansen# Makefile for AppArmor Linux Security Module 3016d825fSJohn Johansen# 4016d825fSJohn Johansenobj-$(CONFIG_SECURITY_APPARMOR) += apparmor.o 5016d825fSJohn Johansen 6de62de59SJohn Johansenapparmor-y := apparmorfs.o audit.o capability.o task.o ipc.o lib.o match.o \ 7016d825fSJohn Johansen path.o domain.o policy.o policy_unpack.o procattr.o lsm.o \ 8*56974a6fSJohn Johansen resource.o secid.o file.o policy_ns.o label.o mount.o net.o 9f8eb8a13SJohn Johansenapparmor-$(CONFIG_SECURITY_APPARMOR_HASH) += crypto.o 10016d825fSJohn Johansen 11*56974a6fSJohn Johansenclean-files := capability_names.h rlim_names.h net_names.h 12016d825fSJohn Johansen 13*56974a6fSJohn Johansen# Build a lower case string table of address family names 14*56974a6fSJohn Johansen# Transform lines from 15*56974a6fSJohn Johansen# #define AF_LOCAL 1 /* POSIX name for AF_UNIX */ 16*56974a6fSJohn Johansen# #define AF_INET 2 /* Internet IP Protocol */ 17*56974a6fSJohn Johansen# to 18*56974a6fSJohn Johansen# [1] = "local", 19*56974a6fSJohn Johansen# [2] = "inet", 20*56974a6fSJohn Johansen# 21*56974a6fSJohn Johansen# and build the securityfs entries for the mapping. 22*56974a6fSJohn Johansen# Transforms lines from 23*56974a6fSJohn Johansen# #define AF_INET 2 /* Internet IP Protocol */ 24*56974a6fSJohn Johansen# to 25*56974a6fSJohn Johansen# #define AA_SFS_AF_MASK "local inet" 26*56974a6fSJohn Johansenquiet_cmd_make-af = GEN $@ 27*56974a6fSJohn Johansencmd_make-af = echo "static const char *address_family_names[] = {" > $@ ;\ 28*56974a6fSJohn Johansen sed $< >>$@ -r -n -e "/AF_MAX/d" -e "/AF_LOCAL/d" -e "/AF_ROUTE/d" -e \ 29*56974a6fSJohn Johansen 's/^\#define[ \t]+AF_([A-Z0-9_]+)[ \t]+([0-9]+)(.*)/[\2] = "\L\1",/p';\ 30*56974a6fSJohn Johansen echo "};" >> $@ ;\ 31*56974a6fSJohn Johansen printf '%s' '\#define AA_SFS_AF_MASK "' >> $@ ;\ 32*56974a6fSJohn Johansen sed -r -n -e "/AF_MAX/d" -e "/AF_LOCAL/d" -e "/AF_ROUTE/d" -e \ 33*56974a6fSJohn Johansen 's/^\#define[ \t]+AF_([A-Z0-9_]+)[ \t]+([0-9]+)(.*)/\L\1/p'\ 34*56974a6fSJohn Johansen $< | tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@ 35*56974a6fSJohn Johansen 36*56974a6fSJohn Johansen# Build a lower case string table of sock type names 37*56974a6fSJohn Johansen# Transform lines from 38*56974a6fSJohn Johansen# SOCK_STREAM = 1, 39*56974a6fSJohn Johansen# to 40*56974a6fSJohn Johansen# [1] = "stream", 41*56974a6fSJohn Johansenquiet_cmd_make-sock = GEN $@ 42*56974a6fSJohn Johansencmd_make-sock = echo "static const char *sock_type_names[] = {" >> $@ ;\ 43*56974a6fSJohn Johansen sed $^ >>$@ -r -n \ 44*56974a6fSJohn Johansen -e 's/^\tSOCK_([A-Z0-9_]+)[\t]+=[ \t]+([0-9]+)(.*)/[\2] = "\L\1",/p';\ 45*56974a6fSJohn Johansen echo "};" >> $@ 464fdef218SJohn Johansen 474fdef218SJohn Johansen# Build a lower case string table of capability names 484fdef218SJohn Johansen# Transforms lines from 494fdef218SJohn Johansen# #define CAP_DAC_OVERRIDE 1 504fdef218SJohn Johansen# to 514fdef218SJohn Johansen# [1] = "dac_override", 52016d825fSJohn Johansenquiet_cmd_make-caps = GEN $@ 537e570145STetsuo Handacmd_make-caps = echo "static const char *const capability_names[] = {" > $@ ;\ 544fdef218SJohn Johansen sed $< >>$@ -r -n -e '/CAP_FS_MASK/d' \ 554fdef218SJohn Johansen -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/[\2] = "\L\1",/p';\ 5684f1f787SJohn Johansen echo "};" >> $@ ;\ 57c97204baSJohn Johansen printf '%s' '\#define AA_SFS_CAPS_MASK "' >> $@ ;\ 5884f1f787SJohn Johansen sed $< -r -n -e '/CAP_FS_MASK/d' \ 5984f1f787SJohn Johansen -e 's/^\#define[ \t]+CAP_([A-Z0-9_]+)[ \t]+([0-9]+)/\L\1/p' | \ 6084f1f787SJohn Johansen tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@ 61016d825fSJohn Johansen 624fdef218SJohn Johansen 634fdef218SJohn Johansen# Build a lower case string table of rlimit names. 644fdef218SJohn Johansen# Transforms lines from 654fdef218SJohn Johansen# #define RLIMIT_STACK 3 /* max stack size */ 664fdef218SJohn Johansen# to 674fdef218SJohn Johansen# [RLIMIT_STACK] = "stack", 684fdef218SJohn Johansen# 694fdef218SJohn Johansen# and build a second integer table (with the second sed cmd), that maps 70d384b0a1SKees Cook# RLIMIT defines to the order defined in asm-generic/resource.h This is 714fdef218SJohn Johansen# required by policy load to map policy ordering of RLIMITs to internal 724fdef218SJohn Johansen# ordering for architectures that redefine an RLIMIT. 734fdef218SJohn Johansen# Transforms lines from 744fdef218SJohn Johansen# #define RLIMIT_STACK 3 /* max stack size */ 754fdef218SJohn Johansen# to 764fdef218SJohn Johansen# RLIMIT_STACK, 77d384b0a1SKees Cook# 78d384b0a1SKees Cook# and build the securityfs entries for the mapping. 79d384b0a1SKees Cook# Transforms lines from 80d384b0a1SKees Cook# #define RLIMIT_FSIZE 1 /* Maximum filesize */ 81d384b0a1SKees Cook# #define RLIMIT_STACK 3 /* max stack size */ 82d384b0a1SKees Cook# to 83c97204baSJohn Johansen# #define AA_SFS_RLIMIT_MASK "fsize stack" 84016d825fSJohn Johansenquiet_cmd_make-rlim = GEN $@ 857e570145STetsuo Handacmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \ 8633e521acSJohn Johansen > $@ ;\ 874fdef218SJohn Johansen sed $< >> $@ -r -n \ 884fdef218SJohn Johansen -e 's/^\# ?define[ \t]+(RLIMIT_([A-Z0-9_]+)).*/[\1] = "\L\2",/p';\ 894fdef218SJohn Johansen echo "};" >> $@ ;\ 90d384b0a1SKees Cook echo "static const int rlim_map[RLIM_NLIMITS] = {" >> $@ ;\ 914fdef218SJohn Johansen sed -r -n "s/^\# ?define[ \t]+(RLIMIT_[A-Z0-9_]+).*/\1,/p" $< >> $@ ;\ 92d384b0a1SKees Cook echo "};" >> $@ ; \ 93c97204baSJohn Johansen printf '%s' '\#define AA_SFS_RLIMIT_MASK "' >> $@ ;\ 94d384b0a1SKees Cook sed -r -n 's/^\# ?define[ \t]+RLIMIT_([A-Z0-9_]+).*/\L\1/p' $< | \ 95d384b0a1SKees Cook tr '\n' ' ' | sed -e 's/ $$/"\n/' >> $@ 96016d825fSJohn Johansen 97016d825fSJohn Johansen$(obj)/capability.o : $(obj)/capability_names.h 98*56974a6fSJohn Johansen$(obj)/net.o : $(obj)/net_names.h 99016d825fSJohn Johansen$(obj)/resource.o : $(obj)/rlim_names.h 10043c422edSJohn Johansen$(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \ 101d384b0a1SKees Cook $(src)/Makefile 102016d825fSJohn Johansen $(call cmd,make-caps) 1038a1ab315SDavid Howells$(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \ 104d384b0a1SKees Cook $(src)/Makefile 105016d825fSJohn Johansen $(call cmd,make-rlim) 106*56974a6fSJohn Johansen$(obj)/net_names.h : $(srctree)/include/linux/socket.h \ 107*56974a6fSJohn Johansen $(srctree)/include/linux/net.h \ 108*56974a6fSJohn Johansen $(src)/Makefile 109*56974a6fSJohn Johansen $(call cmd,make-af) 110*56974a6fSJohn Johansen $(call cmd,make-sock) 111