lkml.org 
[lkml]   [2006]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: strncpy (maybe others) broken on Alpha
On Fri, Apr 21, 2006 at 02:37:59PM -0500, Bob Tracy wrote:
> WITHOUT the patch, and everything else the same, gcc-4.0 and gcc-4.1
> appear to work, but the gcc-3.3 build produces the bad behavior we've
> been seeing.

Actually the bug doesn't show up with gcc-4 *only* because it tends
to pack the data more tightly, so that both src[] and dest[] have different
alignment vs. gcc-3 compiled foo.c:
src 0x11ffff8f4, dest 0x11ffff926 - gcc-4
src 0x11ffff8c0, dest 0x11ffff900 - gcc-3

If you add __attribute__((aligned(8))) to both src and dest declarations
in Mathieu's foo.c, you'll see the bug is still here.

> Pending a knowledgable peer review of Ivan's patch (no insult intended:
> I'm not qualified), I'd say we're close to putting this to rest. If it
> turns out the patch is the correct fix, I'm genuinely concerned about
> how long this bug went undetected :-(. The modification date of
> arch/alpha/lib/strncpy.S is 28 Jul 2003 in my tree. The stxncpy.S file
> is not quite a year newer: 10 May 2004.

Well, these things happen. I think it's not quite surprising.
First, the kernel is not overloaded with strncpy calls. ;-)
Second, strncpy was mostly used in drivers that are rarely (if at all)
used on alpha.
Third, to discover this bug you need some special combination of source
and destination alignment, source string length and byte count.

Ivan.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-04-21 23:14    [W:1.543 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site