Advertisement
RobertBerger

lab1_syscall_patch_4.13.3

Oct 17th, 2017
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. From 3c3820f88d5315af4c52b5f30d749c9d315fef61 Mon Sep 17 00:00:00 2001
  2. From: student <student@ReliableEmbeddedSystems.com>
  3. Date: Wed, 27 Sep 2017 07:34:41 -0500
  4. Subject: [PATCH] introduce new syscall
  5.  
  6. Signed-off-by: student <student@ReliableEmbeddedSystems.com>
  7. ---
  8. arch/x86/entry/syscalls/syscall_32.tbl | 1 +
  9. arch/x86/entry/syscalls/syscall_64.tbl | 1 +
  10. kernel/sys.c | 19 +++++++++++++++++++
  11. 3 files changed, 21 insertions(+)
  12.  
  13. diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
  14. index 448ac21..0a54704 100644
  15. --- a/arch/x86/entry/syscalls/syscall_32.tbl
  16. +++ b/arch/x86/entry/syscalls/syscall_32.tbl
  17. @@ -391,3 +391,4 @@
  18. 382 i386 pkey_free sys_pkey_free
  19. 383 i386 statx sys_statx
  20. 384 i386 arch_prctl sys_arch_prctl compat_sys_arch_prctl
  21. +385 i386 my_syscall sys_my_syscall
  22. diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
  23. index 5aef183..6ac6529 100644
  24. --- a/arch/x86/entry/syscalls/syscall_64.tbl
  25. +++ b/arch/x86/entry/syscalls/syscall_64.tbl
  26. @@ -339,6 +339,7 @@
  27. 330 common pkey_alloc sys_pkey_alloc
  28. 331 common pkey_free sys_pkey_free
  29. 332 common statx sys_statx
  30. +333 common my_syscall sys_my_syscall
  31.  
  32. #
  33. # x32-specific system call numbers start at 512 to avoid cache impact
  34. diff --git a/kernel/sys.c b/kernel/sys.c
  35. index 2855ee7..ab5d7ef 100644
  36. --- a/kernel/sys.c
  37. +++ b/kernel/sys.c
  38. @@ -2552,3 +2552,22 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
  39. return 0;
  40. }
  41. #endif /* CONFIG_COMPAT */
  42. +
  43. +
  44. +/* Adding a dynamical system call */
  45. +struct my_sc_struct {
  46. + long (*fun)(unsigned long p1);
  47. +} my_sc = {
  48. + NULL};
  49. +EXPORT_SYMBOL(my_sc);
  50. +
  51. +SYSCALL_DEFINE1(my_syscall, unsigned long, p1)
  52. +{
  53. + struct my_sc_struct *s = (struct my_sc_struct *)&my_sc;
  54. +
  55. + pr_info("Entering my_syscall with p1 = %ld at jiffies=%ld\n",
  56. + p1, jiffies);
  57. + if (!s || !s->fun)
  58. + return -ENOSYS;
  59. + return s->fun(p1);
  60. +}
  61. --
  62. 2.11.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement