1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

Kernel: Add sys$set_coredump_metadata() syscall

This can be used by applications to store information (key/value pairs)
likely useful for debugging, which will then be embedded in the coredump.
This commit is contained in:
Linus Groh 2020-12-30 15:19:57 +01:00 committed by Andreas Kling
parent 7413a7c509
commit 91332515a6
3 changed files with 34 additions and 1 deletions

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Types.h>
#include <Kernel/Process.h>
#include <Kernel/SharedBuffer.h>
@ -64,4 +65,25 @@ int Process::sys$set_process_name(Userspace<const char*> user_name, size_t user_
return 0;
}
int Process::sys$set_coredump_metadata(Userspace<const Syscall::SC_set_coredump_metadata_params*> user_params)
{
Syscall::SC_set_coredump_metadata_params params;
if (!copy_from_user(&params, user_params))
return -EFAULT;
if (params.key.length == 0 || params.key.length > 16 * KiB)
return -EINVAL;
if (params.value.length > 16 * KiB)
return -EINVAL;
auto copied_key = copy_string_from_user(params.key.characters, params.key.length);
if (copied_key.is_null())
return -EFAULT;
auto copied_value = copy_string_from_user(params.value.characters, params.value.length);
if (copied_value.is_null())
return -EFAULT;
if (!m_coredump_metadata.contains(copied_key) && m_coredump_metadata.size() >= 16)
return -EFAULT;
m_coredump_metadata.set(move(copied_key), move(copied_value));
return 0;
}
}