: do_write_mem() return value check
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · BlaisorBlade
From: Andrew Morton, and me (I did a first fix for 2.6 and sent to him, he checked everything and committed it and I changed the trivial bits for 2.4).
- remove unused `file *' arg from
do_write_mem()- Add checking for
copy_from_user()failures indo_write_mem()(Note:
/dev/kmemcan be written to only by root, so this *cannot* have security implications)- Return correct value from kmem
writes()when a fault is encountered. A write()-style syscall's return values are:0 when nothing was written and there was no error (someone tried to write zero bytes)
Quoted 1 line
0: the number of bytes copied, whether or not there was an error.
Quoted 8 lines
Userspace detects errors by noting that the
write()return value is less than was requested.<0: there was an error and no bytes were copied
TODO: Do the same changes for
read_mem()andread_kmem(). The code is more messy so I must createdo_read_mem()to avoid clumsy counting; I will post the patch first for 2.6.
Hi Paolo,
This is nice -- although I see it as a 2.6 cleanup only.
Do you actually have any practical problem caused by the current broken "always return -EFAULT" ?
Otherwise leave it for 2.6.