• R/O
  • SSH
  • HTTPS

caitsith: コミット


コミットメタ情報

リビジョン85 (tree)
日時2013-02-11 12:22:07
作者kumaneko

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- trunk/caitsith-patch/caitsith/lsm.c (revision 84)
+++ trunk/caitsith-patch/caitsith/lsm.c (revision 85)
@@ -94,6 +94,20 @@
9494 #define CS_INODE_HOOK_HAS_MNT
9595 #endif
9696
97+#if !defined(CONFIG_CAITSITH_DEBUG)
98+#define cs_debug_trace(pos) do { } while (0)
99+#else
100+#define cs_debug_trace(pos) \
101+ do { \
102+ static bool done; \
103+ if (!done) { \
104+ printk(KERN_INFO \
105+ "CAITSITH: Debug trace: " pos " of 4\n"); \
106+ done = true; \
107+ } \
108+ } while (0)
109+#endif
110+
97111 /**
98112 * cs_clear_execve - Release memory used by do_execve().
99113 *
@@ -146,17 +160,7 @@
146160 * immediately after do_execve() has failed.
147161 */
148162 if (ptr->pid && (ptr->cs_flags & CS_TASK_IS_IN_EXECVE)) {
149-#ifdef CONFIG_CAITSITH_DEBUG
150- static bool done;
151- if (!done) {
152- printk(KERN_INFO "CAITSITH: Decrementing "
153- "cs_in_execve_tasks counter "
154- "because some \"struct task_struct\" has "
155- "exit()ed immediately after do_execve() has "
156- "failed.\n");
157- done = true;
158- }
159-#endif
163+ cs_debug_trace("1");
160164 atomic_dec(&cs_in_execve_tasks);
161165 }
162166 #else
@@ -167,17 +171,7 @@
167171 * immediately after do_execve() has failed.
168172 */
169173 if (ptr->pid && ptr->cred) {
170-#ifdef CONFIG_CAITSITH_DEBUG
171- static bool done;
172- if (!done) {
173- printk(KERN_INFO "CAITSITH: Dropping refcount on "
174- "\"struct cred\" in \"struct linux_binprm\" "
175- "because some \"struct task_struct\" has "
176- "exit()ed immediately after do_execve() has "
177- "failed.\n");
178- done = true;
179- }
180-#endif
174+ cs_debug_trace("1");
181175 put_cred(ptr->cred);
182176 atomic_dec(&cs_in_execve_tasks);
183177 }
@@ -187,27 +181,11 @@
187181 * drop refcount obtained by get_pid() in cs_find_task_security().
188182 */
189183 if (ptr->pid) {
190-#ifdef CONFIG_CAITSITH_DEBUG
191- static bool done;
192- if (!done) {
193- printk(KERN_INFO "CAITSITH: Dropping refcount on "
194- "\"struct pid\".\n");
195- done = true;
196- }
197-#endif
184+ cs_debug_trace("2");
198185 put_pid(ptr->pid);
199186 }
200187 if (r) {
201-#ifdef CONFIG_CAITSITH_DEBUG
202- static bool done;
203- if (!done) {
204- printk(KERN_INFO "CAITSITH: Releasing memory in "
205- "\"struct cs_request_info\" because some "
206- "\"struct task_struct\" has exit()ed "
207- "immediately after do_execve() has failed.\n");
208- done = true;
209- }
210-#endif
188+ cs_debug_trace("3");
211189 kfree(r->handler_path);
212190 kfree(r);
213191 }
@@ -2741,15 +2719,7 @@
27412719 if (task == current &&
27422720 (ptr->cs_flags & CS_TASK_IS_IN_EXECVE) &&
27432721 !current->in_execve) {
2744-#ifdef CONFIG_CAITSITH_DEBUG
2745- static bool done;
2746- if (!done) {
2747- printk(KERN_INFO "CAITSITH: Reverting domain "
2748- "transition because do_execve() has "
2749- "failed.\n");
2750- done = true;
2751- }
2752-#endif
2722+ cs_debug_trace("4");
27532723 cs_clear_execve(-1, ptr);
27542724 }
27552725 #else
@@ -2785,15 +2755,7 @@
27852755 */
27862756 if (task == current && ptr->cred &&
27872757 atomic_read(&ptr->cred->usage) == 1) {
2788-#ifdef CONFIG_CAITSITH_DEBUG
2789- static bool done;
2790- if (!done) {
2791- printk(KERN_INFO "CAITSITH: Reverting domain "
2792- "transition because do_execve() has "
2793- "failed.\n");
2794- done = true;
2795- }
2796-#endif
2758+ cs_debug_trace("4");
27972759 cs_clear_execve(-1, ptr);
27982760 }
27992761 #endif
--- trunk/caitsith-patch/caitsith/mclsm.c (revision 84)
+++ trunk/caitsith-patch/caitsith/mclsm.c (revision 85)
@@ -52,6 +52,20 @@
5252 /* Original hooks. */
5353 static struct security_operations original_security_ops;
5454
55+#if !defined(CONFIG_CAITSITH_DEBUG)
56+#define cs_debug_trace(pos) do { } while (0)
57+#else
58+#define cs_debug_trace(pos) \
59+ do { \
60+ static bool done; \
61+ if (!done) { \
62+ printk(KERN_INFO \
63+ "CAITSITH: Debug trace: " pos " of 4\n"); \
64+ done = true; \
65+ } \
66+ } while (0)
67+#endif
68+
5569 /**
5670 * cs_clear_execve - Release memory used by do_execve().
5771 *
@@ -91,17 +105,7 @@
91105 * immediately after do_execve() has failed.
92106 */
93107 if (ptr->pid && (ptr->cs_flags & CS_TASK_IS_IN_EXECVE)) {
94-#ifdef CONFIG_CAITSITH_DEBUG
95- static bool done;
96- if (!done) {
97- printk(KERN_INFO "CAITSITH: Decrementing "
98- "cs_in_execve_tasks counter "
99- "because some \"struct task_struct\" has "
100- "exit()ed immediately after do_execve() has "
101- "failed.\n");
102- done = true;
103- }
104-#endif
108+ cs_debug_trace("1");
105109 atomic_dec(&cs_in_execve_tasks);
106110 }
107111 /*
@@ -109,27 +113,11 @@
109113 * drop refcount obtained by get_pid() in cs_find_task_security().
110114 */
111115 if (ptr->pid) {
112-#ifdef CONFIG_CAITSITH_DEBUG
113- static bool done;
114- if (!done) {
115- printk(KERN_INFO "CAITSITH: Dropping refcount on "
116- "\"struct pid\".\n");
117- done = true;
118- }
119-#endif
116+ cs_debug_trace("2");
120117 put_pid(ptr->pid);
121118 }
122119 if (r) {
123-#ifdef CONFIG_CAITSITH_DEBUG
124- static bool done;
125- if (!done) {
126- printk(KERN_INFO "CAITSITH: Releasing memory in "
127- "\"struct cs_execve\" because some "
128- "\"struct task_struct\" has exit()ed "
129- "immediately after do_execve() has failed.\n");
130- done = true;
131- }
132-#endif
120+ cs_debug_trace("3");
133121 kfree(r->handler_path);
134122 kfree(r);
135123 }
@@ -1215,9 +1203,9 @@
12151203 add_security_ops(op, lsm_list); \
12161204 else { \
12171205 struct security_operations *ops = \
1218- container_of(lsm_list, \
1219- struct security_operations, \
1220- list[0]); \
1206+ list_first_entry(&lsm_list[lsm_##op], \
1207+ typeof(*ops), \
1208+ list[lsm_##op]); \
12211209 original_security_ops.op = ops->op; \
12221210 smp_wmb(); \
12231211 ops->op = cs_##op; \
@@ -1428,15 +1416,7 @@
14281416 if (task == current &&
14291417 (ptr->cs_flags & CS_TASK_IS_IN_EXECVE) &&
14301418 !current->in_execve) {
1431-#ifdef CONFIG_CAITSITH_DEBUG
1432- static bool done;
1433- if (!done) {
1434- printk(KERN_INFO "CAITSITH: Reverting domain "
1435- "transition because do_execve() has "
1436- "failed.\n");
1437- done = true;
1438- }
1439-#endif
1419+ cs_debug_trace("4");
14401420 cs_clear_execve(-1, ptr);
14411421 }
14421422 return ptr;
旧リポジトリブラウザで表示