Prefer -fstack-protector-strong

Resolves: #2044878
This commit is contained in:
Jiri Kucera 2022-02-17 14:20:23 +01:00
parent affb5c8a57
commit d42c832f37
2 changed files with 85 additions and 5 deletions

View File

@ -0,0 +1,74 @@
diff --git a/configure.ac b/configure.ac
index 878284d..9e2ba4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -214,21 +214,46 @@ AC_SEARCH_LIBS([dlopen], [dl], [], [
AC_MSG_ERROR([unable to find the dlopen() function])
])
-# Check for -fstack-protector
-ssp_cc=yes
+# Check for -fstack-protector and -fstack-protector-strong
+SSP_CC_FLAG=""
if test "X$CC-cc" != "X"; then
- AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector])
+ # Do not duplicate options in CFLAGS
+ ssp_sp_set=no
+ ssp_sps_set=no
+ for ssp_x in $CFLAGS; do
+ case "X$ssp_x" in
+ X-fstack-protector) ssp_sp_set=yes ;;
+ X-fstack-protector-strong) ssp_sps_set=yes ;;
+ esac
+ done
ssp_old_cflags="$CFLAGS"
- CFLAGS="$CFLAGS -fstack-protector"
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [], [ssp_cc=no])
+ # Prefer -fstack-protector-strong over -fstack-protector
+ if test "X$ssp_sps_set" = "Xno"; then
+ SSP_CC_FLAG="-fstack-protector-strong"
+ fi
+ AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector-strong])
+ CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [ssp_cc=yes], [ssp_cc=no])
AC_MSG_RESULT([$ssp_cc])
if test "X$ssp_cc" = "Xno"; then
- CFLAGS="$ssp_old_cflags"
- else
+ # Fallback to -fstack-protector
+ if test "X$ssp_sp_set" = "Xno"; then
+ SSP_CC_FLAG="-fstack-protector"
+ fi
+ AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector])
+ CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [ssp_cc=yes], [ssp_cc=no])
+ AC_MSG_RESULT([$ssp_cc])
+ if test "X$ssp_cc" = "Xno"; then
+ SSP_CC_FLAG=""
+ fi
+ fi
+ CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
+ if test "X$ssp_cc" = "Xyes"; then
AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
fi
fi
-AM_CONDITIONAL(USE_SSP, test "$ssp_cc" = "yes")
+AC_SUBST(SSP_CC_FLAG)
# Check for DRM (mandatory)
LIBDRM_VERSION=libdrm_version
diff --git a/va/Makefile.am b/va/Makefile.am
index 0d8eff1..5ee49c4 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -83,9 +83,7 @@ libva_cflags = \
-Wall \
$(NULL)
-if USE_SSP
-libva_cflags += -fstack-protector
-endif
+libva_cflags += $(SSP_CC_FLAG)
lib_LTLIBRARIES = libva.la
libvaincludedir = ${includedir}/va

View File

@ -2,11 +2,13 @@
Name: libva
Version: 2.11.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Video Acceleration (VA) API for Linux
License: MIT
URL: https://github.com/intel/libva
Source0: %{url}/archive/%{version}%{?pre_release}/%{name}-%{version}%{?pre_release}.tar.gz
# Prefer -fstack-protector-strong over -fstack-protector
Patch0: libva-2.11.0-fstack-protector-strong.patch
BuildRequires: libtool
@ -19,10 +21,10 @@ BuildRequires: mesa-libEGL-devel
BuildRequires: mesa-libGL-devel
BuildRequires: mesa-libGLES-devel
%{!?_without_wayland:
BuildRequires: wayland-devel
BuildRequires: pkgconfig(wayland-client) >= 1
BuildRequires: pkgconfig(wayland-scanner) >= 1
BuildRequires: make
BuildRequires: wayland-devel
BuildRequires: pkgconfig(wayland-client) >= 1
BuildRequires: pkgconfig(wayland-scanner) >= 1
BuildRequires: make
}
# owns the %%{_libdir}/dri directory
Requires: mesa-dri-filesystem
@ -73,6 +75,10 @@ find %{buildroot} -regex ".*\.la$" | xargs rm -f --
%{_libdir}/pkgconfig/libva*.pc
%changelog
* Thu Feb 17 2022 Jiri Kucera <jkucera@redhat.com> - 2.11.0-4
- Prefer -fstack-protector-strong
Resolves: #2044878
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.11.0-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688