[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <C10D3FB0CD45994C8A51FEC1227CE22F0E483AD918@shsmsx502.ccr.corp.intel.com>
Date: Thu, 12 Aug 2010 14:52:38 +0800
From: "Ma, Ling" <ling.ma@...el.com>
To: Namhyung Kim <namhyung@...il.com>
CC: "hpa@...or.com" <hpa@...or.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"mingo@...e.hu" <mingo@...e.hu>
Subject: RE: [PATCH V2] [X86] Fix potential issue on memmove
Thanks, I will fix it in next version.
> -----Original Message-----
> From: Namhyung Kim [mailto:namhyung@...il.com]
> Sent: Thursday, August 12, 2010 2:49 PM
> To: Ma, Ling
> Cc: hpa@...or.com; tglx@...utronix.de; linux-kernel@...r.kernel.org;
> mingo@...e.hu
> Subject: Re: [PATCH V2] [X86] Fix potential issue on memmove
>
> > --- a/arch/x86/lib/memcpy_32.c
> > +++ b/arch/x86/lib/memcpy_32.c
> > @@ -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"
> > - "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'.
>
> --
> Regards,
> Namhyung Kim
>
Powered by blists - more mailing lists