From: Linus Torvalds <torvalds@linux-foundation.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, Michael Buesch <mb@bu3sch.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] strcmp: fix overflow error
Date: Tue, 17 Nov 2009 11:12:26 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.01.0911171105350.9384@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.01.0911171102210.9384@localhost.localdomain>
On Tue, 17 Nov 2009, Linus Torvalds wrote:
>
> Yeah, I looked at the history too. It's so old that it might well be me.
In fact, it goes back to at least 1.2.13.
And the copyright dates do imply that they could go back way further.
At least the comment says it all:
"These are buggy as well.."
so I can at least claim that back in the _original_ 0.01 release, it was
correct:
extern inline int strcmp(const char * cs,const char * ct)
{
register int __res __asm__("ax");
__asm__("cld\n"
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tmovl $1,%%eax\n\t"
"jl 3f\n\t"
"negl %%eax\n"
"3:"
:"=a" (__res):"D" (cs),"S" (ct):"si","di");
return __res;
}
and as far as I can tell, the above is actually correct, even if you have
to be a bit crazy to write 'strcmp' as gcc inline asm (hey, I wrote _all_
the string routines that way, and I made gcc do some of them built-in.
Because I was a MAN, dammit!).
So the bug was apparently introduced when we went portable.
Linus
next prev parent reply other threads:[~2009-11-17 19:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 16:51 Uwe Kleine-König
2009-11-17 17:36 ` Andreas Schwab
2009-11-17 17:41 ` Linus Torvalds
2009-11-17 18:16 ` Michael Buesch
2009-11-17 18:40 ` Linus Torvalds
2009-11-17 20:34 ` Andreas Schwab
2009-11-17 18:55 ` Uwe Kleine-König
2009-11-17 19:02 ` Linus Torvalds
2009-11-17 19:12 ` Linus Torvalds [this message]
2009-11-17 19:19 ` Joe Perches
2009-11-18 21:31 ` [PATCH] strcmp: fix overflow and possibly signedness error Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.01.0911171105350.9384@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@bu3sch.de \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®