From patchwork Fri Sep 16 12:20:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 114921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 46815B70D6 for ; Fri, 16 Sep 2011 22:21:12 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1R4XPK-0003dT-2w; Fri, 16 Sep 2011 12:20:38 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1R4XPI-0003d7-0D for kernel-team@lists.ubuntu.com; Fri, 16 Sep 2011 12:20:36 +0000 Received: from 212-139-214-120.dynamic.dsl.as9105.com ([212.139.214.120] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1R4XPH-0007mS-Qx; Fri, 16 Sep 2011 12:20:35 +0000 From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1] UBUNTU: SAUCE: headers_install: fix #include "..." usage for userspace Date: Fri, 16 Sep 2011 13:20:31 +0100 Message-Id: <1316175631-1728-2-git-send-email-apw@canonical.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1316175631-1728-1-git-send-email-apw@canonical.com> References: <1316175631-1728-1-git-send-email-apw@canonical.com> Cc: Andy Whitcroft X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com When headers are converted to userspace headers they may include relative includes. For example x86 has the following in its asm/posix_types.h: # ifdef __i386__ # include "posix_types_32.h" # else # include "posix_types_64.h" # endif However this is not safe in the face of the gcc option -I- which removes "the directory the file I am being included from" from the search list. Convert these references to form avoiding this. BugLink: http://bugs.launchpad.net/bugs/824377 Signed-off-by: Andy Whitcroft Signed-off-by: Leann Ogasawara --- scripts/Makefile.headersinst | 4 ++-- scripts/headers_install.pl | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index a57f5bd..b4018c5 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -50,8 +50,8 @@ printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) cmd_install = \ - $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ - $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ + $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(printdir) $(header-y); \ + $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(printdir) $(objhdr-y); \ for F in $(wrapper-files); do \ echo "\#include " > $(install)/$$F; \ done; \ diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index efb3be1..0425f5f 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl @@ -18,7 +18,9 @@ use strict; -my ($readdir, $installdir, $arch, @files) = @ARGV; +my ($readdir, $installdir, $arch, $printdir, @files) = @ARGV; + +$printdir =~ s@^include/@@; my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"; @@ -30,6 +32,10 @@ foreach my $file (@files) { open(my $out, '>', $tmpfile) or die "$tmpfile: $!\n"; while (my $line = <$in>) { + # Any #include which uses "" and does not have a path needs + # rewriting so that the resultant user space headers are + # safe against the use of -I-. + $line =~ s/^(\s*#\s*include\s+)"([^\/]*?)"/$1<$printdir\/$2>/; $line =~ s/([\s(])__user\s/$1/g; $line =~ s/([\s(])__force\s/$1/g; $line =~ s/([\s(])__iomem\s/$1/g;