goldfish driver: Missing get_user_pages in goldfish_pipe_read_write()
The following code snippet:
drivers/platform/goldfish/goldfish_pipe.c:goldfish_pipe_read_write()
/* Ensure that the corresponding page is properly mapped */
/* FIXME: this isn't safe or sufficient - use get_user_pages */
if (is_write) {
char c;
/* Ensure that the page is mapped and readable */
if (__get_user(c, (char __user *)address)) {
if (!ret)
ret = -EFAULT;
break;
}
} else {
/* Ensure that the page is mapped and writable */
if (__put_user(0, (char __user *)address)) {
if (!ret)
ret = -EFAULT;
break;
}
}Seems to lack the kind of validation required to make it fail properly if the memory range is not fully populated.
I see that this feature has been merged in Linux kernel 3.9, but the FIXME is still there in 3.10-rc7. Any plans on fixing this ?
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Quoted 24 lines · Mathieu Desnoyers
The following code snippet:
drivers/platform/goldfish/goldfish_pipe.c:goldfish_pipe_read_write()/* Ensure that the corresponding page is properly mapped */ /* FIXME: this isn't safe or sufficient - use get_user_pages */ if (is_write) { char c; /* Ensure that the page is mapped and readable */ if (__get_user(c, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } } else { /* Ensure that the page is mapped and writable */ if (__put_user(0, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } }
Quoted 2 lines
Seems to lack the kind of validation required to make it fail properly if the memory range is not fully populated.
This is an emulated platform only, so it's probably not a big deal, right?
Quoted 2 lines
I see that this feature has been merged in Linux kernel 3.9, but the FIXME is still there in 3.10-rc7. Any plans on fixing this ?
It would be good to get fixed, but probably way down on the priority list.
thanks,
greg k-h
Quoted 25 lines · * Greg Kroah-Hartman ([email protected]) wrote:
Quoted 24 lines · Mathieu Desnoyers
The following code snippet:
drivers/platform/goldfish/goldfish_pipe.c:goldfish_pipe_read_write()/* Ensure that the corresponding page is properly mapped */ /* FIXME: this isn't safe or sufficient - use get_user_pages */ if (is_write) { char c; /* Ensure that the page is mapped and readable */ if (__get_user(c, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } } else { /* Ensure that the page is mapped and writable */ if (__put_user(0, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } }
Quoted 5 lines
Quoted 2 lines
Seems to lack the kind of validation required to make it fail properly if the memory range is not fully populated.
This is an emulated platform only, so it's probably not a big deal, right?
You're probably right. As long as it is not configured and somehow still accessible on a production device.
Quoted 6 lines
Quoted 3 lines
I see that this feature has been merged in Linux kernel 3.9, but the FIXME is still there in 3.10-rc7. Any plans on fixing this ?
It would be good to get fixed, but probably way down on the priority list.
Agreed,
Thanks,
Mathieu
Quoted 4 lines
thanks,
greg k-h
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Quoted 26 lines · Mathieu Desnoyers
Quoted 25 lines · * Greg Kroah-Hartman ([email protected]) wrote:
Quoted 24 lines · Mathieu Desnoyers
The following code snippet:
drivers/platform/goldfish/goldfish_pipe.c:goldfish_pipe_read_write()/* Ensure that the corresponding page is properly mapped */ /* FIXME: this isn't safe or sufficient - use get_user_pages */ if (is_write) { char c; /* Ensure that the page is mapped and readable */ if (__get_user(c, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } } else { /* Ensure that the page is mapped and writable */ if (__put_user(0, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } }
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Seems to lack the kind of validation required to make it fail properly if the memory range is not fully populated.
This is an emulated platform only, so it's probably not a big deal, right?
You're probably right. As long as it is not configured and somehow still accessible on a production device.
There is no device that could ever be "production" for this emulated hardware platform, unless a desktop system wants to "emulate" the android userspace system somehow. Then it could be "real", but even then, how would a user application get access to this codepath?
thanks,
greg k-h
Quoted 33 lines · * Greg Kroah-Hartman ([email protected]) wrote:
Quoted 32 lines · Mathieu Desnoyers
Quoted 30 lines · * Greg Kroah-Hartman ([email protected]) wrote:
Quoted 24 lines · Mathieu Desnoyers
The following code snippet:
drivers/platform/goldfish/goldfish_pipe.c:goldfish_pipe_read_write()/* Ensure that the corresponding page is properly mapped */ /* FIXME: this isn't safe or sufficient - use get_user_pages */ if (is_write) { char c; /* Ensure that the page is mapped and readable */ if (__get_user(c, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } } else { /* Ensure that the page is mapped and writable */ if (__put_user(0, (char __user *)address)) { if (!ret) ret = -EFAULT; break; } }Quoted 2 lines
Seems to lack the kind of validation required to make it fail properly if the memory range is not fully populated.
This is an emulated platform only, so it's probably not a big deal, right?
Quoted 7 lines
Quoted 2 lines
You're probably right. As long as it is not configured and somehow still accessible on a production device.
There is no device that could ever be "production" for this emulated hardware platform, unless a desktop system wants to "emulate" the android userspace system somehow. Then it could be "real", but even then, how would a user application get access to this codepath?
I think it would depend on the user access rights given to /dev/qemu_pipe. Assuming it would be only accessible by root, this would minimize the risks even more.
Thanks,
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com