All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]SPARC32: Fixed unaligned memory copying in function
@ 2011-05-08  9:05 kirill
  2011-05-08 23:44 ` David Miller
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: kirill @ 2011-05-08  9:05 UTC (permalink / raw)
  To: sparclinux

When we are in the label cc_dword_align, registers %o0 and %o1 have the
same last 2 bits, but it's not guaranteed any one of them is zero. So we
can get unaligned memory access in label ccte. Example of parameters
which lead to this: %o0=0x7ff183e9, %o1=0x8e709e7d, %g1=3

With the parameters I had a memory corruption, when the additional 5
bytes were rewritten. This patch corrects the error.

One comment to patch. We don't care about the third bit in %o1, because
cc_end_cruft stores word or less.

Signed-off-by: Tkhai Kirill <tkhai@yandex.ru>
---

--- linux-2.6.38.5/arch/sparc/lib/checksum_32.S.orig	2011-05-06
22:54:25.000000000 +0400
+++ linux-2.6.38.5/arch/sparc/lib/checksum_32.S	2011-05-08
11:43:35.000000000 +0400
@@ -289,10 +289,16 @@ cc_end_cruft:
 
 	/* Also, handle the alignment code out of band. */
 cc_dword_align:
-	cmp	%g1, 6
-	bl,a	ccte
+	cmp	%g1, 16
+	bge,a	1f
+	 srl	%g1, 1, %o3
+2:	cmp	%o3, 0
+	be,a	ccte
 	 andcc	%g1, 0xf, %o3
-	andcc	%o0, 0x1, %g0
+	andcc	%o3, %o0, %g0	! Check %o0 only (%o1 has the same last 2 bits)
+	be,a	2b
+	 srl	%o3, 1, %o3
+1:	andcc	%o0, 0x1, %g0
 	bne	ccslow
 	 andcc	%o0, 0x2, %g0
 	be	1f



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-05-12  4:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-08  9:05 [PATCH]SPARC32: Fixed unaligned memory copying in function kirill
2011-05-08 23:44 ` David Miller
2011-05-09  8:49 ` [PATCH]SPARC32: Fixed unaligned memory copying in function __csum_partial_copy_sparc_generic Tkhai Kirill
2011-05-09 18:33 ` [PATCH]SPARC32: Fixed unaligned memory copying in function David Miller
2011-05-09 19:55 ` [PATCH]SPARC32: Fixed unaligned memory copying in function __csum_partial_copy_sparc_generic Tkhai Kirill
2011-05-10 12:31 ` Tkhai Kirill
2011-05-10 20:28 ` [PATCH]SPARC32: Fixed unaligned memory copying in function David Miller
2011-05-10 23:21 ` [PATCH]SPARC32: Fixed unaligned memory copying in function __csum_partial_copy_sparc_generic Tkhai Kirill
2011-05-11 12:53 ` Daniel Hellstrom
2011-05-11 17:10 ` [PATCH]SPARC32: Fixed unaligned memory copying in function David Miller
2011-05-12  4:38 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.