Messages in this thread |  | | From | Markus Gutschke <> | Subject | copy_to_user does not handle constant length parameter (Linux 2.1.5) | Date | 21 Oct 1996 03:13:49 +0200 |
| |
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.
|  |