All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.cz>
To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>
Subject: [RFC] UAPI: Prevent kernel modules from using the exported headers
Date: Fri, 25 Apr 2014 16:56:48 +0200	[thread overview]
Message-ID: <1398437808-9263-1-git-send-email-mmarek@suse.cz> (raw)

Mandriva/Mageia and SUSE have been adding an #error statement to the
/usr/include/linux/version.h header and it does trigger with broken out
of tree modules occasionally. Adding it to all exported headers should
not hurt and is easier to implement.

Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 scripts/headers_install.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 5de5660..1c787da 100644
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -30,16 +30,19 @@ trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT
 for i in "$@"
 do
 	FILE="$(basename "$i")"
+	scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$SRCDIR/$i" \
+		> "$OUTDIR/$FILE.sed"
 	sed -r \
+		-e '1i #ifdef __KERNEL__' \
+		-e '1i #error Kernel modules must not include files from /usr/include/' \
+		-e '1i #endif' \
 		-e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
 		-e 's/__attribute_const__([ \t]|$)/\1/g' \
 		-e 's@^#include <linux/compiler.h>@@' \
 		-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
 		-e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
 		-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
-		"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
-	scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
-		> "$OUTDIR/$FILE"
+		"$OUTDIR/$FILE.sed" >"$OUTDIR/$FILE" || exit 1
 	[ $? -gt 1 ] && exit 1
 	rm -f "$OUTDIR/$FILE.sed"
 done
-- 
1.8.4.5


                 reply	other threads:[~2014-04-25 14:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398437808-9263-1-git-send-email-mmarek@suse.cz \
    --to=mmarek@suse.cz \
    --cc=dhowells@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.