lkml.org 
[lkml]   [1996]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectcopy_to_user does not handle constant length parameter (Linux 2.1.5)
Date
Hi,

when trying to port "kmouse" to Linux 2.1.5, I noticed that mouse
movements would suddenly report bogus Y coordinates. Upon examining
the source code I noticed that the code fragment

long kmouse_read_data(struct inode *inode, struct file *filp,
char *buf, unsigned long count)
{
signed char localbuf[5];
.
.
.
copy_to_user(buf,localbuf,5);
.
.
.
}

did not have the desired effect. The "copy_to_user" instruction would
only copy four instead of five bytes! Replacing the code with "memcpy"
or avoiding the use of a constant length parameter did fix the
problem:

long kmouse_read_data(struct inode *inode, struct file *filp,
char *buf, unsigned long count)
{
static int constant5 = 5;
signed char localbuf[5];
.
.
.
copy_to_user(buf,localbuf,constant5);
.
.
.
}

I assume, there is something wrong with the operand constraints, but I
cannot spot any obvious solution.



Markus

P.S.: I also noticed that passing complex expressions as the source
and/or destination address for copy_to_user() would result in
GCC (2.7.2) complaining about a reserved register being
clobbered.

\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.202 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site