• R/O
  • SSH
  • HTTPS

akari: Commit


Commit MetaInfo

Revision587 (tree)
Time2018-03-26 22:46:16
Authorkumaneko

Log Message

Fix wrong probe_kernel_write() usage.

Change Summary

Incremental Difference

--- branches/kportreserve/kpr.c (revision 586)
+++ branches/kportreserve/kpr.c (revision 587)
@@ -861,25 +861,21 @@
861861
862862 static bool __init check_ro_pages(struct security_hook_heads *hooks)
863863 {
864- struct list_head *list = (struct list_head *) hooks;
864+ struct list_head *list = &hooks->capable;
865865
866- if (!probe_kernel_write(&list->next, list->next, sizeof(void *)))
866+ if (!probe_kernel_write(list, list, sizeof(void *)))
867867 return true;
868868 {
869- const unsigned int idx =
870- ((unsigned long) kpr_hook.head - (unsigned long) hooks)
871- / sizeof(struct list_head);
872- struct list_head *self = &list[idx];
873- struct list_head *prev = self->prev;
869+ struct list_head *head = kpr_hook.head;
870+ struct security_hook_list *shp;
874871
875- if (!lsm_test_page_ro(&prev->next) ||
876- !lsm_test_page_ro(&self->prev))
872+ if (!lsm_test_page_ro(&head->next) ||
873+ !lsm_test_page_ro(&head->prev))
877874 return false;
878- if (!list_empty(self) &&
879- !lsm_test_page_ro(&list_last_entry
880- (self, struct security_hook_list,
881- list)->hook))
882- return false;
875+ list_for_each_entry(shp, head, list)
876+ if (!lsm_test_page_ro(&shp->list.next) ||
877+ !lsm_test_page_ro(&shp->list.prev))
878+ return false;
883879 }
884880 return true;
885881 }
@@ -886,9 +882,9 @@
886882 #else
887883 static bool __init check_ro_pages(struct security_hook_heads *hooks)
888884 {
889- return !probe_kernel_write(&((struct list_head *) hooks)->next,
890- ((struct list_head *) hooks)->next,
891- sizeof(void *));
885+ struct list_head *list = &hooks->capable;
886+
887+ return !probe_kernel_write(list, list, sizeof(void *));
892888 }
893889 #endif
894890 #endif
--- branches/tasktracker/tt.c (revision 586)
+++ branches/tasktracker/tt.c (revision 587)
@@ -658,26 +658,21 @@
658658 static bool __init check_ro_pages(struct security_hook_heads *hooks)
659659 {
660660 int i;
661- struct list_head *list = (struct list_head *) hooks;
661+ struct list_head *list = &hooks->capable;
662662
663- if (!probe_kernel_write(&list->next, list->next, sizeof(void *)))
663+ if (!probe_kernel_write(list, list, sizeof(void *)))
664664 return true;
665665 for (i = 0; i < ARRAY_SIZE(tt_hooks); i++) {
666- const unsigned int idx =
667- ((unsigned long) tt_hooks[i].head
668- - (unsigned long) hooks)
669- / sizeof(struct list_head);
670- struct list_head *self = &list[idx];
671- struct list_head *prev = self->prev;
666+ struct list_head *head = tt_hooks[i].head;
667+ struct security_hook_list *shp;
672668
673- if (!lsm_test_page_ro(&prev->next) ||
674- !lsm_test_page_ro(&self->prev))
669+ if (!lsm_test_page_ro(&head->next) ||
670+ !lsm_test_page_ro(&head->prev))
675671 return false;
676- if (!list_empty(self) &&
677- !lsm_test_page_ro(&list_last_entry
678- (self, struct security_hook_list,
679- list)->hook))
680- return false;
672+ list_for_each_entry(shp, head, list)
673+ if (!lsm_test_page_ro(&shp->list.next) ||
674+ !lsm_test_page_ro(&shp->list.prev))
675+ return false;
681676 }
682677 return true;
683678 }
@@ -684,9 +679,9 @@
684679 #else
685680 static bool __init check_ro_pages(struct security_hook_heads *hooks)
686681 {
687- return !probe_kernel_write(&((struct list_head *) hooks)->next,
688- ((struct list_head *) hooks)->next,
689- sizeof(void *));
682+ struct list_head *list = &hooks->capable;
683+
684+ return !probe_kernel_write(list, list, sizeof(void *));
690685 }
691686 #endif
692687 #endif
--- trunk/akari/lsm-4.12.c (revision 586)
+++ trunk/akari/lsm-4.12.c (revision 587)
@@ -1068,26 +1068,21 @@
10681068 static bool __init check_ro_pages(struct security_hook_heads *hooks)
10691069 {
10701070 int i;
1071- struct list_head *list = (struct list_head *) hooks;
1071+ struct list_head *list = &hooks->capable;
10721072
1073- if (!probe_kernel_write(&list->next, list->next, sizeof(void *)))
1073+ if (!probe_kernel_write(list, list, sizeof(void *)))
10741074 return true;
10751075 for (i = 0; i < ARRAY_SIZE(akari_hooks); i++) {
1076- const unsigned int idx =
1077- ((unsigned long) akari_hooks[i].head
1078- - (unsigned long) hooks)
1079- / sizeof(struct list_head);
1080- struct list_head *self = &list[idx];
1081- struct list_head *prev = self->prev;
1076+ struct list_head *head = akari_hooks[i].head;
1077+ struct security_hook_list *shp;
10821078
1083- if (!lsm_test_page_ro(&prev->next) ||
1084- !lsm_test_page_ro(&self->prev))
1079+ if (!lsm_test_page_ro(&head->next) ||
1080+ !lsm_test_page_ro(&head->prev))
10851081 return false;
1086- if (!list_empty(self) &&
1087- !lsm_test_page_ro(&list_last_entry
1088- (self, struct security_hook_list,
1089- list)->hook))
1090- return false;
1082+ list_for_each_entry(shp, head, list)
1083+ if (!lsm_test_page_ro(&shp->list.next) ||
1084+ !lsm_test_page_ro(&shp->list.prev))
1085+ return false;
10911086 }
10921087 return true;
10931088 }
@@ -1094,9 +1089,9 @@
10941089 #else
10951090 static bool __init check_ro_pages(struct security_hook_heads *hooks)
10961091 {
1097- return !probe_kernel_write(&((struct list_head *) hooks)->next,
1098- ((struct list_head *) hooks)->next,
1099- sizeof(void *));
1092+ struct list_head *list = &hooks->capable;
1093+
1094+ return !probe_kernel_write(list, list, sizeof(void *));
11001095 }
11011096 #endif
11021097 #endif
Show on old repository browser