Bug 463342

Summary: RedHat 5 is missing glibc-kernheaders?
Product: Red Hat Enterprise Linux 5 Reporter: Eric Karlson <eric.karlson>
Component: glibc-kernheadersAssignee: Red Hat Kernel Manager <kernel-mgr>
Status: CLOSED NOTABUG QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.1CC: dhowells, dwmw2, rwheeler
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-23 17:08:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Karlson 2008-09-22 22:55:18 UTC
Description of problem:
The /usr/include/asm/unaligned.h file (which used to come from glibc-kernheaders under RHEL 4) appears to be missing in RedHat 5.

I cannot find a glibc-kernheaders RPM anywhere on the RedHat 5 distro and cannot find any information about where /usr/include/asm/unaligned.h would come from on a RedHat 5 system.

Version-Release number of selected component (if applicable):
RedHat 5.1

How reproducible:
Try to compile a C source file that has "#include <asm/unaligned.h>" in it

Steps to Reproduce:
1.
2.
3.
  
Actual results:
Compile fails because <asm/unaligned.h> doesn't exist.

Expected results:
Should work and file should be present

Additional info:

Comment 1 David Woodhouse 2008-09-22 23:02:23 UTC
That's a kernel header. You shouldn't be including it in userspace.

Those few kernel headers which _are_ available for low-level system tools and libraries to use are provided by the kernel-headers package.

<asm/unaligned.h> is not one of them.

Comment 2 Eric Karlson 2008-09-22 23:47:33 UTC
Yes, technically it is a kernel header.

However, what that files provides is macros/functions for accessing unaligned data, which is something that user-space programs need to do.  Furthermore, there is nothing that requires kernel privileges for that operation.

Comment 3 David Woodhouse 2008-09-23 05:03:56 UTC
No. That file provides nothing for you. You have no business including kernel headers.

It's not as if unaligned access is particularly hard to do without abusing stuff you shouldn't be looking at:

#define get_unaligned(ptr)                      \
({                                              \
        struct __attribute__((packed)) {        \
                typeof(*(ptr)) __v;             \
        } *__p = (void *) (ptr);                \
        __p->__v;                               \
})

Comment 4 Eric Karlson 2008-09-23 09:26:11 UTC
Hm - Guess I disagree with that statement.  Kernel headers are headers that either:

1) Define prototypes for O/S internal functions that cannot be called from user-land
-or-
2) Define functions that use machine instructions that cannot be executed at user-land privilege levels

unaligned access falls into neither of these categories.

Any user-land application that needs to deal with unaligned access most certainly does have business using these headers, which is why they were in /usr/include/asm up until RHEL 5.

In terms of your macro, first, you mis-typed it (it won't compile as you typed it as one gets an illegal cast from void* to <annonymous struct>.  Secondly, that is the macro that is in the unaligned.h file on Itanium - so clearly that macro, and the unaligned.h file are *not* kernel files.  They are perfectly usable in user-land code.

The point of using a glibc supplied header is to ensure portability and performance when porting from one architecture to another.  Using the glibc-supplied header means that if there is a more efficient construct for performing unaligned access on a particular architecture, we'll get it automatically and not have to develop it ourselves.

Pleas stop dickering about religion about what header files one "has business" with and put back the headers that had been there up until the most recent release which are most assuredly usable and useful for user-land programs.  Thank you.

Comment 5 David Woodhouse 2008-09-23 16:26:02 UTC
(In reply to comment #4)
> Hm - Guess I disagree with that statement.  Kernel headers are headers that
> either:
> 
> 1) Define prototypes for O/S internal functions that cannot be called from
> user-land
> -or-
> 2) Define functions that use machine instructions that cannot be executed at
> user-land privilege levels
> 
> unaligned access falls into neither of these categories.
> 
> Any user-land application that needs to deal with unaligned access most
> certainly does have business using these headers, which is why they were in
> /usr/include/asm up until RHEL 5.

No, they were there because the kernel-private headers weren't cleaned up enough and they were accidentally exposed. We've cleaned that up now.
 
> In terms of your macro, first, you mis-typed it (it won't compile as you typed
> it as one gets an illegal cast from void* to <annonymous struct>. 

It certainly compiles for me.

> The point of using a glibc supplied header is to ensure portability and
> performance when porting from one architecture to another. 

You misunderstand. This was never a glibc-supplied header. It was a kernel-private header, and now it is gone. Actually, the macro I used above was taken from /usr/include/bluetooth/bluetooth.h, where it's also a private implementation detail and not part of the public API. If you'd been abusing it from there, and then later found it went away, would you have filed a bug against the bluez-libs-devel package to have it reinstated?

I am no longer maintaining the glibc-kernheaders package, so I cannot respond directly to your request -- but I find it very unlikely that the file will be reinstated.

I hope I have provided sufficient assistance for you to correct your program, and I hope you can learn from the experience and improve your code in future; relying on private APIs which are only exposed by accident is not good engineering practice.

Comment 6 David Howells 2008-09-23 16:39:52 UTC
> unaligned access falls into neither of these categories.

Unfortunately, that is not a good assumption.  There is _no_ requirement that a Linux kernel arch provide support for misaligned data in userspace - and not
all do.  It is perfectly feasible for some arches to provide null misalignment
wrappers and then do the actual work in the misalignment fault handler, and
then to _only_ do it for kernel code (userspace will get a SIGBUS:BUS_ADRALN).

So you may not rely on the misalignment handlers in /usr/include/asm/ and
/usr/include/linux/ as there is no guarantee the functions/macros you find
there will actually work in userspace.

Comment 7 Eric Karlson 2008-09-23 17:46:12 UTC
Please have your manager contact me.

My email is in my login.

You have not been helpful in the least.  You have in fact abused your position as tech support to promote your own ideology regarding something as silly as header files.

Your positions are ridiculous and have no basis in fact.  Our coding is just fine, thank you very much.  It is your attitude that requires some learning.

No API that is exposed in the standard include directories is private, by definition.

Your attitude is offensive and obstructive and I wish to speak to your manager regarding your lack of attention to your customer's needs ASAP.

Comment 8 Ric Wheeler 2008-09-23 18:01:30 UTC
Eric, you are perfectly free to advocate for the linux kernel community providing user space macros to help your code, but you should do that on public mailing lists (like the linux kernel mailing list).

The kernel architecture files (specifically for Intel architecture) have been drastically reworked and some files have been deprecated, rename, moved, etc. Any user space code that makes assumptions on these files is living on dangerous ground.

Comment 9 Ric Wheeler 2008-09-24 14:15:47 UTC
Just a quick update - we did some consulting with the maintainer of glibc and there is no such supported interface today at that level either (and no plans to add one).

What you seem to be looking for is a supported & usable way to have applications handle unaligned access. There is no defined standard for ANSI C or C++, officially supported glibc interface or other linux user space function that I know of that does this today.

The kernel header files are not intended to be used by user space applications unless those applications are intrinsically tied to the kernel and its data structures (applications like file system utilities, things that poke at device state, software raid, etc).

Note that many of those kernel header files also are licensed under GPLV2 (not the LGPL) so you probably do not want to compile any non-GPL code against them.

Regards,

Ric