Lines Matching +full:1 +full:e
32 # define USE_DEBUG 1
38 VERBOSE_STATUS = 1 /* make it zero to save 400 bytes kernel memory */
42 static int enabled = 1;
45 #define MISC_FMT_PRESERVE_ARGV0 (1 << 31)
46 #define MISC_FMT_OPEN_BINARY (1 << 30)
47 #define MISC_FMT_CREDENTIALS (1 << 29)
48 #define MISC_FMT_OPEN_FILE (1 << 28)
72 * - type: 1 byte
95 Node *e = list_entry(l, Node, list); in check_file() local
100 if (!test_bit(Enabled, &e->flags)) in check_file()
104 if (!test_bit(Magic, &e->flags)) { in check_file()
105 if (p && !strcmp(e->magic, p + 1)) in check_file()
106 return e; in check_file()
111 s = bprm->buf + e->offset; in check_file()
112 if (e->mask) { in check_file()
113 for (j = 0; j < e->size; j++) in check_file()
114 if ((*s++ ^ e->magic[j]) & e->mask[j]) in check_file()
117 for (j = 0; j < e->size; j++) in check_file()
118 if ((*s++ ^ e->magic[j])) in check_file()
121 if (j == e->size) in check_file()
122 return e; in check_file()
135 int fd_binary = -1; in load_misc_binary()
190 /* make argv[1] be the path to the binary */ in load_misc_binary()
191 retval = copy_strings_kernel(1, &bprm->interp, bprm); in load_misc_binary()
197 retval = copy_strings_kernel(1, &fmt->interpreter, bprm); in load_misc_binary()
271 s[-1] ='\0'; in scanarg()
275 static char *check_special_flags(char *sfs, Node *e) in check_special_flags() argument
278 int cont = 1; in check_special_flags()
286 e->flags |= MISC_FMT_PRESERVE_ARGV0; in check_special_flags()
291 e->flags |= MISC_FMT_OPEN_BINARY; in check_special_flags()
298 e->flags |= (MISC_FMT_CREDENTIALS | in check_special_flags()
304 e->flags |= MISC_FMT_OPEN_FILE; in check_special_flags()
321 Node *e; in create_entry() local
335 e = kmalloc(memsize, GFP_KERNEL); in create_entry()
336 if (!e) in create_entry()
339 p = buf = (char *)e + sizeof(Node); in create_entry()
341 memset(e, 0, sizeof(Node)); in create_entry()
353 e->name = p; in create_entry()
358 if (!e->name[0] || in create_entry()
359 !strcmp(e->name, ".") || in create_entry()
360 !strcmp(e->name, "..") || in create_entry()
361 strchr(e->name, '/')) in create_entry()
364 pr_debug("register: name: {%s}\n", e->name); in create_entry()
368 case 'E': in create_entry()
369 pr_debug("register: type: E (extension)\n"); in create_entry()
370 e->flags = 1 << Enabled; in create_entry()
374 e->flags = (1 << Enabled) | (1 << Magic); in create_entry()
382 if (test_bit(Magic, &e->flags)) { in create_entry()
392 int r = kstrtoint(p, 10, &e->offset); in create_entry()
393 if (r != 0 || e->offset < 0) in create_entry()
399 pr_debug("register: offset: %#x\n", e->offset); in create_entry()
402 e->magic = p; in create_entry()
406 if (!e->magic[0]) in create_entry()
411 DUMP_PREFIX_NONE, e->magic, p - e->magic); in create_entry()
414 e->mask = p; in create_entry()
418 if (!e->mask[0]) { in create_entry()
419 e->mask = NULL; in create_entry()
424 DUMP_PREFIX_NONE, e->mask, p - e->mask); in create_entry()
432 e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX); in create_entry()
433 if (e->mask && in create_entry()
434 string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size) in create_entry()
436 if (e->size > BINPRM_BUF_SIZE || in create_entry()
437 BINPRM_BUF_SIZE - e->size < e->offset) in create_entry()
439 pr_debug("register: magic/mask length: %i\n", e->size); in create_entry()
443 DUMP_PREFIX_NONE, e->magic, e->size); in create_entry()
445 if (e->mask) { in create_entry()
447 char *masked = kmalloc(e->size, GFP_KERNEL); in create_entry()
451 DUMP_PREFIX_NONE, e->mask, e->size); in create_entry()
454 for (i = 0; i < e->size; ++i) in create_entry()
455 masked[i] = e->magic[i] & e->mask[i]; in create_entry()
458 DUMP_PREFIX_NONE, masked, e->size); in create_entry()
465 /* Handle the 'E' (extension) format. */ in create_entry()
474 e->magic = p; in create_entry()
479 if (!e->magic[0] || strchr(e->magic, '/')) in create_entry()
481 pr_debug("register: extension: {%s}\n", e->magic); in create_entry()
491 e->interpreter = p; in create_entry()
496 if (!e->interpreter[0]) in create_entry()
498 pr_debug("register: interpreter: {%s}\n", e->interpreter); in create_entry()
501 p = check_special_flags(p, e); in create_entry()
507 return e; in create_entry()
513 kfree(e); in create_entry()
516 kfree(e); in create_entry()
522 * '1' enables, '0' disables and '-1' clears entry/binfmt_misc
534 if (s[count - 1] == '\n') in parse_command()
536 if (count == 1 && s[0] == '0') in parse_command()
537 return 1; in parse_command()
538 if (count == 1 && s[0] == '1') in parse_command()
540 if (count == 2 && s[0] == '-' && s[1] == '1') in parse_command()
547 static void entry_status(Node *e, char *page) in entry_status() argument
552 if (test_bit(Enabled, &e->flags)) in entry_status()
560 dp += sprintf(dp, "%s\ninterpreter %s\n", status, e->interpreter); in entry_status()
564 if (e->flags & MISC_FMT_PRESERVE_ARGV0) in entry_status()
566 if (e->flags & MISC_FMT_OPEN_BINARY) in entry_status()
568 if (e->flags & MISC_FMT_CREDENTIALS) in entry_status()
570 if (e->flags & MISC_FMT_OPEN_FILE) in entry_status()
574 if (!test_bit(Magic, &e->flags)) { in entry_status()
575 sprintf(dp, "extension .%s\n", e->magic); in entry_status()
577 dp += sprintf(dp, "offset %i\nmagic ", e->offset); in entry_status()
578 dp = bin2hex(dp, e->magic, e->size); in entry_status()
579 if (e->mask) { in entry_status()
581 dp = bin2hex(dp, e->mask, e->size); in entry_status()
603 Node *e = inode->i_private; in bm_evict_inode() local
605 if (e && e->flags & MISC_FMT_OPEN_FILE) in bm_evict_inode()
606 filp_close(e->interp_file, NULL); in bm_evict_inode()
609 kfree(e); in bm_evict_inode()
612 static void kill_node(Node *e) in kill_node() argument
617 list_del_init(&e->list); in kill_node()
620 dentry = e->dentry; in kill_node()
632 Node *e = file_inode(file)->i_private; in bm_entry_read() local
640 entry_status(e, page); in bm_entry_read()
652 Node *e = file_inode(file)->i_private; in bm_entry_write() local
656 case 1: in bm_entry_write()
658 clear_bit(Enabled, &e->flags); in bm_entry_write()
662 set_bit(Enabled, &e->flags); in bm_entry_write()
669 if (!list_empty(&e->list)) in bm_entry_write()
670 kill_node(e); in bm_entry_write()
692 Node *e; in bm_register_write() local
698 e = create_entry(buffer, count); in bm_register_write()
700 if (IS_ERR(e)) in bm_register_write()
701 return PTR_ERR(e); in bm_register_write()
704 dentry = lookup_one_len(e->name, root, strlen(e->name)); in bm_register_write()
726 if (e->flags & MISC_FMT_OPEN_FILE) { in bm_register_write()
729 f = open_exec(e->interpreter); in bm_register_write()
732 pr_notice("register: failed to install interpreter file %s\n", e->interpreter); in bm_register_write()
738 e->interp_file = f; in bm_register_write()
741 e->dentry = dget(dentry); in bm_register_write()
742 inode->i_private = e; in bm_register_write()
747 list_add(&e->list, &entries); in bm_register_write()
757 kfree(e); in bm_register_write()
785 case 1: in bm_status_write()
791 enabled = 1; in bm_status_write()