Lines Matching refs: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()
230 static char *check_special_flags(char *sfs, Node *e) in check_special_flags() argument
241 e->flags |= MISC_FMT_PRESERVE_ARGV0; in check_special_flags()
246 e->flags |= MISC_FMT_OPEN_BINARY; in check_special_flags()
253 e->flags |= (MISC_FMT_CREDENTIALS | in check_special_flags()
259 e->flags |= MISC_FMT_OPEN_FILE; in check_special_flags()
276 Node *e; in create_entry() local
290 e = kmalloc(memsize, GFP_KERNEL); in create_entry()
291 if (!e) in create_entry()
294 p = buf = (char *)e + sizeof(Node); in create_entry()
296 memset(e, 0, sizeof(Node)); in create_entry()
308 e->name = p; in create_entry()
313 if (!e->name[0] || in create_entry()
314 !strcmp(e->name, ".") || in create_entry()
315 !strcmp(e->name, "..") || in create_entry()
316 strchr(e->name, '/')) in create_entry()
319 pr_debug("register: name: {%s}\n", e->name); in create_entry()
325 e->flags = 1 << Enabled; in create_entry()
329 e->flags = (1 << Enabled) | (1 << Magic); in create_entry()
337 if (test_bit(Magic, &e->flags)) { in create_entry()
347 int r = kstrtoint(p, 10, &e->offset); in create_entry()
348 if (r != 0 || e->offset < 0) in create_entry()
354 pr_debug("register: offset: %#x\n", e->offset); in create_entry()
357 e->magic = p; in create_entry()
361 if (!e->magic[0]) in create_entry()
366 DUMP_PREFIX_NONE, e->magic, p - e->magic); in create_entry()
369 e->mask = p; in create_entry()
373 if (!e->mask[0]) { in create_entry()
374 e->mask = NULL; in create_entry()
379 DUMP_PREFIX_NONE, e->mask, p - e->mask); in create_entry()
387 e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX); in create_entry()
388 if (e->mask && in create_entry()
389 string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size) in create_entry()
391 if (e->size > BINPRM_BUF_SIZE || in create_entry()
392 BINPRM_BUF_SIZE - e->size < e->offset) in create_entry()
394 pr_debug("register: magic/mask length: %i\n", e->size); in create_entry()
398 DUMP_PREFIX_NONE, e->magic, e->size); in create_entry()
400 if (e->mask) { in create_entry()
402 char *masked = kmalloc(e->size, GFP_KERNEL); in create_entry()
406 DUMP_PREFIX_NONE, e->mask, e->size); in create_entry()
409 for (i = 0; i < e->size; ++i) in create_entry()
410 masked[i] = e->magic[i] & e->mask[i]; in create_entry()
413 DUMP_PREFIX_NONE, masked, e->size); in create_entry()
429 e->magic = p; in create_entry()
434 if (!e->magic[0] || strchr(e->magic, '/')) in create_entry()
436 pr_debug("register: extension: {%s}\n", e->magic); in create_entry()
446 e->interpreter = p; in create_entry()
451 if (!e->interpreter[0]) in create_entry()
453 pr_debug("register: interpreter: {%s}\n", e->interpreter); in create_entry()
456 p = check_special_flags(p, e); in create_entry()
462 return e; in create_entry()
468 kfree(e); in create_entry()
471 kfree(e); in create_entry()
502 static void entry_status(Node *e, char *page) in entry_status() argument
507 if (test_bit(Enabled, &e->flags)) in entry_status()
515 dp += sprintf(dp, "%s\ninterpreter %s\n", status, e->interpreter); in entry_status()
519 if (e->flags & MISC_FMT_PRESERVE_ARGV0) in entry_status()
521 if (e->flags & MISC_FMT_OPEN_BINARY) in entry_status()
523 if (e->flags & MISC_FMT_CREDENTIALS) in entry_status()
525 if (e->flags & MISC_FMT_OPEN_FILE) in entry_status()
529 if (!test_bit(Magic, &e->flags)) { in entry_status()
530 sprintf(dp, "extension .%s\n", e->magic); in entry_status()
532 dp += sprintf(dp, "offset %i\nmagic ", e->offset); in entry_status()
533 dp = bin2hex(dp, e->magic, e->size); in entry_status()
534 if (e->mask) { in entry_status()
536 dp = bin2hex(dp, e->mask, e->size); in entry_status()
557 Node *e = inode->i_private; in bm_evict_inode() local
559 if (e && e->flags & MISC_FMT_OPEN_FILE) in bm_evict_inode()
560 filp_close(e->interp_file, NULL); in bm_evict_inode()
563 kfree(e); in bm_evict_inode()
566 static void kill_node(Node *e) in kill_node() argument
571 list_del_init(&e->list); in kill_node()
574 dentry = e->dentry; in kill_node()
586 Node *e = file_inode(file)->i_private; in bm_entry_read() local
594 entry_status(e, page); in bm_entry_read()
606 Node *e = file_inode(file)->i_private; in bm_entry_write() local
612 clear_bit(Enabled, &e->flags); in bm_entry_write()
616 set_bit(Enabled, &e->flags); in bm_entry_write()
623 if (!list_empty(&e->list)) in bm_entry_write()
624 kill_node(e); in bm_entry_write()
646 Node *e; in bm_register_write() local
653 e = create_entry(buffer, count); in bm_register_write()
655 if (IS_ERR(e)) in bm_register_write()
656 return PTR_ERR(e); in bm_register_write()
658 if (e->flags & MISC_FMT_OPEN_FILE) { in bm_register_write()
659 f = open_exec(e->interpreter); in bm_register_write()
662 e->interpreter); in bm_register_write()
663 kfree(e); in bm_register_write()
666 e->interp_file = f; in bm_register_write()
670 dentry = lookup_one_len(e->name, root, strlen(e->name)); in bm_register_write()
692 e->dentry = dget(dentry); in bm_register_write()
693 inode->i_private = e; in bm_register_write()
698 list_add(&e->list, &entries); in bm_register_write()
710 kfree(e); in bm_register_write()