flash-kernel causes postinsts to fail when it happens to be installed on an unsupported system

Bug #1517582 reported by Newell Jensen
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flash-kernel (Ubuntu)
Fix Released
High
Newell Jensen
Trusty
Fix Released
High
dann frazier
Vivid
Fix Released
High
dann frazier
Wily
Fix Released
High
dann frazier
Xenial
Fix Released
High
Newell Jensen

Bug Description

[Impact]

For xgene-2 soc on UEFI system, flash-kernel is failing with:

root@(none):/# apt-get --reinstall install linux-image-4.2.0-1-arm64; echo $?
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/24.2 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg-preconfigure: unable to re-open stdin: No such file or directory
(Reading database ... 39873 files and directories currently installed.)
Preparing to unpack .../linux-image-4.2.0-1-arm64_4.2.6-1_arm64.deb ...
Unpacking linux-image-4.2.0-1-arm64 (4.2.6-1) over (4.2.6-1) ...
Setting up linux-image-4.2.0-1-arm64 (4.2.6-1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.2.0-1-arm64
flash-kernel: deferring update (trigger activated)
/etc/kernel/postinst.d/zz-flash-kernel:
flash-kernel: deferring update (trigger activated)
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-1-arm64
Found initrd image: /boot/initrd.img-4.2.0-1-arm64
done
Processing triggers for flash-kernel (3.50) ...
Unsupported platform.
dpkg: error processing package flash-kernel (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 flash-kernel
E: Sub-process /usr/bin/dpkg returned an error code (1)
100

The patch landed in upstream debian's flash-kernel works like this:

If the machine is found to be unsupported (i.e. is not added to the db file), it then checks if the system is EFI and if it is, it prints a warning and exits instead of erroring out.

This enables us to exit gracefully for all EFI systems if they are not added to the db file and will also allow us to enable UEFI systems if we do add them to the db file.

This change needs to be back-ported for MAAS certification for this hardware.

[Test Case]

To test the bug fix, with the patched flash-kernel in place, you should be able to reinstall the current kernel on an xgene-2 SOC system by running:

# apt-get --reinstall install linux-image-4.2.0-1-arm64; echo $?

You will get a warning message that you are on an unsupported system and that it is an EFI system, instead of erroring out.

[Regression Potential]

Regression potential is extremely low as this has already been tested and landed upstream in debian's flash-kernel package and most importantly because of where the code change occurs. The code change occurs where the program is already exiting with an error. This combination makes it very unlikely for a regression to occur.

Revision history for this message
Ming Lei (tom-leiming) wrote :

The following should fix the issue of flash-kernel, could anyone give a test in MAAS?

diff --git a/functions b/functions
index 97bbdd9..e753054 100644
--- a/functions
+++ b/functions
@@ -429,6 +429,10 @@ fi
 kfile_suffix=$(get_kfile_suffix "$kfile")

 if ! check_supported "$machine"; then
+ # do nothing if one unsupported platform is booted from EFI
+ if [ -d /sys/firmware/efi ]; then
+ exit 0
+ fi
        error "Unsupported platform."
 fi

Revision history for this message
Newell Jensen (newell-jensen) wrote :

I tested this change with MAAS and this gets us past the flash-kernel error.

Changed in flash-kernel (Ubuntu):
status: New → In Progress
Changed in flash-kernel (Ubuntu):
assignee: nobody → Newell Jensen (newell-jensen)
Revision history for this message
Oliver Grawert (ogra) wrote :

please make sure your build tool properly exports FLASH_KERNEL_SKIP=1 to the environment, flash-kernel has the right mechanics builtin since years, your environment needs to provide the right settings for it, this isnt a flash-kernel bug ...

Changed in flash-kernel (Ubuntu):
status: In Progress → Invalid
Revision history for this message
Oliver Grawert (ogra) wrote :

(also note that there are UEFI based arm systems, the patch would break them)

Revision history for this message
Newell Jensen (newell-jensen) wrote :

Trying the export as was mentioned (I believe in the correct way):

root@(none):/# export FLASH_KERNEL_SKIP=1
root@(none):/# apt-get --reinstall install linux-image-4.2.0-1-arm64; echo $?
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/24.2 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg-preconfigure: unable to re-open stdin: No such file or directory
(Reading database ... 39873 files and directories currently installed.)
Preparing to unpack .../linux-image-4.2.0-1-arm64_4.2.6-1_arm64.deb ...
Unpacking linux-image-4.2.0-1-arm64 (4.2.6-1) over (4.2.6-1) ...
Setting up linux-image-4.2.0-1-arm64 (4.2.6-1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.2.0-1-arm64
flash-kernel: deferring update (trigger activated)
/etc/kernel/postinst.d/zz-flash-kernel:
flash-kernel: deferring update (trigger activated)
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-1-arm64
Found initrd image: /boot/initrd.img-4.2.0-1-arm64
done
Processing triggers for flash-kernel (3.50) ...
Unsupported platform.
dpkg: error processing package flash-kernel (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 flash-kernel
E: Sub-process /usr/bin/dpkg returned an error code (1)
100

As I am still seeing the error, is there another way that I should be exporting this to the environmnet?

Revision history for this message
Oliver Grawert (ogra) wrote :

this is actually a different issue to the one from the original bug description ...
here it is flash-kernels postinst itself that gets executed and there is indeed a bug ...

the variable is respected everywhere else (i.e. in /etc/kernel/postinst.d/zz-flash-kernel or /etc/initramfs/post-update.d/flash-kernel)

Changed in flash-kernel (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Oliver Grawert (ogra) wrote :

i just uploaded http://paste.ubuntu.com/13506065/ to xenial ... in case someone wants to SRU that to wily ...

Revision history for this message
Newell Jensen (newell-jensen) wrote :

I already filed a bug and patch to the upstream Debian flash-kernel yesterday:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=806171

Revision history for this message
dann frazier (dannf) wrote :

It seems to me that the mere installation of an installable package - even if it isn't useful on the platform - shouldn't start breaking kernel upgrades. And users shouldn't be expected to know that there's a magic envvar they have to set to to avoid it.

The question is - does it ever make sense to run flash-kernel on an EFI system?

We've been working around this for non-EFI systems that should not run f-k by adding no-op entries in the f-k db (e.g. VMs). Systems in EFI mode seem like a whole class of systems we can blacklist all at once.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package flash-kernel - 3.0~rc.4ubuntu56

---------------
flash-kernel (3.0~rc.4ubuntu56) xenial; urgency=medium

  * make the package postinst respect FLASH_KERNEL_SKIP (LP: #1517582)

 -- Oliver Grawert <email address hidden> Wed, 25 Nov 2015 21:12:16 +0100

Changed in flash-kernel (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Oliver Grawert (ogra) wrote :

i dont know if it will make sense to run f-k on a UEFI system, i can tell you once we support one ;)

in any case there is a mechanism to make f-k skip all f-k calls ever. that didnt work in your case, which i "fixed" (in quotes because the var lives in three places now, it should be moved into main() in the functions file instead to have the code snippet only once in a more central place)

if you want to unseed it instead of using the established skip mechanism i think thats reasonable and a lot cleaner but will also require a bit more work :)
disabling a whole class of devices is IMHO not the way to go here (imagine UEFI systems that store kernel/initrd in encrypted MTD devices etc ... ) lets not make the life of porters harder.

Revision history for this message
Newell Jensen (newell-jensen) wrote :

It should be noted that the upstream patch does not make it so you cannot enable a UEFI system. The patch works like this:

If the machine is found to be unsupported (i.e. is not added to the all.db file for supported or no-op), it then checks if the system is EFI and if it is, it prints a warning and exits instead of erroring out.

Thus, we can still have f-k for UEFI systems if the system is added as a supported device in all.db.

Revision history for this message
dann frazier (dannf) wrote :

We do support arm64 UEFI systems for server and for those, there's no use case for flash-kernel to do anything. It does commonly get installed though. Though flash-kernel-installer knows not to make d-i install it on arm*/efi systems, it does tend to get installed via other mechanisms. curtin image-based installs, for example, do include flash-kernel. When f-k is there, it breaks kernel upgrades because the f-k kernel hooks bail out.

As Newell mentioned, the bypass-on-EFI code change in Debian only skip unknown devices. If a system does appear that has a kernel/initrd in encrypted MTD or similar, we just need to add a db entry for it like any other f-k supported device and this bypass path would not be taken.

I guess an alternate solution would be to make tools like curtin, our factory image creation process, etc be smart enough to detect an efi system and set the FLASH_KERNEL_SKIP variable - but I don't see why that's any better than fixing it in one place.

Unless there's any further objections, I'd like to go ahead and merge/upload w/ Newell's patch from Debian.

Revision history for this message
Oliver Grawert (ogra) wrote :

well, it would just be consistent with the rest of the distro, build system, etc to use the env var, but given that debian accepted and uploaded the patch already, we'll get it anyway with the next upstream sync, so indeed go ahead :)

description: updated
description: updated
Changed in flash-kernel (Ubuntu Wily):
assignee: nobody → Newell Jensen (newell-jensen)
Changed in flash-kernel (Ubuntu Vivid):
assignee: nobody → Newell Jensen (newell-jensen)
Changed in flash-kernel (Ubuntu Trusty):
assignee: nobody → Newell Jensen (newell-jensen)
dann frazier (dannf)
Changed in flash-kernel (Ubuntu Trusty):
status: New → Confirmed
Changed in flash-kernel (Ubuntu Vivid):
status: New → Confirmed
Changed in flash-kernel (Ubuntu Wily):
status: New → Confirmed
Changed in flash-kernel (Ubuntu Trusty):
assignee: Newell Jensen (newell-jensen) → dann frazier (dannf)
Changed in flash-kernel (Ubuntu Vivid):
assignee: Newell Jensen (newell-jensen) → dann frazier (dannf)
Changed in flash-kernel (Ubuntu Wily):
assignee: Newell Jensen (newell-jensen) → dann frazier (dannf)
Changed in flash-kernel (Ubuntu Xenial):
importance: Undecided → High
Changed in flash-kernel (Ubuntu Wily):
importance: Undecided → High
Changed in flash-kernel (Ubuntu Vivid):
importance: Undecided → High
Changed in flash-kernel (Ubuntu Trusty):
importance: Undecided → High
Changed in flash-kernel (Ubuntu Wily):
status: Confirmed → In Progress
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello Newell, or anyone else affected,

Accepted flash-kernel into vivid-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/flash-kernel/3.0~rc.4ubuntu54.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in flash-kernel (Ubuntu Vivid):
status: Confirmed → Fix Committed
Changed in flash-kernel (Ubuntu Trusty):
status: Confirmed → Fix Committed
tags: added: verification-needed
Changed in flash-kernel (Ubuntu Wily):
status: In Progress → Fix Committed
Revision history for this message
Chris J Arges (arges) wrote :

Hello Newell, or anyone else affected,

Accepted flash-kernel into wily-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/flash-kernel/3.0~rc.4ubuntu55.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Revision history for this message
Chris J Arges (arges) wrote :

And also verify for trusty too...

Revision history for this message
Newell Jensen (newell-jensen) wrote :

I verified for trusty, vivid, and wily. Setting to verification-done for these three releases.

tags: added: verification-done-trusty verification-done-vivid verification-done-wily
removed: verification-needed
dann frazier (dannf)
tags: added: verification-done
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package flash-kernel - 3.0~rc.4ubuntu49.7

---------------
flash-kernel (3.0~rc.4ubuntu49.7) trusty; urgency=medium

  * Cherry pick from Debian: Succeed but do nothing when run on an
    unknown machine which was booted via EFI. (LP: #1517582)

 -- dann frazier <email address hidden> Wed, 09 Dec 2015 16:13:59 -0700

Changed in flash-kernel (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote : Update Released

The verification of the Stable Release Update for flash-kernel has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package flash-kernel - 3.0~rc.4ubuntu54.2

---------------
flash-kernel (3.0~rc.4ubuntu54.2) vivid; urgency=medium

  * Cherry pick from Debian: Succeed but do nothing when run on an
    unknown machine which was booted via EFI. (LP: #1517582)

 -- dann frazier <email address hidden> Wed, 09 Dec 2015 16:10:21 -0700

Changed in flash-kernel (Ubuntu Vivid):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package flash-kernel - 3.0~rc.4ubuntu55.1

---------------
flash-kernel (3.0~rc.4ubuntu55.1) wily; urgency=medium

  * Cherry pick from Debian: Succeed but do nothing when run on an
    unknown machine which was booted via EFI. (LP: #1517582)

 -- dann frazier <email address hidden> Wed, 09 Dec 2015 16:06:23 -0700

Changed in flash-kernel (Ubuntu Wily):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.