Ubuntu 24.04 kernel module compile warning "call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]"

My kernel module works properly on Ubuntu 22.04 and earlier version, but report the compile warning on Ubuntu 24.04. I simplified the issue as below demo:

#include <linux/module.h>        /* Needed by all modules */
#include <linux/kernel.h>        /* Needed for KERN_INFO */
#include <linux/init.h>  /* Needed for the macros */

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jack");
MODULE_DESCRIPTION("A simple Hello world");

typedef struct {
    uint32_t a;
    uint32_t b;
    uint8_t data[0];
} demo_t;

static int __init hello_start(void)
{
        demo_t *demo = NULL;
        uint32_t *ptr = NULL;

        demo = kmalloc(1024, GFP_KERNEL);
        if(!demo) { return -1;}

        demo->a = 0xaaaaaaaa;
        demo->b = 0xbbbbbbbb;
        ptr = (uint32_t *)demo->data;
        *ptr = 0xcccccccc;
        ptr = (uint32_t *)(demo->data + 4);
        memset(ptr, 0xdd, 128);
        // other operations ...
        kfree(demo);
        return 0;
}

static void __exit hello_end(void)
{
        printk(KERN_INFO "Goodbye Mr.\n");
}

module_init(hello_start);
module_exit(hello_end);

The image below is the detail compile information:

Use __aligned() alignment if needed, but it depends on the types and their size.

I tried __aligned(1), __aligned(2), __aligned(4), but the compiling warning still exist.

typedef struct {
    uint32_t a;
    uint32_t b;
    uint8_t data[0];
} demo_t __attribute__ ((aligned (1)));

I also tried pragma pack with 1, 2 and 4 bytes, but still no help for the warning

#pragma pack(push, 1)
typedef struct {
    uint32_t a;
    uint32_t b;
    uint8_t data[0];
} demo_t;
#pragma pack(pop)