Accepting request 236915 from home:jeff_mahoney:branches:Base:System

- Add option to warn if unsupported modules are added to the initramfs
  - Enable this option for 'make install' when a kernel with
    CONFIG_SUSE_KERNEL_SUPPORTED enabled is used. (bnc#882332)
  - Add dracut-check-supported.patch

OBS-URL: https://build.opensuse.org/request/show/236915
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=159
This commit is contained in:
Hannes Reinecke 2014-06-12 07:15:53 +00:00 committed by Git OBS Bridge
parent ddda9183bc
commit b74e6b4550
4 changed files with 133 additions and 3 deletions

View File

@ -0,0 +1,113 @@
From: Jeff Mahoney <jeffm@suse.com>
Subject: dracut: add warning when including unsupported modules
References: bnc#882332
Patch-mainline: probably never
With self-built kernels (often used for debugging by both internal and
external development), it's a common mistake to not set up
Module.supported properly. As a result, modules can end up without the
supported tag. "make install" will happily build an initramfs, via
dracut, that will not boot due to the kernel refusing to load the
unsupported modules.
This patch adds a --check-supported option to check whether all modules
added to the initramfs are marked supported and warn if they are not.
It will not cause the initramfs creation to fail.
The option is intended to be called via /sbin/installkernel, which will
check to see if the kernel has CONFIG_SUSE_KERNEL_SUPPORTED before using
the option.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
dracut-functions.sh | 21 +++++++++++++++++++++
dracut.8 | 5 +++++
dracut.sh | 5 +++++
3 files changed, 31 insertions(+)
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -1400,6 +1400,17 @@ for_each_module_dir() {
done
}
+check_supported_kmod() {
+ kmod=$1
+ supported=$(modinfo -k $kernel -F supported $kmod 2>/dev/null)
+ case "$supported" in
+ yes|external) ;;
+ *) dwarn "Module \"$(basename $kmod)\" is unsupported. This may cause" \
+ "problems while booting." ;;
+ esac
+}
+
+
# Install a single kernel module along with any firmware it may require.
# $1 = full path to kernel module to install
install_kmod_with_fw() {
@@ -1462,6 +1473,10 @@ install_kmod_with_fw() {
fi
fi
done
+
+ if [[ "$check_supported" = "yes" ]]; then
+ check_supported_kmod $1
+ fi
return 0
}
@@ -1508,6 +1523,12 @@ dracut_kernel_post() {
inst_simple "$_modpath" "/lib/modules/$kernel/${_destpath}" || exit $?
done < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
fi
+
+ if [[ $check_supported ]]; then
+ while read _modpath; do
+ check_supported_kmod $_modpath
+ done < "$DRACUT_KERNEL_LAZY_HASHDIR/lazylist.dep"
+ fi
) &
_pid=$(jobs -p | while read a ; do printf ":$a";done)
_pid=${_pid##*:}
--- a/dracut.8
+++ b/dracut.8
@@ -1855,6 +1855,11 @@ Print out the module install size
.RS 4
Regenerate all initramfs images at the default location with the kernel versions found on the system\&. Additional parameters are passed through\&.
.RE
+.PP
+\fB\-\-check\-supported\fR
+.RS 4
+The kernel may be configured to check whether a module is supported by the vendor before allowing it to be loaded. On these systems, it's possible to generate an initramfs image that will fail to boot due to unsupported modules being refused. This option enables a check that will issue a warning if a module built without the support option enabled is encountered while building the image. Use of this option assumes that the kernel requires supported modules and will issue a warning on every module if used otherwise.
+.RE
.SH "FILES"
.PP
\fI/var/log/dracut\&.log\fR
--- a/dracut.sh
+++ b/dracut.sh
@@ -193,6 +193,9 @@ Creates initial ramdisk images for prelo
--printsize Print out the module install size
--sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
--logfile [FILE] Logfile to use (overrides configuration setting)
+ --check-supported Check to ensure that modules are marked supported when
+ using a kernel that is configured to check the
+ support status of a module before loading.
If [LIST] has multiple arguments, then you have to put these in quotes.
@@ -374,6 +377,7 @@ rearrange_params()
--long noimageifnotneeded \
--long early-microcode \
--long no-early-microcode \
+ --long check-supported \
-- "$@")
if (( $? != 0 )); then
@@ -557,6 +561,7 @@ while :; do
--printsize) printsize="yes";;
--regenerate-all) regenerate_all="yes";;
--noimageifnotneeded) noimageifnotneeded="yes";;
+ --check-supported) check_supported="yes" ;;
--) shift; break;;

View File

@ -63,6 +63,14 @@ fi
cp -fp $BOOTIMAGE $INSTALL_PATH/$BOOTFILE-$KERNEL_VERSION
cp -fp $MAPFILE $INSTALL_PATH/System.map-$KERNEL_VERSION
CONFIG=$(dirname $MAPFILE)/.config
CHECK_SUPPORTED=
if [ -e "$CONFIG" ]; then
if grep -q "^CONFIG_SUSE_KERNEL_SUPPORTED=y" $CONFIG ; then
CHECK_SUPPORTED="--check-supported"
fi
fi
KERNTYPES=$(dirname $MAPFILE)/init/kerntypes.o
if [ -e $KERNTYPES ]; then
cp -fp $KERNTYPES $INSTALL_PATH/Kerntypes-$KERNEL_VERSION
@ -85,8 +93,8 @@ esac
# Generate initial ramdisk
#
if [ -x /usr/bin/dracut -a -d /lib/modules/$KERNEL_VERSION ]; then
/usr/bin/dracut --hostonly --force $INSTALL_PATH/initrd-$KERNEL_VERSION \
$KERNEL_VERSION
/usr/bin/dracut --hostonly --force $CHECK_SUPPORTED \
$INSTALL_PATH/initrd-$KERNEL_VERSION $KERNEL_VERSION
else
echo "You may need to create an initial ramdisk now."
fi

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Jun 11 18:17:34 UTC 2014 - jeffm@suse.com
- Add option to warn if unsupported modules are added to the initramfs
- Enable this option for 'make install' when a kernel with
CONFIG_SUSE_KERNEL_SUPPORTED enabled is used. (bnc#882332)
- Add dracut-check-supported.patch
-------------------------------------------------------------------
Wed Jun 11 12:49:44 UTC 2014 - meissner@suse.com

View File

@ -82,8 +82,8 @@ Patch53: 0053-01fips-fixup-loading-issues.patch
Patch54: 0054-95iscsi-update-commandline-printing.patch
Patch55: 0055-95fcoe-Only-install-fcoe-module-if-required.patch
Patch56: 0056-81cio_ignore-handle-cio_ignore-commandline.patch
Patch57: more-fips-adjustments.patch
Patch58: dracut-check-supported.patch
BuildRequires: asciidoc
BuildRequires: bash
@ -182,6 +182,7 @@ and its cryptography during startup.
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%build
%configure\