seclvl.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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 -ENOMEM;
  233. if (*ppos != 0) {
  234. return -EINVAL;
  235. }
  236. page = (char *)get_zeroed_page(GFP_KERNEL);
  237. if (!page)
  238. return -ENOMEM;
  239. len = -EFAULT;
  240. if (copy_from_user(page, buf, count))
  241. goto out;
  242. len = strlen(page);
  243. /* ``echo "secret" > seclvl/passwd'' includes a newline */
  244. if (page[len - 1] == '\n') {
  245. len--;
  246. }
  247. /* Hash the password, then compare the hashed values */
  248. if ((rc = plaintext_to_sha1(tmp, page, len))) {
  249. seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
  250. "[%d]\n", rc);
  251. return rc;
  252. }
  253. for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
  254. if (hashedPassword[i] != tmp[i]) {
  255. return -EPERM;
  256. }
  257. }
  258. seclvl_printk(0, KERN_INFO,
  259. "Password accepted; seclvl reduced to 0.\n");
  260. seclvl = 0;
  261. len = count;
  262. out:
  263. free_page((unsigned long)page);
  264. return len;
  265. }
  266. static struct file_operations passwd_file_ops = {
  267. .write = passwd_write_file,
  268. };
  269. /**
  270. * Explicitely disallow ptrace'ing the init process.
  271. */
  272. static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
  273. {
  274. if (seclvl >= 0) {
  275. if (child->pid == 1) {
  276. seclvl_printk(1, KERN_WARNING, "Attempt to ptrace "
  277. "the init process dissallowed in "
  278. "secure level %d\n", seclvl);
  279. return -EPERM;
  280. }
  281. }
  282. return 0;
  283. }
  284. /**
  285. * Capability checks for seclvl. The majority of the policy
  286. * enforcement for seclvl takes place here.
  287. */
  288. static int seclvl_capable(struct task_struct *tsk, int cap)
  289. {
  290. /* init can do anything it wants */
  291. if (tsk->pid == 1)
  292. return 0;
  293. switch (seclvl) {
  294. case 2:
  295. /* fall through */
  296. case 1:
  297. if (cap == CAP_LINUX_IMMUTABLE) {
  298. seclvl_printk(1, KERN_WARNING, "Attempt to modify "
  299. "the IMMUTABLE and/or APPEND extended "
  300. "attribute on a file with the IMMUTABLE "
  301. "and/or APPEND extended attribute set "
  302. "denied in seclvl [%d]\n", seclvl);
  303. return -EPERM;
  304. } else if (cap == CAP_SYS_RAWIO) { // Somewhat broad...
  305. seclvl_printk(1, KERN_WARNING, "Attempt to perform "
  306. "raw I/O while in secure level [%d] "
  307. "denied\n", seclvl);
  308. return -EPERM;
  309. } else if (cap == CAP_NET_ADMIN) {
  310. seclvl_printk(1, KERN_WARNING, "Attempt to perform "
  311. "network administrative task while "
  312. "in secure level [%d] denied\n", seclvl);
  313. return -EPERM;
  314. } else if (cap == CAP_SETUID) {
  315. seclvl_printk(1, KERN_WARNING, "Attempt to setuid "
  316. "while in secure level [%d] denied\n",
  317. seclvl);
  318. return -EPERM;
  319. } else if (cap == CAP_SETGID) {
  320. seclvl_printk(1, KERN_WARNING, "Attempt to setgid "
  321. "while in secure level [%d] denied\n",
  322. seclvl);
  323. } else if (cap == CAP_SYS_MODULE) {
  324. seclvl_printk(1, KERN_WARNING, "Attempt to perform "
  325. "a module operation while in secure "
  326. "level [%d] denied\n", seclvl);
  327. return -EPERM;
  328. }
  329. break;
  330. default:
  331. break;
  332. }
  333. /* from dummy.c */
  334. if (cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0)
  335. return 0; /* capability granted */
  336. seclvl_printk(1, KERN_WARNING, "Capability denied\n");
  337. return -EPERM; /* capability denied */
  338. }
  339. /**
  340. * Disallow reversing the clock in seclvl > 1
  341. */
  342. static int seclvl_settime(struct timespec *tv, struct timezone *tz)
  343. {
  344. struct timespec now;
  345. if (seclvl > 1) {
  346. now = current_kernel_time();
  347. if (tv->tv_sec < now.tv_sec ||
  348. (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) {
  349. seclvl_printk(1, KERN_WARNING, "Attempt to decrement "
  350. "time in secure level %d denied: "
  351. "current->pid = [%d], "
  352. "current->group_leader->pid = [%d]\n",
  353. seclvl, current->pid,
  354. current->group_leader->pid);
  355. return -EPERM;
  356. } /* if attempt to decrement time */
  357. } /* if seclvl > 1 */
  358. return 0;
  359. }
  360. /* claim the blockdev to exclude mounters, release on file close */
  361. static int seclvl_bd_claim(struct inode *inode)
  362. {
  363. int holder;
  364. struct block_device *bdev = NULL;
  365. dev_t dev = inode->i_rdev;
  366. bdev = open_by_devnum(dev, FMODE_WRITE);
  367. if (bdev) {
  368. if (bd_claim(bdev, &holder)) {
  369. blkdev_put(bdev);
  370. return -EPERM;
  371. }
  372. /* claimed, mark it to release on close */
  373. inode->i_security = current;
  374. }
  375. return 0;
  376. }
  377. /* release the blockdev if you claimed it */
  378. static void seclvl_bd_release(struct inode *inode)
  379. {
  380. if (inode && S_ISBLK(inode->i_mode) && inode->i_security == current) {
  381. struct block_device *bdev = inode->i_bdev;
  382. if (bdev) {
  383. bd_release(bdev);
  384. blkdev_put(bdev);
  385. inode->i_security = NULL;
  386. }
  387. }
  388. }
  389. /**
  390. * Security for writes to block devices is regulated by this seclvl
  391. * function. Deny all writes to block devices in seclvl 2. In
  392. * seclvl 1, we only deny writes to *mounted* block devices.
  393. */
  394. static int
  395. seclvl_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
  396. {
  397. if (current->pid != 1 && S_ISBLK(inode->i_mode) && (mask & MAY_WRITE)) {
  398. switch (seclvl) {
  399. case 2:
  400. seclvl_printk(1, KERN_WARNING, "Write to block device "
  401. "denied in secure level [%d]\n", seclvl);
  402. return -EPERM;
  403. case 1:
  404. if (seclvl_bd_claim(inode)) {
  405. seclvl_printk(1, KERN_WARNING,
  406. "Write to mounted block device "
  407. "denied in secure level [%d]\n",
  408. seclvl);
  409. return -EPERM;
  410. }
  411. }
  412. }
  413. return 0;
  414. }
  415. /**
  416. * The SUID and SGID bits cannot be set in seclvl >= 1
  417. */
  418. static int seclvl_inode_setattr(struct dentry *dentry, struct iattr *iattr)
  419. {
  420. if (seclvl > 0) {
  421. if (iattr->ia_valid & ATTR_MODE)
  422. if (iattr->ia_mode & S_ISUID ||
  423. iattr->ia_mode & S_ISGID) {
  424. seclvl_printk(1, KERN_WARNING, "Attempt to "
  425. "modify SUID or SGID bit "
  426. "denied in seclvl [%d]\n",
  427. seclvl);
  428. return -EPERM;
  429. }
  430. }
  431. return 0;
  432. }
  433. /* release busied block devices */
  434. static void seclvl_file_free_security(struct file *filp)
  435. {
  436. struct dentry *dentry = filp->f_dentry;
  437. struct inode *inode = NULL;
  438. if (dentry) {
  439. inode = dentry->d_inode;
  440. seclvl_bd_release(inode);
  441. }
  442. }
  443. /**
  444. * Cannot unmount in secure level 2
  445. */
  446. static int seclvl_umount(struct vfsmount *mnt, int flags)
  447. {
  448. if (current->pid == 1) {
  449. return 0;
  450. }
  451. if (seclvl == 2) {
  452. seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure "
  453. "level %d\n", seclvl);
  454. return -EPERM;
  455. }
  456. return 0;
  457. }
  458. static struct security_operations seclvl_ops = {
  459. .ptrace = seclvl_ptrace,
  460. .capable = seclvl_capable,
  461. .inode_permission = seclvl_inode_permission,
  462. .inode_setattr = seclvl_inode_setattr,
  463. .file_free_security = seclvl_file_free_security,
  464. .settime = seclvl_settime,
  465. .sb_umount = seclvl_umount,
  466. };
  467. /**
  468. * Process the password-related module parameters
  469. */
  470. static int processPassword(void)
  471. {
  472. int rc = 0;
  473. hashedPassword[0] = '\0';
  474. if (*passwd) {
  475. if (*sha1_passwd) {
  476. seclvl_printk(0, KERN_ERR, "Error: Both "
  477. "passwd and sha1_passwd "
  478. "were set, but they are mutually "
  479. "exclusive.\n");
  480. return -EINVAL;
  481. }
  482. if ((rc = plaintext_to_sha1(hashedPassword, passwd,
  483. strlen(passwd)))) {
  484. seclvl_printk(0, KERN_ERR, "Error: SHA1 support not "
  485. "in kernel\n");
  486. return rc;
  487. }
  488. /* All static data goes to the BSS, which zero's the
  489. * plaintext password out for us. */
  490. } else if (*sha1_passwd) { // Base 16
  491. int i;
  492. i = strlen(sha1_passwd);
  493. if (i != (SHA1_DIGEST_SIZE * 2)) {
  494. seclvl_printk(0, KERN_ERR, "Received [%d] bytes; "
  495. "expected [%d] for the hexadecimal "
  496. "representation of the SHA1 hash of "
  497. "the password.\n",
  498. i, (SHA1_DIGEST_SIZE * 2));
  499. return -EINVAL;
  500. }
  501. while ((i -= 2) + 2) {
  502. unsigned char tmp;
  503. tmp = sha1_passwd[i + 2];
  504. sha1_passwd[i + 2] = '\0';
  505. hashedPassword[i / 2] = (unsigned char)
  506. simple_strtol(&sha1_passwd[i], NULL, 16);
  507. sha1_passwd[i + 2] = tmp;
  508. }
  509. }
  510. return 0;
  511. }
  512. /**
  513. * securityfs registrations
  514. */
  515. struct dentry *dir_ino, *seclvl_ino, *passwd_ino;
  516. static int seclvlfs_register(void)
  517. {
  518. dir_ino = securityfs_create_dir("seclvl", NULL);
  519. if (!dir_ino)
  520. return -EFAULT;
  521. seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR,
  522. dir_ino, &seclvl, &seclvl_file_ops);
  523. if (!seclvl_ino)
  524. goto out_deldir;
  525. if (*passwd || *sha1_passwd) {
  526. passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR,
  527. dir_ino, NULL, &passwd_file_ops);
  528. if (!passwd_ino)
  529. goto out_delf;
  530. }
  531. return 0;
  532. out_deldir:
  533. securityfs_remove(dir_ino);
  534. out_delf:
  535. securityfs_remove(seclvl_ino);
  536. return -EFAULT;
  537. }
  538. /**
  539. * Initialize the seclvl module.
  540. */
  541. static int __init seclvl_init(void)
  542. {
  543. int rc = 0;
  544. if (verbosity < 0 || verbosity > 1) {
  545. printk(KERN_ERR "Error: bad verbosity [%d]; only 0 or 1 "
  546. "are valid values\n", verbosity);
  547. rc = -EINVAL;
  548. goto exit;
  549. }
  550. if (initlvl < -1 || initlvl > 2) {
  551. seclvl_printk(0, KERN_ERR, "Error: bad initial securelevel "
  552. "[%d].\n", initlvl);
  553. rc = -EINVAL;
  554. goto exit;
  555. }
  556. seclvl = initlvl;
  557. if ((rc = processPassword())) {
  558. seclvl_printk(0, KERN_ERR, "Error processing the password "
  559. "module parameter(s): rc = [%d]\n", rc);
  560. goto exit;
  561. }
  562. /* register ourselves with the security framework */
  563. if (register_security(&seclvl_ops)) {
  564. seclvl_printk(0, KERN_ERR,
  565. "seclvl: Failure registering with the "
  566. "kernel.\n");
  567. /* try registering with primary module */
  568. rc = mod_reg_security(MY_NAME, &seclvl_ops);
  569. if (rc) {
  570. seclvl_printk(0, KERN_ERR, "seclvl: Failure "
  571. "registering with primary security "
  572. "module.\n");
  573. goto exit;
  574. } /* if primary module registered */
  575. secondary = 1;
  576. } /* if we registered ourselves with the security framework */
  577. if ((rc = seclvlfs_register())) {
  578. seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
  579. goto exit;
  580. }
  581. seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n");
  582. exit:
  583. if (rc) {
  584. printk(KERN_ERR "seclvl: Error during initialization: rc = "
  585. "[%d]\n", rc);
  586. }
  587. return rc;
  588. }
  589. /**
  590. * Remove the seclvl module.
  591. */
  592. static void __exit seclvl_exit(void)
  593. {
  594. securityfs_remove(seclvl_ino);
  595. if (*passwd || *sha1_passwd) {
  596. securityfs_remove(passwd_ino);
  597. }
  598. securityfs_remove(dir_ino);
  599. if (secondary == 1) {
  600. mod_unreg_security(MY_NAME, &seclvl_ops);
  601. } else if (unregister_security(&seclvl_ops)) {
  602. seclvl_printk(0, KERN_INFO,
  603. "seclvl: Failure unregistering with the "
  604. "kernel\n");
  605. }
  606. }
  607. module_init(seclvl_init);
  608. module_exit(seclvl_exit);
  609. MODULE_AUTHOR("Michael A. Halcrow <mike@halcrow.us>");
  610. MODULE_DESCRIPTION("LSM implementation of the BSD Secure Levels");
  611. MODULE_LICENSE("GPL");