* Regarding select() on PPC
@ 2008-09-19 14:04 Halesh S
2008-09-22 14:47 ` Halesh S
0 siblings, 1 reply; 5+ messages in thread
From: Halesh S @ 2008-09-19 14:04 UTC (permalink / raw)
To: linux-kernel
Hi all,
Please find the below testcase.
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdlib.h>
int main()
{
int fd;
fd_set rfds;
struct timeval tv;
int ret_val;
if ((fd = open("test_file", O_RDWR|O_CREAT, 0664)) < 0)
{
printf("Open failed\n");
}
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
/* Wait up to five seconds. */
tv.tv_sec = 1;
tv.tv_usec = 0;
if ( (ret_val = select(-1, &rfds, NULL, NULL, &tv)) < 0)
{
if (errno == EINVAL)
printf("OK\n");
else
printf("Not OK, Got errno %d\n", errno);
}
exit(0);
}
For negetive value of n (first argument to select) select fails with
EINVAL error,
But for the same when I tested for PowerPC it was giving EFAULT,
Its on 2.6.16 kernel.
Please let me know, If this is fixed or it's a issue in PPC.
For other archs its working fine.
Thanks,
Halesh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Regarding select() on PPC
2008-09-19 14:04 Regarding select() on PPC Halesh S
@ 2008-09-22 14:47 ` Halesh S
2008-09-22 15:36 ` Andreas Schwab
0 siblings, 1 reply; 5+ messages in thread
From: Halesh S @ 2008-09-22 14:47 UTC (permalink / raw)
To: linux-kernel
Halesh S <halesh.sadashiv <at> ap.sony.com> writes:
>
> Hi all,
>
> Please find the below testcase.
>
> #include <stdio.h>
> #include <sys/time.h>
> #include <sys/types.h>
> #include <unistd.h>
> #include <fcntl.h>
> #include <string.h>
> #include <time.h>
> #include <errno.h>
> #include <stdlib.h>
>
> int main()
> {
>
> int fd;
> fd_set rfds;
> struct timeval tv;
> int ret_val;
>
> if ((fd = open("test_file", O_RDWR|O_CREAT, 0664)) < 0)
> {
> printf("Open failed\n");
> }
>
> FD_ZERO(&rfds);
> FD_SET(fd, &rfds);
>
> /* Wait up to five seconds. */
> tv.tv_sec = 1;
> tv.tv_usec = 0;
>
> if ( (ret_val = select(-1, &rfds, NULL, NULL, &tv)) < 0)
> {
> if (errno == EINVAL)
> printf("OK\n");
> else
> printf("Not OK, Got errno %d\n", errno);
> }
> exit(0);
> }
>
> For negetive value of n (first argument to select) select fails with
> EINVAL error,
>
> But for the same when I tested for PowerPC it was giving EFAULT,
> Its on 2.6.16 kernel.
>
> Please let me know, If this is fixed or it's a issue in PPC.
> For other archs its working fine.
>
> Thanks,
> Halesh
>
>
On further investigation found, the above problem occurs only in PPC32.
Because select()->ppc_select()->sys_select() only for PPC32.
In the file powerpc/kernel/syscalls.c,
#ifdef CONFIG_PPC32
/*
* Due to some executables calling the wrong select we sometimes
* get wrong args. This determines how the args are being passed
* (a single ptr to them all args passed) then calls
* sys_select() with the appropriate args. -- Cort
*/
int
ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp,
struct timeval __user *tvp)
{
if ( (unsigned long)n >= 4096 )
{
unsigned long __user *buffer = (unsigned long __user *)n;
if (!access_ok(VERIFY_READ, buffer, 5*sizeof(unsigned long))
|| __get_user(n, buffer)
|| __get_user(inp, ((fd_set __user * __user *)(buffer+1)))
|| __get_user(outp, ((fd_set __user * __user *)(buffer+2)))
|| __get_user(exp, ((fd_set __user * __user *)(buffer+3)))
|| __get_user(tvp, ((struct timeval __user * __user *)
(buffer+4))))
return -EFAULT;
}
return sys_select(n, inp, outp, exp, tvp);
}
#endif
What is the purpose of Argument check only for PPC32, is ther any specific
reason? Please let me know if so. Comments were not enough to understad the
actual reason reas for me.
On all archs I have checked like PPC64, ARM, i686 with invalid 'n' val returns
EINVAL, execpet on PPC32, this needs to be fixed ??
either man page / return value in kernel source.
- return -EFAULT
+ return -EINVAL
Please let me know regarding this issue.
Thanks,
Halesh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Regarding select() on PPC
2008-09-22 14:47 ` Halesh S
@ 2008-09-22 15:36 ` Andreas Schwab
2008-09-22 15:45 ` Halesh S
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2008-09-22 15:36 UTC (permalink / raw)
To: Halesh S; +Cc: linux-kernel
Halesh S <halesh.sadashiv@ap.sony.com> writes:
> What is the purpose of Argument check only for PPC32, is ther any specific
> reason?
Probably long obsolete, it predates linux 2.2.0.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Regarding select() on PPC
2008-09-22 15:36 ` Andreas Schwab
@ 2008-09-22 15:45 ` Halesh S
2008-09-23 4:25 ` Halesh S
0 siblings, 1 reply; 5+ messages in thread
From: Halesh S @ 2008-09-22 15:45 UTC (permalink / raw)
To: linux-kernel
Andreas Schwab <schwab <at> suse.de> writes:
>
> Halesh S <halesh.sadashiv <at> ap.sony.com> writes:
>
> > What is the purpose of Argument check only for PPC32, is ther any specific
> > reason?
>
> Probably long obsolete, it predates linux 2.2.0.
Than do you mean by this is not required in later versions.
>
> Andreas.
>
Thanks,
Halesh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Regarding select() on PPC
2008-09-22 15:45 ` Halesh S
@ 2008-09-23 4:25 ` Halesh S
0 siblings, 0 replies; 5+ messages in thread
From: Halesh S @ 2008-09-23 4:25 UTC (permalink / raw)
To: linux-kernel
Halesh S <halesh.sadashiv <at> ap.sony.com> writes:
>
> Andreas Schwab <schwab <at> suse.de> writes:
>
> >
> > Halesh S <halesh.sadashiv <at> ap.sony.com> writes:
> >
> > > What is the purpose of Argument check only for PPC32, is ther any
specific
> > > reason?
> >
> > Probably long obsolete, it predates linux 2.2.0.
>
> Than do you mean by this is not required in later versions.
>
> >
> > Andreas.
> >
>
> Thanks,
> Halesh
>
>
Halesh S <halesh.sadashiv <at> ap.sony.com> writes:
>
> Andreas Schwab <schwab <at> suse.de> writes:
>
> >
> > Halesh S <halesh.sadashiv <at> ap.sony.com> writes:
> >
> > > What is the purpose of Argument check only for PPC32, is ther any
specific
> > > reason?
> >
> > Probably long obsolete, it predates linux 2.2.0.
>
> Than do you mean by this is not required in later versions.
>
> >
> > Andreas.
> >
>
> Thanks,
> Halesh
>
>
Please check this patch be applied for latest linux kernel??
--- arch/powerpc/kernel.old/syscalls.c 2008-09-22 20:47:06.000000000 +0530
+++ arch/powerpc/kernel/syscalls.c 2008-09-23 09:38:31.841327576 +0530
@@ -203,25 +203,13 @@
#ifdef CONFIG_PPC32
/*
- * Due to some executables calling the wrong select we sometimes
- * get wrong args. This determines how the args are being passed
- * (a single ptr to them all args passed) then calls
- * sys_select() with the appropriate args. -- Cort
+ * The argument checking is long obselete, the code was carried from
+ * kernel version 2.2.0, so removing obselete code and directly call
+ * to sys_select()
*/
int
ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user
*exp, struct timeval __user *tvp)
{
- if ( (unsigned long)n >= 4096 )
- {
- unsigned long __user *buffer = (unsigned long __user *)n;
- if (!access_ok(VERIFY_READ, buffer, 5*sizeof(unsigned long))
- || __get_user(n, buffer)
- || __get_user(inp, ((fd_set __user * __user *)(buffer+1)))
- || __get_user(outp, ((fd_set __user * __user *)(buffer+2)))
- || __get_user(exp, ((fd_set __user * __user *)(buffer+3)))
- || __get_user(tvp, ((struct timeval __user * __user *)
(buffer+4))))
- return -EFAULT;
- }
return sys_select(n, inp, outp, exp, tvp);
}
#endif
Tested on PPC32. Works fine with provided testcase.
Thanks,
Halesh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-09-23 4:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19 14:04 Regarding select() on PPC Halesh S
2008-09-22 14:47 ` Halesh S
2008-09-22 15:36 ` Andreas Schwab
2008-09-22 15:45 ` Halesh S
2008-09-23 4:25 ` Halesh S
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox