Re: changes in i386 and x86_64 assembrer

"Markus Wichmann" <[email protected]> Wed, 5 Jan 2011 13:38:43 +0100 (CET)
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
Bela Lubkin schrieb:
> Two notes on what Nikola Vladov wrote.  Neither of these are actually
> about Nikola's change, they are other details I noticed while looking at
> the change: one bug and one tiny code shrink.
>
> 1: wrong errno threshold:
>
>> +.global __error_unified_syscall
>> +__error_unified_syscall:
>> 	cmp	$-124,%eax
>> 	jb	.Lnoerror
>
> This errno threshold is wrong.  Current Linux "normal" errnos go up to
> 132 (ERFKILL).
>

According to the platform ABI, we might as well do it right from the start:

http://www.x86-64.org/documentation/abi.pdf, A.2.1p5:
"Returning from the syscall, register %rax contains the result of the
system-call. A value in the range between -4095 and -1 indicates an error,
it is -errno."

Now, the ABI defines return values of system calls to be 64 bit in length,
so comparing only EAX instead RAX for the one byte size difference might
result in a bug, possibly even a security hazard.

> There are also a population of errors at 521..530, defined in kernel
> source: include/linux/errno.h.  These are inside `#ifdef __KERNEL__' and
> commented "These should never be seen by user programs"; but they do
> leak into user space.
>

Such leakage should result in a bug report.

Markus
-- 
Progress (n.): Process through which USENET evolved from smart people in
front of dumb terminals to dumb people in front of smart terminals.