Bug 473947 - asm-generic/ioctl.h can generate link error undefined __invalid_size_argument_for_IOC
Summary: asm-generic/ioctl.h can generate link error undefined __invalid_size_argument...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel
Version: 5.2
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Jiri Pirko
QA Contact: Red Hat Kernel QE team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-12-01 15:34 UTC by Bob Arendt
Modified: 2015-05-05 01:15 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-09-02 08:59:08 UTC
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2009:1243 0 normal SHIPPED_LIVE Important: Red Hat Enterprise Linux 5.4 kernel security and bug fix update 2009-09-01 08:53:34 UTC

Description Bob Arendt 2008-12-01 15:34:51 UTC
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 14:39:33 UTC
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 12:32:28 UTC
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 13:55:13 UTC
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 14:21:18 UTC
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 15:19:46 UTC
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 09:24:28 UTC
Re c#5
Bob, well, I'm afraid this will most likely not be available before 5.4.

Comment 9 RHEL Program Management 2009-02-03 03:39:01 UTC
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 Program Management 2009-02-16 15:42:37 UTC
Updating PM score.

Comment 11 Don Zickus 2009-03-16 15:21:52 UTC
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 16:09:51 UTC
We've verified that kernel-2.6.18-135.el5 fixes this issue.

Comment 15 errata-xmlrpc 2009-09-02 08:59:08 UTC
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.