Skip to content

Comments

Fix null pointer deref crash when no OEM filesystem label is specified#25

Merged
pothos merged 1 commit intoflatcar-masterfrom
kai/fix-null-pointer-deref
Aug 25, 2021
Merged

Fix null pointer deref crash when no OEM filesystem label is specified#25
pothos merged 1 commit intoflatcar-masterfrom
kai/fix-null-pointer-deref

Conversation

@pothos
Copy link
Member

@pothos pothos commented Aug 19, 2021

The check for reusing a filesystem didn't cover the case where no
filesystem label was specified for the OEM partition, causing a crash.

Instead of handling the missing filesystem labels in the check when an
existing OEM partition is checked for reuse, we relax the conditions
for reuse of the OEM partition and will always reuse it unless a
mismatching FS label or UUID got specified by the user (and the user
doesn't force a wipe).

How to use

Test that a CLC with

storage:
  filesystems:
     - name: oem
       mount:
         device: "/dev/disk/by-label/OEM"
         format: "btrfs"
  files:
    - path: /grub.cfg
      filesystem: oem
      mode: 0644
      contents:
        inline: |
          set linux_append="flatcar.autologin"

which is missing the label label: OEM does not crash the system but reuses the existing OEM partition to write to the file.
With ext4 there is a mismatch and the system is expected to reuse the partition, too, and not enter a bootloop.

Testing done

Tested these three cases:

==> ignition-oem-grub-cfg2.yaml <==
storage:
  filesystems:
     - name: oem
       mount:
         device: "/dev/disk/by-label/OEM"
         format: "btrfs"
  files:
    - path: /grub.cfg
      filesystem: oem
      mode: 0644
      contents:
        inline: |
          set linux_append="flatcar.autologin"

==> ignition-oem-grub-cfg3.yaml <==
storage:
  filesystems:
     - name: oem
       mount:
         device: "/dev/disk/by-label/OEM"
         format: "ext4"
  files:
    - path: /grub.cfg
      filesystem: oem
      mode: 0644
      contents:
        inline: |
          set linux_append="flatcar.autologin"

==> ignition-oem-grub-cfg.yaml <==
storage:
  filesystems:
    - name: oem
      mount:
        device: /dev/disk/by-label/OEM
        format: ext4
        label: OEM
  files:
    - path: /grub.cfg
      filesystem: oem
      mode: 0644
      contents:
        inline: |
          set linux_append="flatcar.autologin"

@pothos pothos requested a review from a team August 19, 2021 12:31
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Aug 19, 2021
The check for reusing a filesystem didn't cover the case where no
filesystem label was specified for the OEM partition, causing a crash.

Instead of handling the missing filesystem labels in the check when an
existing OEM partition is checked for reuse, we relax the conditions
for reuse of the OEM partition and will always reuse it unless a
mismatching FS label or UUID got specified by the user (and the user
doesn't force a wipe).
@pothos pothos force-pushed the kai/fix-null-pointer-deref branch from f50a2cc to 0a5340e Compare August 25, 2021 13:30
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Aug 25, 2021
@pothos pothos merged commit 57009f9 into flatcar-master Aug 25, 2021
@pothos pothos deleted the kai/fix-null-pointer-deref branch August 25, 2021 19:25
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Aug 25, 2021
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Aug 25, 2021
t-lo pushed a commit to flatcar/scripts that referenced this pull request Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants