seclvl.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /**
  2. * BSD Secure Levels LSM
  3. *
  4. * Maintainers:
  5. * Michael A. Halcrow <mike@halcrow.us>
  6. * Serge Hallyn <hallyn@cs.wm.edu>
  7. *
  8. * Copyright (c) 2001 WireX Communications, Inc <chris@wirex.com>
  9. * Copyright (c) 2001 Greg Kroah-Hartman <greg@kroah.com>
  10. * Copyright (c) 2002 International Business Machines <robb@austin.ibm.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. */
  17. #include <linux/config.h>
  18. #include <linux/module.h>
  19. #include <linux/moduleparam.h>
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/security.h>
  23. #include <linux/netlink.h>
  24. #include <linux/fs.h>
  25. #include <linux/namei.h>
  26. #include <linux/mount.h>
  27. #include <linux/capability.h>
  28. #include <linux/time.h>
  29. #include <linux/proc_fs.h>
  30. #include <linux/kobject.h>
  31. #include <linux/crypto.h>
  32. #include <asm/scatterlist.h>
  33. #include <linux/gfp.h>
  34. #include <linux/sysfs.h>
  35. #define SHA1_DIGEST_SIZE 20
  36. /**
  37. * Module parameter that defines the initial secure level.
  38. *
  39. * When built as a module, it defaults to seclvl 1, which is the
  40. * behavior of BSD secure levels. Note that this default behavior
  41. * wrecks havoc on a machine when the seclvl module is compiled into
  42. * the kernel. In that case, we default to seclvl 0.
  43. */
  44. #ifdef CONFIG_SECURITY_SECLVL_MODULE
  45. static int initlvl = 1;
  46. #else
  47. static int initlvl;
  48. #endif
  49. module_param(initlvl, int, 0);
  50. MODULE_PARM_DESC(initlvl, "Initial secure level (defaults to 1)");
  51. /* Module parameter that defines the verbosity level */
  52. static int verbosity;
  53. module_param(verbosity, int, 0);
  54. MODULE_PARM_DESC(verbosity, "Initial verbosity level (0 or 1; defaults to "
  55. "0, which is Quiet)");
  56. /**
  57. * Optional password which can be passed in to bring seclvl to 0
  58. * (i.e., for halt/reboot). Defaults to NULL (the passwd attribute
  59. * file will not be registered in sysfs).
  60. *
  61. * This gets converted to its SHA1 hash when stored. It's probably
  62. * not a good idea to use this parameter when loading seclvl from a
  63. * script; use sha1_passwd instead.
  64. */
  65. #define MAX_PASSWD_SIZE 32
  66. static char passwd[MAX_PASSWD_SIZE];
  67. module_param_string(passwd, passwd, sizeof(passwd), 0);
  68. MODULE_PARM_DESC(passwd,
  69. "Plaintext of password that sets seclvl=0 when written to "
  70. "(sysfs mount point)/seclvl/passwd\n");
  71. /**
  72. * SHA1 hashed version of the optional password which can be passed in
  73. * to bring seclvl to 0 (i.e., for halt/reboot). Must be in
  74. * hexadecimal format (40 characters). Defaults to NULL (the passwd
  75. * attribute file will not be registered in sysfs).
  76. *
  77. * Use the sha1sum utility to generate the SHA1 hash of a password:
  78. *
  79. * echo -n "secret" | sha1sum
  80. */
  81. #define MAX_SHA1_PASSWD 41
  82. static char sha1_passwd[MAX_SHA1_PASSWD];
  83. module_param_string(sha1_passwd, sha1_passwd, sizeof(sha1_passwd), 0);
  84. MODULE_PARM_DESC(sha1_passwd,
  85. "SHA1 hash (40 hexadecimal characters) of password that "
  86. "sets seclvl=0 when plaintext password is written to "
  87. "(sysfs mount point)/seclvl/passwd\n");
  88. static int hideHash = 1;
  89. module_param(hideHash, int, 0);
  90. MODULE_PARM_DESC(hideHash, "When set to 0, reading seclvl/passwd from sysfs "
  91. "will return the SHA1-hashed value of the password that "
  92. "lowers the secure level to 0.\n");
  93. #define MY_NAME "seclvl"
  94. /**
  95. * This time-limits log writes to one per second.
  96. */
  97. #define seclvl_printk(verb, type, fmt, arg...) \
  98. do { \
  99. if (verbosity >= verb) { \
  100. static unsigned long _prior; \
  101. unsigned long _now = jiffies; \
  102. if ((_now - _prior) > HZ) { \
  103. printk(type "%s: %s: " fmt, \
  104. MY_NAME, __FUNCTION__ , \
  105. ## arg); \
  106. _prior = _now; \
  107. } \
  108. } \
  109. } while (0)
  110. /**
  111. * The actual security level. Ranges between -1 and 2 inclusive.
  112. */
  113. static int seclvl;
  114. /**
  115. * flag to keep track of how we were registered
  116. */
  117. static int secondary;
  118. /**
  119. * Verifies that the requested secure level is valid, given the current
  120. * secure level.
  121. */
  122. static int seclvl_sanity(int reqlvl)
  123. {
  124. if ((reqlvl < -1) || (reqlvl > 2)) {
  125. seclvl_printk(1, KERN_WARNING, "Attempt to set seclvl out of "
  126. "range: [%d]\n", reqlvl);
  127. return -EINVAL;
  128. }
  129. if ((seclvl == 0) && (reqlvl == -1))
  130. return 0;
  131. if (reqlvl < seclvl) {
  132. seclvl_printk(1, KERN_WARNING, "Attempt to lower seclvl to "
  133. "[%d]\n", reqlvl);
  134. return -EPERM;
  135. }
  136. return 0;
  137. }
  138. /**
  139. * security level advancement rules:
  140. * Valid levels are -1 through 2, inclusive.
  141. * From -1, stuck. [ in case compiled into kernel ]
  142. * From 0 or above, can only increment.
  143. */
  144. static void do_seclvl_advance(void *data, u64 val)
  145. {
  146. int ret;
  147. int newlvl = (int)val;
  148. ret = seclvl_sanity(newlvl);
  149. if (ret)
  150. return;
  151. if (newlvl > 2) {
  152. seclvl_printk(1, KERN_WARNING, "Cannot advance to seclvl "
  153. "[%d]\n", newlvl);
  154. return;
  155. }
  156. if (seclvl == -1) {
  157. seclvl_printk(1, KERN_WARNING, "Not allowed to advance to "
  158. "seclvl [%d]\n", seclvl);
  159. return;
  160. }
  161. seclvl = newlvl; /* would it be more "correct" to set *data? */
  162. return;
  163. }
  164. static u64 seclvl_int_get(void *data)
  165. {
  166. return *(int *)data;
  167. }
  168. DEFINE_SIMPLE_ATTRIBUTE(seclvl_file_ops, seclvl_int_get, do_seclvl_advance, "%lld\n");
  169. static unsigned char hashedPassword[SHA1_DIGEST_SIZE];
  170. /**
  171. * Converts a block of plaintext of into its SHA1 hashed value.
  172. *
  173. * It would be nice if crypto had a wrapper to do this for us linear
  174. * people...
  175. */
  176. static int
  177. plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
  178. {
  179. char *pgVirtAddr;
  180. struct crypto_tfm *tfm;
  181. struct scatterlist sg[1];
  182. if (len > PAGE_SIZE) {
  183. seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d "
  184. "characters). Largest possible is %lu "
  185. "bytes.\n", len, PAGE_SIZE);
  186. return -ENOMEM;
  187. }
  188. tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP);
  189. if (tfm == NULL) {
  190. seclvl_printk(0, KERN_ERR,
  191. "Failed to load transform for SHA1\n");
  192. return -ENOSYS;
  193. }
  194. // Just get a new page; don't play around with page boundaries
  195. // and scatterlists.
  196. pgVirtAddr = (char *)__get_free_page(GFP_KERNEL);
  197. sg[0].page = virt_to_page(pgVirtAddr);
  198. sg[0].offset = 0;
  199. sg[0].length = len;
  200. strncpy(pgVirtAddr, plaintext, len);
  201. crypto_digest_init(tfm);
  202. crypto_digest_update(tfm, sg, 1);
  203. crypto_digest_final(tfm, hash);
  204. crypto_free_tfm(tfm);
  205. free_page((unsigned long)pgVirtAddr);
  206. return 0;
  207. }
  208. /**
  209. * Called whenever the user writes to the sysfs passwd handle to this kernel
  210. * object. It hashes the password and compares the hashed results.
  211. */
  212. static ssize_t
  213. passwd_write_file(struct file * file, const char __user * buf,
  214. size_t count, loff_t *ppos)
  215. {
  216. int i;
  217. unsigned char tmp[SHA1_DIGEST_SIZE];
  218. char *page;
  219. int rc;
  220. int len;
  221. if (!*passwd && !*sha1_passwd) {
  222. seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the "
  223. "seclvl module, but neither a plain text "
  224. "password nor a SHA1 hashed password was "
  225. "passed in as a module parameter! This is a "
  226. "bug, since it should not be possible to be in "
  227. "this part of the module; please tell a "
  228. "maintainer about this event.\n");
  229. return -EINVAL;
  230. }
  231. if (count < 0 || count >= PAGE_SIZE)
  232. return -EINVAL;
  233. if (*ppos != 0)
  234. return -EINVAL;
  235. page = (char *)get_zeroed_page(GFP_KERNEL);
  236. if (!page)
  237. return -ENOMEM;
  238. len = -EFAULT;
  239. if (copy_from_user(page, buf, count))
  240. goto out;
  241. len = strlen(page);
  242. /* ``echo "secret" > seclvl/passwd'' includes a newline */
  243. if (page[len - 1] == '\n')
  244. len--;
  245. /* Hash the password, then compare the hashed values */
  246. if ((rc = plaintext_to_sha1(tmp, page, len))) {
  247. seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
  248. "[%d]\n", rc);
  249. return rc;
  250. }
  251. for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
  252. if (hashedPassword[i] != tmp[i])
  253. return -EPERM;
  254. }
  255. seclvl_printk(0, KERN_INFO,
  256. "Password accepted; seclvl reduced to 0.\n");
  257. seclvl = 0;
  258. len = count;
  259. out:
  260. free_page((unsigned long)page);
  261. return len;
  262. }
  263. static struct file_operations passwd_file_ops = {
  264. .write = passwd_write_file,
  265. };
  266. /**
  267. * Explicitely disallow ptrace'ing the init process.
  268. */
  269. static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
  270. {
  271. if (seclvl >= 0) {
  272. if (child->pid == 1) {
  273. seclvl_printk(1, KERN_WARNING, "Attempt to ptrace "
  274. "the init process dissallowed in "
  275. "secure level %d\n", seclvl);
  276. return -EPERM;
  277. }
  278. }
  279. return 0;
  280. }
  281. /**
  282. * Capability checks for seclvl. The majority of the policy
  283. * enforcement for seclvl takes place here.
  284. */
  285. static int seclvl_capable(struct task_struct *tsk, int cap)
  286. {
  287. /* init can do anything it wants */
  288. if (tsk->pid == 1)
  289. return 0;
  290. switch (seclvl) {
  291. case 2:
  292. /* fall through */
  293. case 1:
  294. if (cap == CAP_LINUX_IMMUTABLE) {
  295. seclvl_printk(1, KERN_WARNING, "Attempt to modify "
  296. "the IMMUTABLE and/or APPEND extended "
  297. "attribute on a file with the IMMUTABLE "
  298. "and/or APPEND extended attribute set "
  299. "denied in seclvl [%d]\n", seclvl);
  300. return -EPERM;
  301. } else if (cap == CAP_SYS_RAWIO) { // Somewhat broad...
  302. seclvl_printk(1, KERN_WARNING, "Attempt to perform "
  303. "raw I/O while in secure level [%d] "
  304. "denied\n", seclvl);
  305. return -EPERM;
  306. } else if (cap == CAP_NET_ADMIN) {
  307. seclvl_printk(1, KERN_WARNING, "Attempt to perform "
  308. "network administrative task while "
  309. "in secure level [%d] denied\n", seclvl);
  310. return -EPERM;
  311. } else if (cap == CAP_SETUID) {
  312. seclvl_printk(1, KERN_WARNING, "Attempt to setuid "
  313. "while in secure level [%d] denied\n",
  314. seclvl);
  315. return -EPERM;
  316. } else if (cap == CAP_SETGID) {
  317. seclvl_printk(1, KERN_WARNING, "Attempt to setgid "
  318. "while in secure level [%d] denied\n",
  319. seclvl);
  320. } else if (cap == CAP_SYS_MODULE) {
  321. seclvl_printk(1, KERN_WARNING, "Attempt to perform "
  322. "a module operation while in secure "
  323. "level [%d] denied\n", seclvl);
  324. return -EPERM;
  325. }
  326. break;
  327. default:
  328. break;
  329. }
  330. /* from dummy.c */
  331. if (cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0)
  332. return 0; /* capability granted */
  333. seclvl_printk(1, KERN_WARNING, "Capability denied\n");
  334. return -EPERM; /* capability denied */
  335. }
  336. /**
  337. * Disallow reversing the clock in seclvl > 1
  338. */
  339. static int seclvl_settime(struct timespec *tv, struct timezone *tz)
  340. {
  341. struct timespec now;
  342. if (seclvl > 1) {
  343. now = current_kernel_time();
  344. if (tv->tv_sec < now.tv_sec ||
  345. (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) {
  346. seclvl_printk(1, KERN_WARNING, "Attempt to decrement "
  347. "time in secure level %d denied: "
  348. "current->pid = [%d], "
  349. "current->group_leader->pid = [%d]\n",
  350. seclvl, current->pid,
  351. current->group_leader->pid);
  352. return -EPERM;
  353. } /* if attempt to decrement time */
  354. } /* if seclvl > 1 */
  355. return 0;
  356. }
  357. /* claim the blockdev to exclude mounters, release on file close */
  358. static int seclvl_bd_claim(struct inode *inode)
  359. {
  360. int holder;
  361. struct block_device *bdev = NULL;
  362. dev_t dev = inode->i_rdev;
  363. bdev = open_by_devnum(dev, FMODE_WRITE);
  364. if (bdev) {
  365. if (bd_claim(bdev, &holder)) {
  366. blkdev_put(bdev);
  367. return -EPERM;
  368. }
  369. /* claimed, mark it to release on close */
  370. inode->i_security = current;
  371. }
  372. return 0;
  373. }
  374. /* release the blockdev if you claimed it */
  375. static void seclvl_bd_release(struct inode *inode)
  376. {
  377. if (inode && S_ISBLK(inode->i_mode) && inode->i_security == current) {
  378. struct block_device *bdev = inode->i_bdev;
  379. if (bdev) {
  380. bd_release(bdev);
  381. blkdev_put(bdev);
  382. inode->i_security = NULL;
  383. }
  384. }
  385. }
  386. /**
  387. * Security for writes to block devices is regulated by this seclvl
  388. * function. Deny all writes to block devices in seclvl 2. In
  389. * seclvl 1, we only deny writes to *mounted* block devices.
  390. */
  391. static int
  392. seclvl_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
  393. {
  394. if (current->pid != 1 && S_ISBLK(inode->i_mode) && (mask & MAY_WRITE)) {
  395. switch (seclvl) {
  396. case 2:
  397. seclvl_printk(1, KERN_WARNING, "Write to block device "
  398. "denied in secure level [%d]\n", seclvl);
  399. return -EPERM;
  400. case 1:
  401. if (seclvl_bd_claim(inode)) {
  402. seclvl_printk(1, KERN_WARNING,
  403. "Write to mounted block device "
  404. "denied in secure level [%d]\n",
  405. seclvl);
  406. return -EPERM;
  407. }
  408. }
  409. }
  410. return 0;
  411. }
  412. /**
  413. * The SUID and SGID bits cannot be set in seclvl >= 1
  414. */
  415. static int seclvl_inode_setattr(struct dentry *dentry, struct iattr *iattr)
  416. {
  417. if (seclvl > 0) {
  418. if (iattr->ia_valid & ATTR_MODE)
  419. if (iattr->ia_mode & S_ISUID ||
  420. iattr->ia_mode & S_ISGID) {
  421. seclvl_printk(1, KERN_WARNING, "Attempt to "
  422. "modify SUID or SGID bit "
  423. "denied in seclvl [%d]\n",
  424. seclvl);
  425. return -EPERM;
  426. }
  427. }
  428. return 0;
  429. }
  430. /* release busied block devices */
  431. static void seclvl_file_free_security(struct file *filp)
  432. {
  433. struct dentry *dentry = filp->f_dentry;
  434. struct inode *inode = NULL;
  435. if (dentry) {
  436. inode = dentry->d_inode;
  437. seclvl_bd_release(inode);
  438. }
  439. }
  440. /**
  441. * Cannot unmount in secure level 2
  442. */
  443. static int seclvl_umount(struct vfsmount *mnt, int flags)
  444. {
  445. if (current->pid == 1)
  446. return 0;
  447. if (seclvl == 2) {
  448. seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure "
  449. "level %d\n", seclvl);
  450. return -EPERM;
  451. }
  452. return 0;
  453. }
  454. static struct security_operations seclvl_ops = {
  455. .ptrace = seclvl_ptrace,
  456. .capable = seclvl_capable,
  457. .inode_permission = seclvl_inode_permission,
  458. .inode_setattr = seclvl_inode_setattr,
  459. .file_free_security = seclvl_file_free_security,
  460. .settime = seclvl_settime,
  461. .sb_umount = seclvl_umount,
  462. };
  463. /**
  464. * Process the password-related module parameters
  465. */
  466. static int processPassword(void)
  467. {
  468. int rc = 0;
  469. hashedPassword[0] = '\0';
  470. if (*passwd) {
  471. if (*sha1_passwd) {
  472. seclvl_printk(0, KERN_ERR, "Error: Both "
  473. "passwd and sha1_passwd "
  474. "were set, but they are mutually "
  475. "exclusive.\n");
  476. return -EINVAL;
  477. }
  478. if ((rc = plaintext_to_sha1(hashedPassword, passwd,
  479. strlen(passwd)))) {
  480. seclvl_printk(0, KERN_ERR, "Error: SHA1 support not "
  481. "in kernel\n");
  482. return rc;
  483. }
  484. /* All static data goes to the BSS, which zero's the
  485. * plaintext password out for us. */
  486. } else if (*sha1_passwd) { // Base 16
  487. int i;
  488. i = strlen(sha1_passwd);
  489. if (i != (SHA1_DIGEST_SIZE * 2)) {
  490. seclvl_printk(0, KERN_ERR, "Received [%d] bytes; "
  491. "expected [%d] for the hexadecimal "
  492. "representation of the SHA1 hash of "
  493. "the password.\n",
  494. i, (SHA1_DIGEST_SIZE * 2));
  495. return -EINVAL;
  496. }
  497. while ((i -= 2) + 2) {
  498. unsigned char tmp;
  499. tmp = sha1_passwd[i + 2];
  500. sha1_passwd[i + 2] = '\0';
  501. hashedPassword[i / 2] = (unsigned char)
  502. simple_strtol(&sha1_passwd[i], NULL, 16);
  503. sha1_passwd[i + 2] = tmp;
  504. }
  505. }
  506. return 0;
  507. }
  508. /**
  509. * securityfs registrations
  510. */
  511. struct dentry *dir_ino, *seclvl_ino, *passwd_ino;
  512. static int seclvlfs_register(void)
  513. {
  514. dir_ino = securityfs_create_dir("seclvl", NULL);
  515. if (!dir_ino)
  516. return -EFAULT;
  517. seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR,
  518. dir_ino, &seclvl, &seclvl_file_ops);
  519. if (!seclvl_ino)
  520. goto out_deldir;
  521. if (*passwd || *sha1_passwd) {
  522. passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR,
  523. dir_ino, NULL, &passwd_file_ops);
  524. if (!passwd_ino)
  525. goto out_delf;
  526. }
  527. return 0;
  528. out_deldir:
  529. securityfs_remove(dir_ino);
  530. out_delf:
  531. securityfs_remove(seclvl_ino);
  532. return -EFAULT;
  533. }
  534. /**
  535. * Initialize the seclvl module.
  536. */
  537. static int __init seclvl_init(void)
  538. {
  539. int rc = 0;
  540. if (verbosity < 0 || verbosity > 1) {
  541. printk(KERN_ERR "Error: bad verbosity [%d]; only 0 or 1 "
  542. "are valid values\n", verbosity);
  543. rc = -EINVAL;
  544. goto exit;
  545. }
  546. if (initlvl < -1 || initlvl > 2) {
  547. seclvl_printk(0, KERN_ERR, "Error: bad initial securelevel "
  548. "[%d].\n", initlvl);
  549. rc = -EINVAL;
  550. goto exit;
  551. }
  552. seclvl = initlvl;
  553. if ((rc = processPassword())) {
  554. seclvl_printk(0, KERN_ERR, "Error processing the password "
  555. "module parameter(s): rc = [%d]\n", rc);
  556. goto exit;
  557. }
  558. /* register ourselves with the security framework */
  559. if (register_security(&seclvl_ops)) {
  560. seclvl_printk(0, KERN_ERR,
  561. "seclvl: Failure registering with the "
  562. "kernel.\n");
  563. /* try registering with primary module */
  564. rc = mod_reg_security(MY_NAME, &seclvl_ops);
  565. if (rc) {
  566. seclvl_printk(0, KERN_ERR, "seclvl: Failure "
  567. "registering with primary security "
  568. "module.\n");
  569. goto exit;
  570. } /* if primary module registered */
  571. secondary = 1;
  572. } /* if we registered ourselves with the security framework */
  573. if ((rc = seclvlfs_register())) {
  574. seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
  575. goto exit;
  576. }
  577. seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n");
  578. exit:
  579. if (rc) {
  580. printk(KERN_ERR "seclvl: Error during initialization: rc = "
  581. "[%d]\n", rc);
  582. }
  583. return rc;
  584. }
  585. /**
  586. * Remove the seclvl module.
  587. */
  588. static void __exit seclvl_exit(void)
  589. {
  590. securityfs_remove(seclvl_ino);
  591. if (*passwd || *sha1_passwd)
  592. securityfs_remove(passwd_ino);
  593. securityfs_remove(dir_ino);
  594. if (secondary == 1) {
  595. mod_unreg_security(MY_NAME, &seclvl_ops);
  596. } else if (unregister_security(&seclvl_ops)) {
  597. seclvl_printk(0, KERN_INFO,
  598. "seclvl: Failure unregistering with the "
  599. "kernel\n");
  600. }
  601. }
  602. module_init(seclvl_init);
  603. module_exit(seclvl_exit);
  604. MODULE_AUTHOR("Michael A. Halcrow <mike@halcrow.us>");
  605. MODULE_DESCRIPTION("LSM implementation of the BSD Secure Levels");
  606. MODULE_LICENSE("GPL");