[PATCH v2 0/9] initramfs: kunit tests and cleanups

2024-11-06 Thread David Disseldorp
- rework patch: avoid static buffer for error message + drop unnecessary message propagation - drop patch: cpio_buf reuse for built-in and bootloader initramfs + no good justification for the change Feedback appreciated. David Disseldorp (9): init: add initramfs_internal.h

[PATCH v3 1/9] init: add initramfs_internal.h

2024-11-06 Thread David Disseldorp
The new header only exports a single unpack function and a CPIO_HDRLEN constant for future test use. Signed-off-by: David Disseldorp --- init/initramfs.c | 16 +--- init/initramfs_internal.h | 8 2 files changed, 21 insertions(+), 3 deletions(-) create mode

[PATCH v3 2/9] initramfs_test: kunit tests for initramfs unpacking

2024-11-06 Thread David Disseldorp
Provide some basic initramfs unpack sanity tests covering: - simple file / dir extraction - filename field overrun, as reported and fixed separately via https://lore.kernel.org/r/20241030035509.20194-2-dd...@suse.de - "070702" cpio data checksums - hardlinks Signed-off-by: David

[PATCH v3 3/9] vsprintf: add simple_strntoul

2024-11-06 Thread David Disseldorp
cpio extraction currently does a memcpy to ensure that the archive hex fields are null terminated for simple_strtoul(). simple_strntoul() will allow us to avoid the memcpy. Signed-off-by: David Disseldorp --- include/linux/kstrtox.h | 1 + lib/vsprintf.c | 7 +++ 2 files changed, 8

[PATCH v3 6/9] initramfs: merge header_buf and name_buf

2024-11-06 Thread David Disseldorp
. Signed-off-by: David Disseldorp --- init/initramfs.c | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 59b4a43fa491b..4e2506a4bc76f 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -250,11 +250,11

[PATCH v3 7/9] initramfs: reuse name_len for dir mtime tracking

2024-11-06 Thread David Disseldorp
We already have a nulterm-inclusive, checked name_len for the directory name, so use that instead of calling strlen(). Signed-off-by: David Disseldorp --- init/initramfs.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index

[PATCH v3 5/9] initramfs: remove extra symlink path buffer

2024-11-06 Thread David Disseldorp
cpio entries. Separate symlink / non-symlink buffers are unnecessary, so just extend the size of name_buf and use it for both. Signed-off-by: David Disseldorp --- init/initramfs.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c

[PATCH v3 9/9] initramfs: avoid static buffer for error message

2024-11-06 Thread David Disseldorp
76951102 888052265 ./init/initramfs.o After: textdata bss dec hex filename 76831006 8869721f9 ./init/initramfs.o Signed-off-by: David Disseldorp --- init/initramfs.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --

[PATCH v3 4/9] initramfs: avoid memcpy for hex header fields

2024-11-06 Thread David Disseldorp
newc/crc cpio headers contain a bunch of 8-character hexadecimal fields which we convert via simple_strtoul(), following memcpy() into a zero-terminated stack buffer. The new simple_strntoul() helper allows us to pass in max_chars=8 to avoid zero-termination and memcpy(). Signed-off-by: David

[PATCH v3 8/9] initramfs: fix hardlink hash leak without TRAILER

2024-11-06 Thread David Disseldorp
cing side-effect of this fix: hardlinks can currently be associated across built-in and external initramfs archives, *if* the built-in initramfs archive lacks a "TRAILER!!!" terminator. I'd consider this cross-archive association broken, but perhaps it's used. Signed-off-by: David Diss

Re: [PATCH v2 2/9] initramfs_test: kunit tests for initramfs unpacking

2024-11-06 Thread David Disseldorp
[adding kunit lists to cc, see lore link below for context] https://lore.kernel.org/linux-fsdevel/20241104141750.16119-3-dd...@suse.de/ On Wed, 6 Nov 2024 07:04:21 +0800, kernel test robot wrote: ... > All warnings (new ones prefixed by >>, old ones prefixed by <<): > > >> WARNING: modpost: vmli

Re: [PATCH v3 8/9] initramfs: fix hardlink hash leak without TRAILER

2024-11-26 Thread David Disseldorp
On Thu, 7 Nov 2024 11:17:27 +1100, David Disseldorp wrote: > Covered in Documentation/driver-api/early-userspace/buffer-format.rst , > initramfs archives can carry an optional "TRAILER!!!" entry which serves > as a boundary for collecting and associating hardlinks with matchin

Re: [brauner-github:vfs.all 205/231] WARNING: modpost: vmlinux: section mismatch in reference: initramfs_test_cases+0x0 (section: .data) -> initramfs_test_extract (section: .init.text)

