Skip to contentSkip to conversation

udevadm: update prev properly

PATCH Applied Kei Tokunaga 2 participants 2 messages Feb 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udevadm: update prev properly

Hi,

When I tried to boot a system with 256 disks x 4 paths with device-mapper, udevadm trigger (--typeÞvices) that was called from start_udev ended up dumping a core due to a segmentation fault.

In udev_enumerate_get_list_entry(), if it finds the devices that should be delayed, it calls syspath_add(). If realloc() in syspath_add() allocates the required memory at a different memory address, referring prev->len afterward causes the segmentation fault. I think something like this patch may be needed.

---

 udev-166-kei/libudev/libudev-enumerate.c |    3 +++
 1 file changed, 3 insertions(+)
libudev/libudev-enumerate.c renamed from libudev/libudev-enumerate.c~fix-prev-segfault +3 -0
diff -puN libudev/libudev-enumerate.c~fix-prev-segfault libudev/libudev-enumerate.c
@@ -274,6 +274,9 @@ struct udev_list_entry *udev_enumerate_g
 			/* skip to be delayed devices, and add them to the end of the list */
 			if (devices_delay_end(udev_enumerate->udev, entry->syspath)) {
 				syspath_add(udev_enumerate, entry->syspath);
+				/* need to update prev here for the case realloc() gives
+				   a different address */
+				prev = &udev_enumerate->devices[i];
 				continue;
 			}
 

_

Applied
#1 lore raw
Quoted 10 lines · Kei Tokunaga

When I tried to boot a system with 256 disks x 4 paths with device-mapper, udevadm trigger (--typeÞvices) that was called from start_udev ended up dumping a core due to a segmentation fault.

In udev_enumerate_get_list_entry(), if it finds the devices that should be delayed, it calls syspath_add().  If realloc() in syspath_add() allocates the required memory at a different memory address, referring prev->len afterward causes the segmentation fault.  I think something like this patch may be needed.

Applied.

Thanks,
Kay