Skip to content

Commit fbe093a

Browse files
Sakari Ailusmchehab
authored andcommitted
[media] media: Sanitise the reserved fields of the G_TOPOLOGY IOCTL arguments
The argument structs are used in arrays for G_TOPOLOGY IOCTL. The arguments themselves do not need to be aligned to a power of two, but aligning them up to the largest basic type alignment (u64) on common ABIs is a good thing to do. The patch changes the size of the reserved fields to 5 or 6 u32's and aligns the size of the struct to 8 bytes so we do no longer depend on the compiler to perform the alignment. While at it, add __attribute__ ((packed)) to these structs as well. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
1 parent 9312509 commit fbe093a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

include/uapi/linux/media.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,14 @@ struct media_v2_entity {
297297
__u32 id;
298298
char name[64]; /* FIXME: move to a property? (RFC says so) */
299299
__u32 function; /* Main function of the entity */
300-
__u16 reserved[12];
301-
};
300+
__u32 reserved[6];
301+
} __attribute__ ((packed));
302302

303303
/* Should match the specific fields at media_intf_devnode */
304304
struct media_v2_intf_devnode {
305305
__u32 major;
306306
__u32 minor;
307-
};
307+
} __attribute__ ((packed));
308308

309309
struct media_v2_interface {
310310
__u32 id;
@@ -316,22 +316,22 @@ struct media_v2_interface {
316316
struct media_v2_intf_devnode devnode;
317317
__u32 raw[16];
318318
};
319-
};
319+
} __attribute__ ((packed));
320320

321321
struct media_v2_pad {
322322
__u32 id;
323323
__u32 entity_id;
324324
__u32 flags;
325-
__u16 reserved[9];
326-
};
325+
__u32 reserved[5];
326+
} __attribute__ ((packed));
327327

328328
struct media_v2_link {
329329
__u32 id;
330330
__u32 source_id;
331331
__u32 sink_id;
332332
__u32 flags;
333-
__u32 reserved[5];
334-
};
333+
__u32 reserved[6];
334+
} __attribute__ ((packed));
335335

336336
struct media_v2_topology {
337337
__u64 topology_version;
@@ -351,7 +351,7 @@ struct media_v2_topology {
351351
__u32 num_links;
352352
__u32 reserved4;
353353
__u64 ptr_links;
354-
};
354+
} __attribute__ ((packed));
355355

356356
static inline void __user *media_get_uptr(__u64 arg)
357357
{

0 commit comments

Comments
 (0)