2025-03-04 Thread David Disseldorp
[cc'ing linux-kselftest and kunit-dev] Hi, On Wed, 5 Mar 2025 01:47:55 +0800, kernel test robot wrote: > tree: https://github.com/brauner/linux.git vfs.all > head: ea47e99a3a234837d5fea0d1a20bb2ad1eaa6dd4 > commit: b6736cfccb582b7c016cba6cd484fbcf30d499af [205/231] initramfs_test: > kunit t

[PATCH v4 7/8] initramfs: fix hardlink hash leak without TRAILER

2025-03-03 Thread David Disseldorp
cing side-effect of this fix: hardlinks can currently be associated across built-in and external initramfs archives, *if* the built-in initramfs archive lacks a "TRAILER!!!" terminator. I'd consider this cross-archive association broken, but perhaps it's used. Signed-off-by: David

[PATCH v4 5/8] initramfs: allocate heap buffers together

2025-03-03 Thread David Disseldorp
uring early boot isn't really worth the extra review complexity. Link: https://lore.kernel.org/all/20241107002044.16477-7-dd...@suse.de/ Signed-off-by: David Disseldorp --- init/initramfs.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/init/initramf

[PATCH v4 2/8] initramfs_test: kunit tests for initramfs unpacking

2025-03-03 Thread David Disseldorp
ew modpost warnings for initramfs_test_cases section=.data -> section=.init.text run_case() hooks. The kunit_case/_suite struct cannot be marked as __initdata as this will be used in debugfs to retrieve results after a test has run. Signed-off-by: David Disseldorp --- init/.kunitconfig

[PATCH v4 1/8] init: add initramfs_internal.h

2025-03-03 Thread David Disseldorp
The new header only exports a single unpack function and a CPIO_HDRLEN constant for future test use. Signed-off-by: David Disseldorp --- init/initramfs.c | 16 +--- init/initramfs_internal.h | 8 2 files changed, 21 insertions(+), 3 deletions(-) create mode

[PATCH v4 4/8] initramfs: avoid memcpy for hex header fields

2025-03-03 Thread David Disseldorp
newc/crc cpio headers contain a bunch of 8-character hexadecimal fields which we convert via simple_strtoul(), following memcpy() into a zero-terminated stack buffer. The new simple_strntoul() helper allows us to pass in max_chars=8 to avoid zero-termination and memcpy(). Signed-off-by: David

[PATCH v4 8/8] initramfs: avoid static buffer for error message

2025-03-03 Thread David Disseldorp
80061118 8913223ac init/initramfs.o After: textdata bss dec hex filename 79381022 889682308 init/initramfs.o Signed-off-by: David Disseldorp --- init/initramfs.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a

[PATCH v4 0/8] initramfs: kunit tests and cleanups

2025-03-03 Thread David Disseldorp
tch: fix hardlink hash leak without TRAILER - rework patch: avoid static buffer for error message + drop unnecessary message propagation - drop patch: cpio_buf reuse for built-in and bootloader initramfs + no good justification for the change Feedback appreciated. David Disseldorp (8): i

[PATCH v4 6/8] initramfs: reuse name_len for dir mtime tracking

2025-03-03 Thread David Disseldorp
We already have a nulterm-inclusive, checked name_len for the directory name, so use that instead of calling strlen(). Signed-off-by: David Disseldorp --- init/initramfs.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index

[PATCH v4 3/8] vsprintf: add simple_strntoul

2025-03-03 Thread David Disseldorp
cpio extraction currently does a memcpy to ensure that the archive hex fields are null terminated for simple_strtoul(). simple_strntoul() will allow us to avoid the memcpy. Signed-off-by: David Disseldorp --- include/linux/kstrtox.h | 1 + lib/vsprintf.c | 7 +++ 2 files changed, 8

Re: [brauner-github:vfs.all 205/231] WARNING: modpost: vmlinux: section mismatch in reference: initramfs_test_cases+0x0 (section: .data) -> initramfs_test_extract (section: .init.text)

2025-03-05 Thread David Disseldorp
On Wed, 5 Mar 2025 11:47:01 +1100, David Disseldorp wrote: > [cc'ing linux-kselftest and kunit-dev] > > Hi, > > On Wed, 5 Mar 2025 01:47:55 +0800, kernel test robot wrote: > > > tree: https://github.com/brauner/linux.git vfs.all > > head: ea47e99a3a234837

[PATCH] initramfs_test: flag kunit_case __refdata to suppress warning

2025-03-05 Thread David Disseldorp
hen Rothwell Signed-off-by: David Disseldorp --- @Christian: feel free to squash this in with commit b6736cfccb582 ("initramfs_test: kunit tests for initramfs unpacking") in your vfs-6.15.initramfs branch if you like (and remove "These tests introduce new modpost warnings..." from