mbox

[RFC,0/2] wic: warn on usage of Y2038 affected file systems

Message ID 20210201185815.382326-1-florian.bezdeka@siemens.com
State Accepted, archived
Headers show

Message

Florian Bezdeka Feb. 1, 2021, 8:58 a.m. UTC
From: Florian Bezdeka <florian.bezdeka@siemens.com>

Hi ISAR developers,

this series is the summary of a nice journey through the file system
jungle regarding Y2038 problem. It all began with a warning which is
reported by kernels >= 5.4:

ext4 filesystem being mounted at (mountpoint) supports timestamps until
2038 (0x7fffffff)

I guess that most ISAR layers are using the Debian kernels, so that
warning was not recognized yet or at least not very often.

When reading this warning I was surprised. Shouldn't a modern file
system like ext4 be Y2038-safe? As it turned out it depends on the
inode size if an ext4 file system is safe or not. So why was the
inode size not sufficient in my case?

The inode size is chosen during file system generation and depends on
the size of the file system that is going to be created. For details
let's have a look at `man mke2fs`:

-T usage-type[,...]
    Specify how the filesystem is going to be used, so that mke2fs can
    choose optimal filesystem parameters for that use. The usage types
    that are supported are defined in the configuration file
    /etc/mke2fs.conf. The user may specify one or more usage types
    using a comma separated list.

    If this option is is not specified, mke2fs will pick a single
    default usage type based on the size of the filesystem to be
    created. If the filesystem size is less than 3 megabytes, mke2fs
    will use the filesystem type floppy. If the filesystem size is
    greater than or equal to 3 but less than 512 megabytes, mke2fs(8)
    will use the filesystem type small.

The relevant parts from /etc/mke2fs.conf:
[fs_types]
...
        small = {
                blocksize = 1024
                inode_size = 128
                inode_ratio = 4096
        }
...

So whenever you create an ext4 file system with less than 512MB in
size you will end up with 128 byte inodes and your file system is
not Y2038-safe.

The ISAR part:
ext4 may often be used in combination with the expand-on-first-boot
recipe / feature. So whenever creating a small partition (e.g. inside
a wic file) and extending it later may result in a Y2038 affected ext4
file system.

That is exactly what happened to me and I would like to make sure that
all other ISAR users are aware of this situation.

Valid workarounds found so far:
 - Tell wic that an partition will grow:
   Add `--mkfs-extraopts "-T ext4"` to your wic partition definition
 - Set the inode size to 256 (for small ext4 partitions)
   Add `--mkfs-extraopts "-I 256"` to your wic partition definition

The upstream part:
None of the following patches has been sent to any upstream (OE)
mailing lists yet but hopefully that will happen soon. So far: Any
comments welcome!

Best regards,
Florian

Florian Bezdeka (2):
  wic-img: Forward warnings from wic to bitbake
  wic: Warn if an ext filesystem affected by the Y2038 problem is used

 meta/classes/wic-img.bbclass | 20 ++++++++++++++-----
 scripts/lib/wic/partition.py | 38 ++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 5 deletions(-)