Nicolin Chen
7caf6c4bc2
iommufd: Fix struct iommu_hwpt_pgfault init and padding
commit e721f619e3 upstream.
The iommu_hwpt_pgfault is used to report IO page fault data to userspace,
but iommufd_fault_fops_read was never zeroing its padding. This leaks the
content of the kernel stack memory to userspace.
Also, the iommufd uAPI requires explicit padding and use of __aligned_u64
to ensure ABI compatibility's with 32 bit.
pahole result, before:
struct iommu_hwpt_pgfault {
__u32 flags; /* 0 4 */
__u32 dev_id; /* 4 4 */
__u32 pasid; /* 8 4 */
__u32 grpid; /* 12 4 */
__u32 perm; /* 16 4 */
/* XXX 4 bytes hole, try to pack */
__u64 addr; /* 24 8 */
__u32 length; /* 32 4 */
__u32 cookie; /* 36 4 */
/* size: 40, cachelines: 1, members: 8 */
/* sum members: 36, holes: 1, sum holes: 4 */
/* last cacheline: 40 bytes */
};
pahole result, after:
struct iommu_hwpt_pgfault {
__u32 flags; /* 0 4 */
__u32 dev_id; /* 4 4 */
__u32 pasid; /* 8 4 */
__u32 grpid; /* 12 4 */
__u32 perm; /* 16 4 */
__u32 __reserved; /* 20 4 */
__u64 addr __attribute__((__aligned__(8))); /* 24 8 */
__u32 length; /* 32 4 */
__u32 cookie; /* 36 4 */
/* size: 40, cachelines: 1, members: 9 */
/* forced alignments: 1 */
/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));
Fixes: c714f15860 ("iommufd: Add fault and response message definitions")
Link: https://patch.msgid.link/r/20250120195051.2450-1-nicolinc@nvidia.com
Cc: stable@vger.kernel.org
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-02-17 10:05:31 +01:00
..
2024-07-31 13:56:00 +02:00
2024-09-26 17:14:35 +02:00
2025-02-17 10:05:04 +01:00
2024-09-11 11:23:56 +02:00
2024-07-29 01:19:51 +01:00
2024-08-22 17:25:59 +08:00
2024-08-20 14:02:22 -04:00
2024-08-30 08:22:36 +02:00
2024-08-28 06:53:58 -07:00
2024-09-11 10:45:28 -06:00
2024-10-24 10:17:12 -07:00
2024-08-08 15:23:21 +02:00
2024-08-28 06:53:58 -07:00
2024-08-26 19:21:14 -07:00
2024-09-17 14:46:17 +02:00
2024-08-26 09:33:58 -07:00
2024-08-23 13:04:34 +01:00
2024-09-18 07:40:56 +09:00
2024-08-28 16:53:57 +02:00
2024-12-14 20:03:48 +01:00
2024-09-05 11:39:17 +02:00
2024-09-13 21:15:44 -07:00
2024-07-21 17:15:46 -07:00
2024-09-04 16:51:11 +02:00
2024-08-29 10:39:37 +02:00
2024-12-09 10:40:56 +01:00
2024-08-26 09:37:22 -07:00
2024-07-25 11:57:27 +02:00
2024-09-04 16:40:33 -07:00
2024-08-26 09:37:23 -07:00
2024-08-26 09:37:23 -07:00
2025-02-17 10:04:55 +01:00
2024-09-14 08:51:15 -06:00
2024-08-22 10:45:12 +02:00
2025-02-17 10:05:31 +01:00
2024-09-01 20:26:05 -07:00
2024-09-06 17:55:05 -04:00
2024-07-16 09:53:05 -04:00
2024-09-16 23:50:52 +02:00
2024-09-12 20:28:46 -07:00
2024-08-19 22:36:26 -04:00
2024-09-11 20:53:43 -07:00
2024-07-19 20:22:12 +02:00
2024-09-06 08:31:40 -06:00
2024-09-10 16:55:23 -07:00
2024-09-11 20:44:32 -07:00
2024-08-12 17:50:34 -07:00
2024-09-16 11:15:26 +02:00
2024-09-19 14:25:26 -05:00
2024-08-14 20:37:47 -07:00
2024-08-14 13:05:42 -04:00
2024-09-08 18:40:33 +01:00
2024-07-19 20:22:48 +02:00
2024-08-14 16:42:58 +03:00
2024-12-05 14:01:53 +01:00
2024-09-05 20:11:43 +02:00
2024-07-16 11:44:00 -04:00
2024-08-20 11:38:23 +02:00
2025-01-02 10:34:16 +01:00
2024-10-16 08:08:18 -06:00
2024-09-11 20:44:32 -07:00
2024-08-22 16:56:24 -07:00
2024-09-10 02:51:48 -04:00
2024-09-05 20:10:34 +02:00
2024-09-10 02:51:48 -04:00
2024-07-24 20:49:42 +03:00
2025-02-08 09:58:00 +01:00