binfmt_misc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /*
  2. * binfmt_misc.c
  3. *
  4. * Copyright (C) 1997 Richard Günther
  5. *
  6. * binfmt_misc detects binaries via a magic or filename extension and invokes
  7. * a specified wrapper. This should obsolete binfmt_java, binfmt_em86 and
  8. * binfmt_mz.
  9. *
  10. * 1997-04-25 first version
  11. * [...]
  12. * 1997-05-19 cleanup
  13. * 1997-06-26 hpa: pass the real filename rather than argv[0]
  14. * 1997-06-30 minor cleanup
  15. * 1997-08-09 removed extension stripping, locking cleanup
  16. * 2001-02-28 AV: rewritten into something that resembles C. Original didn't.
  17. */
  18. #include <linux/module.h>
  19. #include <linux/init.h>
  20. #include <linux/sched.h>
  21. #include <linux/binfmts.h>
  22. #include <linux/slab.h>
  23. #include <linux/ctype.h>
  24. #include <linux/file.h>
  25. #include <linux/pagemap.h>
  26. #include <linux/namei.h>
  27. #include <linux/mount.h>
  28. #include <linux/syscalls.h>
  29. #include <asm/uaccess.h>
  30. enum {
  31. VERBOSE_STATUS = 1 /* make it zero to save 400 bytes kernel memory */
  32. };
  33. static LIST_HEAD(entries);
  34. static int enabled = 1;
  35. enum {Enabled, Magic};
  36. #define MISC_FMT_PRESERVE_ARGV0 (1<<31)
  37. #define MISC_FMT_OPEN_BINARY (1<<30)
  38. #define MISC_FMT_CREDENTIALS (1<<29)
  39. typedef struct {
  40. struct list_head list;
  41. unsigned long flags; /* type, status, etc. */
  42. int offset; /* offset of magic */
  43. int size; /* size of magic/mask */
  44. char *magic; /* magic or filename extension */
  45. char *mask; /* mask, NULL for exact match */
  46. char *interpreter; /* filename of interpreter */
  47. char *name;
  48. struct dentry *dentry;
  49. } Node;
  50. static DEFINE_RWLOCK(entries_lock);
  51. static struct file_system_type bm_fs_type;
  52. static struct vfsmount *bm_mnt;
  53. static int entry_count;
  54. /*
  55. * Check if we support the binfmt
  56. * if we do, return the node, else NULL
  57. * locking is done in load_misc_binary
  58. */
  59. static Node *check_file(struct linux_binprm *bprm)
  60. {
  61. char *p = strrchr(bprm->interp, '.');
  62. struct list_head *l;
  63. list_for_each(l, &entries) {
  64. Node *e = list_entry(l, Node, list);
  65. char *s;
  66. int j;
  67. if (!test_bit(Enabled, &e->flags))
  68. continue;
  69. if (!test_bit(Magic, &e->flags)) {
  70. if (p && !strcmp(e->magic, p + 1))
  71. return e;
  72. continue;
  73. }
  74. s = bprm->buf + e->offset;
  75. if (e->mask) {
  76. for (j = 0; j < e->size; j++)
  77. if ((*s++ ^ e->magic[j]) & e->mask[j])
  78. break;
  79. } else {
  80. for (j = 0; j < e->size; j++)
  81. if ((*s++ ^ e->magic[j]))
  82. break;
  83. }
  84. if (j == e->size)
  85. return e;
  86. }
  87. return NULL;
  88. }
  89. /*
  90. * the loader itself
  91. */
  92. static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
  93. {
  94. Node *fmt;
  95. struct file * interp_file = NULL;
  96. char iname[BINPRM_BUF_SIZE];
  97. char *iname_addr = iname;
  98. int retval;
  99. int fd_binary = -1;
  100. struct files_struct *files = NULL;
  101. retval = -ENOEXEC;
  102. if (!enabled)
  103. goto _ret;
  104. /* to keep locking time low, we copy the interpreter string */
  105. read_lock(&entries_lock);
  106. fmt = check_file(bprm);
  107. if (fmt)
  108. strlcpy(iname, fmt->interpreter, BINPRM_BUF_SIZE);
  109. read_unlock(&entries_lock);
  110. if (!fmt)
  111. goto _ret;
  112. if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) {
  113. retval = remove_arg_zero(bprm);
  114. if (retval)
  115. goto _ret;
  116. }
  117. if (fmt->flags & MISC_FMT_OPEN_BINARY) {
  118. files = current->files;
  119. retval = unshare_files();
  120. if (retval < 0)
  121. goto _ret;
  122. if (files == current->files) {
  123. put_files_struct(files);
  124. files = NULL;
  125. }
  126. /* if the binary should be opened on behalf of the
  127. * interpreter than keep it open and assign descriptor
  128. * to it */
  129. fd_binary = get_unused_fd();
  130. if (fd_binary < 0) {
  131. retval = fd_binary;
  132. goto _unshare;
  133. }
  134. fd_install(fd_binary, bprm->file);
  135. /* if the binary is not readable than enforce mm->dumpable=0
  136. regardless of the interpreter's permissions */
  137. if (file_permission(bprm->file, MAY_READ))
  138. bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
  139. allow_write_access(bprm->file);
  140. bprm->file = NULL;
  141. /* mark the bprm that fd should be passed to interp */
  142. bprm->interp_flags |= BINPRM_FLAGS_EXECFD;
  143. bprm->interp_data = fd_binary;
  144. } else {
  145. allow_write_access(bprm->file);
  146. fput(bprm->file);
  147. bprm->file = NULL;
  148. }
  149. /* make argv[1] be the path to the binary */
  150. retval = copy_strings_kernel (1, &bprm->interp, bprm);
  151. if (retval < 0)
  152. goto _error;
  153. bprm->argc++;
  154. /* add the interp as argv[0] */
  155. retval = copy_strings_kernel (1, &iname_addr, bprm);
  156. if (retval < 0)
  157. goto _error;
  158. bprm->argc ++;
  159. bprm->interp = iname; /* for binfmt_script */
  160. interp_file = open_exec (iname);
  161. retval = PTR_ERR (interp_file);
  162. if (IS_ERR (interp_file))
  163. goto _error;
  164. bprm->file = interp_file;
  165. if (fmt->flags & MISC_FMT_CREDENTIALS) {
  166. /*
  167. * No need to call prepare_binprm(), it's already been
  168. * done. bprm->buf is stale, update from interp_file.
  169. */
  170. memset(bprm->buf, 0, BINPRM_BUF_SIZE);
  171. retval = kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE);
  172. } else
  173. retval = prepare_binprm (bprm);
  174. if (retval < 0)
  175. goto _error;
  176. retval = search_binary_handler (bprm, regs);
  177. if (retval < 0)
  178. goto _error;
  179. if (files) {
  180. put_files_struct(files);
  181. files = NULL;
  182. }
  183. _ret:
  184. return retval;
  185. _error:
  186. if (fd_binary > 0)
  187. sys_close(fd_binary);
  188. bprm->interp_flags = 0;
  189. bprm->interp_data = 0;
  190. _unshare:
  191. if (files)
  192. reset_files_struct(current, files);
  193. goto _ret;
  194. }
  195. /* Command parsers */
  196. /*
  197. * parses and copies one argument enclosed in del from *sp to *dp,
  198. * recognising the \x special.
  199. * returns pointer to the copied argument or NULL in case of an
  200. * error (and sets err) or null argument length.
  201. */
  202. static char *scanarg(char *s, char del)
  203. {
  204. char c;
  205. while ((c = *s++) != del) {
  206. if (c == '\\' && *s == 'x') {
  207. s++;
  208. if (!isxdigit(*s++))
  209. return NULL;
  210. if (!isxdigit(*s++))
  211. return NULL;
  212. }
  213. }
  214. return s;
  215. }
  216. static int unquote(char *from)
  217. {
  218. char c = 0, *s = from, *p = from;
  219. while ((c = *s++) != '\0') {
  220. if (c == '\\' && *s == 'x') {
  221. s++;
  222. c = toupper(*s++);
  223. *p = (c - (isdigit(c) ? '0' : 'A' - 10)) << 4;
  224. c = toupper(*s++);
  225. *p++ |= c - (isdigit(c) ? '0' : 'A' - 10);
  226. continue;
  227. }
  228. *p++ = c;
  229. }
  230. return p - from;
  231. }
  232. static char * check_special_flags (char * sfs, Node * e)
  233. {
  234. char * p = sfs;
  235. int cont = 1;
  236. /* special flags */
  237. while (cont) {
  238. switch (*p) {
  239. case 'P':
  240. p++;
  241. e->flags |= MISC_FMT_PRESERVE_ARGV0;
  242. break;
  243. case 'O':
  244. p++;
  245. e->flags |= MISC_FMT_OPEN_BINARY;
  246. break;
  247. case 'C':
  248. p++;
  249. /* this flags also implies the
  250. open-binary flag */
  251. e->flags |= (MISC_FMT_CREDENTIALS |
  252. MISC_FMT_OPEN_BINARY);
  253. break;
  254. default:
  255. cont = 0;
  256. }
  257. }
  258. return p;
  259. }
  260. /*
  261. * This registers a new binary format, it recognises the syntax
  262. * ':name:type:offset:magic:mask:interpreter:flags'
  263. * where the ':' is the IFS, that can be chosen with the first char
  264. */
  265. static Node *create_entry(const char __user *buffer, size_t count)
  266. {
  267. Node *e;
  268. int memsize, err;
  269. char *buf, *p;
  270. char del;
  271. /* some sanity checks */
  272. err = -EINVAL;
  273. if ((count < 11) || (count > 256))
  274. goto out;
  275. err = -ENOMEM;
  276. memsize = sizeof(Node) + count + 8;
  277. e = kmalloc(memsize, GFP_USER);
  278. if (!e)
  279. goto out;
  280. p = buf = (char *)e + sizeof(Node);
  281. memset(e, 0, sizeof(Node));
  282. if (copy_from_user(buf, buffer, count))
  283. goto Efault;
  284. del = *p++; /* delimeter */
  285. memset(buf+count, del, 8);
  286. e->name = p;
  287. p = strchr(p, del);
  288. if (!p)
  289. goto Einval;
  290. *p++ = '\0';
  291. if (!e->name[0] ||
  292. !strcmp(e->name, ".") ||
  293. !strcmp(e->name, "..") ||
  294. strchr(e->name, '/'))
  295. goto Einval;
  296. switch (*p++) {
  297. case 'E': e->flags = 1<<Enabled; break;
  298. case 'M': e->flags = (1<<Enabled) | (1<<Magic); break;
  299. default: goto Einval;
  300. }
  301. if (*p++ != del)
  302. goto Einval;
  303. if (test_bit(Magic, &e->flags)) {
  304. char *s = strchr(p, del);
  305. if (!s)
  306. goto Einval;
  307. *s++ = '\0';
  308. e->offset = simple_strtoul(p, &p, 10);
  309. if (*p++)
  310. goto Einval;
  311. e->magic = p;
  312. p = scanarg(p, del);
  313. if (!p)
  314. goto Einval;
  315. p[-1] = '\0';
  316. if (!e->magic[0])
  317. goto Einval;
  318. e->mask = p;
  319. p = scanarg(p, del);
  320. if (!p)
  321. goto Einval;
  322. p[-1] = '\0';
  323. if (!e->mask[0])
  324. e->mask = NULL;
  325. e->size = unquote(e->magic);
  326. if (e->mask && unquote(e->mask) != e->size)
  327. goto Einval;
  328. if (e->size + e->offset > BINPRM_BUF_SIZE)
  329. goto Einval;
  330. } else {
  331. p = strchr(p, del);
  332. if (!p)
  333. goto Einval;
  334. *p++ = '\0';
  335. e->magic = p;
  336. p = strchr(p, del);
  337. if (!p)
  338. goto Einval;
  339. *p++ = '\0';
  340. if (!e->magic[0] || strchr(e->magic, '/'))
  341. goto Einval;
  342. p = strchr(p, del);
  343. if (!p)
  344. goto Einval;
  345. *p++ = '\0';
  346. }
  347. e->interpreter = p;
  348. p = strchr(p, del);
  349. if (!p)
  350. goto Einval;
  351. *p++ = '\0';
  352. if (!e->interpreter[0])
  353. goto Einval;
  354. p = check_special_flags (p, e);
  355. if (*p == '\n')
  356. p++;
  357. if (p != buf + count)
  358. goto Einval;
  359. return e;
  360. out:
  361. return ERR_PTR(err);
  362. Efault:
  363. kfree(e);
  364. return ERR_PTR(-EFAULT);
  365. Einval:
  366. kfree(e);
  367. return ERR_PTR(-EINVAL);
  368. }
  369. /*
  370. * Set status of entry/binfmt_misc:
  371. * '1' enables, '0' disables and '-1' clears entry/binfmt_misc
  372. */
  373. static int parse_command(const char __user *buffer, size_t count)
  374. {
  375. char s[4];
  376. if (!count)
  377. return 0;
  378. if (count > 3)
  379. return -EINVAL;
  380. if (copy_from_user(s, buffer, count))
  381. return -EFAULT;
  382. if (s[count-1] == '\n')
  383. count--;
  384. if (count == 1 && s[0] == '0')
  385. return 1;
  386. if (count == 1 && s[0] == '1')
  387. return 2;
  388. if (count == 2 && s[0] == '-' && s[1] == '1')
  389. return 3;
  390. return -EINVAL;
  391. }
  392. /* generic stuff */
  393. static void entry_status(Node *e, char *page)
  394. {
  395. char *dp;
  396. char *status = "disabled";
  397. const char * flags = "flags: ";
  398. if (test_bit(Enabled, &e->flags))
  399. status = "enabled";
  400. if (!VERBOSE_STATUS) {
  401. sprintf(page, "%s\n", status);
  402. return;
  403. }
  404. sprintf(page, "%s\ninterpreter %s\n", status, e->interpreter);
  405. dp = page + strlen(page);
  406. /* print the special flags */
  407. sprintf (dp, "%s", flags);
  408. dp += strlen (flags);
  409. if (e->flags & MISC_FMT_PRESERVE_ARGV0) {
  410. *dp ++ = 'P';
  411. }
  412. if (e->flags & MISC_FMT_OPEN_BINARY) {
  413. *dp ++ = 'O';
  414. }
  415. if (e->flags & MISC_FMT_CREDENTIALS) {
  416. *dp ++ = 'C';
  417. }
  418. *dp ++ = '\n';
  419. if (!test_bit(Magic, &e->flags)) {
  420. sprintf(dp, "extension .%s\n", e->magic);
  421. } else {
  422. int i;
  423. sprintf(dp, "offset %i\nmagic ", e->offset);
  424. dp = page + strlen(page);
  425. for (i = 0; i < e->size; i++) {
  426. sprintf(dp, "%02x", 0xff & (int) (e->magic[i]));
  427. dp += 2;
  428. }
  429. if (e->mask) {
  430. sprintf(dp, "\nmask ");
  431. dp += 6;
  432. for (i = 0; i < e->size; i++) {
  433. sprintf(dp, "%02x", 0xff & (int) (e->mask[i]));
  434. dp += 2;
  435. }
  436. }
  437. *dp++ = '\n';
  438. *dp = '\0';
  439. }
  440. }
  441. static struct inode *bm_get_inode(struct super_block *sb, int mode)
  442. {
  443. struct inode * inode = new_inode(sb);
  444. if (inode) {
  445. inode->i_mode = mode;
  446. inode->i_uid = 0;
  447. inode->i_gid = 0;
  448. inode->i_blocks = 0;
  449. inode->i_atime = inode->i_mtime = inode->i_ctime =
  450. current_fs_time(inode->i_sb);
  451. }
  452. return inode;
  453. }
  454. static void bm_clear_inode(struct inode *inode)
  455. {
  456. kfree(inode->i_private);
  457. }
  458. static void kill_node(Node *e)
  459. {
  460. struct dentry *dentry;
  461. write_lock(&entries_lock);
  462. dentry = e->dentry;
  463. if (dentry) {
  464. list_del_init(&e->list);
  465. e->dentry = NULL;
  466. }
  467. write_unlock(&entries_lock);
  468. if (dentry) {
  469. dentry->d_inode->i_nlink--;
  470. d_drop(dentry);
  471. dput(dentry);
  472. simple_release_fs(&bm_mnt, &entry_count);
  473. }
  474. }
  475. /* /<entry> */
  476. static ssize_t
  477. bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
  478. {
  479. Node *e = file->f_path.dentry->d_inode->i_private;
  480. loff_t pos = *ppos;
  481. ssize_t res;
  482. char *page;
  483. int len;
  484. if (!(page = (char*) __get_free_page(GFP_KERNEL)))
  485. return -ENOMEM;
  486. entry_status(e, page);
  487. len = strlen(page);
  488. res = -EINVAL;
  489. if (pos < 0)
  490. goto out;
  491. res = 0;
  492. if (pos >= len)
  493. goto out;
  494. if (len < pos + nbytes)
  495. nbytes = len - pos;
  496. res = -EFAULT;
  497. if (copy_to_user(buf, page + pos, nbytes))
  498. goto out;
  499. *ppos = pos + nbytes;
  500. res = nbytes;
  501. out:
  502. free_page((unsigned long) page);
  503. return res;
  504. }
  505. static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
  506. size_t count, loff_t *ppos)
  507. {
  508. struct dentry *root;
  509. Node *e = file->f_path.dentry->d_inode->i_private;
  510. int res = parse_command(buffer, count);
  511. switch (res) {
  512. case 1: clear_bit(Enabled, &e->flags);
  513. break;
  514. case 2: set_bit(Enabled, &e->flags);
  515. break;
  516. case 3: root = dget(file->f_path.mnt->mnt_sb->s_root);
  517. mutex_lock(&root->d_inode->i_mutex);
  518. kill_node(e);
  519. mutex_unlock(&root->d_inode->i_mutex);
  520. dput(root);
  521. break;
  522. default: return res;
  523. }
  524. return count;
  525. }
  526. static const struct file_operations bm_entry_operations = {
  527. .read = bm_entry_read,
  528. .write = bm_entry_write,
  529. };
  530. /* /register */
  531. static ssize_t bm_register_write(struct file *file, const char __user *buffer,
  532. size_t count, loff_t *ppos)
  533. {
  534. Node *e;
  535. struct inode *inode;
  536. struct dentry *root, *dentry;
  537. struct super_block *sb = file->f_path.mnt->mnt_sb;
  538. int err = 0;
  539. e = create_entry(buffer, count);
  540. if (IS_ERR(e))
  541. return PTR_ERR(e);
  542. root = dget(sb->s_root);
  543. mutex_lock(&root->d_inode->i_mutex);
  544. dentry = lookup_one_len(e->name, root, strlen(e->name));
  545. err = PTR_ERR(dentry);
  546. if (IS_ERR(dentry))
  547. goto out;
  548. err = -EEXIST;
  549. if (dentry->d_inode)
  550. goto out2;
  551. inode = bm_get_inode(sb, S_IFREG | 0644);
  552. err = -ENOMEM;
  553. if (!inode)
  554. goto out2;
  555. err = simple_pin_fs(&bm_fs_type, &bm_mnt, &entry_count);
  556. if (err) {
  557. iput(inode);
  558. inode = NULL;
  559. goto out2;
  560. }
  561. e->dentry = dget(dentry);
  562. inode->i_private = e;
  563. inode->i_fop = &bm_entry_operations;
  564. d_instantiate(dentry, inode);
  565. write_lock(&entries_lock);
  566. list_add(&e->list, &entries);
  567. write_unlock(&entries_lock);
  568. err = 0;
  569. out2:
  570. dput(dentry);
  571. out:
  572. mutex_unlock(&root->d_inode->i_mutex);
  573. dput(root);
  574. if (err) {
  575. kfree(e);
  576. return -EINVAL;
  577. }
  578. return count;
  579. }
  580. static const struct file_operations bm_register_operations = {
  581. .write = bm_register_write,
  582. };
  583. /* /status */
  584. static ssize_t
  585. bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
  586. {
  587. char *s = enabled ? "enabled" : "disabled";
  588. return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
  589. }
  590. static ssize_t bm_status_write(struct file * file, const char __user * buffer,
  591. size_t count, loff_t *ppos)
  592. {
  593. int res = parse_command(buffer, count);
  594. struct dentry *root;
  595. switch (res) {
  596. case 1: enabled = 0; break;
  597. case 2: enabled = 1; break;
  598. case 3: root = dget(file->f_path.mnt->mnt_sb->s_root);
  599. mutex_lock(&root->d_inode->i_mutex);
  600. while (!list_empty(&entries))
  601. kill_node(list_entry(entries.next, Node, list));
  602. mutex_unlock(&root->d_inode->i_mutex);
  603. dput(root);
  604. default: return res;
  605. }
  606. return count;
  607. }
  608. static const struct file_operations bm_status_operations = {
  609. .read = bm_status_read,
  610. .write = bm_status_write,
  611. };
  612. /* Superblock handling */
  613. static const struct super_operations s_ops = {
  614. .statfs = simple_statfs,
  615. .clear_inode = bm_clear_inode,
  616. };
  617. static int bm_fill_super(struct super_block * sb, void * data, int silent)
  618. {
  619. static struct tree_descr bm_files[] = {
  620. [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO},
  621. [3] = {"register", &bm_register_operations, S_IWUSR},
  622. /* last one */ {""}
  623. };
  624. int err = simple_fill_super(sb, 0x42494e4d, bm_files);
  625. if (!err)
  626. sb->s_op = &s_ops;
  627. return err;
  628. }
  629. static int bm_get_sb(struct file_system_type *fs_type,
  630. int flags, const char *dev_name, void *data, struct vfsmount *mnt)
  631. {
  632. return get_sb_single(fs_type, flags, data, bm_fill_super, mnt);
  633. }
  634. static struct linux_binfmt misc_format = {
  635. .module = THIS_MODULE,
  636. .load_binary = load_misc_binary,
  637. };
  638. static struct file_system_type bm_fs_type = {
  639. .owner = THIS_MODULE,
  640. .name = "binfmt_misc",
  641. .get_sb = bm_get_sb,
  642. .kill_sb = kill_litter_super,
  643. };
  644. static int __init init_misc_binfmt(void)
  645. {
  646. int err = register_filesystem(&bm_fs_type);
  647. if (!err) {
  648. err = register_binfmt(&misc_format);
  649. if (err)
  650. unregister_filesystem(&bm_fs_type);
  651. }
  652. return err;
  653. }
  654. static void __exit exit_misc_binfmt(void)
  655. {
  656. unregister_binfmt(&misc_format);
  657. unregister_filesystem(&bm_fs_type);
  658. }
  659. core_initcall(init_misc_binfmt);
  660. module_exit(exit_misc_binfmt);
  661. MODULE_LICENSE("GPL");