mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
Kernel: Remove SmapDisabler in sys$ioctl()
Use copy_{to,from}_user() in the various File::ioctl() implementations instead of disabling SMAP wholesale in sys$ioctl(). This patch does not port IPv4Socket::ioctl() to those API's since that will be more involved. That function now creates a local SmapDisabler.
This commit is contained in:
parent
be7add690d
commit
292cd53192
5 changed files with 78 additions and 51 deletions
|
@ -81,32 +81,38 @@ int MBVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
|
|||
auto* out = (size_t*)arg;
|
||||
if (!Process::current()->validate_write_typed(out))
|
||||
return -EFAULT;
|
||||
*out = framebuffer_size_in_bytes();
|
||||
size_t value = framebuffer_size_in_bytes();
|
||||
copy_to_user(out, &value);
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_GET_BUFFER: {
|
||||
auto* index = (int*)arg;
|
||||
if (!Process::current()->validate_write_typed(index))
|
||||
return -EFAULT;
|
||||
*index = 0;
|
||||
int value = 0;
|
||||
copy_to_user(index, &value);
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_GET_RESOLUTION: {
|
||||
auto* resolution = (FBResolution*)arg;
|
||||
if (!Process::current()->validate_write_typed(resolution))
|
||||
auto* user_resolution = (FBResolution*)arg;
|
||||
if (!Process::current()->validate_write_typed(user_resolution))
|
||||
return -EFAULT;
|
||||
resolution->pitch = m_framebuffer_pitch;
|
||||
resolution->width = m_framebuffer_width;
|
||||
resolution->height = m_framebuffer_height;
|
||||
FBResolution resolution;
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
copy_to_user(user_resolution, &resolution);
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_SET_RESOLUTION: {
|
||||
auto* resolution = (FBResolution*)arg;
|
||||
if (!Process::current()->validate_read_typed(resolution) || !Process::current()->validate_write_typed(resolution))
|
||||
auto* user_resolution = (FBResolution*)arg;
|
||||
if (!Process::current()->validate_read_typed(user_resolution) || !Process::current()->validate_write_typed(user_resolution))
|
||||
return -EFAULT;
|
||||
resolution->pitch = m_framebuffer_pitch;
|
||||
resolution->width = m_framebuffer_width;
|
||||
resolution->height = m_framebuffer_height;
|
||||
FBResolution resolution;
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
copy_to_user(user_resolution, &resolution);
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue