linux-3.5.patch 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. diff --git a/Pal/linux-3.5/Kconfig b/Pal/linux-3.5/Kconfig
  2. index c13f48d..e18713e 100644
  3. --- a/Pal/linux-3.5/Kconfig
  4. +++ b/Pal/linux-3.5/Kconfig
  5. @@ -9,3 +9,4 @@ config SRCARCH
  6. option env="SRCARCH"
  7. source "arch/$SRCARCH/Kconfig"
  8. +source "graphene/Kconfig"
  9. diff --git a/Pal/linux-3.5/Makefile b/Pal/linux-3.5/Makefile
  10. index 4bb09e1..6ecc21c 100644
  11. --- a/Pal/linux-3.5/Makefile
  12. +++ b/Pal/linux-3.5/Makefile
  13. @@ -715,7 +715,7 @@ export mod_strip_cmd
  14. ifeq ($(KBUILD_EXTMOD),)
  15. -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
  16. +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ graphene/
  17. vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
  18. $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
  19. diff --git a/Pal/linux-3.5/include/linux/miscdevice.h b/Pal/linux-3.5/include/linux/miscdevice.h
  20. index 0549d21..4243619 100644
  21. --- a/Pal/linux-3.5/include/linux/miscdevice.h
  22. +++ b/Pal/linux-3.5/include/linux/miscdevice.h
  23. @@ -3,6 +3,7 @@
  24. #include <linux/major.h>
  25. #include <linux/list.h>
  26. #include <linux/types.h>
  27. +#include <../graphene/graphene.h>
  28. /*
  29. * These allocations are managed by device@lanana.org. If you use an
  30. diff --git a/Pal/linux-3.5/include/linux/sched.h b/Pal/linux-3.5/include/linux/sched.h
  31. index 4a1f493..a9e5445 100644
  32. --- a/Pal/linux-3.5/include/linux/sched.h
  33. +++ b/Pal/linux-3.5/include/linux/sched.h
  34. @@ -1226,6 +1226,11 @@ enum perf_event_task_context {
  35. perf_nr_task_contexts,
  36. };
  37. +#ifdef CONFIG_GRAPHENE
  38. +# include <../graphene/graphene.h>
  39. +struct graphene_struct;
  40. +#endif
  41. +
  42. struct task_struct {
  43. volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
  44. void *stack;
  45. @@ -1583,6 +1588,11 @@ struct task_struct {
  46. struct uprobe_task *utask;
  47. int uprobe_srcu_id;
  48. #endif
  49. +
  50. +#ifdef CONFIG_GRAPHENE
  51. + /* for graphene tasks */
  52. + struct graphene_struct *graphene; /* structure to store graphene info */
  53. +#endif
  54. };
  55. /* Future-safe accessor for struct task_struct's cpus_allowed. */
  56. diff --git a/Pal/linux-3.5/kernel/fork.c b/Pal/linux-3.5/kernel/fork.c
  57. index f00e319..2e2a084 100644
  58. --- a/Pal/linux-3.5/kernel/fork.c
  59. +++ b/Pal/linux-3.5/kernel/fork.c
  60. @@ -83,6 +83,10 @@
  61. #define CREATE_TRACE_POINTS
  62. #include <trace/events/task.h>
  63. +#ifdef CONFIG_GRAPHENE
  64. +# include <../graphene/graphene.h>
  65. +#endif
  66. +
  67. /*
  68. * Protected counters by write_lock_irq(&tasklist_lock)
  69. */
  70. @@ -237,6 +241,10 @@ void __put_task_struct(struct task_struct *tsk)
  71. delayacct_tsk_free(tsk);
  72. put_signal_struct(tsk->signal);
  73. +#ifdef CONFIG_GRAPHENE
  74. + put_graphene_struct(tsk);
  75. +#endif
  76. +
  77. if (!profile_handoff_task(tsk))
  78. free_task(tsk);
  79. }
  80. @@ -305,6 +313,12 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
  81. err = arch_dup_task_struct(tsk, orig);
  82. +#ifdef CONFIG_GRAPHENE
  83. + err = dup_graphene_struct(tsk);
  84. + if (err)
  85. + goto out;
  86. +#endif
  87. +
  88. /*
  89. * We defer looking at err, because we will need this setup
  90. * for the clean up path to work correctly.
  91. diff --git a/Pal/linux-3.5/security/apparmor/lsm.c b/Pal/linux-3.5/security/apparmor/lsm.c
  92. index 8ea39aa..33b4e15 100644
  93. --- a/Pal/linux-3.5/security/apparmor/lsm.c
  94. +++ b/Pal/linux-3.5/security/apparmor/lsm.c
  95. @@ -36,6 +36,10 @@
  96. #include "include/policy.h"
  97. #include "include/procattr.h"
  98. +#ifdef CONFIG_GRAPHENE
  99. +# include <../graphene/graphene.h>
  100. +#endif
  101. +
  102. /* Flag indicating whether initialization completed */
  103. int apparmor_initialized __initdata;
  104. @@ -165,6 +169,12 @@ static int common_perm(int op, struct path *path, u32 mask,
  105. struct aa_profile *profile;
  106. int error = 0;
  107. +#ifdef CONFIG_GRAPHENE
  108. + if (GRAPHENE_ENABLED() &&
  109. + (error = graphene_common_perm(op, path, mask)))
  110. + return error;
  111. +#endif
  112. +
  113. profile = __aa_current_profile();
  114. if (!unconfined(profile))
  115. error = aa_path_perm(op, profile, path, 0, mask, cond);
  116. @@ -377,6 +387,7 @@ static int apparmor_file_open(struct file *file, const struct cred *cred)
  117. {
  118. struct aa_file_cxt *fcxt = file->f_security;
  119. struct aa_profile *profile;
  120. + u32 mask;
  121. int error = 0;
  122. if (!mediated_filesystem(file->f_path.dentry->d_inode))
  123. @@ -388,10 +399,21 @@ static int apparmor_file_open(struct file *file, const struct cred *cred)
  124. * actually execute the image.
  125. */
  126. if (current->in_execve) {
  127. +#ifdef CONFIG_GRAPHENE
  128. + if (GRAPHENE_ENABLED() && (error = graphene_execve_open(file)))
  129. + return error;
  130. +#endif
  131. fcxt->allow = MAY_EXEC | MAY_READ | AA_EXEC_MMAP;
  132. return 0;
  133. }
  134. +#ifdef CONFIG_GRAPHENE
  135. + mask = aa_map_file_to_perms(file);
  136. + if (GRAPHENE_ENABLED() &&
  137. + (error = graphene_common_perm(OP_OPEN, &file->f_path, mask)))
  138. + return error;
  139. +#endif
  140. +
  141. profile = aa_cred_profile(cred);
  142. if (!unconfined(profile)) {
  143. struct inode *inode = file->f_path.dentry->d_inode;
  144. @@ -646,6 +668,14 @@ static struct security_operations apparmor_ops = {
  145. .getprocattr = apparmor_getprocattr,
  146. .setprocattr = apparmor_setprocattr,
  147. +#ifdef CONFIG_GRAPHENE
  148. + .socket_bind = graphene_socket_bind,
  149. + .socket_listen = graphene_socket_listen,
  150. + .socket_connect = graphene_socket_connect,
  151. + .socket_sendmsg = graphene_socket_sendmsg,
  152. + .socket_recvmsg = graphene_socket_recvmsg,
  153. +#endif
  154. +
  155. .cred_alloc_blank = apparmor_cred_alloc_blank,
  156. .cred_free = apparmor_cred_free,
  157. .cred_prepare = apparmor_cred_prepare,
  158. @@ -657,6 +687,10 @@ static struct security_operations apparmor_ops = {
  159. .bprm_secureexec = apparmor_bprm_secureexec,
  160. .task_setrlimit = apparmor_task_setrlimit,
  161. +
  162. +#ifdef CONFIG_GRAPHENE
  163. + .task_kill = graphene_task_kill,
  164. +#endif
  165. };
  166. /*