summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-17 20:32:53 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-17 20:32:53 +0200
commit10fd862a5562ff96d8abd45c46b9ff17e24820a5 (patch)
tree6f624802949e9ffd4968d4bf389bd96ce3af908c /Kernel/Process.cpp
parent2ad1c2d959019e565a641adbd80ab6cee8a2e364 (diff)
downloadserenity-10fd862a5562ff96d8abd45c46b9ff17e24820a5.zip
Kernel: Unbreak sys$setkeymap()
This syscall was disabling SMAP too late and would crash every time when trying to set a new keymap.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 9c066baf95..e91b38f1e0 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -4305,28 +4305,20 @@ int Process::sys$setkeymap(const Syscall::SC_setkeymap_params* user_params)
Keyboard::CharacterMapData character_map_data;
- const u32* map = params.map;
- const u32* shift_map = params.shift_map;
- const u32* alt_map = params.alt_map;
- const u32* altgr_map = params.altgr_map;
-
- if (!validate_read(map, CHAR_MAP_SIZE))
+ if (!validate_read(params.map, CHAR_MAP_SIZE))
return -EFAULT;
- if (!validate_read(shift_map, CHAR_MAP_SIZE))
+ if (!validate_read(params.shift_map, CHAR_MAP_SIZE))
return -EFAULT;
- if (!validate_read(alt_map, CHAR_MAP_SIZE))
+ if (!validate_read(params.alt_map, CHAR_MAP_SIZE))
return -EFAULT;
- if (!validate_read(altgr_map, CHAR_MAP_SIZE))
+ if (!validate_read(params.altgr_map, CHAR_MAP_SIZE))
return -EFAULT;
- for (int i = 0; i < CHAR_MAP_SIZE; i++) {
- character_map_data.map[i] = map[i];
- character_map_data.shift_map[i] = shift_map[i];
- character_map_data.alt_map[i] = alt_map[i];
- character_map_data.altgr_map[i] = altgr_map[i];
- }
+ copy_from_user(character_map_data.map, params.map, CHAR_MAP_SIZE * sizeof(u32));
+ copy_from_user(character_map_data.shift_map, params.shift_map, CHAR_MAP_SIZE * sizeof(u32));
+ copy_from_user(character_map_data.alt_map, params.alt_map, CHAR_MAP_SIZE * sizeof(u32));
+ copy_from_user(character_map_data.altgr_map, params.altgr_map, CHAR_MAP_SIZE * sizeof(u32));
- SmapDisabler disabler;
KeyboardDevice::the().set_maps(character_map_data);
return 0;
}