Commit 561e79b0 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Enforce UTS limit, use LANG=C for date/time

Patch by Keith Owens, ported to 2.5.

If the length of $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
exceeds 64 characters it silently corrupts the utsname data, resulting
in garbage for uname -r and problems running the kernel and modules.
Abort if KERNELRELEASE is too long.  Truncation is not good enough, it
results in ambiguous /lib/modules/`uname -r` contents.

Ensure that the date/time in uname are always in LANG=C.  Users with
other languages report that 8 bit values cause the boot messages to go
haywire.
parent 053cf0e6
...@@ -298,7 +298,13 @@ include/linux/autoconf.h: .config ...@@ -298,7 +298,13 @@ include/linux/autoconf.h: .config
# version.h changes when $(KERNELRELEASE) etc change, as defined in # version.h changes when $(KERNELRELEASE) etc change, as defined in
# this Makefile # this Makefile
uts_len := 64
include/linux/version.h: Makefile include/linux/version.h: Makefile
@if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
exit 1; \
fi;
@echo -n 'Generating $@' @echo -n 'Generating $@'
@(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \ @(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
......
...@@ -22,4 +22,5 @@ $(TOPDIR)/include/linux/compile.h: ../include/linux/compile.h ; ...@@ -22,4 +22,5 @@ $(TOPDIR)/include/linux/compile.h: ../include/linux/compile.h ;
# actual file if its content has changed. # actual file if its content has changed.
../include/linux/compile.h: FORCE ../include/linux/compile.h: FORCE
@echo -n 'Generating $@'
@../scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)" @../scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)"
...@@ -10,24 +10,32 @@ else ...@@ -10,24 +10,32 @@ else
echo 0 > ../.version echo 0 > ../.version
fi fi
UTS_VERSION="#$VERSION"
if [ -n "$SMP" ] ; then UTS_VERSION="$UTS_VERSION SMP"; fi
UTS_VERSION="$UTS_VERSION `LANG=C date`"
# Truncate to maximum length
UTS_LEN=64
UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
# Generate a temporary compile.h # Generate a temporary compile.h
( echo /\* This file is auto generated, version $VERSION \*/ ( echo /\* This file is auto generated, version $VERSION \*/
echo \#define UTS_MACHINE \"$ARCH\" echo \#define UTS_MACHINE \"$ARCH\"
echo -n \#define UTS_VERSION \"\#$VERSION echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
if [ -n "$SMP" ] ; then echo -n " SMP"; fi
echo ' '`date`'"'
echo \#define LINUX_COMPILE_TIME \"`date +%T`\" echo \#define LINUX_COMPILE_TIME \"`LANG=C date +%T`\"
echo \#define LINUX_COMPILE_BY \"`whoami`\" echo \#define LINUX_COMPILE_BY \"`whoami`\"
echo \#define LINUX_COMPILE_HOST \"`hostname`\" echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
if [ -x /bin/dnsdomainname ]; then if [ -x /bin/dnsdomainname ]; then
echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\" echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\"
elif [ -x /bin/domainname ]; then elif [ -x /bin/domainname ]; then
echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\" echo \#define LINUX_COMPILE_DOMAIN \"`domainname | $UTS_TRUNCATE`\"
else else
echo \#define LINUX_COMPILE_DOMAIN echo \#define LINUX_COMPILE_DOMAIN
fi fi
...@@ -48,10 +56,10 @@ if [ -r $TARGET ] && \ ...@@ -48,10 +56,10 @@ if [ -r $TARGET ] && \
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \ grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \ grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \
cmp -s .tmpver.1 .tmpver.2; then cmp -s .tmpver.1 .tmpver.2; then
echo $TARGET was not updated; echo ' (unchanged)'
rm -f .tmpcompile rm -f .tmpcompile
else else
echo $TARGET was updated echo ' (updated)'
mv -f .tmpcompile $TARGET mv -f .tmpcompile $TARGET
fi fi
rm -f .tmpver.1 .tmpver.2 rm -f .tmpver.1 .tmpver.2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment