lkml.org 
[lkml]   [2014]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC] UAPI: Prevent kernel modules from using the exported headers
Date
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


\
 
 \ /
  Last update: 2014-04-25 17:21    [W:0.028 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site