From 175367346a52349fe97fcfa5e5c1ecab050f0790 Mon Sep 17 00:00:00 2001 From: "Justin M. Forbes" Date: Wed, 15 Mar 2017 11:38:19 -0500 Subject: [PATCH] Forgot the config scripts --- build_configs.sh | 91 +++++++++++++++++++++++++++++++++++++++ configs/merge.pl | 66 ++++++++++++++++++++++++++++ generate_all_configs.sh | 6 +++ generate_debug_configs.sh | 8 ++++ kernel.spec | 1 + 5 files changed, 172 insertions(+) create mode 100755 build_configs.sh create mode 100755 configs/merge.pl create mode 100755 generate_all_configs.sh create mode 100755 generate_debug_configs.sh diff --git a/build_configs.sh b/build_configs.sh new file mode 100755 index 000000000..55fb89d01 --- /dev/null +++ b/build_configs.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# This script merges together the hierarchy of CONFIG_* files under generic +# and debug to form the necessary $PACKAGE_NAME--.config +# files for building RHEL kernels, based on the contents of a control file + +PACKAGE_NAME=kernel # defines the package name used + +set errexit +set nounset + +control_file="config_generation" + +function combine_config_layer() +{ + dir=$1 + file="config-$(echo $dir | sed -e 's|/|-|g')" + + if [ $(ls $dir/ | grep -c "^CONFIG_") -eq 0 ]; then + touch $file + return + fi + + cat $dir/CONFIG_* > $file +} + +function merge_configs() +{ + archvar=$1 + arch=$(echo "$archvar" | cut -f1 -d"-") + configs=$2 + name=$PACKAGE_NAME-$archvar.config + echo -n "Building $name ... " + touch config-merging config-merged + for config in $(echo $configs | sed -e 's/:/ /g') + do + perl merge.pl config-$config config-merging > config-merged + if [ ! $? -eq 0 ]; then + exit + fi + mv config-merged config-merging + done + if [ "x$arch" == "xaarch64" ]; then + echo "# arm64" > $name + elif [ "x$arch" == "xppc64" ]; then + echo "# powerpc" > $name + elif [ "x$arch" == "xppc64le" ]; then + echo "# powerpc" > $name + elif [ "x$arch" == "xppc64p7" ]; then + echo "# powerpc" > $name + elif [ "x$arch" == "xs390x" ]; then + echo "# s390" > $name + elif [ "x$arch" == "xarmv7hl" ]; then + echo "# arm" > $name + elif [ "x$arch" == "xi686" ]; then + echo "# i386" > $name + else + echo "# $arch" > $name + fi + sort config-merging >> $name + rm -f config-merged config-merging + echo "done" +} + +glist=$(find baseconfig -type d) +dlist=$(find debugconfig -type d) + +for d in $glist $dlist +do + combine_config_layer $d +done + +while read line +do + if [ $(echo "$line" | grep -c "^#") -ne 0 ]; then + continue + elif [ $(echo "$line" | grep -c "^$") -ne 0 ]; then + continue + else + arch=$(echo "$line" | cut -f1 -d"=") + configs=$(echo "$line" | cut -f2 -d"=") + + if [ -n "$SUBARCH" -a "$SUBARCH" != "$arch" ]; then + continue + fi + + merge_configs $arch $configs + fi +done < $control_file + +rm -f config-* diff --git a/configs/merge.pl b/configs/merge.pl new file mode 100755 index 000000000..8c318156a --- /dev/null +++ b/configs/merge.pl @@ -0,0 +1,66 @@ +#! /usr/bin/perl + +my @args=@ARGV; +my %configvalues; +my @configoptions; +my $configcounter = 0; + +# optionally print out the architecture as the first line of our output +my $arch = $args[2]; +if (defined $arch) { + print "# $arch\n"; +} + +# first, read the override file + +open (FILE,"$args[0]") || die "Could not open $args[0]"; +while () { + my $str = $_; + my $configname; + + if (/\# ([\w]+) is not set/) { + $configname = $1; + } elsif (/([\w]+)=/) { + $configname = $1; + } + + if (defined($configname) && !exists($configvalues{$configname})) { + $configvalues{$configname} = $str; + $configoptions[$configcounter] = $configname; + $configcounter ++; + } +}; + +# now, read and output the entire configfile, except for the overridden +# parts... for those the new value is printed. + +open (FILE2,"$args[1]") || die "Could not open $args[1]"; +while () { + my $configname; + + if (/\# ([\w]+) is not set/) { + $configname = $1; + } elsif (/([\w]+)=/) { + $configname = $1; + } + + if (defined($configname) && exists($configvalues{$configname})) { + print "$configvalues{$configname}"; + delete($configvalues{$configname}); + } else { + print "$_"; + } +} + +# now print the new values from the overridden configfile +my $counter = 0; + +while ($counter < $configcounter) { + my $configname = $configoptions[$counter]; + if (exists($configvalues{$configname})) { + print "$configvalues{$configname}"; + } + $counter++; +} + +1; diff --git a/generate_all_configs.sh b/generate_all_configs.sh new file mode 100755 index 000000000..dde72eaff --- /dev/null +++ b/generate_all_configs.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for i in kernel-*.config; do + NEW=kernel-$VERSION-`echo $i | cut -d - -f2-` + mv $i $NEW +done diff --git a/generate_debug_configs.sh b/generate_debug_configs.sh new file mode 100755 index 000000000..ce082fe1b --- /dev/null +++ b/generate_debug_configs.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +for i in kernel-*debug.config; do + base=`echo $i | sed -r s/-?debug//g` + NEW=kernel-$VERSION-`echo $base | cut -d - -f2-` + mv $i $NEW + rm $base +done diff --git a/kernel.spec b/kernel.spec index 5864e54a0..e06f75b98 100644 --- a/kernel.spec +++ b/kernel.spec @@ -2186,6 +2186,7 @@ fi %changelog * Wed Mar 15 2017 Justin M. Forbes - 4.10.3-200 - Linux v4.10.3 rebase +- CVE-2017-6874 Fix race condition in ucount.c (rhbz 1432429 1432430) * Mon Mar 13 2017 Laura Abbott - 4.9.14-200 - Linux v4.9.14