Skip to contentSkip to conversation

media: info leak in __media_device_enum_links()

PATCH In review Dan Carpenter 2 participants 3 messages Apr 13, 2013 – Jun 10, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: info leak in __media_device_enum_links()

These structs have holes and reserved struct members which aren't cleared. I've added a memset() so we don't leak stack information.

drivers/media/media-device.c +3 -0
index 99b80b6..450c0d1 100644
@@ -139,6 +139,8 @@ static long __media_device_enum_links(struct media_device *mdev,
 
 		for (p = 0; p < entity->num_pads; p++) {
 			struct media_pad_desc pad;
+
+			memset(&pad, 0, sizeof(pad));
 			media_device_kpad_to_upad(&entity->pads[p], &pad);
 			if (copy_to_user(&links->pads[p], &pad, sizeof(pad)))
 				return -EFAULT;
@@ -156,6 +158,7 @@ static long __media_device_enum_links(struct media_device *mdev,
 			if (entity->links[l].source->entity != entity)
 				continue;
 
+			memset(&link, 0, sizeof(link));
 			media_device_kpad_to_upad(entity->links[l].source,
 						  &link.source);
 			media_device_kpad_to_upad(entity->links[l].sink,
#1 lore raw

Ping?

regards,
dan carpenter

Quoted 26 lines · Dan Carpenter

These structs have holes and reserved struct members which aren't cleared. I've added a memset() so we don't leak stack information.

drivers/media/media-device.c +3 -0
index 99b80b6..450c0d1 100644
@@ -139,6 +139,8 @@ static long __media_device_enum_links(struct media_device *mdev,
 
 		for (p = 0; p < entity->num_pads; p++) {
 			struct media_pad_desc pad;
+
+			memset(&pad, 0, sizeof(pad));
 			media_device_kpad_to_upad(&entity->pads[p], &pad);
 			if (copy_to_user(&links->pads[p], &pad, sizeof(pad)))
 				return -EFAULT;
@@ -156,6 +158,7 @@ static long __media_device_enum_links(struct media_device *mdev,
 			if (entity->links[l].source->entity != entity)
 				continue;
 
+			memset(&link, 0, sizeof(link));
 			media_device_kpad_to_upad(entity->links[l].source,
 						  &link.source);
 			media_device_kpad_to_upad(entity->links[l].sink,
#2 lore raw

Hi Dan,

Quoted 1 line · On Friday 31 May 2013 15:24:45 Dan Carpenter wrote:

Ping?

Oops, sorry for having missed the patch.

Quoted 5 lines · Dan Carpenter
Quoted 4 lines

These structs have holes and reserved struct members which aren't cleared. I've added a memset() so we don't leak stack information.

I've taken the patch in my tree, Added a "CC: [email protected]" and issued a pull request.

Quoted 31 lines
Quoted 31 lines
drivers/media/media-device.c +0 -0
index 99b80b6..450c0d1 100644
@@ -139,6 +139,8 @@ static long __media_device_enum_links(struct

media_device *mdev,>

drivers/media/media-device.c +2 -0
 		for (p = 0; p < entity->num_pads; p++) {
 
 			struct media_pad_desc pad;
 
+
+			memset(&pad, 0, sizeof(pad));
 
 			media_device_kpad_to_upad(&entity->pads[p], &pad);
 			if (copy_to_user(&links->pads[p], &pad, sizeof(pad)))
 
 				return -EFAULT;
@@ -156,6 +158,7 @@ static long __media_device_enum_links(struct

media_device *mdev,>

drivers/media/media-device.c +1 -0
 			if (entity->links[l].source->entity != entity)
 
 				continue;
 
+			memset(&link, 0, sizeof(link));
 
 			media_device_kpad_to_upad(entity->links[l].source,
 
 						  &link.source);
 
 			media_device_kpad_to_upad(entity->links[l].sink,
Signature · 3 lines
Regards,

Laurent Pinchart