- Avoid out of bounds array index diagnostic with gcc-11

This commit is contained in:
Jeff Law 2020-10-19 16:14:11 -06:00
parent 820ce82918
commit d27398a782
2 changed files with 32 additions and 1 deletions

26
libpsm2-gcc11.patch Normal file
View File

@ -0,0 +1,26 @@
diff -Nrup a/include/linux-i386/sysdep.h b/include/linux-i386/sysdep.h
--- a/include/linux-i386/sysdep.h 2019-10-03 20:00:29.000000000 -0600
+++ b/include/linux-i386/sysdep.h 2020-10-19 16:10:45.680585173 -0600
@@ -139,12 +139,18 @@ static __inline__ uint32_t ips_cmpxchg(v
uint32_t old_val, uint32_t new_val)
{
uint32_t prev;
- struct xchg_dummy {
- uint32_t a[100];
- };
+ /* This code used to cast PTR to a type which was an array of 100
+ uint32_t objects. That makes no sense as the cmpxchgl's side
+ effect can be covered by an single int.
+
+ The semantics of GCC's ASMs for memory is that it clobbers the
+ whole pointed-to object. Thus analyzers saw a 100 uint32_t sized
+ store which triggers diagnostics for out of bounds array writes.
+
+ The cast to the dummy type has been removed. */
asm volatile (LOCK_PREFIX "cmpxchgl %1,%2" : "=a"(prev)
- : "q"(new_val), "m"(*(struct xchg_dummy *)ptr), "0"(old_val)
+ : "q"(new_val), "m"(*ptr), "0"(old_val)
: "memory");
return prev;

View File

@ -53,7 +53,7 @@
Summary: Intel PSM Libraries
Name: libpsm2
Version: 11.2.86
Release: 6%{?dist}
Release: 7%{?dist}
License: BSD or GPLv2
URL: https://github.com/01org/opa-psm2/
@ -65,6 +65,7 @@ URL: https://github.com/01org/opa-psm2/
Source0: %{name}-%{version}.tar.gz
Patch0: 0001-Fix-multiple-definition-issues.patch
Patch1: makefile-distro-from-environment.patch
Patch2: %{name}-gcc11.patch
# The OPA product is supported on x86 64 only:
ExclusiveArch: x86_64
@ -105,6 +106,7 @@ Support for MPIs linked with PSM versions < 2
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
%{set_build_flags}
@ -150,6 +152,9 @@ rm -f %{buildroot}%{_libdir}/*.a
%endif
%changelog
* Mon Oct 19 2020 Jeff Law <law@redhat.com> - 11.2.86-7
- Avoid out of bounds array index diagnostic with gcc-11
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 11.2.86-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild