* pread and pwrite
@ 2002-07-17 9:03 Carsten Langgaard
2002-07-17 13:59 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: Carsten Langgaard @ 2002-07-17 9:03 UTC (permalink / raw)
To: H. J. Lu, Ralf Baechle, linux-mips
I'm running some tests from LTP, which tests pread and pwrite.
It look like pread/pwrite doesn't do any check, if they are called with
'buf =NULL' or 'offset < 0', and no error is return.
If I look in glibc in sysdeps/generic/pread.c it look like this:
ssize_t
__libc_pread (int fd, void *buf, size_t nbytes, off_t offset)
{
if (nbytes == 0)
return 0;
if (fd < 0)
{
__set_errno (EBADF);
return -1;
}
if (buf == NULL || offset < 0)
{
__set_errno (EINVAL);
return -1;
}
__set_errno (ENOSYS);
return -1;
}
Here there is some checking for sane values and a proper error value is
return.
I guess this routine is replaced, if we have the syscall implemented
with the sysdeps/unix/sysv/linux/mips/pread.c file.
Here there is no check for sane values, is there any reason why ?
The same thing goes for pwrite.
/Carsten
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pread and pwrite
2002-07-17 9:03 pread and pwrite Carsten Langgaard
@ 2002-07-17 13:59 ` Ralf Baechle
2002-07-17 14:18 ` Carsten Langgaard
0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2002-07-17 13:59 UTC (permalink / raw)
To: Carsten Langgaard; +Cc: H. J. Lu, linux-mips
On Wed, Jul 17, 2002 at 11:03:55AM +0200, Carsten Langgaard wrote:
>
> Here there is some checking for sane values and a proper error value is
> return.
> I guess this routine is replaced, if we have the syscall implemented
> with the sysdeps/unix/sysv/linux/mips/pread.c file.
> Here there is no check for sane values, is there any reason why ?
> The same thing goes for pwrite.
The kernel does it's own error checking. No need to duplicate that in
userspace.
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pread and pwrite
2002-07-17 13:59 ` Ralf Baechle
@ 2002-07-17 14:18 ` Carsten Langgaard
2002-07-17 19:01 ` H. J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: Carsten Langgaard @ 2002-07-17 14:18 UTC (permalink / raw)
To: Ralf Baechle; +Cc: H. J. Lu, linux-mips
Ralf Baechle wrote:
> On Wed, Jul 17, 2002 at 11:03:55AM +0200, Carsten Langgaard wrote:
>
> >
> > Here there is some checking for sane values and a proper error value is
> > return.
> > I guess this routine is replaced, if we have the syscall implemented
> > with the sysdeps/unix/sysv/linux/mips/pread.c file.
> > Here there is no check for sane values, is there any reason why ?
> > The same thing goes for pwrite.
>
> The kernel does it's own error checking. No need to duplicate that in
> userspace.
The kernel doesn't do this a proper check then.
The pread/pwrite parameters is also convert in glibc, the 'offset' is
convert from a 'long' to a 'long long', but it isn't sign extended.
So when pread is call with offset -1, then kernel won't see it as -1.
>
> Ralf
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pread and pwrite
2002-07-17 14:18 ` Carsten Langgaard
@ 2002-07-17 19:01 ` H. J. Lu
2002-07-17 20:14 ` Carsten Langgaard
0 siblings, 1 reply; 5+ messages in thread
From: H. J. Lu @ 2002-07-17 19:01 UTC (permalink / raw)
To: Carsten Langgaard; +Cc: Ralf Baechle, linux-mips
On Wed, Jul 17, 2002 at 04:18:17PM +0200, Carsten Langgaard wrote:
> Ralf Baechle wrote:
>
> > On Wed, Jul 17, 2002 at 11:03:55AM +0200, Carsten Langgaard wrote:
> >
> > >
> > > Here there is some checking for sane values and a proper error value is
> > > return.
> > > I guess this routine is replaced, if we have the syscall implemented
> > > with the sysdeps/unix/sysv/linux/mips/pread.c file.
> > > Here there is no check for sane values, is there any reason why ?
> > > The same thing goes for pwrite.
> >
> > The kernel does it's own error checking. No need to duplicate that in
> > userspace.
>
> The kernel doesn't do this a proper check then.
> The pread/pwrite parameters is also convert in glibc, the 'offset' is
> convert from a 'long' to a 'long long', but it isn't sign extended.
> So when pread is call with offset -1, then kernel won't see it as -1.
>
Please check it out:
http://sources.redhat.com/ml/libc-alpha/2002-07/msg00188.html
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pread and pwrite
2002-07-17 19:01 ` H. J. Lu
@ 2002-07-17 20:14 ` Carsten Langgaard
0 siblings, 0 replies; 5+ messages in thread
From: Carsten Langgaard @ 2002-07-17 20:14 UTC (permalink / raw)
To: H. J. Lu; +Cc: Ralf Baechle, linux-mips
"H. J. Lu" wrote:
> On Wed, Jul 17, 2002 at 04:18:17PM +0200, Carsten Langgaard wrote:
> > Ralf Baechle wrote:
> >
> > > On Wed, Jul 17, 2002 at 11:03:55AM +0200, Carsten Langgaard wrote:
> > >
> > > >
> > > > Here there is some checking for sane values and a proper error value is
> > > > return.
> > > > I guess this routine is replaced, if we have the syscall implemented
> > > > with the sysdeps/unix/sysv/linux/mips/pread.c file.
> > > > Here there is no check for sane values, is there any reason why ?
> > > > The same thing goes for pwrite.
> > >
> > > The kernel does it's own error checking. No need to duplicate that in
> > > userspace.
> >
> > The kernel doesn't do this a proper check then.
> > The pread/pwrite parameters is also convert in glibc, the 'offset' is
> > convert from a 'long' to a 'long long', but it isn't sign extended.
> > So when pread is call with offset -1, then kernel won't see it as -1.
> >
>
> Please check it out:
>
> http://sources.redhat.com/ml/libc-alpha/2002-07/msg00188.html
>
> H.J.
So the same issue has been raised today on the glibc list, amazing. I guess the
problem has existed quite some time.
But it look like the patch will fix the problem. Do you know if the patch has
been committed and which version of glibc will it then be fixed in ?
Thanks,
/Carsten
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-07-18 17:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-17 9:03 pread and pwrite Carsten Langgaard
2002-07-17 13:59 ` Ralf Baechle
2002-07-17 14:18 ` Carsten Langgaard
2002-07-17 19:01 ` H. J. Lu
2002-07-17 20:14 ` Carsten Langgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox