seclvl.c 17 KB

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