1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org> 4 * 5 * This is the online Runtime Verification (RV) interface. 6 * 7 * RV is a lightweight (yet rigorous) method that complements classical 8 * exhaustive verification techniques (such as model checking and 9 * theorem proving) with a more practical approach to complex systems. 10 * 11 * RV works by analyzing the trace of the system's actual execution, 12 * comparing it against a formal specification of the system behavior. 13 * RV can give precise information on the runtime behavior of the 14 * monitored system while enabling the reaction for unexpected 15 * events, avoiding, for example, the propagation of a failure on 16 * safety-critical systems. 17 * 18 * The development of this interface roots in the development of the 19 * paper: 20 * 21 * De Oliveira, Daniel Bristot; Cucinotta, Tommaso; De Oliveira, Romulo 22 * Silva. Efficient formal verification for the Linux kernel. In: 23 * International Conference on Software Engineering and Formal Methods. 24 * Springer, Cham, 2019. p. 315-332. 25 * 26 * And: 27 * 28 * De Oliveira, Daniel Bristot, et al. Automata-based formal analysis 29 * and verification of the real-time Linux kernel. PhD Thesis, 2020. 30 * 31 * == Runtime monitor interface == 32 * 33 * A monitor is the central part of the runtime verification of a system. 34 * 35 * The monitor stands in between the formal specification of the desired 36 * (or undesired) behavior, and the trace of the actual system. 37 * 38 * In Linux terms, the runtime verification monitors are encapsulated 39 * inside the "RV monitor" abstraction. A RV monitor includes a reference 40 * model of the system, a set of instances of the monitor (per-cpu monitor, 41 * per-task monitor, and so on), and the helper functions that glue the 42 * monitor to the system via trace. Generally, a monitor includes some form 43 * of trace output as a reaction for event parsing and exceptions, 44 * as depicted below: 45 * 46 * Linux +----- RV Monitor ----------------------------------+ Formal 47 * Realm | | Realm 48 * +-------------------+ +----------------+ +-----------------+ 49 * | Linux kernel | | Monitor | | Reference | 50 * | Tracing | -> | Instance(s) | <- | Model | 51 * | (instrumentation) | | (verification) | | (specification) | 52 * +-------------------+ +----------------+ +-----------------+ 53 * | | | 54 * | V | 55 * | +----------+ | 56 * | | Reaction | | 57 * | +--+--+--+-+ | 58 * | | | | | 59 * | | | +-> trace output ? | 60 * +------------------------|--|----------------------+ 61 * | +----> panic ? 62 * +-------> <user-specified> 63 * 64 * This file implements the interface for loading RV monitors, and 65 * to control the verification session. 66 * 67 * == Registering monitors == 68 * 69 * The struct rv_monitor defines a set of callback functions to control 70 * a verification session. For instance, when a given monitor is enabled, 71 * the "enable" callback function is called to hook the instrumentation 72 * functions to the kernel trace events. The "disable" function is called 73 * when disabling the verification session. 74 * 75 * A RV monitor is registered via: 76 * int rv_register_monitor(struct rv_monitor *monitor); 77 * And unregistered via: 78 * int rv_unregister_monitor(struct rv_monitor *monitor); 79 * 80 * == User interface == 81 * 82 * The user interface resembles kernel tracing interface. It presents 83 * these files: 84 * 85 * "available_monitors" 86 * - List the available monitors, one per line. 87 * 88 * For example: 89 * # cat available_monitors 90 * wip 91 * wwnr 92 * 93 * "enabled_monitors" 94 * - Lists the enabled monitors, one per line; 95 * - Writing to it enables a given monitor; 96 * - Writing a monitor name with a '!' prefix disables it; 97 * - Truncating the file disables all enabled monitors. 98 * 99 * For example: 100 * # cat enabled_monitors 101 * # echo wip > enabled_monitors 102 * # echo wwnr >> enabled_monitors 103 * # cat enabled_monitors 104 * wip 105 * wwnr 106 * # echo '!wip' >> enabled_monitors 107 * # cat enabled_monitors 108 * wwnr 109 * # echo > enabled_monitors 110 * # cat enabled_monitors 111 * # 112 * 113 * Note that more than one monitor can be enabled concurrently. 114 * 115 * "monitoring_on" 116 * - It is an on/off general switcher for monitoring. Note 117 * that it does not disable enabled monitors or detach events, 118 * but stops the per-entity monitors from monitoring the events 119 * received from the instrumentation. It resembles the "tracing_on" 120 * switcher. 121 * 122 * "monitors/" 123 * Each monitor will have its own directory inside "monitors/". There 124 * the monitor specific files will be presented. 125 * The "monitors/" directory resembles the "events" directory on 126 * tracefs. 127 * 128 * For example: 129 * # cd monitors/wip/ 130 * # ls 131 * desc enable 132 * # cat desc 133 * auto-generated wakeup in preemptive monitor. 134 * # cat enable 135 * 0 136 * 137 * For further information, see: 138 * Documentation/trace/rv/runtime-verification.rst 139 */ 140 141 #include <linux/kernel.h> 142 #include <linux/module.h> 143 #include <linux/init.h> 144 #include <linux/slab.h> 145 146 #ifdef CONFIG_RV_MON_EVENTS 147 #define CREATE_TRACE_POINTS 148 #include <rv_trace.h> 149 #endif 150 151 #include "rv.h" 152 153 DEFINE_MUTEX(rv_interface_lock); 154 155 static struct rv_interface rv_root; 156 157 struct dentry *get_monitors_root(void) 158 { 159 return rv_root.monitors_dir; 160 } 161 162 /* 163 * Interface for the monitor register. 164 */ 165 LIST_HEAD(rv_monitors_list); 166 167 static int task_monitor_count; 168 static bool task_monitor_slots[CONFIG_RV_PER_TASK_MONITORS]; 169 170 int rv_get_task_monitor_slot(void) 171 { 172 int i; 173 174 lockdep_assert_held(&rv_interface_lock); 175 176 if (task_monitor_count == CONFIG_RV_PER_TASK_MONITORS) 177 return -EBUSY; 178 179 task_monitor_count++; 180 181 for (i = 0; i < CONFIG_RV_PER_TASK_MONITORS; i++) { 182 if (task_monitor_slots[i] == false) { 183 task_monitor_slots[i] = true; 184 return i; 185 } 186 } 187 188 WARN_ONCE(1, "RV task_monitor_count and slots are out of sync\n"); 189 190 return -EINVAL; 191 } 192 193 void rv_put_task_monitor_slot(int slot) 194 { 195 lockdep_assert_held(&rv_interface_lock); 196 197 if (slot < 0 || slot >= CONFIG_RV_PER_TASK_MONITORS) { 198 WARN_ONCE(1, "RV releasing an invalid slot!: %d\n", slot); 199 return; 200 } 201 202 WARN_ONCE(!task_monitor_slots[slot], "RV releasing unused task_monitor_slots: %d\n", 203 slot); 204 205 task_monitor_count--; 206 task_monitor_slots[slot] = false; 207 } 208 209 /* 210 * Monitors with a parent are nested, 211 * Monitors without a parent could be standalone or containers. 212 */ 213 bool rv_is_nested_monitor(struct rv_monitor *mon) 214 { 215 return mon->parent != NULL; 216 } 217 218 /* 219 * We set our list to have nested monitors listed after their parent 220 * if a monitor has a child element its a container. 221 * Containers can be also identified based on their function pointers: 222 * as they are not real monitors they do not need function definitions 223 * for enable()/disable(). Use this condition to find empty containers. 224 * Keep both conditions in case we have some non-compliant containers. 225 */ 226 bool rv_is_container_monitor(struct rv_monitor *mon) 227 { 228 struct rv_monitor *next; 229 230 if (list_is_last(&mon->list, &rv_monitors_list)) 231 return false; 232 233 next = list_next_entry(mon, list); 234 235 return next->parent == mon || !mon->enable; 236 } 237 238 /* 239 * This section collects the monitor/ files and folders. 240 */ 241 static ssize_t monitor_enable_read_data(struct file *filp, char __user *user_buf, size_t count, 242 loff_t *ppos) 243 { 244 struct rv_monitor *mon = filp->private_data; 245 const char *buff; 246 247 buff = mon->enabled ? "1\n" : "0\n"; 248 249 return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff)+1); 250 } 251 252 /* 253 * __rv_disable_monitor - disabled an enabled monitor 254 */ 255 static int __rv_disable_monitor(struct rv_monitor *mon, bool sync) 256 { 257 lockdep_assert_held(&rv_interface_lock); 258 259 if (mon->enabled) { 260 mon->enabled = 0; 261 if (mon->disable) 262 mon->disable(); 263 264 /* 265 * Wait for the execution of all events to finish. 266 * Otherwise, the data used by the monitor could 267 * be inconsistent. i.e., if the monitor is re-enabled. 268 */ 269 if (sync) 270 tracepoint_synchronize_unregister(); 271 return 1; 272 } 273 return 0; 274 } 275 276 static void rv_disable_single(struct rv_monitor *mon) 277 { 278 __rv_disable_monitor(mon, true); 279 } 280 281 static int rv_enable_single(struct rv_monitor *mon) 282 { 283 int retval; 284 285 lockdep_assert_held(&rv_interface_lock); 286 287 if (mon->enabled) 288 return 0; 289 290 retval = mon->enable(); 291 292 if (!retval) 293 mon->enabled = 1; 294 295 return retval; 296 } 297 298 static void rv_disable_container(struct rv_monitor *mon) 299 { 300 struct rv_monitor *p = mon; 301 int enabled = 0; 302 303 list_for_each_entry_continue(p, &rv_monitors_list, list) { 304 if (p->parent != mon) 305 break; 306 enabled += __rv_disable_monitor(p, false); 307 } 308 if (enabled) 309 tracepoint_synchronize_unregister(); 310 mon->enabled = 0; 311 } 312 313 static int rv_enable_container(struct rv_monitor *mon) 314 { 315 struct rv_monitor *p = mon; 316 int retval = 0; 317 318 list_for_each_entry_continue(p, &rv_monitors_list, list) { 319 if (retval || p->parent != mon) 320 break; 321 retval = rv_enable_single(p); 322 } 323 if (retval) 324 rv_disable_container(mon); 325 else 326 mon->enabled = 1; 327 return retval; 328 } 329 330 /** 331 * rv_disable_monitor - disable a given runtime monitor 332 * @mon: Pointer to the monitor definition structure. 333 * 334 * Returns 0 on success. 335 */ 336 int rv_disable_monitor(struct rv_monitor *mon) 337 { 338 if (rv_is_container_monitor(mon)) 339 rv_disable_container(mon); 340 else 341 rv_disable_single(mon); 342 343 return 0; 344 } 345 346 /** 347 * rv_enable_monitor - enable a given runtime monitor 348 * @mon: Pointer to the monitor definition structure. 349 * 350 * Returns 0 on success, error otherwise. 351 */ 352 int rv_enable_monitor(struct rv_monitor *mon) 353 { 354 int retval; 355 356 if (rv_is_container_monitor(mon)) 357 retval = rv_enable_container(mon); 358 else 359 retval = rv_enable_single(mon); 360 361 return retval; 362 } 363 364 /* 365 * interface for enabling/disabling a monitor. 366 */ 367 static ssize_t monitor_enable_write_data(struct file *filp, const char __user *user_buf, 368 size_t count, loff_t *ppos) 369 { 370 struct rv_monitor *mon = filp->private_data; 371 int retval; 372 bool val; 373 374 retval = kstrtobool_from_user(user_buf, count, &val); 375 if (retval) 376 return retval; 377 378 guard(mutex)(&rv_interface_lock); 379 380 if (val) 381 retval = rv_enable_monitor(mon); 382 else 383 retval = rv_disable_monitor(mon); 384 385 return retval ? : count; 386 } 387 388 static const struct file_operations interface_enable_fops = { 389 .open = simple_open, 390 .write = monitor_enable_write_data, 391 .read = monitor_enable_read_data, 392 }; 393 394 /* 395 * Interface to read monitors description. 396 */ 397 static ssize_t monitor_desc_read_data(struct file *filp, char __user *user_buf, size_t count, 398 loff_t *ppos) 399 { 400 struct rv_monitor *mon = filp->private_data; 401 char buff[256]; 402 403 memset(buff, 0, sizeof(buff)); 404 405 snprintf(buff, sizeof(buff), "%s\n", mon->description); 406 407 return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff) + 1); 408 } 409 410 static const struct file_operations interface_desc_fops = { 411 .open = simple_open, 412 .read = monitor_desc_read_data, 413 }; 414 415 /* 416 * During the registration of a monitor, this function creates 417 * the monitor dir, where the specific options of the monitor 418 * are exposed. 419 */ 420 static int create_monitor_dir(struct rv_monitor *mon, struct rv_monitor *parent) 421 { 422 struct dentry *root = parent ? parent->root_d : get_monitors_root(); 423 const char *name = mon->name; 424 struct dentry *tmp; 425 int retval; 426 427 mon->root_d = rv_create_dir(name, root); 428 if (!mon->root_d) 429 return -ENOMEM; 430 431 tmp = rv_create_file("enable", RV_MODE_WRITE, mon->root_d, mon, &interface_enable_fops); 432 if (!tmp) { 433 retval = -ENOMEM; 434 goto out_remove_root; 435 } 436 437 tmp = rv_create_file("desc", RV_MODE_READ, mon->root_d, mon, &interface_desc_fops); 438 if (!tmp) { 439 retval = -ENOMEM; 440 goto out_remove_root; 441 } 442 443 retval = reactor_populate_monitor(mon); 444 if (retval) 445 goto out_remove_root; 446 447 return 0; 448 449 out_remove_root: 450 rv_remove(mon->root_d); 451 return retval; 452 } 453 454 /* 455 * Available/Enable monitor shared seq functions. 456 */ 457 static int monitors_show(struct seq_file *m, void *p) 458 { 459 struct rv_monitor *mon = container_of(p, struct rv_monitor, list); 460 461 if (mon->parent) 462 seq_printf(m, "%s:%s\n", mon->parent->name, mon->name); 463 else 464 seq_printf(m, "%s\n", mon->name); 465 return 0; 466 } 467 468 /* 469 * Used by the seq file operations at the end of a read 470 * operation. 471 */ 472 static void monitors_stop(struct seq_file *m, void *p) 473 { 474 mutex_unlock(&rv_interface_lock); 475 } 476 477 /* 478 * Available monitor seq functions. 479 */ 480 static void *available_monitors_start(struct seq_file *m, loff_t *pos) 481 { 482 mutex_lock(&rv_interface_lock); 483 return seq_list_start(&rv_monitors_list, *pos); 484 } 485 486 static void *available_monitors_next(struct seq_file *m, void *p, loff_t *pos) 487 { 488 return seq_list_next(p, &rv_monitors_list, pos); 489 } 490 491 /* 492 * Enable monitor seq functions. 493 */ 494 static void *enabled_monitors_next(struct seq_file *m, void *p, loff_t *pos) 495 { 496 struct rv_monitor *mon = container_of(p, struct rv_monitor, list); 497 498 (*pos)++; 499 500 list_for_each_entry_continue(mon, &rv_monitors_list, list) { 501 if (mon->enabled) 502 return &mon->list; 503 } 504 505 return NULL; 506 } 507 508 static void *enabled_monitors_start(struct seq_file *m, loff_t *pos) 509 { 510 struct list_head *head; 511 loff_t l; 512 513 mutex_lock(&rv_interface_lock); 514 515 if (list_empty(&rv_monitors_list)) 516 return NULL; 517 518 head = &rv_monitors_list; 519 520 for (l = 0; l <= *pos; ) { 521 head = enabled_monitors_next(m, head, &l); 522 if (!head) 523 break; 524 } 525 526 return head; 527 } 528 529 /* 530 * available/enabled monitors seq definition. 531 */ 532 static const struct seq_operations available_monitors_seq_ops = { 533 .start = available_monitors_start, 534 .next = available_monitors_next, 535 .stop = monitors_stop, 536 .show = monitors_show 537 }; 538 539 static const struct seq_operations enabled_monitors_seq_ops = { 540 .start = enabled_monitors_start, 541 .next = enabled_monitors_next, 542 .stop = monitors_stop, 543 .show = monitors_show 544 }; 545 546 /* 547 * available_monitors interface. 548 */ 549 static int available_monitors_open(struct inode *inode, struct file *file) 550 { 551 return seq_open(file, &available_monitors_seq_ops); 552 }; 553 554 static const struct file_operations available_monitors_ops = { 555 .open = available_monitors_open, 556 .read = seq_read, 557 .llseek = seq_lseek, 558 .release = seq_release 559 }; 560 561 /* 562 * enabled_monitors interface. 563 */ 564 static void disable_all_monitors(void) 565 { 566 struct rv_monitor *mon; 567 int enabled = 0; 568 569 guard(mutex)(&rv_interface_lock); 570 571 list_for_each_entry(mon, &rv_monitors_list, list) 572 enabled += __rv_disable_monitor(mon, false); 573 574 if (enabled) { 575 /* 576 * Wait for the execution of all events to finish. 577 * Otherwise, the data used by the monitor could 578 * be inconsistent. i.e., if the monitor is re-enabled. 579 */ 580 tracepoint_synchronize_unregister(); 581 } 582 } 583 584 static int enabled_monitors_open(struct inode *inode, struct file *file) 585 { 586 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) 587 disable_all_monitors(); 588 589 return seq_open(file, &enabled_monitors_seq_ops); 590 }; 591 592 static ssize_t enabled_monitors_write(struct file *filp, const char __user *user_buf, 593 size_t count, loff_t *ppos) 594 { 595 char buff[MAX_RV_MONITOR_NAME_SIZE + 2]; 596 struct rv_monitor *mon; 597 int retval = -EINVAL; 598 bool enable = true; 599 char *ptr, *tmp; 600 int len; 601 602 if (count < 1 || count > MAX_RV_MONITOR_NAME_SIZE + 1) 603 return -EINVAL; 604 605 memset(buff, 0, sizeof(buff)); 606 607 retval = simple_write_to_buffer(buff, sizeof(buff) - 1, ppos, user_buf, count); 608 if (retval < 0) 609 return -EFAULT; 610 611 ptr = strim(buff); 612 613 if (ptr[0] == '!') { 614 enable = false; 615 ptr++; 616 } 617 618 len = strlen(ptr); 619 if (!len) 620 return count; 621 622 guard(mutex)(&rv_interface_lock); 623 624 retval = -EINVAL; 625 626 /* we support 1 nesting level, trim the parent */ 627 tmp = strstr(ptr, ":"); 628 if (tmp) 629 ptr = tmp+1; 630 631 list_for_each_entry(mon, &rv_monitors_list, list) { 632 if (strcmp(ptr, mon->name) != 0) 633 continue; 634 635 /* 636 * Monitor found! 637 */ 638 if (enable) 639 retval = rv_enable_monitor(mon); 640 else 641 retval = rv_disable_monitor(mon); 642 643 if (retval) 644 return retval; 645 return count; 646 } 647 648 return retval; 649 } 650 651 static const struct file_operations enabled_monitors_ops = { 652 .open = enabled_monitors_open, 653 .read = seq_read, 654 .write = enabled_monitors_write, 655 .llseek = seq_lseek, 656 .release = seq_release, 657 }; 658 659 /* 660 * Monitoring on global switcher! 661 */ 662 static bool __read_mostly monitoring_on; 663 664 /** 665 * rv_monitoring_on - checks if monitoring is on 666 * 667 * Returns 1 if on, 0 otherwise. 668 */ 669 bool rv_monitoring_on(void) 670 { 671 return READ_ONCE(monitoring_on); 672 } 673 674 /* 675 * monitoring_on general switcher. 676 */ 677 static ssize_t monitoring_on_read_data(struct file *filp, char __user *user_buf, 678 size_t count, loff_t *ppos) 679 { 680 const char *buff; 681 682 buff = rv_monitoring_on() ? "1\n" : "0\n"; 683 684 return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff) + 1); 685 } 686 687 static void turn_monitoring_off(void) 688 { 689 WRITE_ONCE(monitoring_on, false); 690 } 691 692 static void reset_all_monitors(void) 693 { 694 struct rv_monitor *mon; 695 696 list_for_each_entry(mon, &rv_monitors_list, list) { 697 if (mon->enabled && mon->reset) 698 mon->reset(); 699 } 700 } 701 702 static void turn_monitoring_on(void) 703 { 704 WRITE_ONCE(monitoring_on, true); 705 } 706 707 static void turn_monitoring_on_with_reset(void) 708 { 709 lockdep_assert_held(&rv_interface_lock); 710 711 if (rv_monitoring_on()) 712 return; 713 714 /* 715 * Monitors might be out of sync with the system if events were not 716 * processed because of !rv_monitoring_on(). 717 * 718 * Reset all monitors, forcing a re-sync. 719 */ 720 reset_all_monitors(); 721 turn_monitoring_on(); 722 } 723 724 static ssize_t monitoring_on_write_data(struct file *filp, const char __user *user_buf, 725 size_t count, loff_t *ppos) 726 { 727 int retval; 728 bool val; 729 730 retval = kstrtobool_from_user(user_buf, count, &val); 731 if (retval) 732 return retval; 733 734 guard(mutex)(&rv_interface_lock); 735 736 if (val) 737 turn_monitoring_on_with_reset(); 738 else 739 turn_monitoring_off(); 740 741 /* 742 * Wait for the execution of all events to finish 743 * before returning to user-space. 744 */ 745 tracepoint_synchronize_unregister(); 746 747 return count; 748 } 749 750 static const struct file_operations monitoring_on_fops = { 751 .open = simple_open, 752 .write = monitoring_on_write_data, 753 .read = monitoring_on_read_data, 754 }; 755 756 static void destroy_monitor_dir(struct rv_monitor *mon) 757 { 758 rv_remove(mon->root_d); 759 } 760 761 /** 762 * rv_register_monitor - register a rv monitor. 763 * @monitor: The rv_monitor to be registered. 764 * @parent: The parent of the monitor to be registered, NULL if not nested. 765 * 766 * Returns 0 if successful, error otherwise. 767 */ 768 int rv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent) 769 { 770 struct rv_monitor *r; 771 int retval = 0; 772 773 if (strlen(monitor->name) >= MAX_RV_MONITOR_NAME_SIZE) { 774 pr_info("Monitor %s has a name longer than %d\n", monitor->name, 775 MAX_RV_MONITOR_NAME_SIZE); 776 return -EINVAL; 777 } 778 779 guard(mutex)(&rv_interface_lock); 780 781 list_for_each_entry(r, &rv_monitors_list, list) { 782 if (strcmp(monitor->name, r->name) == 0) { 783 pr_info("Monitor %s is already registered\n", monitor->name); 784 return -EEXIST; 785 } 786 } 787 788 if (parent && rv_is_nested_monitor(parent)) { 789 pr_info("Parent monitor %s is already nested, cannot nest further\n", 790 parent->name); 791 return -EINVAL; 792 } 793 794 monitor->parent = parent; 795 796 retval = create_monitor_dir(monitor, parent); 797 if (retval) 798 return retval; 799 800 /* keep children close to the parent for easier visualisation */ 801 if (parent) 802 list_add(&monitor->list, &parent->list); 803 else 804 list_add_tail(&monitor->list, &rv_monitors_list); 805 806 return 0; 807 } 808 809 /** 810 * rv_unregister_monitor - unregister a rv monitor. 811 * @monitor: The rv_monitor to be unregistered. 812 * 813 * Returns 0 if successful, error otherwise. 814 */ 815 int rv_unregister_monitor(struct rv_monitor *monitor) 816 { 817 guard(mutex)(&rv_interface_lock); 818 819 rv_disable_monitor(monitor); 820 list_del(&monitor->list); 821 destroy_monitor_dir(monitor); 822 823 return 0; 824 } 825 826 int __init rv_init_interface(void) 827 { 828 struct dentry *tmp; 829 int retval; 830 831 rv_root.root_dir = rv_create_dir("rv", NULL); 832 if (!rv_root.root_dir) 833 goto out_err; 834 835 rv_root.monitors_dir = rv_create_dir("monitors", rv_root.root_dir); 836 if (!rv_root.monitors_dir) 837 goto out_err; 838 839 tmp = rv_create_file("available_monitors", RV_MODE_READ, rv_root.root_dir, NULL, 840 &available_monitors_ops); 841 if (!tmp) 842 goto out_err; 843 844 tmp = rv_create_file("enabled_monitors", RV_MODE_WRITE, rv_root.root_dir, NULL, 845 &enabled_monitors_ops); 846 if (!tmp) 847 goto out_err; 848 849 tmp = rv_create_file("monitoring_on", RV_MODE_WRITE, rv_root.root_dir, NULL, 850 &monitoring_on_fops); 851 if (!tmp) 852 goto out_err; 853 retval = init_rv_reactors(rv_root.root_dir); 854 if (retval) 855 goto out_err; 856 857 turn_monitoring_on(); 858 859 return 0; 860 861 out_err: 862 rv_remove(rv_root.root_dir); 863 printk(KERN_ERR "RV: Error while creating the RV interface\n"); 864 return 1; 865 } 866