Skip to content

Commit 8ab2924

Browse files
committed
[skip ci] kernel-6.18: Add FIPS support
Signed-off-by: Gaurav Sharma <mgsharm@amazon.com>
1 parent e1accfe commit 8ab2924

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Unit]
2+
Requires=fips-modprobe@__FIPS_MODULE__.service
3+
After=fips-modprobe@__FIPS_MODULE__.service
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
sha1
2+
sha224
3+
sha256
4+
sha384
5+
sha512
6+
sha3-224
7+
sha3-256
8+
sha3-384
9+
sha3-512
10+
crc32c
11+
ghash
12+
xxhash64
13+
ghash-ce
14+
sha3-ce
15+
cipher_null
16+
des3_ede
17+
aes
18+
dh
19+
ecdh
20+
aes-arm64
21+
aes-ce-blk
22+
aes-ce-ccm
23+
aes-ce-cipher
24+
aes-neon-blk
25+
aes-neon-bs
26+
ecb
27+
cbc
28+
ctr
29+
xts
30+
gcm
31+
ccm
32+
authenc
33+
hmac
34+
cmac
35+
cts
36+
lzo
37+
essiv
38+
seqiv
39+
drbg
40+
aead
41+
cryptomgr
42+
tcrypt
43+
crypto_user
44+
rsa
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
sha1
2+
sha224
3+
sha256
4+
sha384
5+
sha512
6+
sha3-224
7+
sha3-256
8+
sha3-384
9+
sha3-512
10+
crc32c
11+
ghash
12+
xxhash64
13+
ghash_clmulni_intel
14+
cipher_null
15+
des3_ede
16+
aes
17+
dh
18+
ecdh
19+
aesni-intel
20+
ecb
21+
cbc
22+
ctr
23+
xts
24+
gcm
25+
ccm
26+
authenc
27+
hmac
28+
cmac
29+
cts
30+
lzo
31+
essiv
32+
seqiv
33+
drbg
34+
aead
35+
cryptomgr
36+
tcrypt
37+
crypto_user
38+
rsa

packages/kernel-6.18/kernel-6.18.spec

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ Source100: config-bottlerocket
2323
Source101: config-bottlerocket-x86_64
2424
Source102: config-bottlerocket-aarch64
2525

26+
# This list of FIPS modules is extracted from /etc/fipsmodules in the initramfs
27+
# after placing AL2023 in FIPS mode.
28+
Source200: check-fips-modules.drop-in.conf.in
29+
Source201: fipsmodules-x86_64
30+
Source202: fipsmodules-aarch64
31+
2632
# Adjust kernel-devel mount behavior if not squashfs.
2733
Source210: var-lib-kernel-devel-lower.mount.drop-in.conf.in
2834

@@ -90,6 +96,9 @@ Requires: (%{name}-modules-neuron if (%{_cross_os}variant-platform(aws) without
9096

9197
Requires: %{_cross_os}kmod-6.18-efa
9298

99+
# Pull in FIPS-related files if needed.
100+
Requires: (%{name}-fips if %{_cross_os}image-feature(fips))
101+
93102
%global _cross_ksrcdir %{_cross_usrsrc}/kernels/%{version}
94103
%global _cross_kmoddir %{_cross_libdir}/modules/%{version}
95104

@@ -145,6 +154,14 @@ Summary: Header files for the Linux kernel for use by glibc
145154
%description headers
146155
%{summary}.
147156

157+
%package fips
158+
Summary: FIPS related configuration for the Linux kernel
159+
Requires: (%{_cross_os}image-feature(fips) and %{name})
160+
Conflicts: %{_cross_os}image-feature(no-fips)
161+
162+
%description fips
163+
%{summary}.
164+
148165
%prep
149166
%if "%{_cross_arch}" == "aarch64"
150167
%global _cross_kimage vmlinuz.efi
@@ -370,6 +387,20 @@ sed -e 's|PREFIX|%{_cross_prefix}|g' %{S:210} \
370387
mkdir -p %{buildroot}%{_cross_datadir}/xfsprogs/mkfs
371388
ln -s lts_6.12.conf %{buildroot}%{_cross_datadir}/xfsprogs/mkfs/default.conf
372389

390+
# Ensure that each required FIPS module is loaded as a dependency of the
391+
# check-fips-module.service. The list of FIPS modules is different across
392+
# kernels but the check is consistent: it loads the "tcrypt" module after
393+
# the other modules are loaded.
394+
mkdir -p %{buildroot}%{_cross_unitdir}/check-fips-modules.service.d
395+
i=0
396+
for fipsmod in $(cat %{_sourcedir}/fipsmodules-%{_cross_arch}) ; do
397+
[ "${fipsmod}" == "tcrypt" ] && continue
398+
drop_in="$(printf "%03d\n" "${i}")-${fipsmod}.conf"
399+
sed -e "s|__FIPS_MODULE__|${fipsmod}|g" %{S:200} \
400+
> %{buildroot}%{_cross_unitdir}/check-fips-modules.service.d/"${drop_in}"
401+
(( i+=1 ))
402+
done
403+
373404
%if "%{_cross_arch}" == "x86_64"
374405
# Add Neuron-related configuration files to load the module when the hardware is present.
375406
install -d 0644 %{buildroot}%{_cross_tmpfilesdir}
@@ -448,6 +479,9 @@ install -p -m 0644 %{S:301} %{buildroot}%{_cross_bootconfigdir}/05-vmware.conf
448479
%{_cross_kmoddir}/build
449480
%attr(775, root, builder) %{_cross_ksrcdir}/scripts/*
450481

482+
%files fips
483+
%{_cross_unitdir}/check-fips-modules.service.d/*.conf
484+
451485
%files bootconfig-aws
452486
%{_cross_bootconfigdir}/05-aws.conf
453487

0 commit comments

Comments
 (0)