seclvl.c 17 KB

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