From 839502ca0d2c47fc576ad2a66da715852153b8c1 Mon Sep 17 00:00:00 2001 From: Chan Lee Date: Fri, 25 Aug 2017 10:46:44 +0900 Subject: [PATCH] packaging: Set shadow address space to unlimited for ASan Currently, at the beginning of gbs build, shadow address space is set according to the environment of the host machine. It makes ASan build fail because ASan needs a whole shadow address space. Actually ASan tries to set the value to unlimited at init time( ASanInitInternal() ) but it failes because of lack of permission like below. [ 39s] ==6800==ERROR: AddressSanitizer setrlimit() failed 1 The value could be set at package install time because the user is 'root' at this time. Using ulimit can only set the value for current user('root') not 'abuild' which is the user at build time so we need to set /etc/security/limits.conf directly. Change-Id: Ia03911a37a689c186d0e028d01b665cf6a0c3073 Signed-off-by: Chan Lee --- packaging/gcc-aarch64.spec | 5 +++++ packaging/gcc-armv7l.spec | 5 +++++ packaging/linaro-gcc.spec | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/packaging/gcc-aarch64.spec b/packaging/gcc-aarch64.spec index cd7301d..dcb6c48 100644 --- a/packaging/gcc-aarch64.spec +++ b/packaging/gcc-aarch64.spec @@ -671,6 +671,9 @@ cat >> /usr/lib/rpm/tizen_macros << EOF %%gcc_unforce_options \\ %%gcc_force_options %%asan_force_options -fcommon EOF +# ASan needs a whole shadow address space +# Using ulimit can only set the value for current user so we need to set /etc/security/limits.conf directly. +sed '/End of file/i\abuild\tsoft\tas\t-1\nabuild\thard\tas\t-1' -i /etc/security/limits.conf %preun -n asan-force-options # Restore read-only mode @@ -679,6 +682,8 @@ chmod a-w %{libsubdir} [ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w /usr/bin/gcc-unforce-options +# Restore limit configurations set for ASan +sed '/abuild/d' -i /etc/security/limits.conf %package -n ubsan-force-options Summary: Scripts to enable automatic package sanitization diff --git a/packaging/gcc-armv7l.spec b/packaging/gcc-armv7l.spec index 79ce827..0dbf0e8 100644 --- a/packaging/gcc-armv7l.spec +++ b/packaging/gcc-armv7l.spec @@ -671,6 +671,9 @@ cat >> /usr/lib/rpm/tizen_macros << EOF %%gcc_unforce_options \\ %%gcc_force_options %%asan_force_options -fcommon EOF +# ASan needs a whole shadow address space +# Using ulimit can only set the value for current user so we need to set /etc/security/limits.conf directly. +sed '/End of file/i\abuild\tsoft\tas\t-1\nabuild\thard\tas\t-1' -i /etc/security/limits.conf %preun -n asan-force-options # Restore read-only mode @@ -679,6 +682,8 @@ chmod a-w %{libsubdir} [ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w /usr/bin/gcc-unforce-options +# Restore limit configurations set for ASan +sed '/abuild/d' -i /etc/security/limits.conf %package -n ubsan-force-options Summary: Scripts to enable automatic package sanitization diff --git a/packaging/linaro-gcc.spec b/packaging/linaro-gcc.spec index 17293f1..85db176 100644 --- a/packaging/linaro-gcc.spec +++ b/packaging/linaro-gcc.spec @@ -668,6 +668,9 @@ cat >> /usr/lib/rpm/tizen_macros << EOF %%gcc_unforce_options \\ %%gcc_force_options %%asan_force_options -fcommon EOF +# ASan needs a whole shadow address space +# Using ulimit can only set the value for current user so we need to set /etc/security/limits.conf directly. +sed '/End of file/i\abuild\tsoft\tas\t-1\nabuild\thard\tas\t-1' -i /etc/security/limits.conf %preun -n asan-force-options # Restore read-only mode @@ -676,6 +679,8 @@ chmod a-w %{libsubdir} [ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w /usr/bin/gcc-unforce-options +# Restore limit configurations set for ASan +sed '/abuild/d' -i /etc/security/limits.conf %package -n ubsan-force-options Summary: Scripts to enable automatic package sanitization -- 2.7.4