Fix potential issue on memmove
Quoted 22 lines
arch/x86/lib/memcpy_32.c +12
-3@@ -25,19 +25,35 @@ void *memmove(void *dest, const void *src, size_t n)int d0, d1, d2;if (dest < src) { -memcpy (dest, src, n); +if ((dest + n) < src) +return memcpy (dest, src, n); +else + __asm__ __volatile__( +"rep\n\t" +"movsb\n\t" + :"=&c" (d0),"=&S" (d1),"=&D" (d2) + :"0" (n), +"1" (src), +"2" (dest) + :"memory" ); + }else { - __asm__ __volatile__( - "std\n\t"
arch/x86/lib/memcpy_32.c void *memmove(void *dest, const void *src, size_t n) · line 42
Quoted 10 lines
arch/x86/lib/memcpy_32.c +2
-8-"rep\n\t" -"movsb\n\t" -"cld" - : "=&c" (d0), "=&S" (d1), "=&D" (d2) - :"0" (n), - "1" (n-1+src), - "2" (n-1+dest) - :"memory"); +if ((src + count) < dest) +return memcpy (dest, src, count);
'count' should be 'n'.
Signature · 2 lines
Regards, Namhyung Kim
Thanks, I will fix it in next version.
Quoted 44 lines
-----Original Message-----
From: Namhyung Kim [mailto:[email protected]]
Sent: Thursday, August 12, 2010 2:49 PM
To: Ma, Ling
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH V2] [X86] Fix potential issue on memmovearch/x86/lib/memcpy_32.c void *memmove(void *dest, const void *src, size_t
Quoted 3 lines
arch/x86/lib/memcpy_32.c +0
-0@@ -25,19 +25,35 @@ void *memmove(void *dest, const void *src, size_tn)
Quoted 19 lines
arch/x86/lib/memcpy_32.c +12
-3int d0, d1, d2;if (dest < src) { -memcpy (dest, src, n); +if ((dest + n) < src) +return memcpy (dest, src, n); +else + __asm__ __volatile__( +"rep\n\t" +"movsb\n\t" + :"=&c" (d0),"=&S" (d1),"=&D" (d2) + :"0" (n), +"1" (src), +"2" (dest) + :"memory" ); + }else { - __asm__ __volatile__( - "std\n\t"arch/x86/lib/memcpy_32.c void *memmove(void *dest, const void *src, size_t · line 42
Quoted 10 lines
arch/x86/lib/memcpy_32.c +2
-8-"rep\n\t" -"movsb\n\t" -"cld" - : "=&c" (d0), "=&S" (d1), "=&D" (d2) - :"0" (n), - "1" (n-1+src), - "2" (n-1+dest) - :"memory"); +if ((src + count) < dest) +return memcpy (dest, src, count);'count' should be 'n'.
Quoted 4 lines
--
Regards,
Namhyung Kim
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 1 line · Ling
Thanks, I will fix it in next version.
Also, please split this into two patches -- one for fixing memmove, and the other for re-enabling the alias avoidance in memcpy.
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Quoted 8 lines · H. Peter Anvin
Quoted 1 line · Ling
Thanks, I will fix it in next version.
Also, please split this into two patches -- one for fixing memmove, and the other for re-enabling the alias avoidance in memcpy.
-hpa
Nevermind, the patch doesn't actually contain the x86/mem patch.
It's rather confusing to put "re-active patch id a1e5278e40f16a4611264f8da9e557c16cb6f6ed" for a patch that was caught in testing rather than ever included; it doesn't even exist under that patch ID anymore.
-hpa