Re: [PATCH v3 4/4] thunderbolt: test: add KUnit regression tests for XDomain property parser

From: Mika Westerberg

Date: Tue May 05 2026 - 08:02:10 EST


Hi,

On Sun, May 03, 2026 at 10:15:08AM -0400, Michael Bommarito wrote:
> +/*
> + * Reproducers for three memory-safety defects in
> + * drivers/thunderbolt/property.c reached from a crafted XDomain
> + * PROPERTIES_RESPONSE payload. Without the fix these trip KASAN or
> + * smash the kernel stack; with the fix each returns NULL cleanly.
> + *
> + * The on-wire entry layout mirrors struct tb_property_entry in
> + * property.c (private to that translation unit).
> + */
> +struct tb_test_property_entry {
> + u32 key_hi, key_lo;
> + u16 length;
> + u8 reserved;
> + u8 type;
> + u32 value;
> +};

If possible, can you make the below just be u32 as we have root_directory
already? That way we don't need to duplicate this and I think with the AI
should not be a big deal.

[The other option is to move the structure into tb.h as that's internal but
I prefer the u32 array in tests].

> +static void tb_test_property_parse_u32_wrap(struct kunit *test)
> +{
> + u32 *block = kunit_kzalloc(test, 500 * sizeof(u32), GFP_KERNEL);

This one is fine to be dynamic and just fill in below what is needed as
u32.

Otherwise this is good and I like the fact that you added the tests so I
can just first apply the test patch and see that it breaks left and right
and then apply fixes and expect it now passes :)