|
From: | Fabrice Bellard |
Subject: | Re: [Qemu-devel] [PATCH] linux-user EFAULT implementation |
Date: | Mon, 09 Jul 2007 23:15:09 +0200 |
User-agent: | Thunderbird 1.5.0.9 (X11/20070212) |
Stuart Anderson wrote:
On Fri, 6 Jul 2007, Stuart Anderson wrote:So, the question is: Can I simplify this code to assume that guest and host addresses coexist and use the copy_*_user() or just the access_ok() interfaces?
No. Ideally you should use the same conventions as the Linux kernel and assume that you cannot access the user data directly. To summarise:
- access_ok() is needed before __copy_*_user and __[get|put]_user. - access_ok() is not needed before copy_[to|from]_user and [get|put]_user. - [get|put]_user do automatic endianness change.- Use tswapx and the other related functions to change the endianness before or after copy_*_user.
- for specific cases requiring speed (e.g. buffers for read/write syscalls), specific tricks to avoid memory copies can be used with a lock/unlock style API.
Attached is a diff [...]
Please send a unified diff.For the time being, I would suggest to minimize the number of changes and just extend lock_user()/unlock_user() as you began to do to handle -EFAULT. The rest is mostly a question of cosmetics.
Regards, Fabrice.
[Prev in Thread] | Current Thread | [Next in Thread] |