From 4f148ef7b4759800d79931404f03697da705e62b Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Wed, 29 Jun 2022 15:26:23 +0900 Subject: [PATCH] For asan, copy asan-runtime-env and libasan files into ramdisk In asan environment, there should be asan-runtime-env and libasan, but ramdisk mkinitrd.sh does not copy the files. For asan, copy required files into ramdisk. Change-Id: Ic7fe94312e9e8193eb786b95f9b35d4c66ab98e8 Signed-off-by: Seung-Woo Kim --- data/initrd-file-asan.list.in | 12 ++++++++++++ packaging/initrd.spec | 12 ++++++++++++ scripts/mkinitrd.sh | 10 +++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 data/initrd-file-asan.list.in diff --git a/data/initrd-file-asan.list.in b/data/initrd-file-asan.list.in new file mode 100644 index 0000000..19837ab --- /dev/null +++ b/data/initrd-file-asan.list.in @@ -0,0 +1,12 @@ +# ----- asan contents ----- # + +VERBATIMS=" +/etc/ld.so.preload +/ASAN_OPTIONS +" + +PROGS=" +@INITRD_LIB_DIR@/libcrypt-2.30.so +@INITRD_LIB_DIR@/libasan.so +@INITRD_LIB_DIR@/libasansi.so +" diff --git a/packaging/initrd.spec b/packaging/initrd.spec index 866706a..df1e859 100644 --- a/packaging/initrd.spec +++ b/packaging/initrd.spec @@ -66,6 +66,15 @@ cp -f data/initrd-file.list %{buildroot}%{_initrd_dir} cp -f data/initrd-file-64bit.list %{buildroot}%{_initrd_dir} %endif cp -f data/initrd-file-dmverity.list %{buildroot}%{_initrd_dir} + +%if 0%{?asan} +_libdir_string=$(echo %{_libdir} | sed 's_/_\\/_g') +sed -i "s/@INITRD_LIB_DIR@/${_libdir_string}/g" data/initrd-file-asan.list.in +cp -f data/initrd-file-asan.list.in %{buildroot}%{_initrd_dir}/initrd-file-asan.list +sed -i "s/@ASAN_FILE_LIST@/${_libdir_string}\/initrd\/initrd-file-asan.list/g" scripts/mkinitrd.sh +%else +sed -i "s/@ASAN_FILE_LIST@//g" scripts/mkinitrd.sh +%endif cp -f scripts/mkinitrd.sh %{buildroot}%{_initrd_dir} cp -f scripts/init.sh %{buildroot}%{_initrd_dir} mkdir -p %{buildroot}/sbin @@ -104,6 +113,9 @@ rm -rf %{_initrd_dir} %{_initrd_dir}/initrd-file-64bit.list %endif %{_initrd_dir}/initrd-file-dmverity.list +%if 0%{?asan} +%{_initrd_dir}/initrd-file-asan.list +%endif %{_initrd_dir}/init.sh %{_unitdir}/ramdisk-flush.service %{_unitdir}/delayed.target.wants/ramdisk-flush.service diff --git a/scripts/mkinitrd.sh b/scripts/mkinitrd.sh index ac2cf78..47a361f 100755 --- a/scripts/mkinitrd.sh +++ b/scripts/mkinitrd.sh @@ -12,24 +12,24 @@ ARCH=`$UNAME -m` if [ "z$ARCH" == "zarmv7l" ]; then LD_LINUX="/lib/ld-linux.so.3" INIT="/usr/lib/initrd/init.sh" - OBJECTS_SPECIFY_LIST="/usr/lib/initrd/initrd-file.list /usr/lib/initrd/initrd-file-dmverity.list" + OBJECTS_SPECIFY_LIST="/usr/lib/initrd/initrd-file.list /usr/lib/initrd/initrd-file-dmverity.list @ASAN_FILE_LIST@" elif [ "z$ARCH" == "zaarch64" ]; then LD_LINUX="/lib64/ld-linux-aarch64.so.1" INIT="/usr/lib64/initrd/init.sh" - OBJECTS_SPECIFY_LIST="/usr/lib64/initrd/initrd-file.list /usr/lib64/initrd/initrd-file-64bit.list /usr/lib64/initrd/initrd-file-dmverity.list " + OBJECTS_SPECIFY_LIST="/usr/lib64/initrd/initrd-file.list /usr/lib64/initrd/initrd-file-64bit.list /usr/lib64/initrd/initrd-file-dmverity.list @ASAN_FILE_LIST@" elif [ "z$ARCH" == "zi686" ]; then LD_LINUX="/lib/ld-linux.so.2" INIT="/usr/lib/initrd/init.sh" - OBJECTS_SPECIFY_LIST="/usr/lib/initrd/initrd-file.list" + OBJECTS_SPECIFY_LIST="/usr/lib/initrd/initrd-file.list @ASAN_FILE_LIST@" elif [ "z$ARCH" == "zx86-64" ]; then LD_LINUX="/lib64/ld-linux-x86-64.so.2" INIT="/usr/lib64/initrd/init.sh" - OBJECTS_SPECIFY_LIST="/usr/lib64/initrd/initrd-file.list /usr/lib64/initrd/initrd-file-64bit.list" + OBJECTS_SPECIFY_LIST="/usr/lib64/initrd/initrd-file.list /usr/lib64/initrd/initrd-file-64bit.list @ASAN_FILE_LIST@" else # set as i686, need to assign properly LD_LINUX="/lib/ld-linux.so.2" INIT="/usr/lib/initrd/init.sh" - OBJECTS_SPECIFY_LIST="/usr/lib/initrd/initrd-file.list" + OBJECTS_SPECIFY_LIST="/usr/lib/initrd/initrd-file.list @ASAN_FILE_LIST@" fi INITRD_ROOT=/mnt/initrd -- 2.7.4