Bug 473947 - asm-generic/ioctl.h can generate link error undefined __invalid_size_argument_for_IOC
asm-generic/ioctl.h can generate link error undefined __invalid_size_argument...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel (Show other bugs)
5.2
All Linux
low Severity low
: rc
: ---
Assigned To: Jiri Pirko
Red Hat Kernel QE team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-01 10:34 EST by Bob Arendt
Modified: 2015-05-04 21:15 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-02 04:59:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Reproducer source code for this bug (648 bytes, text/plain)
2008-12-01 10:34 EST, Bob Arendt
no flags Details

  None (edit)
Description Bob Arendt 2008-12-01 10:34:51 EST
Created attachment 325241 [details]
Reproducer source code for this bug

Description of problem:
This is actually an issue with the kernel-headers package, the file
/usr/include/asm-generic/ioctl.h
This has been resolved in the upstream kernel, see:
http://bugzilla.kernel.org/show_bug.cgi?id=11106
The Fedora10 kernel-headers already includes this commit.

Version-Release number of selected component (if applicable):
kernel-headers-2.6.18-92.el5

How reproducible:
always

Steps to Reproduce:

Building a program with debug (-g flag) can result in undefined reference to
"__invalid_size_argument_for_IOC".

This code from include/asm-generic/ioctl.h is the culprit:
     50 /* provoke compile error for invalid uses of size argument */
     51 extern unsigned int __invalid_size_argument_for_IOC;
     52 #define _IOC_TYPECHECK(t) \
     53         ((sizeof(t) == sizeof(t[1]) && \
     54           sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
     55           sizeof(t) : __invalid_size_argument_for_IOC)
     ....
     61 #define _IOWR(type,nr,size)    
_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))

This gets used in the various _IO definitions.  The comment indicates this was
intended to throw a compiler error.  It doesn't - it will always compile and
end up generating a link-error for an undefined reference to
__invalid_size_argument_for_IOC.

In fact, lines 51-55 will only work *if* the compiler always optimizes away the
reference to __invalid_size_argument_for_IOC.  It turns out that gcc
(currently) actually does optimize this out in all cases (even -g -O0), and
never generates the undefined link reference.

This isn't true for Intel's compilers (icc and icpc).  If the -g flag is
asserted the reference is generated and the error *always* occurs.  It's hard
to generate a debug image;  The work-around hack is ugly - add a global def for
__invalid_size_argument_for_IOC.  This also disables the test.  The intel
compiler might not be the only one that has this behaviour.

Steps to reproduce:
I've attached a short reproducer program.

Build with:
(OK)      gcc    -Wall ioctl_broke.c
(OK)      gcc -g -Wall ioctl_broke.c
(OK)      icc    -Wall ioctl_broke.c
(Breaks)  icc -g -Wall ioctl_broke.c
          /tmp/iccRFH4Pa.o: In function `main':
          /home/rda/ioctl_test.c:23: undefined reference to '__invalid_size_argument_for_IOC'
Comment 1 Bob Arendt 2009-01-13 09:39:33 EST
BTW - I posted this here to document for other users, and the upstream patch (#ifdefs so it only does the check when building the kernel) seems like it could be readily applied to the RHEL5 kernel without impact.
Comment 2 Jiri Pirko 2009-01-19 07:32:28 EST
Hi Bob - I have patched build but I do not have Intel compiler. Can you please test my rpms? Which ARCH do you have? Thanks.
Comment 3 Bob Arendt 2009-01-19 08:55:13 EST
I have a i386 box running kernel-2.6.18-92.el5.i686.rpm (RHEL 5.2) available.  Would this just be a kernel-headers update, or would all of kernel + kernel-devel + kernel-headers need to be installed?
Comment 4 Jiri Pirko 2009-01-19 09:21:18 EST
kernel, kernel-devel and kernel-headers packages for this bz are here:
http://people.redhat.com/jpirko/test/bz473947/

It should be sufficient to install only kernel-headers. But try yourself.
Comment 5 Bob Arendt 2009-01-21 10:19:46 EST
Thanks, this works with just the kernel-headers update.  It looks like RHEL update 5.3 just went out.  Will this be available as an update before 5.4?  I'd like to reflect when the patch goes out in our internal bug tracking system (we've logged a couple of minor build bugs that tie back to this issue).
Comment 8 Jiri Pirko 2009-01-22 04:24:28 EST
Re c#5
Bob, well, I'm afraid this will most likely not be available before 5.4.
Comment 9 RHEL Product and Program Management 2009-02-02 22:39:01 EST
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 10 RHEL Product and Program Management 2009-02-16 10:42:37 EST
Updating PM score.
Comment 11 Don Zickus 2009-03-16 11:21:52 EDT
in kernel-2.6.18-135.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5

Please do NOT transition this bugzilla state to VERIFIED until our QE team
has sent specific instructions indicating when to do so.  However feel free
to provide a comment indicating that this fix has been verified.
Comment 13 Bob Arendt 2009-03-23 12:09:51 EDT
We've verified that kernel-2.6.18-135.el5 fixes this issue.
Comment 15 errata-xmlrpc 2009-09-02 04:59:08 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2009-1243.html

Note You need to log in before you can comment on or make changes to this bug.