/* Special entry to just crash directly. Available without KPROBEs */ static ssize_t direct_entry(struct file *f, const char __user *user_buf, size_t count, loff_t *off) { enum ctype type; char *buf; if (count >= PAGE_SIZE) return -EINVAL; if (count < 1) return -EINVAL; buf = (char *)__get_free_page(GFP_KERNEL); if (!buf) return -ENOMEM; if (copy_from_user(buf, user_buf, count)) { free_page((unsigned long) buf); return -EFAULT; } /* NULL-terminate and remove enter */ buf[count] = '\0'; strim(buf); type = parse_cp_type(buf, count); free_page((unsigned long) buf); if (type == CT_NONE) return -EINVAL; pr_info("Performing direct entry %s\n", cp_type_to_str(type)); lkdtm_do_action(type); *off += count; return count; }
static void lkdtm_handler(void) { count--; printk(KERN_INFO "lkdtm: Crash point %s of type %s hit, trigger in %d rounds\n", cp_name_to_str(cpoint), cp_type_to_str(cptype), count); if (count == 0) { lkdtm_do_action(cptype); count = cpoint_count; } }
static void lkdtm_handler(void) { unsigned long flags; bool do_it = false; spin_lock_irqsave(&count_lock, flags); count--; pr_info("Crash point %s of type %s hit, trigger in %d rounds\n", cp_name_to_str(cpoint), cp_type_to_str(cptype), count); if (count == 0) { do_it = true; count = cpoint_count; } spin_unlock_irqrestore(&count_lock, flags); if (do_it) lkdtm_do_action(cptype); }