https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490

Kees Cook <kees at outflux dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kees at outflux dot net

--- Comment #6 from Kees Cook <kees at outflux dot net> ---
Refreshed PoC, which is still emitting a bad warning.

// -std=gnu99  -O2 -Wstringop-overflow -fsanitize=kernel-address -c -o test.o
test.c
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;

struct _ieee80211_hdr {
        u8 addr1[6];
};
struct _haddr_pair {
        u8 h_dest[6];
};
struct _ath_dyn_txbuf {
        u16 t_rb;       // this member must be used for offset
        struct _haddr_pair addr[64];
};
struct _ath_dynack {
        struct _ath_dyn_txbuf st_rbf;
};
struct _ath_hw {
        int reg_ops;    // this member must be here
        struct _ath_dynack dynack;
};

void _ath_dynack_sample_tx_ts(struct _ath_hw *ah, struct _ieee80211_hdr *hdr)
{
        // this address-taking is required to trigger the warn
        struct _ath_dynack *da = &ah->dynack;
        struct _haddr_pair *addr;

// bounds checking doesn't change anything...
//      if (da->st_rbf.t_rb < sizeof(da->st_rbf.addr) + sizeof(u32) +
sizeof(u16)) {
                addr = &da->st_rbf.addr[da->st_rbf.t_rb];

                *(u32 *)addr->h_dest = *(const u32 *)hdr->addr1;

                // this does not warn:
                //u32 *dst = (u32 *)addr->h_dest;
                //const u32 *src = (const u32 *)hdr->addr1;
                //*dst = *src;
//      }
}

Reply via email to