[RFC 1/1] Fix varargs in prctl syscall

Hans-Christian Egtvedt hans-christian.egtvedt at atmel.com
Mon Jul 27 11:31:46 UTC 2009


On Mon, 27 Jul 2009 02:46:45 -0400
Mike Frysinger <vapier at gentoo.org> wrote:

> On Monday 27 July 2009 02:19:37 Hans-Christian Egtvedt wrote:
> > On Mon, 20 Jul 2009 08:50:25 -0400 Mike Frysinger wrote:
> > > On Friday 12 September 2008 09:34:14 Hans-Christian Egtvedt wrote:
> > > > This patch properly handles the variodic argument
> > > > before the syscall is passed to the kernel.
> > >
> > > i dont see why this is needed ?  are you seeing an actual bug or
> > > you just noticed it and thought you'd fix it ?
> >
> > Yes, on AVR32 you must properly handle variadic arguments, as the
> > arguments are passed on the stack.
> 
> the location of the arguments (stack/register) really doesnt matter
> by themselves, only in relation to the normal function calling
> convention.
> 
> i'm guessing what you mean to say is that the people who implemented
> the avr32 ABI made a stupid decision and decided to not have variadic
> arguments follow the normal function calling convention.
> 

Indeed, the programmer needs to handle varargs for varargs to work ;)

> > > afaict, there is nothing wrong here.  variodic function calls have
> > > the same calling convention as non-variodic function calls.
> > > presumably the kernel isnt going to check arg2 unless the option
> > > is appropriate, and passing along a non- zero value shouldnt be a
> > > problem anyways.
> >
> > Well, works by accident for most architectures, but when using
> > variadic arguments you must grab the arguments passed to the
> > function appropriately.
> 
> if the majority of arches are doing the sane thing, then the odd
> balls should not force them to suffer.  in other words, the bloat
> here is not OK.  instead, add a new "__UCLIBC_VARARGS_REQUIRED__" or
> something to uClibc_arch_features.h and you can key off of that.
> 

Sounds fair to me. But it still works by accident for the other
architectures.

> also, the method for calling syscalls has changed and your code is
> still using the old method.  the return should read:
> 	return INLINE_SYSCALL(prctl, 5, option, arg2, 0, 0, 0);
> 

Okay, the patch is quite old, so that is expected.

-- 
Best regards,
Hans-Christian Egtvedt


More information about the uClibc mailing list