From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 24/26] fuzz: add 4K-sector partition ramdisk target
Date: Fri, 26 Jun 2026 10:42:35 +0200 [thread overview]
Message-ID: <20260626084608.1388806-25-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260626084608.1388806-1-a.fatoum@barebox.org>
Make fuzz_test_ramdisk() take the ramdisk sector size so the partition
parser fuzzer can exercise both 512-byte and 4096-byte block devices.
Keep the existing fuzz-partitions target on 512-byte sectors and
add fuzz-partitions-4k for the 4K-sector case.
Assisted-by: Codex:gpt-5.5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
Documentation/devel/fuzzing.rst | 1 +
common/partitions.c | 3 ++-
images/Makefile.sandbox | 1 +
include/fuzz.h | 9 +++++----
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Documentation/devel/fuzzing.rst b/Documentation/devel/fuzzing.rst
index b475fd12fcea..a34d92b97e2e 100644
--- a/Documentation/devel/fuzzing.rst
+++ b/Documentation/devel/fuzzing.rst
@@ -25,6 +25,7 @@ options to crash barebox on detection of memory safety issues::
fuzz-dtb
fuzz-fdt-compatible
fuzz-partitions
+ fuzz-partitions-4k
All fuzzers generated are symlinks to the same barebox executable. barebox
will detect that it was invoked via symlink and switch to fuzzing mode.
diff --git a/common/partitions.c b/common/partitions.c
index 617c2770eadf..617b33460429 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -408,7 +408,8 @@ static int fuzz_partition_table_parser(struct block_device *ramdisk)
free(buf);
return 0;
}
-fuzz_test_ramdisk("partitions", fuzz_partition_table_parser);
+fuzz_test_ramdisk("partitions", fuzz_partition_table_parser, 512);
+fuzz_test_ramdisk("partitions-4k", fuzz_partition_table_parser, 4096);
/**
* cdev_unallocated_space - return unallocated space
diff --git a/images/Makefile.sandbox b/images/Makefile.sandbox
index 210a7bf48ac8..2af83b395f9f 100644
--- a/images/Makefile.sandbox
+++ b/images/Makefile.sandbox
@@ -9,6 +9,7 @@ fuzzer-$(CONFIG_FITIMAGE) += fit
fuzzer-$(CONFIG_OFTREE) += dtb
fuzzer-$(CONFIG_OFTREE) += fdt-compatible
fuzzer-$(CONFIG_PARTITION) += partitions
+fuzzer-$(CONFIG_PARTITION) += partitions-4k
ifeq ($(CONFIG_SANDBOX),y)
diff --git a/include/fuzz.h b/include/fuzz.h
index 4d637f72b176..559e67a09b50 100644
--- a/include/fuzz.h
+++ b/include/fuzz.h
@@ -47,13 +47,14 @@ extern const struct fuzz_test __barebox_fuzz_tests_end;
static __always_unused void * _unused##_func = _func
#endif
-#define fuzz_test_ramdisk(_name, _func) \
- static int _func##_ramdisk(const u8 *data, size_t size) \
+#define fuzz_test_ramdisk(_name, _func, _sector_size) \
+ static int _func##_ramdisk_##_sector_size(const u8 *data, \
+ size_t size) \
{ \
static struct ramdisk *ramdisk; \
int ret; \
if (!ramdisk) \
- ramdisk = ramdisk_init(512); \
+ ramdisk = ramdisk_init(_sector_size); \
if (!ramdisk) \
return -ENODEV; \
ramdisk_setup_ro(ramdisk, data, size); \
@@ -61,7 +62,7 @@ extern const struct fuzz_test __barebox_fuzz_tests_end;
ramdisk_setup_ro(ramdisk, NULL, 0); \
return ret; \
} \
- fuzz_test(_name, _func##_ramdisk)
+ fuzz_test(_name, _func##_ramdisk_##_sector_size)
#define fuzz_test_str(_name, _func) \
static int _func##_str(const u8 *_data, size_t size) \
--
2.47.3
next prev parent reply other threads:[~2026-06-26 8:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 8:42 [PATCH 00/26] block: add support for non-512 byte sectors Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 01/26] nvme: use barebox-appropriate 64-bit type for timeouts Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 02/26] nvme: fix buffer advancement when chunking due to max_hw_sectors Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 03/26] nvme: allow flush opcode Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 04/26] nvme: honor namespace block size for I/O Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 05/26] bootscan: fix detection of GPT Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 06/26] block: clarify that writebuffer_io_len returns sector counts Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 07/26] block: fix wrong type for discard_start/size byte ranges Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 08/26] block: fix discard zeroing too little memory Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 09/26] block: use logical block size for reparse checks Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 10/26] block: require lower bound of sector size to be 512 bytes Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 11/26] filetype: don't hardcode sector size in file_detect_partition_table Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 12/26] block: define helpers for non-512-byte sector support Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 13/26] bootscan: use block size for partition table probe Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 14/26] ramdisk: validate exported sector size Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 15/26] efi: block: fix sector size mismatch in block device registration and ops Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 16/26] efi: loader: disk: report block device size in Block I/O Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 17/26] efi: loader: file: report cdev block size in file info Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 18/26] partitions: use byte offset for first partition policy Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 19/26] partitions: dos: allocate correctly sized buffer for dos_partition_desc Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 20/26] partition: support non-512 byte sectors Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 21/26] fs: fat: fix garbage read when writing with bigger block size Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 22/26] fs: fat: support larger block device sectors Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 23/26] usb-storage: preserve READ CAPACITY sector size Ahmad Fatoum
2026-06-26 8:42 ` Ahmad Fatoum [this message]
2026-06-26 8:42 ` [PATCH 25/26] commands: parted: prepare use of non-512-byte sectors Ahmad Fatoum
2026-06-26 8:42 ` [PATCH 26/26] commands: parted: exit if block size if not 512 Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260626084608.1388806-25-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox