Linux MIPS Architecture development
 help / color / mirror / Atom feed
* execve errno setting on MIPS
@ 2008-09-18 11:39 Sadashiiv, Halesh
  2008-09-18 11:39 ` Sadashiiv, Halesh
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sadashiiv, Halesh @ 2008-09-18 11:39 UTC (permalink / raw)
  To: linux-mips

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

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], "helloword");
 
  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

 



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 9668 bytes --]

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

* execve errno setting on MIPS
  2008-09-18 11:39 execve errno setting on MIPS Sadashiiv, Halesh
@ 2008-09-18 11:39 ` Sadashiiv, Halesh
  2008-09-18 21:16 ` Ralf Baechle
  2008-09-18 21:25 ` Thomas Bogendoerfer
  2 siblings, 0 replies; 9+ messages in thread
From: Sadashiiv, Halesh @ 2008-09-18 11:39 UTC (permalink / raw)
  To: linux-mips

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

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], "helloword");
 
  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

 



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 9668 bytes --]

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

* Re: execve errno setting on MIPS
  2008-09-18 11:39 execve errno setting on MIPS Sadashiiv, Halesh
  2008-09-18 11:39 ` Sadashiiv, Halesh
@ 2008-09-18 21:16 ` Ralf Baechle
  2008-09-18 21:25 ` Thomas Bogendoerfer
  2 siblings, 0 replies; 9+ messages in thread
From: Ralf Baechle @ 2008-09-18 21:16 UTC (permalink / raw)
  To: Sadashiiv, Halesh; +Cc: linux-mips

On Thu, Sep 18, 2008 at 05:09:35PM +0530, Sadashiiv, Halesh wrote:
> From: "Sadashiiv, Halesh" <halesh.sadashiv@ap.sony.com>
> Date: Thu, 18 Sep 2008 17:09:35 +0530
> To: linux-mips@linux-mips.org
> Subject: execve errno setting on MIPS
> Content-Type: multipart/alternative;
> 	boundary="----_=_NextPart_001_01C91983.39F24AAB"
> 
> 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], "helloword");
>  
>   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....

Let there be light:

  char *foo[] != char foo[][]

char *e2BIG[ARG_MAX + 1] = {
        [0 ... ARG_MAX] = "helloword"
};

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

is different from

char *e2BIG[ARG_MAX + 1] = {
        [0 ... ARG_MAX] = "helloword"
};

The one is two dimensional array, the other an array of pointers to char.

  Ralf

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

* Re: execve errno setting on MIPS
  2008-09-18 11:39 execve errno setting on MIPS Sadashiiv, Halesh
  2008-09-18 11:39 ` Sadashiiv, Halesh
  2008-09-18 21:16 ` Ralf Baechle
@ 2008-09-18 21:25 ` Thomas Bogendoerfer
  2 siblings, 0 replies; 9+ messages in thread
From: Thomas Bogendoerfer @ 2008-09-18 21:25 UTC (permalink / raw)
  To: Sadashiiv, Halesh; +Cc: linux-mips

On Thu, Sep 18, 2008 at 05:09:35PM +0530, Sadashiiv, Halesh wrote:
> 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], "helloword");

this is broken and does cause an EFAULT on x86 as well (you should
take the warning from gcc about the second argument of execve serious).

Try:

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

int main(void)
{
  int ret,ind;

    for(ind = 0; ind < ARG_MAX+1; ind++)
    	e2BIG[ind] = strdup("helloword");


And it looks like the ARG_MAX limit is bigger than my installed glibc
thinks, because it works at least on x86. When I increase the array two
2 * ARG_MAX I'll get the wanted E2BIG.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

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

* Re: execve errno setting on MIPS
@ 2008-09-19  3:27 Sadashiiv, Halesh
  2008-09-19  3:27 ` Sadashiiv, Halesh
  2008-09-19  7:48 ` Thomas Bogendoerfer
  0 siblings, 2 replies; 9+ messages in thread
From: Sadashiiv, Halesh @ 2008-09-19  3:27 UTC (permalink / raw)
  To: tsbogend; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

>this is broken and does cause an EFAULT on x86 as well (you should
>take the warning from gcc about the second argument of execve serious).
 
 Thanks, you are right.
 
>Try:
 
>char *e2BIG[ARG_MAX+1];
>char *envList[]={NULL};
> 
>int main(void)
>{
>  int ret,ind;
> 
>   for(ind = 0; ind < ARG_MAX+1; ind++)
>        e2BIG[ind] = strdup("helloword");
> 
> 
 It wroks on X86 and other Archs.
> 
> 
>And it looks like the ARG_MAX limit is bigger than my installed glibc
>thinks, because it works at least on x86. When I increase the array two
>2 * ARG_MAX I'll get the wanted E2BIG.
 
 Yes, on MIPS we need to increase the ARM_MAX to 2*ARG_MAX to get E2BIG.
 
Thanks,
Halesh

 



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 6916 bytes --]

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

* Re: execve errno setting on MIPS
  2008-09-19  3:27 Sadashiiv, Halesh
@ 2008-09-19  3:27 ` Sadashiiv, Halesh
  2008-09-19  7:48 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 9+ messages in thread
From: Sadashiiv, Halesh @ 2008-09-19  3:27 UTC (permalink / raw)
  To: tsbogend; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

>this is broken and does cause an EFAULT on x86 as well (you should
>take the warning from gcc about the second argument of execve serious).
 
 Thanks, you are right.
 
>Try:
 
>char *e2BIG[ARG_MAX+1];
>char *envList[]={NULL};
> 
>int main(void)
>{
>  int ret,ind;
> 
>   for(ind = 0; ind < ARG_MAX+1; ind++)
>        e2BIG[ind] = strdup("helloword");
> 
> 
 It wroks on X86 and other Archs.
> 
> 
>And it looks like the ARG_MAX limit is bigger than my installed glibc
>thinks, because it works at least on x86. When I increase the array two
>2 * ARG_MAX I'll get the wanted E2BIG.
 
 Yes, on MIPS we need to increase the ARM_MAX to 2*ARG_MAX to get E2BIG.
 
Thanks,
Halesh

 



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 6916 bytes --]

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

* Re: execve errno setting on MIPS
@ 2008-09-19  3:30 Sadashiiv, Halesh
  2008-09-19  3:30 ` Sadashiiv, Halesh
  0 siblings, 1 reply; 9+ messages in thread
From: Sadashiiv, Halesh @ 2008-09-19  3:30 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 925 bytes --]

 
 
