linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [uml-devel] [patch 2/6] uml: critical change memcpy to memmove [critical, for 2.6.12]
@ 2005-05-09 22:45 blaisorblade
  0 siblings, 0 replies; only message in thread
From: blaisorblade @ 2005-05-09 22:45 UTC (permalink / raw)
  To: akpm; +Cc: jdike, linux-kernel, user-mode-linux-devel, blaisorblade


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

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 linux-2.6.12-paolo/arch/um/kernel/irq_user.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff -puN arch/um/kernel/irq_user.c~uml-critical-change-memcpy-to-memmove arch/um/kernel/irq_user.c
--- linux-2.6.12/arch/um/kernel/irq_user.c~uml-critical-change-memcpy-to-memmove	2005-05-02 17:54:20.000000000 +0200
+++ linux-2.6.12-paolo/arch/um/kernel/irq_user.c	2005-05-02 17:54:20.000000000 +0200
@@ -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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-05-09 23:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-09 22:45 [uml-devel] [patch 2/6] uml: critical change memcpy to memmove [critical, for 2.6.12] blaisorblade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).