Lines Matching full:e
97 Node *e = list_entry(l, Node, list); in check_file() local
102 if (!test_bit(Enabled, &e->flags)) in check_file()
106 if (!test_bit(Magic, &e->flags)) { in check_file()
107 if (p && !strcmp(e->magic, p + 1)) in check_file()
108 return e; in check_file()
113 s = bprm->buf + e->offset; in check_file()
114 if (e->mask) { in check_file()
115 for (j = 0; j < e->size; j++) in check_file()
116 if ((*s++ ^ e->magic[j]) & e->mask[j]) in check_file()
119 for (j = 0; j < e->size; j++) in check_file()
120 if ((*s++ ^ e->magic[j])) in check_file()
123 if (j == e->size) in check_file()
124 return e; in check_file()
228 static char *check_special_flags(char *sfs, Node *e) in check_special_flags() argument
239 e->flags |= MISC_FMT_PRESERVE_ARGV0; in check_special_flags()
244 e->flags |= MISC_FMT_OPEN_BINARY; in check_special_flags()
251 e->flags |= (MISC_FMT_CREDENTIALS | in check_special_flags()
257 e->flags |= MISC_FMT_OPEN_FILE; in check_special_flags()
274 Node *e; in create_entry() local
288 e = kmalloc(memsize, GFP_KERNEL); in create_entry()
289 if (!e) in create_entry()
292 p = buf = (char *)e + sizeof(Node); in create_entry()
294 memset(e, 0, sizeof(Node)); in create_entry()
306 e->name = p; in create_entry()
311 if (!e->name[0] || in create_entry()
312 !strcmp(e->name, ".") || in create_entry()
313 !strcmp(e->name, "..") || in create_entry()
314 strchr(e->name, '/')) in create_entry()
317 pr_debug("register: name: {%s}\n", e->name); in create_entry()
321 case 'E': in create_entry()
322 pr_debug("register: type: E (extension)\n"); in create_entry()
323 e->flags = 1 << Enabled; in create_entry()
327 e->flags = (1 << Enabled) | (1 << Magic); in create_entry()
335 if (test_bit(Magic, &e->flags)) { in create_entry()
345 int r = kstrtoint(p, 10, &e->offset); in create_entry()
346 if (r != 0 || e->offset < 0) in create_entry()
352 pr_debug("register: offset: %#x\n", e->offset); in create_entry()
355 e->magic = p; in create_entry()
359 if (!e->magic[0]) in create_entry()
364 DUMP_PREFIX_NONE, e->magic, p - e->magic); in create_entry()
367 e->mask = p; in create_entry()
371 if (!e->mask[0]) { in create_entry()
372 e->mask = NULL; in create_entry()
377 DUMP_PREFIX_NONE, e->mask, p - e->mask); in create_entry()
385 e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX); in create_entry()
386 if (e->mask && in create_entry()
387 string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size) in create_entry()
389 if (e->size > BINPRM_BUF_SIZE || in create_entry()
390 BINPRM_BUF_SIZE - e->size < e->offset) in create_entry()
392 pr_debug("register: magic/mask length: %i\n", e->size); in create_entry()
396 DUMP_PREFIX_NONE, e->magic, e->size); in create_entry()
398 if (e->mask) { in create_entry()
400 char *masked = kmalloc(e->size, GFP_KERNEL); in create_entry()
404 DUMP_PREFIX_NONE, e->mask, e->size); in create_entry()
407 for (i = 0; i < e->size; ++i) in create_entry()
408 masked[i] = e->magic[i] & e->mask[i]; in create_entry()
411 DUMP_PREFIX_NONE, masked, e->size); in create_entry()
418 /* Handle the 'E' (extension) format. */ in create_entry()
427 e->magic = p; in create_entry()
432 if (!e->magic[0] || strchr(e->magic, '/')) in create_entry()
434 pr_debug("register: extension: {%s}\n", e->magic); in create_entry()
444 e->interpreter = p; in create_entry()
449 if (!e->interpreter[0]) in create_entry()
451 pr_debug("register: interpreter: {%s}\n", e->interpreter); in create_entry()
454 p = check_special_flags(p, e); in create_entry()
460 return e; in create_entry()
466 kfree(e); in create_entry()
469 kfree(e); in create_entry()
500 static void entry_status(Node *e, char *page) in entry_status() argument
505 if (test_bit(Enabled, &e->flags)) in entry_status()
513 dp += sprintf(dp, "%s\ninterpreter %s\n", status, e->interpreter); in entry_status()
517 if (e->flags & MISC_FMT_PRESERVE_ARGV0) in entry_status()
519 if (e->flags & MISC_FMT_OPEN_BINARY) in entry_status()
521 if (e->flags & MISC_FMT_CREDENTIALS) in entry_status()
523 if (e->flags & MISC_FMT_OPEN_FILE) in entry_status()
527 if (!test_bit(Magic, &e->flags)) { in entry_status()
528 sprintf(dp, "extension .%s\n", e->magic); in entry_status()
530 dp += sprintf(dp, "offset %i\nmagic ", e->offset); in entry_status()
531 dp = bin2hex(dp, e->magic, e->size); in entry_status()
532 if (e->mask) { in entry_status()
534 dp = bin2hex(dp, e->mask, e->size); in entry_status()
556 Node *e = inode->i_private; in bm_evict_inode() local
558 if (e && e->flags & MISC_FMT_OPEN_FILE) in bm_evict_inode()
559 filp_close(e->interp_file, NULL); in bm_evict_inode()
562 kfree(e); in bm_evict_inode()
565 static void kill_node(Node *e) in kill_node() argument
570 list_del_init(&e->list); in kill_node()
573 dentry = e->dentry; in kill_node()
585 Node *e = file_inode(file)->i_private; in bm_entry_read() local
593 entry_status(e, page); in bm_entry_read()
605 Node *e = file_inode(file)->i_private; in bm_entry_write() local
611 clear_bit(Enabled, &e->flags); in bm_entry_write()
615 set_bit(Enabled, &e->flags); in bm_entry_write()
622 if (!list_empty(&e->list)) in bm_entry_write()
623 kill_node(e); in bm_entry_write()
645 Node *e; in bm_register_write() local
651 e = create_entry(buffer, count); in bm_register_write()
653 if (IS_ERR(e)) in bm_register_write()
654 return PTR_ERR(e); in bm_register_write()
657 dentry = lookup_one_len(e->name, root, strlen(e->name)); in bm_register_write()
679 if (e->flags & MISC_FMT_OPEN_FILE) { in bm_register_write()
682 f = open_exec(e->interpreter); in bm_register_write()
685 pr_notice("register: failed to install interpreter file %s\n", e->interpreter); in bm_register_write()
691 e->interp_file = f; in bm_register_write()
694 e->dentry = dget(dentry); in bm_register_write()
695 inode->i_private = e; in bm_register_write()
700 list_add(&e->list, &entries); in bm_register_write()
710 kfree(e); in bm_register_write()