Skip to contentSkip to conversation

Harden check for used modules in hostonly mode

PATCH In review Andrey Borzenkov 2 participants 3 messages May 9, 2010 – Aug 4, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Harden check for used modules in hostonly mode

Make sure that we do not accept module name which is substring of some other module name. This resulted in piix being mistakenly loaded together with ata_piix. It completely broke DVD access here.

---

 dracut-functions |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
dracut-functions +1 -1
index fdcfb7e..ebf09c0 100755
@@ -502,7 +502,7 @@ instmods() {
 	        [[ -f $initdir/$1 ]] && { shift; continue; }
 		# If we are building a host-specific initramfs and this
 		# module is not already loaded, move on to the next one.
-		[[ $hostonly ]] && ! grep -q "${mod//-/_}" /proc/modules && \
+		[[ $hostonly ]] && ! grep -qe "\<${mod//-/_}\>" /proc/modules && \
 	        ! echo $add_drivers | grep -qe "\<${mod}\>" &&	{
 		    shift; continue; 
 		}
#1 lore raw
Quoted 1 line · On Sunday 09 of May 2010 22:23:58 Andrey Borzenkov wrote:

Make sure

that we do not accept module name which is substring of

Quoted 1 line

some other

module name. This resulted in piix being mistakenly loaded

Quoted 1 line

together

with ata_piix. It completely broke DVD access here.

Quoted 2 lines
Quoted 1 line

Ping. In
2.6.35 it became much worse. In 2.6.33 I had DVD as IDE and HD as PATA which was OK. In 2.6.35 using exactly the same setup I lost any access to HD. I.e. with these modules:

{pts/1}% lsmod | grep piix
ata_piix

            22460  0 

libata 193241 4
ata_generic,pata_acpi,ata_piix,ahci
piix 5408 1

ide_core 116373 3
ide_cd_mod,ide_pci_generic,piix

2.6.33 detects DVD as hda and HDD as
sda; with 2.6.35 only hda is detected. If I unload IDE stack and reload ata_piix it correctly detects both HDD as sda and DVD as sr0.

So without this patch dracut generates initrd that cannot find root device.

Thank you!

Quoted 4 lines

---

 dracut-functions |    2 +-

1

files changed, 1 insertions(+), 1 deletions(-)

Quoted 2 lines

diff --git

a/dracut-functions b/dracut-functions

Quoted 1 line

index fdcfb7e..ebf09c0

100755

Quoted 3 lines
dracut-functions +0 -0

@@ -502,7

+502,7 @@ instmods() {

Quoted 1 line

[[ -f $initdir/$1 ]] && { shift;

continue; }

Quoted 1 line

# If we are building a host-specific initramfs and

this

Quoted 2 lines
 		# module is not already loaded, move on to the next one.

- [[ $hostonly ]] && ! grep -q "${mod//-/_}" /proc/modules && \

Quoted 1 line

+ [[ $hostonly ]] && ! grep -qe "\<${mod//-/_}\>" /proc/modules &&
\

Quoted 2 lines

! echo $add_drivers | grep -qe "\<${mod}\>" && {

shift; continue;

Quoted 4 lines

}

--
To unsubscribe from this list: send

the line "unsubscribe initramfs"

Quoted 1 line

in the body of a message to

[email protected]

Quoted 1 line

More majordomo info at

http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Andrey Borzenkov

pushed

Quoted 29 lines · Andrey Borzenkov

Make sure that we do not accept module name which is substring of some other module name. This resulted in piix being mistakenly loaded together with ata_piix. It completely broke DVD access here.

---

  dracut-functions |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
dracut-functions +1 -2
index fdcfb7e..ebf09c0 100755
@@ -502,7 +502,7 @@ instmods() {
  	        [[ -f $initdir/$1 ]]&&  { shift; continue; }
  		# If we are building a host-specific initramfs and this
  		# module is not already loaded, move on to the next one.
-		[[ $hostonly ]]&&  ! grep -q "${mod//-/_}" /proc/modules&&  \
+		[[ $hostonly ]]&&  ! grep -qe "\<${mod//-/_}\>" /proc/modules&&  \
  	        ! echo $add_drivers | grep -qe "\<${mod}\>"&&	{
  		    shift; continue;
  		}
 
--

To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html