>> The one is two dimensional array, the other an array of pointers to
char.
 
Yes, Fixed the problem, 
But on MIPS, ARG_MAX is not considered, I was able to get the E2BIG on
2*ARG_MAX.
 
Check
http://www.linux-mips.org/archives/linux-mips/2008-09/msg00136.html  
 

Thanks,

Halesh



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 3613 bytes --]

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

* Re: execve errno setting on MIPS
  2008-09-19  3:30 Sadashiiv, Halesh
@ 2008-09-19  3:30 ` Sadashiiv, Halesh
  0 siblings, 0 replies; 9+ messages in thread
From: Sadashiiv, Halesh @ 2008-09-19  3:30 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 925 bytes --]

 
 
>> The one is two dimensional array, the other an array of pointers to
char.
 
Yes, Fixed the problem, 
But on MIPS, ARG_MAX is not considered, I was able to get the E2BIG on
2*ARG_MAX.
 
Check
http://www.linux-mips.org/archives/linux-mips/2008-09/msg00136.html  
 

Thanks,

Halesh



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or entity named above and may contain information that is privileged. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or telephone and destroy the original message. - This mail is sent via Sony Asia Pacific Mail Gateway.
-------------------------------------------------------------------

[-- Attachment #2: Type: text/html, Size: 3613 bytes --]

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

* Re: execve errno setting on MIPS
  2008-09-19  3:27 Sadashiiv, Halesh
  2008-09-19  3:27 ` Sadashiiv, Halesh
@ 2008-09-19  7:48 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 9+ messages in thread
From: Thomas Bogendoerfer @ 2008-09-19  7:48 UTC (permalink / raw)
  To: Sadashiiv, Halesh; +Cc: linux-mips

On Fri, Sep 19, 2008 at 08:57:17AM +0530, Sadashiiv, Halesh wrote:
> >And it looks like the ARG_MAX limit is bigger than my installed glibc
> >thinks, because it works at least on x86. When I increase the array two
> >2 * ARG_MAX I'll get the wanted E2BIG.
>  
>  Yes, on MIPS we need to increase the ARM_MAX to 2*ARG_MAX to get E2BIG.

I've tested only on x86 and I also needed to use 2 * ARG_MAX. This all
depends on the installed glibc, which provides ARG_MAX and the installed
kernel, which sets the rules independand from glibc. If you look at
fs/exec.c in the kernel source, you see these rules. Current kernels
for example have a limit of 

#define MAX_ARG_STRINGS 0x7FFFFFFF

for the number of strings. Looks like E2BIG is triggered by the space
needed for the strings (I only had a quick look at exec.c).

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

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

end of thread, other threads:[~2008-09-19  7:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18 11:39 execve errno setting on MIPS Sadashiiv, Halesh
2008-09-18 11:39 ` Sadashiiv, Halesh
2008-09-18 21:16 ` Ralf Baechle
2008-09-18 21:25 ` Thomas Bogendoerfer
  -- strict thread matches above, loose matches on Subject: below --
2008-09-19  3:27 Sadashiiv, Halesh
2008-09-19  3:27 ` Sadashiiv, Halesh
2008-09-19  7:48 ` Thomas Bogendoerfer
2008-09-19  3:30 Sadashiiv, Halesh
2008-09-19  3:30 ` Sadashiiv, Halesh

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