Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fbe093ac authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab
Browse files

[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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 93125094
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -297,14 +297,14 @@ struct media_v2_entity {
	__u32 id;
	__u32 id;
	char name[64];		/* FIXME: move to a property? (RFC says so) */
	char name[64];		/* FIXME: move to a property? (RFC says so) */
	__u32 function;		/* Main function of the entity */
	__u32 function;		/* Main function of the entity */
	__u16 reserved[12];
	__u32 reserved[6];
};
} __attribute__ ((packed));


/* Should match the specific fields at media_intf_devnode */
/* Should match the specific fields at media_intf_devnode */
struct media_v2_intf_devnode {
struct media_v2_intf_devnode {
	__u32 major;
	__u32 major;
	__u32 minor;
	__u32 minor;
};
} __attribute__ ((packed));


struct media_v2_interface {
struct media_v2_interface {
	__u32 id;
	__u32 id;
@@ -316,22 +316,22 @@ struct media_v2_interface {
		struct media_v2_intf_devnode devnode;
		struct media_v2_intf_devnode devnode;
		__u32 raw[16];
		__u32 raw[16];
	};
	};
};
} __attribute__ ((packed));


struct media_v2_pad {
struct media_v2_pad {
	__u32 id;
	__u32 id;
	__u32 entity_id;
	__u32 entity_id;
	__u32 flags;
	__u32 flags;
	__u16 reserved[9];
	__u32 reserved[5];
};
} __attribute__ ((packed));


struct media_v2_link {
struct media_v2_link {
	__u32 id;
	__u32 id;
	__u32 source_id;
	__u32 source_id;
	__u32 sink_id;
	__u32 sink_id;
	__u32 flags;
	__u32 flags;
	__u32 reserved[5];
	__u32 reserved[6];
};
} __attribute__ ((packed));


struct media_v2_topology {
struct media_v2_topology {
	__u64 topology_version;
	__u64 topology_version;
@@ -351,7 +351,7 @@ struct media_v2_topology {
	__u32 num_links;
	__u32 num_links;
	__u32 reserved4;
	__u32 reserved4;
	__u64 ptr_links;
	__u64 ptr_links;
};
} __attribute__ ((packed));


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