debuggers.hg

view xen/xsm/dummy.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 4063894c0c1f
children
line source
1 /*
2 * This work is based on the LSM implementation in Linux 2.6.13.4.
3 *
4 * Author: George Coker, <gscoker@alpha.ncsc.mil>
5 *
6 * Contributors: Michael LeMay, <mdlemay@epoch.ncsc.mil>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
11 */
13 #include <xen/sched.h>
14 #include <xsm/xsm.h>
16 static void dummy_security_domaininfo(struct domain *d,
17 struct xen_domctl_getdomaininfo *info)
18 {
19 return;
20 }
22 static int dummy_setvcpucontext(struct domain *d)
23 {
24 return 0;
25 }
27 static int dummy_pausedomain (struct domain *d)
28 {
29 return 0;
30 }
32 static int dummy_unpausedomain (struct domain *d)
33 {
34 return 0;
35 }
37 static int dummy_resumedomain (struct domain *d)
38 {
39 return 0;
40 }
42 static int dummy_domain_create(struct domain *d, u32 ssidref)
43 {
44 return 0;
45 }
47 static int dummy_max_vcpus(struct domain *d)
48 {
49 return 0;
50 }
52 static int dummy_destroydomain (struct domain *d)
53 {
54 return 0;
55 }
57 static int dummy_vcpuaffinity (int cmd, struct domain *d)
58 {
59 return 0;
60 }
62 static int dummy_scheduler (struct domain *d)
63 {
64 return 0;
65 }
67 static int dummy_getdomaininfo (struct domain *d)
68 {
69 return 0;
70 }
72 static int dummy_getvcpucontext (struct domain *d)
73 {
74 return 0;
75 }
77 static int dummy_getvcpuinfo (struct domain *d)
78 {
79 return 0;
80 }
82 static int dummy_domain_settime (struct domain *d)
83 {
84 return 0;
85 }
87 static int dummy_set_target (struct domain *d, struct domain *e)
88 {
89 return 0;
90 }
92 static int dummy_tbufcontrol (void)
93 {
94 return 0;
95 }
97 static int dummy_readconsole (uint32_t clear)
98 {
99 return 0;
100 }
102 static int dummy_sched_id (void)
103 {
104 return 0;
105 }
107 static int dummy_setdomainmaxmem (struct domain *d)
108 {
109 return 0;
110 }
112 static int dummy_setdomainhandle (struct domain *d)
113 {
114 return 0;
115 }
117 static int dummy_setdebugging (struct domain *d)
118 {
119 return 0;
120 }
122 static int dummy_perfcontrol (void)
123 {
124 return 0;
125 }
127 static int dummy_debug_keys (void)
128 {
129 return 0;
130 }
132 static int dummy_getcpuinfo (void)
133 {
134 return 0;
135 }
137 static int dummy_get_pmstat (void)
138 {
139 return 0;
140 }
142 static int dummy_pm_op (void)
143 {
144 return 0;
145 }
147 static int dummy_availheap (void)
148 {
149 return 0;
150 }
152 static int dummy_alloc_security_domain (struct domain *d)
153 {
154 return 0;
155 }
157 static void dummy_free_security_domain (struct domain *d)
158 {
159 return;
160 }
162 static int dummy_grant_mapref (struct domain *d1, struct domain *d2,
163 uint32_t flags)
164 {
165 return 0;
166 }
168 static int dummy_grant_unmapref (struct domain *d1, struct domain *d2)
169 {
170 return 0;
171 }
173 static int dummy_grant_setup (struct domain *d1, struct domain *d2)
174 {
175 return 0;
176 }
178 static int dummy_grant_transfer (struct domain *d1, struct domain *d2)
179 {
180 return 0;
181 }
183 static int dummy_grant_copy (struct domain *d1, struct domain *d2)
184 {
185 return 0;
186 }
188 static int dummy_grant_query_size (struct domain *d1, struct domain *d2)
189 {
190 return 0;
191 }
193 static int dummy_memory_adjust_reservation (struct domain *d1,
194 struct domain *d2)
195 {
196 return 0;
197 }
199 static int dummy_memory_stat_reservation (struct domain *d1, struct domain *d2)
200 {
201 return 0;
202 }
204 static int dummy_console_io (struct domain *d, int cmd)
205 {
206 return 0;
207 }
209 static int dummy_profile (struct domain *d, int op)
210 {
211 return 0;
212 }
214 static int dummy_kexec (void)
215 {
216 return 0;
217 }
219 static int dummy_schedop_shutdown (struct domain *d1, struct domain *d2)
220 {
221 return 0;
222 }
224 static int dummy_memory_pin_page(struct domain *d, struct page_info *page)
225 {
226 return 0;
227 }
229 static int dummy_evtchn_unbound (struct domain *d, struct evtchn *chn,
230 domid_t id2)
231 {
232 return 0;
233 }
235 static int dummy_evtchn_interdomain (struct domain *d1, struct evtchn
236 *chan1, struct domain *d2, struct evtchn *chan2)
237 {
238 return 0;
239 }
241 static void dummy_evtchn_close_post (struct evtchn *chn)
242 {
243 return;
244 }
246 static int dummy_evtchn_send (struct domain *d, struct evtchn *chn)
247 {
248 return 0;
249 }
251 static int dummy_evtchn_status (struct domain *d, struct evtchn *chn)
252 {
253 return 0;
254 }
256 static int dummy_evtchn_reset (struct domain *d1, struct domain *d2)
257 {
258 return 0;
259 }
261 static int dummy_alloc_security_evtchn (struct evtchn *chn)
262 {
263 return 0;
264 }
266 static void dummy_free_security_evtchn (struct evtchn *chn)
267 {
268 return;
269 }
271 static long dummy___do_xsm_op(XEN_GUEST_HANDLE(xsm_op_t) op)
272 {
273 return -ENOSYS;
274 }
276 static int dummy_add_range (struct domain *d, char *name, unsigned long s, unsigned long e)
277 {
278 return 0;
279 }
281 static int dummy_remove_range (struct domain *d, char *name, unsigned long s,
282 unsigned long e)
283 {
284 return 0;
285 }
287 #ifdef CONFIG_X86
288 static int dummy_shadow_control (struct domain *d, uint32_t op)
289 {
290 return 0;
291 }
293 static int dummy_getpageframeinfo (struct page_info *page)
294 {
295 return 0;
296 }
298 static int dummy_getmemlist (struct domain *d)
299 {
300 return 0;
301 }
303 static int dummy_hypercall_init (struct domain *d)
304 {
305 return 0;
306 }
308 static int dummy_hvmcontext (struct domain *d, uint32_t cmd)
309 {
310 return 0;
311 }
313 static int dummy_address_size (struct domain *d, uint32_t cmd)
314 {
315 return 0;
316 }
318 static int dummy_machine_address_size (struct domain *d, uint32_t cmd)
319 {
320 return 0;
321 }
323 static int dummy_hvm_param (struct domain *d, unsigned long op)
324 {
325 return 0;
326 }
328 static int dummy_hvm_set_pci_intx_level (struct domain *d)
329 {
330 return 0;
331 }
333 static int dummy_hvm_set_isa_irq_level (struct domain *d)
334 {
335 return 0;
336 }
338 static int dummy_hvm_set_pci_link_route (struct domain *d)
339 {
340 return 0;
341 }
343 static int dummy_apic (struct domain *d, int cmd)
344 {
345 return 0;
346 }
348 static int dummy_assign_vector (struct domain *d, uint32_t pirq)
349 {
350 return 0;
351 }
353 static int dummy_xen_settime (void)
354 {
355 return 0;
356 }
358 static int dummy_memtype (uint32_t access)
359 {
360 return 0;
361 }
363 static int dummy_microcode (void)
364 {
365 return 0;
366 }
368 static int dummy_physinfo (void)
369 {
370 return 0;
371 }
373 static int dummy_platform_quirk (uint32_t quirk)
374 {
375 return 0;
376 }
378 static int dummy_firmware_info (void)
379 {
380 return 0;
381 }
383 static int dummy_acpi_sleep (void)
384 {
385 return 0;
386 }
388 static int dummy_change_freq (void)
389 {
390 return 0;
391 }
393 static int dummy_getidletime (void)
394 {
395 return 0;
396 }
398 static int dummy_machine_memory_map (void)
399 {
400 return 0;
401 }
403 static int dummy_domain_memory_map (struct domain *d)
404 {
405 return 0;
406 }
408 static int dummy_mmu_normal_update (struct domain *d, struct domain *f,
409 intpte_t fpte)
410 {
411 return 0;
412 }
414 static int dummy_mmu_machphys_update (struct domain *d, unsigned long mfn)
415 {
416 return 0;
417 }
419 static int dummy_update_va_mapping (struct domain *d, struct domain *f,
420 l1_pgentry_t pte)
421 {
422 return 0;
423 }
425 static int dummy_add_to_physmap (struct domain *d1, struct domain *d2)
426 {
427 return 0;
428 }
430 static int dummy_sendtrigger (struct domain *d)
431 {
432 return 0;
433 }
435 static int dummy_test_assign_device (uint32_t machine_bdf)
436 {
437 return 0;
438 }
440 static int dummy_assign_device (struct domain *d, uint32_t machine_bdf)
441 {
442 return 0;
443 }
445 static int dummy_deassign_device (struct domain *d, uint32_t machine_bdf)
446 {
447 return 0;
448 }
450 static int dummy_bind_pt_irq (struct domain *d, struct xen_domctl_bind_pt_irq *bind)
451 {
452 return 0;
453 }
455 static int dummy_pin_mem_cacheattr (struct domain *d)
456 {
457 return 0;
458 }
460 static int dummy_ext_vcpucontext (struct domain *d, uint32_t cmd)
461 {
462 return 0;
463 }
465 #endif
467 struct xsm_operations dummy_xsm_ops;
469 #define set_to_dummy_if_null(ops, function) \
470 do { \
471 if ( !ops->function ) \
472 { \
473 ops->function = dummy_##function; \
474 dprintk(XENLOG_DEBUG, "Had to override the " #function \
475 " security operation with the dummy one.\n"); \
476 } \
477 } while (0)
479 void xsm_fixup_ops (struct xsm_operations *ops)
480 {
481 set_to_dummy_if_null(ops, security_domaininfo);
482 set_to_dummy_if_null(ops, setvcpucontext);
483 set_to_dummy_if_null(ops, pausedomain);
484 set_to_dummy_if_null(ops, unpausedomain);
485 set_to_dummy_if_null(ops, resumedomain);
486 set_to_dummy_if_null(ops, domain_create);
487 set_to_dummy_if_null(ops, max_vcpus);
488 set_to_dummy_if_null(ops, destroydomain);
489 set_to_dummy_if_null(ops, vcpuaffinity);
490 set_to_dummy_if_null(ops, scheduler);
491 set_to_dummy_if_null(ops, getdomaininfo);
492 set_to_dummy_if_null(ops, getvcpucontext);
493 set_to_dummy_if_null(ops, getvcpuinfo);
494 set_to_dummy_if_null(ops, domain_settime);
495 set_to_dummy_if_null(ops, set_target);
496 set_to_dummy_if_null(ops, tbufcontrol);
497 set_to_dummy_if_null(ops, readconsole);
498 set_to_dummy_if_null(ops, sched_id);
499 set_to_dummy_if_null(ops, setdomainmaxmem);
500 set_to_dummy_if_null(ops, setdomainhandle);
501 set_to_dummy_if_null(ops, setdebugging);
502 set_to_dummy_if_null(ops, perfcontrol);
503 set_to_dummy_if_null(ops, debug_keys);
504 set_to_dummy_if_null(ops, getcpuinfo);
505 set_to_dummy_if_null(ops, pm_op);
506 set_to_dummy_if_null(ops, get_pmstat);
507 set_to_dummy_if_null(ops, availheap);
509 set_to_dummy_if_null(ops, evtchn_unbound);
510 set_to_dummy_if_null(ops, evtchn_interdomain);
511 set_to_dummy_if_null(ops, evtchn_close_post);
512 set_to_dummy_if_null(ops, evtchn_send);
513 set_to_dummy_if_null(ops, evtchn_status);
514 set_to_dummy_if_null(ops, evtchn_reset);
516 set_to_dummy_if_null(ops, grant_mapref);
517 set_to_dummy_if_null(ops, grant_unmapref);
518 set_to_dummy_if_null(ops, grant_setup);
519 set_to_dummy_if_null(ops, grant_transfer);
520 set_to_dummy_if_null(ops, grant_copy);
521 set_to_dummy_if_null(ops, grant_query_size);
523 set_to_dummy_if_null(ops, alloc_security_domain);
524 set_to_dummy_if_null(ops, free_security_domain);
525 set_to_dummy_if_null(ops, alloc_security_evtchn);
526 set_to_dummy_if_null(ops, free_security_evtchn);
528 set_to_dummy_if_null(ops, memory_adjust_reservation);
529 set_to_dummy_if_null(ops, memory_stat_reservation);
530 set_to_dummy_if_null(ops, memory_pin_page);
532 set_to_dummy_if_null(ops, console_io);
534 set_to_dummy_if_null(ops, profile);
536 set_to_dummy_if_null(ops, kexec);
537 set_to_dummy_if_null(ops, schedop_shutdown);
539 set_to_dummy_if_null(ops, add_range);
540 set_to_dummy_if_null(ops, remove_range);
542 set_to_dummy_if_null(ops, __do_xsm_op);
544 #ifdef CONFIG_X86
545 set_to_dummy_if_null(ops, shadow_control);
546 set_to_dummy_if_null(ops, getpageframeinfo);
547 set_to_dummy_if_null(ops, getmemlist);
548 set_to_dummy_if_null(ops, hypercall_init);
549 set_to_dummy_if_null(ops, hvmcontext);
550 set_to_dummy_if_null(ops, address_size);
551 set_to_dummy_if_null(ops, machine_address_size);
552 set_to_dummy_if_null(ops, hvm_param);
553 set_to_dummy_if_null(ops, hvm_set_pci_intx_level);
554 set_to_dummy_if_null(ops, hvm_set_isa_irq_level);
555 set_to_dummy_if_null(ops, hvm_set_pci_link_route);
556 set_to_dummy_if_null(ops, apic);
557 set_to_dummy_if_null(ops, assign_vector);
558 set_to_dummy_if_null(ops, xen_settime);
559 set_to_dummy_if_null(ops, memtype);
560 set_to_dummy_if_null(ops, microcode);
561 set_to_dummy_if_null(ops, physinfo);
562 set_to_dummy_if_null(ops, platform_quirk);
563 set_to_dummy_if_null(ops, firmware_info);
564 set_to_dummy_if_null(ops, acpi_sleep);
565 set_to_dummy_if_null(ops, change_freq);
566 set_to_dummy_if_null(ops, getidletime);
567 set_to_dummy_if_null(ops, machine_memory_map);
568 set_to_dummy_if_null(ops, domain_memory_map);
569 set_to_dummy_if_null(ops, mmu_normal_update);
570 set_to_dummy_if_null(ops, mmu_machphys_update);
571 set_to_dummy_if_null(ops, update_va_mapping);
572 set_to_dummy_if_null(ops, add_to_physmap);
573 set_to_dummy_if_null(ops, sendtrigger);
574 set_to_dummy_if_null(ops, test_assign_device);
575 set_to_dummy_if_null(ops, assign_device);
576 set_to_dummy_if_null(ops, deassign_device);
577 set_to_dummy_if_null(ops, bind_pt_irq);
578 set_to_dummy_if_null(ops, pin_mem_cacheattr);
579 set_to_dummy_if_null(ops, ext_vcpucontext);
580 #endif
581 }