##// END OF EJS Templates
- added new kernel features asked in interactive setup while compiling...
Unknown -
r522:b527883a9d40
parent child
Show More
@@ -7,9 +7,10
7 7
8 8 # Need to use kali kernel src if nexmon is enabled
9 9 if [ "$ENABLE_NEXMON" = true ] ; then
10 echo "WARNING: if ENABLE_NEXMON is used remember to put the CORRECT KERNELSRC IN KERNELSRC_DIR!!!!!1!"
11 10 KERNEL_URL="${KALI_KERNEL_URL}"
11 # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel
12 12 KERNEL_BRANCH=""
13 KERNELSRC_DIR=""
13 14 fi
14 15
15 16 # Fetch and build latest raspberry kernel
@@ -93,7 +94,7 if [ "$BUILD_KERNEL" = true ] ; then
93 94 if [ "$KERNELSRC_CONFIG" = true ] ; then
94 95 # Load default raspberry kernel configuration
95 96 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
96
97
97 98 #Switch to KERNELSRC_DIR so we can use set_kernel_config
98 99 cd "${KERNEL_DIR}" || exit
99 100
@@ -106,7 +107,7 if [ "$BUILD_KERNEL" = true ] ; then
106 107 set_kernel_config CONFIG_ZSMALLOC y
107 108 set_kernel_config CONFIG_PGTABLE_MAPPING y
108 109 fi
109
110
110 111 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
111 112 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
112 113 set_kernel_config CONFIG_VIRTUALIZATION y
@@ -114,90 +115,109 if [ "$BUILD_KERNEL" = true ] ; then
114 115 set_kernel_config CONFIG_VHOST_NET m
115 116 set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y
116 117 fi
117
118
118 119 # enable apparmor,integrity audit,
119 120 if [ "$KERNEL_SECURITY" = true ] ; then
120 121
121 122 # security filesystem, security models and audit
122 set_kernel_config CONFIG_SECURITYFS y
123 set_kernel_config CONFIG_SECURITY y
123 set_kernel_config CONFIG_SECURITYFS y
124 set_kernel_config CONFIG_SECURITY y
124 125 set_kernel_config CONFIG_AUDIT y
125 126
126 # harden strcpy and memcpy
127 # harden strcpy and memcpy
127 128 set_kernel_config CONFIG_HARDENED_USERCOPY=y
128 129 set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y
129 set_kernel_config CONFIG_FORTIFY_SOURCE=y
130
131 # integrity sub-system
130 set_kernel_config CONFIG_FORTIFY_SOURCE=y
131
132 # integrity sub-system
132 133 set_kernel_config CONFIG_INTEGRITY=y
133 134 set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y
134 135 set_kernel_config CONFIG_INTEGRITY_AUDIT=y
135 136 set_kernel_config CONFIG_INTEGRITY_SIGNATURE=y
136 137 set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING=y
137
138 # This option provides support for retaining authentication tokens and access keys in the kernel.
138
139 # This option provides support for retaining authentication tokens and access keys in the kernel.
139 140 set_kernel_config CONFIG_KEYS=y
140 141 set_kernel_config CONFIG_KEYS_COMPAT=y
141
142 # Apparmor
142
143 # Apparmor
143 144 set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0
144 145 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y
145 set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y
146 set_kernel_config CONFIG_SECURITY_APPARMOR y
147 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y
148 set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor"
149
150 # restrictions on unprivileged users reading the kernel
146 set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y
147 set_kernel_config CONFIG_SECURITY_APPARMOR y
148 set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y
149 set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor"
150
151 # restrictions on unprivileged users reading the kernel
151 152 set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT=y
152
153 # network security hooks
153
154 # network security hooks
154 155 set_kernel_config CONFIG_SECURITY_NETWORK y
155 156 set_kernel_config CONFIG_SECURITY_NETWORK_XFRM=y
156 157 set_kernel_config CONFIG_SECURITY_PATH=y
157 158 set_kernel_config CONFIG_SECURITY_YAMA=y
158
159 # New Options
160 if [ "$KERNEL_NF" = true ] ; then
161 set_kernel_config CONFIG_IP_NF_SECURITY m
162 set_kernel_config CONFIG_NETLABEL m
163 set_kernel_config CONFIG_IP6_NF_SECURITY m
164 fi
165 set_kernel_config CONFIG_SECURITY_SELINUX n
166 set_kernel_config CONFIG_SECURITY_SMACK n
167 set_kernel_config CONFIG_SECURITY_TOMOYO n
168 set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n
169 set_kernel_config CONFIG_SECURITY_LOADPIN n
170 set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n
171 set_kernel_config CONFIG_IMA n
172 set_kernel_config CONFIG_EVM n
173 set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y
174 set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y
175 set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y
176 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y
177 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS y
178 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y
179 set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y
180 set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n
181 fi
182
159
160 # New Options
161 if [ "$KERNEL_NF" = true ] ; then
162 set_kernel_config CONFIG_IP_NF_SECURITY m
163 set_kernel_config CONFIG_NETLABEL y
164 set_kernel_config CONFIG_IP6_NF_SECURITY m
165 fi
166 set_kernel_config CONFIG_SECURITY_SELINUX n
167 set_kernel_config CONFIG_SECURITY_SMACK n
168 set_kernel_config CONFIG_SECURITY_TOMOYO n
169 set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n
170 set_kernel_config CONFIG_SECURITY_LOADPIN n
171 set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n
172 set_kernel_config CONFIG_IMA n
173 set_kernel_config CONFIG_EVM n
174 set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y
175 set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y
176 set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y
177 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y
178 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS y
179 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y
180 set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y
181 set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n
182 set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m
183 set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096
184
185 set_kernel_config CONFIG_ARM64_CRYPTO y
186 set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m
187 set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m
188 set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m
189 set_kernel_config CRYPTO_GHASH_ARM64_CE m
190 set_kernel_config CRYPTO_SHA2_ARM64_CE m
191 set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m
192 set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m
193 set_kernel_config CONFIG_CRYPTO_AES_ARM64 m
194 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m
195 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y
196 set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y
197 set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m
198 set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m
199 set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m
200 set_kernel_config SYSTEM_TRUSTED_KEYS
201 fi
202
183 203 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
184 if [ "$KERNEL_NF" = true ] ; then
185 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
186 set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m
187 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
188 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
189 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
190 set_kernel_config CONFIG_NFT_FIB_INET m
191 set_kernel_config CONFIG_NFT_FIB_IPV4 m
192 set_kernel_config CONFIG_NFT_FIB_IPV6 m
193 set_kernel_config CONFIG_NFT_FIB_NETDEV m
194 set_kernel_config CONFIG_NFT_OBJREF m
195 set_kernel_config CONFIG_NFT_RT m
196 set_kernel_config CONFIG_NFT_SET_BITMAP m
197 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
198 set_kernel_config CONFIG_NF_LOG_ARP m
199 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
200 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
204 if [ "$KERNEL_NF" = true ] ; then
205 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
206 set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m
207 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
208 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
209 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
210 set_kernel_config CONFIG_NFT_FIB_INET m
211 set_kernel_config CONFIG_NFT_FIB_IPV4 m
212 set_kernel_config CONFIG_NFT_FIB_IPV6 m
213 set_kernel_config CONFIG_NFT_FIB_NETDEV m
214 set_kernel_config CONFIG_NFT_OBJREF m
215 set_kernel_config CONFIG_NFT_RT m
216 set_kernel_config CONFIG_NFT_SET_BITMAP m
217 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
218 set_kernel_config CONFIG_NF_LOG_ARP m
219 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
220 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
201 221 set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m
202 222 set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m
203 223 set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m
@@ -207,7 +227,7 if [ "$BUILD_KERNEL" = true ] ; then
207 227 set_kernel_config CONFIG_IP6_NF_NAT m
208 228 set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m
209 229 set_kernel_config CONFIG_IP6_NF_TARGET_NPT m
210 set_kernel_config CONFIG_IP_NF_SECURITY m
230 set_kernel_config CONFIG_IP_NF_SECURITY m
211 231 set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m
212 232 set_kernel_config CONFIG_IP_SET_BITMAP_PORT m
213 233 set_kernel_config CONFIG_IP_SET_HASH_IP m
@@ -296,10 +316,10 if [ "$BUILD_KERNEL" = true ] ; then
296 316 set_kernel_config CONFIG_BPF_STREAM_PARSER y
297 317 set_kernel_config CONFIG_CGROUP_BPF y
298 318 fi
299
319
300 320 # KERNEL_DEFAULT_GOV was set by user
301 if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ]; then
302
321 if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then
322
303 323 case "$KERNEL_DEFAULT_GOV" in
304 324 performance)
305 325 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
@@ -321,12 +341,10 if [ "$BUILD_KERNEL" = true ] ; then
321 341 exit 1
322 342 ;;
323 343 esac
324
325 # unset previous default governor
344
345 # unset previous default governor
326 346 unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE
327 347 fi
328
329
330 348
331 349 #Revert to previous directory
332 350 cd "${WORKDIR}" || exit
@@ -484,18 +502,18 if [ "$BUILD_KERNEL" = true ] ; then
484 502
485 503 else # BUILD_KERNEL=false
486 504 if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
487
505
488 506 # Use Sakakis modified kernel if ZSWAP is active
489 507 if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then
490 508 RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}"
491 509 fi
492
510
493 511 # Create temporary directory for dl
494 512 temp_dir=$(as_nobody mktemp -d)
495 513
496 514 # Fetch kernel dl
497 515 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
498
516
499 517 #extract download
500 518 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}"
501 519
@@ -506,12 +524,12 else # BUILD_KERNEL=false
506 524
507 525 # Remove temporary directory for kernel sources
508 526 rm -fr "${temp_dir}"
509
527
510 528 # Set permissions of the kernel sources
511 529 chown -R root:root "${R}/boot/firmware"
512 530 chown -R root:root "${R}/lib/modules"
513 531 fi
514
532
515 533 # Install Kernel from hypriot comptabile with all Raspberry PI
516 534 if [ "$SET_ARCH" = 32 ] ; then
517 535 # Create temporary directory for dl
@@ -525,7 +543,7 else # BUILD_KERNEL=false
525 543
526 544 # Set permissions
527 545 chown -R root:root "${R}"/tmp/kernel.deb
528
546
529 547 # Install kernel
530 548 chroot_exec dpkg -i /tmp/kernel.deb
531 549
@@ -534,7 +552,7 else # BUILD_KERNEL=false
534 552 mkdir "${temp_dir}"/firmware
535 553 mv "${R}"/boot/* "${temp_dir}"/firmware/
536 554 mv "${temp_dir}"/firmware "${R}"/boot/
537
555
538 556 #same for kernel headers
539 557 if [ "$KERNEL_HEADERS" = true ] ; then
540 558 # Fetch kernel header
@@ -545,7 +563,7 else # BUILD_KERNEL=false
545 563 chroot_exec dpkg -i /tmp/kernel-header.deb
546 564 rm -f "${R}"/tmp/kernel-header.deb
547 565 fi
548
566
549 567 # Remove temporary directory and files
550 568 rm -fr "${temp_dir}"
551 569 rm -f "${R}"/tmp/kernel.deb
@@ -8,6 +8,11
8 8 # Install and setup fstab
9 9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
10 10
11 if [ "$ENABLE_UBOOTUSB" = true ] ; then
12 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
13 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
14 fi
15
11 16 # Add usb/sda disk root partition to fstab
12 17 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
13 18 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
@@ -29,7 +34,7 if [ "$ENABLE_CRYPTFS" = true ] ; then
29 34 fi
30 35
31 36 # Generate initramfs file
32 if [ "$BUILD_KERNEL" = true ] && [ "$ENABLE_INITRAMFS" = true ] ; then
37 if [ "$ENABLE_INITRAMFS" = true ] ; then
33 38 if [ "$ENABLE_CRYPTFS" = true ] ; then
34 39 # Include initramfs scripts to auto expand encrypted root partition
35 40 if [ "$EXPANDROOT" = true ] ; then
@@ -77,6 +77,11 if [ "$ENABLE_UBOOT" = true ] ; then
77 77 #in 64bit uboot booti is used instead of bootz [like in KERNEL_BIN_IMAGE=zImage (armv7)|| Image(armv8)]
78 78 sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage"
79 79 fi
80
81 # instead of sd, boot from usb device
82 if [ "$ENABLE_UBOOTUSB" = true ] ; then
83 sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage"
84 fi
80 85
81 86 # Set mkfile to use the correct dtb file
82 87 sed -i "s|bcm2709-rpi-2-b.dtb|${DTB_FILE}|" "${BOOT_DIR}/uboot.mkimage"
@@ -157,6 +157,7 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
157 157 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
158 158 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
159 159 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
160 ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false}
160 161 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
161 162 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
162 163 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
@@ -318,6 +319,17 case "$RPI_MODEL" in
318 319 ;;
319 320 esac
320 321
322 if [ "$ENABLE_UBOOTUSB" = true ] ; then
323 if [ "$ENABLE_UBOOT" = false ] ; then
324 echo "error: Enabling UBOOTUSB requires u-boot to be enabled"
325 exit 1
326 fi
327 if [ "$RPI_MODEL" != 3 ] || [ "$RPI_MODEL" != 3P ] ; then
328 echo "error: Enabling UBOOTUSB requires Raspberry 3"
329 exit 1
330 fi
331 fi
332
321 333 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
322 334 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
323 335 # Include bluetooth packages on supported boards
@@ -398,14 +410,6 if [ "$ENABLE_UBOOT" = true ] ; then
398 410 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
399 411 fi
400 412
401 if [ "$ENABLE_BLUETOOTH" = true ] ; then
402 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
403 if [ "$ENABLE_CONSOLE" = false ] ; then
404 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
405 fi
406 fi
407 fi
408
409 413 # Check if root SSH (v2) public key file exists
410 414 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
411 415 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant