Bug 1182804

Summary: GCC 11: fcoe-utils package fails
Product: [openSUSE] openSUSE Tumbleweed Reporter: Martin Liška <martin.liska>
Component: BasesystemAssignee: Lee Duncan <lduncan>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 1181859    
Attachments: possible fix for compiler issues
Test patch (not yet upstream) to make gcc-11 happy

Description Martin Liška 2021-02-26 13:56:42 UTC
The package build fails here:
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:Staging:Gcc7/fcoe-utils/standard/x86_64

due to:
[   10s]     inlined from 'fp_ns_get_id.constprop' at fcping.c:587:2:
[   10s] /usr/include/bits/string_fortified.h:29:10: error: '__builtin_memcpy' writing 12 bytes into a region of size 4 [-Werror=stringop-overflow=]
[   10s]    29 |   return __builtin___memcpy_chk (__dest, __src, __len,
[   10s]       |          ^
[   10s] fcping.c: In function 'fp_ns_get_id.constprop':
[   10s] ./include/scsi_bsg_fc.h:201:25: note: destination object 'preamble_word0' of size 4
[   10s]   201 |         uint32_t        preamble_word0; /* revision & IN_ID */
[   10s]       |                         ^
[   10s] lto1: all warnings being treated as errors
[   10s] make[1]: *** [/tmp/ccC2YcRp.mk:2: /tmp/ccCuGJzw.ltrans0.ltrans.o] Error 1
[   10s] lto-wrapper: fatal error: make returned 2 exit status
[   10s] compilation terminated.
[   10s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: error: lto-wrapper failed
[   10s] collect2: error: ld returned 1 exit status
[   10s] make: *** [Makefile:569: fcping] Error 1
[   10s] make: *** Waiting for unfinished jobs....
[   10s] In function 'memcpy',
[   10s]     inlined from 'rtnl_recv_newlink' at fipvlan.c:450:2:
[   10s] /usr/include/bits/string_fortified.h:29:10: error: '__builtin_memcpy' reading 6 bytes from a region of size 0 [-Werror=stringop-overread]
[   10s]    29 |   return __builtin___memcpy_chk (__dest, __src, __len,
[   10s]       |          ^
[   10s] In function 'strncpy',
[   10s]     inlined from 'rtnl_recv_newlink' at fipvlan.c:451:2:
[   10s] /usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' reading between 1 and 16 bytes from a region of size 0 [-Werror=stringop-overread]
[   10s]    95 |   return __builtin___strncpy_chk (__dest, __src, __len,
[   10s]       |          ^
[   10s] lto1: all warnings being treated as errors
[   10s] make[1]: *** [/tmp/ccTHeBGR.mk:2: /tmp/ccVkQAvF.ltrans0.ltrans.o] Error 1
[   10s] lto-wrapper: fatal error: make returned 2 exit status
[   10s] compilation terminated.
[   10s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: error: lto-wrapper failed
[   10s] collect2: error: ld returned 1 exit status
[   10s] make: *** [Makefile:577: fipvlan] Error 1
[   10s] error: Bad exit status from /var/tmp/rpm-tmp.mjJr8p (%build)
Comment 1 Martin Liška 2021-03-18 13:51:22 UTC
May I please ping this?
Comment 2 Hannes Reinecke 2021-03-19 10:36:29 UTC
Lee, can you have a look?
Comment 3 Lee Duncan 2021-03-19 19:02:51 UTC
Some of this is nasty ... :(
Comment 4 Lee Duncan 2021-03-19 20:44:38 UTC
Created attachment 847477 [details]
possible fix for compiler issues

Not sure why the compiler doesn't like some of this stuff (I tried to figure it out but could not), but this diff makes the compiler happy and hopefully does not change any functionality.
Comment 5 Martin Liška 2021-03-22 08:36:29 UTC
(In reply to Lee Duncan from comment #4)
> Created attachment 847477 [details]
> possible fix for compiler issues
> 
> Not sure why the compiler doesn't like some of this stuff (I tried to figure
> it out but could not), but this diff makes the compiler happy and hopefully
> does not change any functionality.

From a quick look, it seems the compiler complains correctly. You copy memory to (or from) a location which storage is smaller than the request length. Note that there may be padding in between the fields for instance.
You can likely cast to (char *) and do the copying, it should silent the warning.
Comment 6 Lee Duncan 2021-03-23 16:58:22 UTC
Working upstream, at github.com://openSUSE/fcoe-utils, and my clone of that.

I will attach the latest suggested fix.
Comment 7 Lee Duncan 2021-03-23 17:00:56 UTC
Created attachment 847561 [details]
Test patch (not yet upstream) to make gcc-11 happy

Feel free to comment on this patch. Manually compiling with gcc-11 fails before this patch and passes after it.

This commit is still being discussed upstream but seems likely to be the final version.
Comment 8 Lee Duncan 2021-03-23 17:02:29 UTC
(In reply to Martin Liška from comment #5)
> (In reply to Lee Duncan from comment #4)
> > Created attachment 847477 [details]
> > possible fix for compiler issues
> > 
> > Not sure why the compiler doesn't like some of this stuff (I tried to figure
> > it out but could not), but this diff makes the compiler happy and hopefully
> > does not change any functionality.
> 
> From a quick look, it seems the compiler complains correctly. You copy
> memory to (or from) a location which storage is smaller than the request
> length. Note that there may be padding in between the fields for instance.
> You can likely cast to (char *) and do the copying, it should silent the
> warning.

A cast to uint32_t* worked. Thanks.
Comment 9 Lee Duncan 2021-03-25 17:25:56 UTC
Changes committed upstream, new version tagged, and now updating Factory.
Comment 10 Martin Liška 2021-03-25 18:18:39 UTC
Thanks, fixed in devel project.
Comment 12 Swamp Workflow Management 2021-10-12 19:57:13 UTC
SUSE-RU-2021:3390-1: An update that has two recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1010047,1182804
CVE References: 
JIRA References: 
Sources used:
SUSE MicroOS 5.1 (src):    fcoe-utils-1.0.34-12.3.1
SUSE Linux Enterprise Module for Basesystem 15-SP3 (src):    fcoe-utils-1.0.34-12.3.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 13 Swamp Workflow Management 2021-10-12 19:59:36 UTC
openSUSE-RU-2021:3390-1: An update that has two recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1010047,1182804
CVE References: 
JIRA References: 
Sources used:
openSUSE Leap 15.3 (src):    fcoe-utils-1.0.34-12.3.1