Skip to contentSkip to conversation

The policy on initramfs decompression failure

DISCUSSION Bodo Eggert 3 participants 7 messages Jan 13, 2009 – Jan 18, 2009 8 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

H. Peter Anvin <[email protected]> wrote:

[initramfs decryption failed]

Quoted 12 lines

I had personally assumed the proper policy would be to panic, since it is unlikely to mean the system can be booted. However, Ingo brought up the case where the initramfs is auxilliary to being able to boot the full system, for example the initramfs supplied is primarily a data carrier, and either the builtin initramfs or the kernel itself is sufficient to boot.

By this argument, we should change initramfs decoding failure to a KERN_CRIT message, and in the (presumably most common) case that it does not suffice to boot the system, we will get a panic in short order as the system is unable to find init.

Quoted 6 lines

This argument seems to mostly hold water, but it does implement a policy change over the current code. Furthermore, it does make me concerned that a *partial* decoding failure (such as can be caused by a corrupt image, or, say, a gzipped image concatenated to a bzip2 image, with the kernel only supporting bzip2) could cause a booted-but-dysfunctional system, which is in many configurations a worse failure mode than a panic.

If the initrd is not decompressed successfully, and if it's not there for fun, the system boot will be most likely fubar, and at worst a wrong system or a less secured configuration may be started. Therefore I'd create a kernel option. Possible values would be e.g. [*panic,continue] or [*auto|required|optional|ignore], with:

panic, continue: As expected
auto: If there is an initrd, it's required, otherwise it's ignored
required: Panic if the initrd did not exist or was not unpacked correctly
optional: Like continue
ignore: Don't load the initrd
*: Default value

I currently don't know how to name the option.

#2 lore raw
Quoted 1 line · Bodo Eggert

If the initrd is not decompressed successfully, [...]

No, that's not the issue - i think hpa's description was misleading in that respect.

This is not some sort of corruption. I have hit this pointless panic during testing: there was nothing wrong with either the initrd or the system, the bzImage simply did not include the right decompressor .config option to even read the initrd.

The analogue is if i booted a kernel with CONFIG_MODULES disabled. I do it all the time, it always worked without problems and the initrd with modules in it cannot be interpreted in any sane way CONFIG_MODULES - still it works just fine because the initrd is uninteresting as far as the modules go.

So basically now the kernel has regressed in its bzImage utility: "oh, i dont have a decompressor for the initrd. PANIC!". And that is a step backwards. Unless you use bzImage i dont think you can really appreciate this argument.

I would not mind a warning message though, that bit makes sense.

Ingo

#3 lore raw
Quoted 3 lines · Ingo Molnar

So basically now the kernel has regressed in its bzImage utility: "oh, i dont have a decompressor for the initrd. PANIC!". And that is a step backwards.

Well, for the precise case of gzip I agree with you. The reason why you are right in that special case is that gzip used to be the *only* decompressor available, so it was always available, so you couldn't easily chose a config option which removes the decompressor for a gzip initrd.

However, if you think in more general terms, you _could_ get into that case by attempting to boot up using a bzip2-compressed initrd. If you fed such an initrd to the old unpatched code, you'd get an exception at exactly the same place (populate_rootfs) for exactly the same reason (kernel doesn't have a decompressor for the initrd). Please think about it...

I'm not against fixing old problems with new code, that's in general a good thing. What I do have an issue with is that this seems to become _mandatory_, at least in this case...

And the result of such strictness will not be better code, but stagnant code. Nobody will be able to address one problem, because anybody attempting to do that will have his patch rejected because it doesn't also solve the "hunger in the 3rd world" problem.

Quoted 2 lines

Unless you use bzImage i dont think you can really appreciate this argument.

Maybe that's the source of our misunderstanding. What is this bzImage? (I suppose it's not just the kernel name/format but something more. But what?)

Regards,

Alain

#4 lore raw
Quoted 6 lines · Alain Knaff
Quoted 2 lines

Unless you use bzImage i dont think you can really appreciate this argument.

Maybe that's the source of our misunderstanding. What is this bzImage? (I suppose it's not just the kernel name/format but something more. But what?)

pure bzImages is what many kernel developers use to boot static kernel images, with drivers built in, often with no module support, etc.:

 $ make help | grep -i bzImage
 * bzImage      - Compressed kernel image (arch/x86/boot/bzImage)

the bzImage method never led to a panic related to a ramdisk before (unless the ramdisk was materially corrupted - which is not the case here), and should not lead to a panic afterwards either.

We use panics/crashes when the kernel meets a problem that makes continuing impossible, but that is not an issue here.

Ingo

#5 lore raw
In reply to Ingo Molnar
Quoted 11 lines · Ingo Molnar
Quoted 1 line · Bodo Eggert

If the initrd is not decompressed successfully, [...]

No, that's not the issue - i think hpa's description was misleading in that respect.

This is not some sort of corruption. I have hit this pointless panic during testing: there was nothing wrong with either the initrd or the system, the bzImage simply did not include the right decompressor .config option to even read the initrd.

A unknown-compressed initrd is as good or as bad as a corrupted rd. The kernel can't decide if it's got /dev/random or e.g. a RAR archive. Therefore it must and should behave the same.

Quoted 10 lines

The analogue is if i booted a kernel with CONFIG_MODULES disabled. I do it all the time, it always worked without problems and the initrd with modules in it cannot be interpreted in any sane way CONFIG_MODULES - still it works just fine because the initrd is uninteresting as far as the modules go.

So basically now the kernel has regressed in its bzImage utility: "oh, i dont have a decompressor for the initrd. PANIC!". And that is a step backwards. Unless you use bzImage i dont think you can really appreciate this argument.

If there is no initrd, you won't get a panic. If you use a gzip initrd with a bz2-only kernel what do you expect? What do you expect if you say "root=/dev/internal-disk", but /dev/usb/attacker's-USB-stick is currently the only working alternative?

I think having a kernel parameter ist the right thing, since it won't decrease security, it gives everything you want and it allows you to skip even "good" initrds if they turn out not to be good.

Quoted 1 line

I would not mind a warning message though, that bit makes sense.

"Warning, I'm starting a setup which you didn't intend to start
at all! Muahahahaha, good luck!"

Signature · 1 line
Interchangeable parts aren't.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 5 lines · Ingo Molnar

Exactly how is such a warning different from other warnings that the kernel already emits? For which people supposedly have to set up a serial console? (which they dont have to)

Answer:

A warning is given if the systen knows the correct way how to deal with the situation, even if it shouldn't be there. How would you know that any system being at the compiled-in default root device location (e.g. /dev/sda1, if I did not have raid) WILL NOT boot unless I intend it to boot? Maybe it's a rescue system supposed to run from initrd only? Or a public terminal supposedly running from initrd + network only, where /dev/sda is the client's USB stick? Or it's a remote setup, and panic() will reboot into the old, working setup?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw
Quoted 6 lines · H. Peter Anvin

Thought about this whole thing some more, and it seems to me as follows:
what we really want, and need, is a "panic-level=X" option, where X will naturally vary for differnet users. I suspect there are many users today who would prefer a panic (and reboot) on a KERN_CRIT message, even at runtime. For finer control, we need a message subsystem tag, but that is something that would be highly desirable anyway.

This will be fun if there are read errors on the CDROM.

Quoted 2 lines

As such, the initramfs decompression failure should be a KERN_CRIT or KERN_ALERT message, and not a panic per se.

Only if you can argue that not using the initrd WILL NEVER be bad.