Monday, March 3, 2008

Sanitizing The Linux Kernel Headers -- Strange fact in Kernel 2.6.24.3

It's not a widely known fact that you can create a "sanitized" a.k.a ABI-stable kernel headers automatically from the kernel source yourself since Linux Kernel 2.6.18 introduced.

One can do this by cd-ing into the root directory of the kernel source and invoking
the following command:

make mrproper
make headers_check
make ARCH=<your_target_architecture> INSTALL_HDR_PATH=<your_target_header_directory> headers_install

The target architecture defaults to the architecture of the machine where you run the command. You can see all the available architecture by doing an 'ls' in the arch directory inside the root directory of the kernel source. Nonetheless, at least, there is one obscure target that is not shown there, i.e. x86_64. I know this because I'm building a sanitized kernel headers for x86_64 architecture recently. My invocation
command as follows:

make mrproper
make headers_check
make ARCH=x86_64 INSTALL_HDR_PATH=/tools/include headers_install


Now, what this have to do with the recent kernel 2.6.24.3? Apparently, the current Linux source code maintainer has made an obscure mistake, but it's not his fault entirely. This mistake causes the "make headers_check" failing because of wrong header file. It happens because a header that's meant to be for kernel 2.6.25-rcX slipped into the kernel 2.6.24.3 release. You can check it in the following link:
http://marc.info/?l=linux-kernel&m=120405715327409&w=2
The following is the "naked" message from the current kernel maintainer:

----------------------------------------------------------
List: linux-kernel
Subject: Re: [stable] Linux 2.6.24.3 (if_addrlabel.h HEADERS_CHECK failure)
From: Greg KH
Date: 2008-02-26 20:01:37
Message-ID: 20080226200137.GB10249 () kroah ! com
[Download message RAW]

On Tue, Feb 26, 2008 at 07:29:43AM -0800, Stephen Hemminger wrote:
> On Tue, 26 Feb 2008 14:38:47 +0000
> Daniel Drake wrote:
>
> > Randy Dunlap wrote:
> > > > We (the -stable team) are announcing the release of the 2.6.24.3
> > > > kernel.
> > >
> > > When HEADERS_CHECK=y:
> > >
> > > make[3]: *** No rule to make target \
> > > `/local/linsrc/linux-2.6.24.3/include/linux/if_addrlabel.h', needed by \
> > > `/local/linsrc/linux-2.6.24.3/usr/include/linux/if_addrlabel.h'. Stop. \
> > > make[2]: *** [linux] Error 2
> >
> > This appears to have been caused by the patch titled:
> >
> > NET: Add if_addrlabel.h to sanitized headers.
> >
> > The patch only adds the unifdef-y entry for this header file, however
> > that header was only added after 2.6.24.
> >
> > It seems that this patch was submitted to -stable in error. Stephen, can
> > you confirm?
>
> The patch was meant for 2.6.25 only.

So should it be reverted? David sent it to me for some reason :)

thanks,

greg k-h
----------------------------------------------------------


So, how did I find it? I found that mistake when I build my sanitized x86_64 kernel headers a few days ago. I stumbled upon error in the "make headers_check" step. Therefore, I choose to use kernel 2.6.24.2 header to make the sanitized x86_64 kernel headers and it works just fine.


Note: ABI = Application Binary Interface
Post a Comment