Skip to contentSkip to conversation

uml: critical change memcpy to memmove [critical, for 2.6.12]

PATCH In review [email protected] 1 participant 1 message May 9, 2005 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

PATCH 2/6 uml: critical change memcpy to memmove [critical, for 2.6.12]

Replace one memcpy() call with overlapping source and dest arguments with one call to memmove(), to avoid data corruption.

---

 linux-2.6.12-paolo/arch/um/kernel/irq_user.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
arch/um/kernel/irq_user.c renamed from arch/um/kernel/irq_user.c~uml-critical-change-memcpy-to-memmove +8 -2
diff -puN arch/um/kernel/irq_user.c~uml-critical-change-memcpy-to-memmove arch/um/kernel/irq_user.c
@@ -236,9 +236,15 @@ static void free_irq_by_cb(int (*test)(s
 				       (*prev)->fd, pollfds[i].fd);
 				goto out;
 			}
-			memcpy(&pollfds[i], &pollfds[i + 1],
-			       (pollfds_num - i - 1) * sizeof(pollfds[0]));
+
 			pollfds_num--;
+
+			/* This moves the *whole* array after pollfds[i] (though
+			 * it doesn't spot as such)! */
+
+			memmove(&pollfds[i], &pollfds[i + 1],
+			       (pollfds_num - i) * sizeof(pollfds[0]));
+
 			if(last_irq_ptr == &old_fd->next) 
 				last_irq_ptr = prev;
 			*prev = (*prev)->next;

_

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel