[PATCH v3 0/6] initramfs: test and improve cpio hex header validation

From: Andy Shevchenko

Date: Mon Mar 23 2026 - 11:06:58 EST


The series that introduced simple_strntoul() had passed into kernel
without proper review and hence reinvented a wheel that's not needed.
Here is the refactoring to show that. It can go via PRINTK or VFS
tree.

I have tested this on x86, but I believe the same result will be
on big-endian CPUs (I deduced that from how strtox() works).

I also run KUnit tests.

Changelog v3:
- rebased on top of latest kernel
- squashed patches proposed by David

v2: 20260121172749.32322-1-ddiss@xxxxxxx
v1: 20260119204151.1447503-1-andriy.shevchenko@xxxxxxxxxxxxxxx

Andy Shevchenko (4):
initramfs: Sort headers alphabetically
initramfs: Refactor to use hex2bin() instead of custom approach
vsprintf: Revert "add simple_strntoul"
kstrtox: Drop extern keyword in the simple_strtox() declarations

David Disseldorp (2):
initramfs_test: add fill_cpio() format parameter
initramfs_test: test header fields with 0x hex prefix

include/linux/kstrtox.h | 9 +++---
init/initramfs.c | 68 +++++++++++++++++++++-----------------
init/initramfs_test.c | 72 +++++++++++++++++++++++++++++++++--------
lib/vsprintf.c | 7 ----
4 files changed, 101 insertions(+), 55 deletions(-)

--
2.50.1