git: 4aead44fa14f - stable/13 - md driver compat32: fix structure padding for arm, powerpc

From: Mike Karels <>
Date: Fri, 18 Aug 2023 12:40:13 UTC
The branch stable/13 has been updated by karels:


commit 4aead44fa14fd089b8e3eeb48c24c2c14aea8f93
Author:     Mike Karels <>
AuthorDate: 2023-08-08 14:09:03 +0000
Commit:     Mike Karels <>
CommitDate: 2023-08-18 12:39:55 +0000

    md driver compat32: fix structure padding for arm, powerpc
    Because the 32-bit md_ioctl structure contains 64-bit members, arm
    and powerpc add padding to a multiple of 8.  i386 doesn't do this.
    The md_ioctl32 definition was correct for amd64/i386 without padding,
    but wrong for arm64 and powerpc64.  Make __packed__ conditional on
    __amd64__, and test for the expected size on non-amd64.  Note that
    mdconfig is used in the ATF test suite.  Note, I verified the
    structure size for powerpc, but was unable to test.
    Reviewed by:    jrtc27
    Differential Revision:
    Discussed with: jhibbits
    (cherry picked from commit 58a46cfd751ac726ddca8544bf73a290b0154a57)
 sys/dev/md/md.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 52d64d6721cd..6878eb387fda 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -146,8 +146,16 @@ struct md_ioctl32 {
 	int		md_fwsectors;
 	uint32_t	md_label;
 	int		md_pad[MDNPAD];
-} __attribute__((__packed__));
+#ifdef __amd64__
+#ifndef __amd64__
+CTASSERT((sizeof(struct md_ioctl32)) == 440);
 CTASSERT((sizeof(struct md_ioctl32)) == 436);
 #define	MDIOCATTACH_32	_IOC_NEWTYPE(MDIOCATTACH, struct md_ioctl32)
 #define	MDIOCDETACH_32	_IOC_NEWTYPE(MDIOCDETACH, struct md_ioctl32)