Skip to contentSkip to conversation

fix syscallN() macro errno value checking for i386

PATCH In review [email protected] 4 participants 5 messages Jan 29, 2005 – Mar 8, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix syscallN() macro errno value checking for i386

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Cc: David Howells <[email protected]>

The errno values which are visible for userspace are actually in the range -1 - -129, not until -128 (): this value was added:

#define EKEYREJECTED 129 /* Key was rejected by service */

And this would break ucLibc (for what I heard).

This is just a quick-fix, because putting a macro inside errno.h instead of having it copied in two places would be probably nicer.

However, I've heard by D. Howells it wasn't accepted, so this is the solution for now.

---

 linux-2.6.11-paolo/include/asm-i386/unistd.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
include/asm-i386/unistd.h renamed from include/asm-i386/unistd.h~fix-syscall-macro +3 -3
diff -puN include/asm-i386/unistd.h~fix-syscall-macro include/asm-i386/unistd.h
@@ -298,12 +298,12 @@
 #define NR_syscalls 289
 
 /*
- * user-visible error numbers are in the range -1 - -128: see
- * <asm-i386/errno.h>
+ * user-visible error numbers are in the range -1 - -129: see
+ * <asm-i386/errno.h> (currently it includes <asm-generic/errno.h>)
  */
 #define __syscall_return(type, res) \
 do { \
-	if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \
+	if ((unsigned long)(res) >= (unsigned long)(-(129 + 1))) { \
 		errno = -(res); \
 		res = -1; \
 	} \

_

#1 lore raw
Quoted 7 lines · On Sünnavend 29 Januar 2005 02:01, [email protected] wrote:

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Cc: David Howells <[email protected]>

The errno values which are visible for userspace are actually in the range -1 - -129, not until -128 (): this value was added:

Quoted 6 lines

#define EKEYREJECTED 129 /* Key was rejected by service */

And this would break ucLibc (for what I heard).

This is just a quick-fix, because putting a macro inside errno.h instead of having it copied in two places would be probably nicer.

Yes. Note that your patch only fixes the bug on i386. The code has been copied to many other architectures, and some of them have been updated less recently and are checking for values lower than 128. There should really be a way to keep them all in sync.

	Arnd <><
#2 lore raw
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · On Sünnavend 29 Januar 2005 02:01, [email protected] wrote:

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Cc: David Howells <[email protected]>

The errno values which are visible for userspace are actually in the range -1 - -129, not until -128 (): this value was added:

#define EKEYREJECTED 129 /* Key was rejected by service */

And this would break ucLibc (for what I heard).

Quoted 7 lines
Quoted 2 lines

This is just a quick-fix, because putting a macro inside errno.h instead of having it copied in two places would be probably nicer.

Yes. Note that your patch only fixes the bug on i386. The code has been copied to many other architectures, and some of them have been updated less recently and are checking for values lower than 128. There should really be a way to keep them all in sync.

what about something along?

#define EKEYNEXT 130 /* key counter */

and

if ((unsigned long)(res) >= (unsigned long)(-EKEYNEXT)) {

JL

#3 lore raw
Followup to:  <[email protected]>
By author:    jerome lacoste <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 9 lines

what about something along?

#define EKEYNEXT 130 /* key counter */

and

if ((unsigned long)(res) >= (unsigned long)(-EKEYNEXT)) {

What you really need is EMAX.

-hpa

#4 lore raw
In reply to jerome lacoste
Quoted 20 lines · jerome lacoste
Quoted 11 lines · Arnd Bergmann
Quoted 10 lines · On Sünnavend 29 Januar 2005 02:01, [email protected] wrote:

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Cc: David Howells <[email protected]>

The errno values which are visible for userspace are actually in the range -1 - -129, not until -128 (): this value was added:

#define EKEYREJECTED 129 /* Key was rejected by service */

And this would break ucLibc (for what I heard).

Quoted 7 lines
Quoted 2 lines

This is just a quick-fix, because putting a macro inside errno.h instead of having it copied in two places would be probably nicer.

Yes. Note that your patch only fixes the bug on i386. The code has been copied to many other architectures, and some of them have been updated less recently and are checking for values lower than 128. There should really be a way to keep them all in sync.

Quoted 7 lines

what about something along?

#define EKEYNEXT 130 /* key counter */

and

if ((unsigned long)(res) >= (unsigned long)(-EKEYNEXT)) {

Yes, I agree with you... I didn't do it that way because of this mail:

"Subject: Re: Fw: Re: [patch 02/11] uml: fix compilation for missing headers
From: David Howells <[email protected]>
To: Andrew Morton <[email protected]>
CC: [email protected]
Date: Fri Jan 14 12:19:33 2005
[....]

Quoted 1 line

I think that the max errno value should become a macro defined in errno.h.

I agree with him on this, but I seem to remember that this didn't go down very well.

David"

Now, I don't know why it was not done that way, but I wanted to do a quick-fix to merge it. Somebody please fix it definitively... in 2.6.11 official this is still unfixed.

Signature · 3 lines
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade