Re: compat_sys_times() bogus until jiffies >= 0.

From: David Miller
Date: Thu Nov 08 2007 - 02:14:51 EST


From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 7 Nov 2007 23:09:16 -0800

> I don't think that's a big problem? This syscall can (oddly) return any
> 32-bit (64-bit) number and a smart application developer (after saying wtf)
> would realise that he just can't check for errors and have correctly
> working code.
>
> Then again, if he was smart he just wouldn't use times(2)'s return value
> for anything. But what is the alternative? I don't think there is one,
> apart from much saner things like gettimeofday().

You and I would say "wtf", but the manual states what it does:

On error, (clock_t) -1 is returned, and errno is set appro-
priately.

And I think this (obviously bogus) convention is something we
are really stuck with.

Another awful aspect of this is that glibc is going to overwrite
'errno' for this return value range. That will likely cause more
application misbehavior than some of the other side effects we've been
discussing.

In short we have two problems:

1) glibc thinks -4096 < x < 0 is an error, and will write this
value into errno and return -1 to the application

2) the manual states that -1 means error

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