public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* execve exit status on MIPS
@ 2008-09-18  4:33 Halesh S
  2008-09-18  4:55 ` David Newall
  0 siblings, 1 reply; 3+ messages in thread
From: Halesh S @ 2008-09-18  4:33 UTC (permalink / raw)
  To: linux-kernel


Hi all,

Please find the below testcase..

#include <stdio.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>

#define EXE_NAME "./exe"

char e2BIG[ARG_MAX+1][10];
char *envList[]={NULL};

int main(void)
{
  int ret,ind;

  for(ind = 0; ind < ARG_MAX+1; ind++)
    strcpy(e2BIG[ind], "helloworld");

  if ((ret = chmod(EXE_NAME,0744)) != 0){
    printf("chmod failed\n");
    exit(1);
  }

  /* whne arg list is too long */
  if ((ret = execve(EXE_NAME,e2BIG,envList)) == -1) {
    if ( errno == E2BIG)
      printf("Test Pass\n");
    else
      printf("Test Fail : Got Errno %d\n", errno);
    exit(0);
  }
  else
    printf("execve worked out of limit\n");
  exit(1);
}


On MIPS E2BIG is not getting set as errno instead EFAULT is set, while on 
other archs like ARM, PowerPC and i686 I am able to get E2BIG.

Please let me know about the issue...

Let EXE_NAME be any executable....

Thanks,
Halesh


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: execve exit status on MIPS
  2008-09-18  4:33 execve exit status on MIPS Halesh S
@ 2008-09-18  4:55 ` David Newall
  2008-09-18  5:34   ` execve errno setting " Halesh S
  0 siblings, 1 reply; 3+ messages in thread
From: David Newall @ 2008-09-18  4:55 UTC (permalink / raw)
  To: Halesh S; +Cc: linux-kernel

Halesh S wrote:
> char e2BIG[ARG_MAX+1][10];
> ...
>   for(ind = 0; ind < ARG_MAX+1; ind++)
>     strcpy(e2BIG[ind], "helloworld");
>   

Did you intend to overflow e2BIG?  You're copying 11 bytes (including
terminating NUL) into a 10 byte array.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: execve errno setting on MIPS
  2008-09-18  4:55 ` David Newall
@ 2008-09-18  5:34   ` Halesh S
  0 siblings, 0 replies; 3+ messages in thread
From: Halesh S @ 2008-09-18  5:34 UTC (permalink / raw)
  To: linux-kernel


I will change the Subject line "execve exit status on MIPS" first.


David Newall <davidn <at> davidnewall.com> writes:
> 
> Halesh S wrote:
> > char e2BIG[ARG_MAX+1][10];
> > ...
> >   for(ind = 0; ind < ARG_MAX+1; ind++)
> >     strcpy(e2BIG[ind], "helloworld");
> >   
> 
> Did you intend to overflow e2BIG?  You're copying 11 bytes (including
> terminating NUL) into a 10 byte array.
> 

My intenstion is not to overflow in string...
We can change
> >     strcpy(e2BIG[ind], "helloworld");
to
     strcpy(e2BIG[ind], "helloworl");

But intenstion is to generate E2BIG in
  if ((ret = execve(EXE_NAME,e2BIG,envList)) == -1) {

where e2BIG array has more number arguments than ARG_MAX.

Which was possible on ARM,PPC and i386....

For the same code...I got 14 EFAULT....


Thanks,
Halesh









^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-18  5:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18  4:33 execve exit status on MIPS Halesh S
2008-09-18  4:55 ` David Newall
2008-09-18  5:34   ` execve errno setting " Halesh S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox