diff options
author | youzhongyang <[email protected]> | 2023-04-13 12:12:03 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2023-04-13 09:12:03 -0700 |
commit | 27a82cbb3ef2e30a54860b955fb257fb7f8307cd (patch) | |
tree | e93ab753d85e4194234335feb7c252c8e4d43ca8 | |
parent | c71fe716401f6919068f84b389dcd1b7ec2b8b0e (diff) |
Linux 6.3 compat: Fix memcpy "detected field-spanning write" error
Add a new union member of flexible array to dnode_phys_t and use
it in the macro so we can silence the memcpy() fortify error.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Youzhong Yang <[email protected]>
Closes #14737
-rw-r--r-- | include/sys/dnode.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/sys/dnode.h b/include/sys/dnode.h index 2d741ea36..dbe7350d4 100644 --- a/include/sys/dnode.h +++ b/include/sys/dnode.h @@ -120,7 +120,11 @@ extern "C" { #define DN_MAX_LEVELS (DIV_ROUND_UP(DN_MAX_OFFSET_SHIFT - SPA_MINBLOCKSHIFT, \ DN_MIN_INDBLKSHIFT - SPA_BLKPTRSHIFT) + 1) -#define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \ +/* + * Use the flexible array instead of the fixed length one dn_bonus + * to address memcpy/memmove fortify error + */ +#define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus_flexible + \ (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t)))) #define DN_MAX_BONUS_LEN(dnp) \ ((dnp->dn_flags & DNODE_FLAG_SPILL_BLKPTR) ? \ @@ -266,6 +270,10 @@ typedef struct dnode_phys { sizeof (blkptr_t)]; blkptr_t dn_spill; }; + struct { + blkptr_t __dn_ignore4; + uint8_t dn_bonus_flexible[]; + }; }; } dnode_phys_t; |