smackfs.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  1. /*
  2. * Copyright (C) 2007 Casey Schaufler <casey@schaufler-ca.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, version 2.
  7. *
  8. * Authors:
  9. * Casey Schaufler <casey@schaufler-ca.com>
  10. * Ahmed S. Darwish <darwish.07@gmail.com>
  11. *
  12. * Special thanks to the authors of selinuxfs.
  13. *
  14. * Karl MacMillan <kmacmillan@tresys.com>
  15. * James Morris <jmorris@redhat.com>
  16. *
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/vmalloc.h>
  20. #include <linux/security.h>
  21. #include <linux/mutex.h>
  22. #include <linux/slab.h>
  23. #include <net/net_namespace.h>
  24. #include <net/netlabel.h>
  25. #include <net/cipso_ipv4.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/ctype.h>
  28. #include <linux/audit.h>
  29. #include "smack.h"
  30. /*
  31. * smackfs pseudo filesystem.
  32. */
  33. enum smk_inos {
  34. SMK_ROOT_INO = 2,
  35. SMK_LOAD = 3, /* load policy */
  36. SMK_CIPSO = 4, /* load label -> CIPSO mapping */
  37. SMK_DOI = 5, /* CIPSO DOI */
  38. SMK_DIRECT = 6, /* CIPSO level indicating direct label */
  39. SMK_AMBIENT = 7, /* internet ambient label */
  40. SMK_NETLBLADDR = 8, /* single label hosts */
  41. SMK_ONLYCAP = 9, /* the only "capable" label */
  42. SMK_LOGGING = 10, /* logging */
  43. };
  44. /*
  45. * List locks
  46. */
  47. static DEFINE_MUTEX(smack_list_lock);
  48. static DEFINE_MUTEX(smack_cipso_lock);
  49. static DEFINE_MUTEX(smack_ambient_lock);
  50. static DEFINE_MUTEX(smk_netlbladdr_lock);
  51. /*
  52. * This is the "ambient" label for network traffic.
  53. * If it isn't somehow marked, use this.
  54. * It can be reset via smackfs/ambient
  55. */
  56. char *smack_net_ambient = smack_known_floor.smk_known;
  57. /*
  58. * This is the level in a CIPSO header that indicates a
  59. * smack label is contained directly in the category set.
  60. * It can be reset via smackfs/direct
  61. */
  62. int smack_cipso_direct = SMACK_CIPSO_DIRECT_DEFAULT;
  63. /*
  64. * Unless a process is running with this label even
  65. * having CAP_MAC_OVERRIDE isn't enough to grant
  66. * privilege to violate MAC policy. If no label is
  67. * designated (the NULL case) capabilities apply to
  68. * everyone. It is expected that the hat (^) label
  69. * will be used if any label is used.
  70. */
  71. char *smack_onlycap;
  72. /*
  73. * Certain IP addresses may be designated as single label hosts.
  74. * Packets are sent there unlabeled, but only from tasks that
  75. * can write to the specified label.
  76. */
  77. LIST_HEAD(smk_netlbladdr_list);
  78. LIST_HEAD(smack_rule_list);
  79. static int smk_cipso_doi_value = SMACK_CIPSO_DOI_DEFAULT;
  80. const char *smack_cipso_option = SMACK_CIPSO_OPTION;
  81. #define SEQ_READ_FINISHED 1
  82. /*
  83. * Values for parsing cipso rules
  84. * SMK_DIGITLEN: Length of a digit field in a rule.
  85. * SMK_CIPSOMIN: Minimum possible cipso rule length.
  86. * SMK_CIPSOMAX: Maximum possible cipso rule length.
  87. */
  88. #define SMK_DIGITLEN 4
  89. #define SMK_CIPSOMIN (SMK_LABELLEN + 2 * SMK_DIGITLEN)
  90. #define SMK_CIPSOMAX (SMK_CIPSOMIN + SMACK_CIPSO_MAXCATNUM * SMK_DIGITLEN)
  91. /*
  92. * Values for parsing MAC rules
  93. * SMK_ACCESS: Maximum possible combination of access permissions
  94. * SMK_ACCESSLEN: Maximum length for a rule access field
  95. * SMK_LOADLEN: Smack rule length
  96. */
  97. #define SMK_OACCESS "rwxa"
  98. #define SMK_ACCESS "rwxat"
  99. #define SMK_OACCESSLEN (sizeof(SMK_OACCESS) - 1)
  100. #define SMK_ACCESSLEN (sizeof(SMK_ACCESS) - 1)
  101. #define SMK_OLOADLEN (SMK_LABELLEN + SMK_LABELLEN + SMK_OACCESSLEN)
  102. #define SMK_LOADLEN (SMK_LABELLEN + SMK_LABELLEN + SMK_ACCESSLEN)
  103. /**
  104. * smk_netlabel_audit_set - fill a netlbl_audit struct
  105. * @nap: structure to fill
  106. */
  107. static void smk_netlabel_audit_set(struct netlbl_audit *nap)
  108. {
  109. nap->loginuid = audit_get_loginuid(current);
  110. nap->sessionid = audit_get_sessionid(current);
  111. nap->secid = smack_to_secid(smk_of_current());
  112. }
  113. /*
  114. * Values for parsing single label host rules
  115. * "1.2.3.4 X"
  116. * "192.168.138.129/32 abcdefghijklmnopqrstuvw"
  117. */
  118. #define SMK_NETLBLADDRMIN 9
  119. #define SMK_NETLBLADDRMAX 42
  120. /*
  121. * Seq_file read operations for /smack/load
  122. */
  123. static void *load_seq_start(struct seq_file *s, loff_t *pos)
  124. {
  125. if (*pos == SEQ_READ_FINISHED)
  126. return NULL;
  127. if (list_empty(&smack_rule_list))
  128. return NULL;
  129. return smack_rule_list.next;
  130. }
  131. static void *load_seq_next(struct seq_file *s, void *v, loff_t *pos)
  132. {
  133. struct list_head *list = v;
  134. if (list_is_last(list, &smack_rule_list)) {
  135. *pos = SEQ_READ_FINISHED;
  136. return NULL;
  137. }
  138. return list->next;
  139. }
  140. static int load_seq_show(struct seq_file *s, void *v)
  141. {
  142. struct list_head *list = v;
  143. struct smack_rule *srp =
  144. list_entry(list, struct smack_rule, list);
  145. seq_printf(s, "%s %s", (char *)srp->smk_subject,
  146. (char *)srp->smk_object);
  147. seq_putc(s, ' ');
  148. if (srp->smk_access & MAY_READ)
  149. seq_putc(s, 'r');
  150. if (srp->smk_access & MAY_WRITE)
  151. seq_putc(s, 'w');
  152. if (srp->smk_access & MAY_EXEC)
  153. seq_putc(s, 'x');
  154. if (srp->smk_access & MAY_APPEND)
  155. seq_putc(s, 'a');
  156. if (srp->smk_access & MAY_TRANSMUTE)
  157. seq_putc(s, 't');
  158. if (srp->smk_access == 0)
  159. seq_putc(s, '-');
  160. seq_putc(s, '\n');
  161. return 0;
  162. }
  163. static void load_seq_stop(struct seq_file *s, void *v)
  164. {
  165. /* No-op */
  166. }
  167. static const struct seq_operations load_seq_ops = {
  168. .start = load_seq_start,
  169. .next = load_seq_next,
  170. .show = load_seq_show,
  171. .stop = load_seq_stop,
  172. };
  173. /**
  174. * smk_open_load - open() for /smack/load
  175. * @inode: inode structure representing file
  176. * @file: "load" file pointer
  177. *
  178. * For reading, use load_seq_* seq_file reading operations.
  179. */
  180. static int smk_open_load(struct inode *inode, struct file *file)
  181. {
  182. return seq_open(file, &load_seq_ops);
  183. }
  184. /**
  185. * smk_set_access - add a rule to the rule list
  186. * @srp: the new rule to add
  187. *
  188. * Looks through the current subject/object/access list for
  189. * the subject/object pair and replaces the access that was
  190. * there. If the pair isn't found add it with the specified
  191. * access.
  192. *
  193. * Returns 0 if nothing goes wrong or -ENOMEM if it fails
  194. * during the allocation of the new pair to add.
  195. */
  196. static int smk_set_access(struct smack_rule *srp)
  197. {
  198. struct smack_rule *sp;
  199. int ret = 0;
  200. int found;
  201. mutex_lock(&smack_list_lock);
  202. found = 0;
  203. list_for_each_entry_rcu(sp, &smack_rule_list, list) {
  204. if (sp->smk_subject == srp->smk_subject &&
  205. sp->smk_object == srp->smk_object) {
  206. found = 1;
  207. sp->smk_access = srp->smk_access;
  208. break;
  209. }
  210. }
  211. if (found == 0)
  212. list_add_rcu(&srp->list, &smack_rule_list);
  213. mutex_unlock(&smack_list_lock);
  214. return ret;
  215. }
  216. /**
  217. * smk_write_load - write() for /smack/load
  218. * @file: file pointer, not actually used
  219. * @buf: where to get the data from
  220. * @count: bytes sent
  221. * @ppos: where to start - must be 0
  222. *
  223. * Get one smack access rule from above.
  224. * The format is exactly:
  225. * char subject[SMK_LABELLEN]
  226. * char object[SMK_LABELLEN]
  227. * char access[SMK_ACCESSLEN]
  228. *
  229. * writes must be SMK_LABELLEN+SMK_LABELLEN+SMK_ACCESSLEN bytes.
  230. */
  231. static ssize_t smk_write_load(struct file *file, const char __user *buf,
  232. size_t count, loff_t *ppos)
  233. {
  234. struct smack_rule *rule;
  235. char *data;
  236. int rc = -EINVAL;
  237. /*
  238. * Must have privilege.
  239. * No partial writes.
  240. * Enough data must be present.
  241. */
  242. if (!capable(CAP_MAC_ADMIN))
  243. return -EPERM;
  244. if (*ppos != 0)
  245. return -EINVAL;
  246. /*
  247. * Minor hack for backward compatability
  248. */
  249. if (count < (SMK_OLOADLEN) || count > SMK_LOADLEN)
  250. return -EINVAL;
  251. data = kzalloc(SMK_LOADLEN, GFP_KERNEL);
  252. if (data == NULL)
  253. return -ENOMEM;
  254. if (copy_from_user(data, buf, count) != 0) {
  255. rc = -EFAULT;
  256. goto out;
  257. }
  258. /*
  259. * More on the minor hack for backward compatability
  260. */
  261. if (count == (SMK_OLOADLEN))
  262. data[SMK_OLOADLEN] = '-';
  263. rule = kzalloc(sizeof(*rule), GFP_KERNEL);
  264. if (rule == NULL) {
  265. rc = -ENOMEM;
  266. goto out;
  267. }
  268. rule->smk_subject = smk_import(data, 0);
  269. if (rule->smk_subject == NULL)
  270. goto out_free_rule;
  271. rule->smk_object = smk_import(data + SMK_LABELLEN, 0);
  272. if (rule->smk_object == NULL)
  273. goto out_free_rule;
  274. rule->smk_access = 0;
  275. switch (data[SMK_LABELLEN + SMK_LABELLEN]) {
  276. case '-':
  277. break;
  278. case 'r':
  279. case 'R':
  280. rule->smk_access |= MAY_READ;
  281. break;
  282. default:
  283. goto out_free_rule;
  284. }
  285. switch (data[SMK_LABELLEN + SMK_LABELLEN + 1]) {
  286. case '-':
  287. break;
  288. case 'w':
  289. case 'W':
  290. rule->smk_access |= MAY_WRITE;
  291. break;
  292. default:
  293. goto out_free_rule;
  294. }
  295. switch (data[SMK_LABELLEN + SMK_LABELLEN + 2]) {
  296. case '-':
  297. break;
  298. case 'x':
  299. case 'X':
  300. rule->smk_access |= MAY_EXEC;
  301. break;
  302. default:
  303. goto out_free_rule;
  304. }
  305. switch (data[SMK_LABELLEN + SMK_LABELLEN + 3]) {
  306. case '-':
  307. break;
  308. case 'a':
  309. case 'A':
  310. rule->smk_access |= MAY_APPEND;
  311. break;
  312. default:
  313. goto out_free_rule;
  314. }
  315. switch (data[SMK_LABELLEN + SMK_LABELLEN + 4]) {
  316. case '-':
  317. break;
  318. case 't':
  319. case 'T':
  320. rule->smk_access |= MAY_TRANSMUTE;
  321. break;
  322. default:
  323. goto out_free_rule;
  324. }
  325. rc = smk_set_access(rule);
  326. if (!rc)
  327. rc = count;
  328. goto out;
  329. out_free_rule:
  330. kfree(rule);
  331. out:
  332. kfree(data);
  333. return rc;
  334. }
  335. static const struct file_operations smk_load_ops = {
  336. .open = smk_open_load,
  337. .read = seq_read,
  338. .llseek = seq_lseek,
  339. .write = smk_write_load,
  340. .release = seq_release,
  341. };
  342. /**
  343. * smk_cipso_doi - initialize the CIPSO domain
  344. */
  345. static void smk_cipso_doi(void)
  346. {
  347. int rc;
  348. struct cipso_v4_doi *doip;
  349. struct netlbl_audit nai;
  350. smk_netlabel_audit_set(&nai);
  351. rc = netlbl_cfg_map_del(NULL, PF_INET, NULL, NULL, &nai);
  352. if (rc != 0)
  353. printk(KERN_WARNING "%s:%d remove rc = %d\n",
  354. __func__, __LINE__, rc);
  355. doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
  356. if (doip == NULL)
  357. panic("smack: Failed to initialize cipso DOI.\n");
  358. doip->map.std = NULL;
  359. doip->doi = smk_cipso_doi_value;
  360. doip->type = CIPSO_V4_MAP_PASS;
  361. doip->tags[0] = CIPSO_V4_TAG_RBITMAP;
  362. for (rc = 1; rc < CIPSO_V4_TAG_MAXCNT; rc++)
  363. doip->tags[rc] = CIPSO_V4_TAG_INVALID;
  364. rc = netlbl_cfg_cipsov4_add(doip, &nai);
  365. if (rc != 0) {
  366. printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
  367. __func__, __LINE__, rc);
  368. kfree(doip);
  369. return;
  370. }
  371. rc = netlbl_cfg_cipsov4_map_add(doip->doi, NULL, NULL, NULL, &nai);
  372. if (rc != 0) {
  373. printk(KERN_WARNING "%s:%d map add rc = %d\n",
  374. __func__, __LINE__, rc);
  375. kfree(doip);
  376. return;
  377. }
  378. }
  379. /**
  380. * smk_unlbl_ambient - initialize the unlabeled domain
  381. * @oldambient: previous domain string
  382. */
  383. static void smk_unlbl_ambient(char *oldambient)
  384. {
  385. int rc;
  386. struct netlbl_audit nai;
  387. smk_netlabel_audit_set(&nai);
  388. if (oldambient != NULL) {
  389. rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai);
  390. if (rc != 0)
  391. printk(KERN_WARNING "%s:%d remove rc = %d\n",
  392. __func__, __LINE__, rc);
  393. }
  394. rc = netlbl_cfg_unlbl_map_add(smack_net_ambient, PF_INET,
  395. NULL, NULL, &nai);
  396. if (rc != 0)
  397. printk(KERN_WARNING "%s:%d add rc = %d\n",
  398. __func__, __LINE__, rc);
  399. }
  400. /*
  401. * Seq_file read operations for /smack/cipso
  402. */
  403. static void *cipso_seq_start(struct seq_file *s, loff_t *pos)
  404. {
  405. if (*pos == SEQ_READ_FINISHED)
  406. return NULL;
  407. if (list_empty(&smack_known_list))
  408. return NULL;
  409. return smack_known_list.next;
  410. }
  411. static void *cipso_seq_next(struct seq_file *s, void *v, loff_t *pos)
  412. {
  413. struct list_head *list = v;
  414. /*
  415. * labels with no associated cipso value wont be printed
  416. * in cipso_seq_show
  417. */
  418. if (list_is_last(list, &smack_known_list)) {
  419. *pos = SEQ_READ_FINISHED;
  420. return NULL;
  421. }
  422. return list->next;
  423. }
  424. /*
  425. * Print cipso labels in format:
  426. * label level[/cat[,cat]]
  427. */
  428. static int cipso_seq_show(struct seq_file *s, void *v)
  429. {
  430. struct list_head *list = v;
  431. struct smack_known *skp =
  432. list_entry(list, struct smack_known, list);
  433. struct smack_cipso *scp = skp->smk_cipso;
  434. char *cbp;
  435. char sep = '/';
  436. int cat = 1;
  437. int i;
  438. unsigned char m;
  439. if (scp == NULL)
  440. return 0;
  441. seq_printf(s, "%s %3d", (char *)&skp->smk_known, scp->smk_level);
  442. cbp = scp->smk_catset;
  443. for (i = 0; i < SMK_LABELLEN; i++)
  444. for (m = 0x80; m != 0; m >>= 1) {
  445. if (m & cbp[i]) {
  446. seq_printf(s, "%c%d", sep, cat);
  447. sep = ',';
  448. }
  449. cat++;
  450. }
  451. seq_putc(s, '\n');
  452. return 0;
  453. }
  454. static void cipso_seq_stop(struct seq_file *s, void *v)
  455. {
  456. /* No-op */
  457. }
  458. static const struct seq_operations cipso_seq_ops = {
  459. .start = cipso_seq_start,
  460. .stop = cipso_seq_stop,
  461. .next = cipso_seq_next,
  462. .show = cipso_seq_show,
  463. };
  464. /**
  465. * smk_open_cipso - open() for /smack/cipso
  466. * @inode: inode structure representing file
  467. * @file: "cipso" file pointer
  468. *
  469. * Connect our cipso_seq_* operations with /smack/cipso
  470. * file_operations
  471. */
  472. static int smk_open_cipso(struct inode *inode, struct file *file)
  473. {
  474. return seq_open(file, &cipso_seq_ops);
  475. }
  476. /**
  477. * smk_write_cipso - write() for /smack/cipso
  478. * @file: file pointer, not actually used
  479. * @buf: where to get the data from
  480. * @count: bytes sent
  481. * @ppos: where to start
  482. *
  483. * Accepts only one cipso rule per write call.
  484. * Returns number of bytes written or error code, as appropriate
  485. */
  486. static ssize_t smk_write_cipso(struct file *file, const char __user *buf,
  487. size_t count, loff_t *ppos)
  488. {
  489. struct smack_known *skp;
  490. struct smack_cipso *scp = NULL;
  491. char mapcatset[SMK_LABELLEN];
  492. int maplevel;
  493. int cat;
  494. int catlen;
  495. ssize_t rc = -EINVAL;
  496. char *data = NULL;
  497. char *rule;
  498. int ret;
  499. int i;
  500. /*
  501. * Must have privilege.
  502. * No partial writes.
  503. * Enough data must be present.
  504. */
  505. if (!capable(CAP_MAC_ADMIN))
  506. return -EPERM;
  507. if (*ppos != 0)
  508. return -EINVAL;
  509. if (count < SMK_CIPSOMIN || count > SMK_CIPSOMAX)
  510. return -EINVAL;
  511. data = kzalloc(count + 1, GFP_KERNEL);
  512. if (data == NULL)
  513. return -ENOMEM;
  514. if (copy_from_user(data, buf, count) != 0) {
  515. rc = -EFAULT;
  516. goto unlockedout;
  517. }
  518. /* labels cannot begin with a '-' */
  519. if (data[0] == '-') {
  520. rc = -EINVAL;
  521. goto unlockedout;
  522. }
  523. data[count] = '\0';
  524. rule = data;
  525. /*
  526. * Only allow one writer at a time. Writes should be
  527. * quite rare and small in any case.
  528. */
  529. mutex_lock(&smack_cipso_lock);
  530. skp = smk_import_entry(rule, 0);
  531. if (skp == NULL)
  532. goto out;
  533. rule += SMK_LABELLEN;
  534. ret = sscanf(rule, "%d", &maplevel);
  535. if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
  536. goto out;
  537. rule += SMK_DIGITLEN;
  538. ret = sscanf(rule, "%d", &catlen);
  539. if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
  540. goto out;
  541. if (count != (SMK_CIPSOMIN + catlen * SMK_DIGITLEN))
  542. goto out;
  543. memset(mapcatset, 0, sizeof(mapcatset));
  544. for (i = 0; i < catlen; i++) {
  545. rule += SMK_DIGITLEN;
  546. ret = sscanf(rule, "%d", &cat);
  547. if (ret != 1 || cat > SMACK_CIPSO_MAXCATVAL)
  548. goto out;
  549. smack_catset_bit(cat, mapcatset);
  550. }
  551. if (skp->smk_cipso == NULL) {
  552. scp = kzalloc(sizeof(struct smack_cipso), GFP_KERNEL);
  553. if (scp == NULL) {
  554. rc = -ENOMEM;
  555. goto out;
  556. }
  557. }
  558. spin_lock_bh(&skp->smk_cipsolock);
  559. if (scp == NULL)
  560. scp = skp->smk_cipso;
  561. else
  562. skp->smk_cipso = scp;
  563. scp->smk_level = maplevel;
  564. memcpy(scp->smk_catset, mapcatset, sizeof(mapcatset));
  565. spin_unlock_bh(&skp->smk_cipsolock);
  566. rc = count;
  567. out:
  568. mutex_unlock(&smack_cipso_lock);
  569. unlockedout:
  570. kfree(data);
  571. return rc;
  572. }
  573. static const struct file_operations smk_cipso_ops = {
  574. .open = smk_open_cipso,
  575. .read = seq_read,
  576. .llseek = seq_lseek,
  577. .write = smk_write_cipso,
  578. .release = seq_release,
  579. };
  580. /*
  581. * Seq_file read operations for /smack/netlabel
  582. */
  583. static void *netlbladdr_seq_start(struct seq_file *s, loff_t *pos)
  584. {
  585. if (*pos == SEQ_READ_FINISHED)
  586. return NULL;
  587. if (list_empty(&smk_netlbladdr_list))
  588. return NULL;
  589. return smk_netlbladdr_list.next;
  590. }
  591. static void *netlbladdr_seq_next(struct seq_file *s, void *v, loff_t *pos)
  592. {
  593. struct list_head *list = v;
  594. if (list_is_last(list, &smk_netlbladdr_list)) {
  595. *pos = SEQ_READ_FINISHED;
  596. return NULL;
  597. }
  598. return list->next;
  599. }
  600. #define BEBITS (sizeof(__be32) * 8)
  601. /*
  602. * Print host/label pairs
  603. */
  604. static int netlbladdr_seq_show(struct seq_file *s, void *v)
  605. {
  606. struct list_head *list = v;
  607. struct smk_netlbladdr *skp =
  608. list_entry(list, struct smk_netlbladdr, list);
  609. unsigned char *hp = (char *) &skp->smk_host.sin_addr.s_addr;
  610. int maskn;
  611. u32 temp_mask = be32_to_cpu(skp->smk_mask.s_addr);
  612. for (maskn = 0; temp_mask; temp_mask <<= 1, maskn++);
  613. seq_printf(s, "%u.%u.%u.%u/%d %s\n",
  614. hp[0], hp[1], hp[2], hp[3], maskn, skp->smk_label);
  615. return 0;
  616. }
  617. static void netlbladdr_seq_stop(struct seq_file *s, void *v)
  618. {
  619. /* No-op */
  620. }
  621. static const struct seq_operations netlbladdr_seq_ops = {
  622. .start = netlbladdr_seq_start,
  623. .stop = netlbladdr_seq_stop,
  624. .next = netlbladdr_seq_next,
  625. .show = netlbladdr_seq_show,
  626. };
  627. /**
  628. * smk_open_netlbladdr - open() for /smack/netlabel
  629. * @inode: inode structure representing file
  630. * @file: "netlabel" file pointer
  631. *
  632. * Connect our netlbladdr_seq_* operations with /smack/netlabel
  633. * file_operations
  634. */
  635. static int smk_open_netlbladdr(struct inode *inode, struct file *file)
  636. {
  637. return seq_open(file, &netlbladdr_seq_ops);
  638. }
  639. /**
  640. * smk_netlbladdr_insert
  641. * @new : netlabel to insert
  642. *
  643. * This helper insert netlabel in the smack_netlbladdrs list
  644. * sorted by netmask length (longest to smallest)
  645. * locked by &smk_netlbladdr_lock in smk_write_netlbladdr
  646. *
  647. */
  648. static void smk_netlbladdr_insert(struct smk_netlbladdr *new)
  649. {
  650. struct smk_netlbladdr *m, *m_next;
  651. if (list_empty(&smk_netlbladdr_list)) {
  652. list_add_rcu(&new->list, &smk_netlbladdr_list);
  653. return;
  654. }
  655. m = list_entry_rcu(smk_netlbladdr_list.next,
  656. struct smk_netlbladdr, list);
  657. /* the comparison '>' is a bit hacky, but works */
  658. if (new->smk_mask.s_addr > m->smk_mask.s_addr) {
  659. list_add_rcu(&new->list, &smk_netlbladdr_list);
  660. return;
  661. }
  662. list_for_each_entry_rcu(m, &smk_netlbladdr_list, list) {
  663. if (list_is_last(&m->list, &smk_netlbladdr_list)) {
  664. list_add_rcu(&new->list, &m->list);
  665. return;
  666. }
  667. m_next = list_entry_rcu(m->list.next,
  668. struct smk_netlbladdr, list);
  669. if (new->smk_mask.s_addr > m_next->smk_mask.s_addr) {
  670. list_add_rcu(&new->list, &m->list);
  671. return;
  672. }
  673. }
  674. }
  675. /**
  676. * smk_write_netlbladdr - write() for /smack/netlabel
  677. * @file: file pointer, not actually used
  678. * @buf: where to get the data from
  679. * @count: bytes sent
  680. * @ppos: where to start
  681. *
  682. * Accepts only one netlbladdr per write call.
  683. * Returns number of bytes written or error code, as appropriate
  684. */
  685. static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,
  686. size_t count, loff_t *ppos)
  687. {
  688. struct smk_netlbladdr *skp;
  689. struct sockaddr_in newname;
  690. char smack[SMK_LABELLEN];
  691. char *sp;
  692. char data[SMK_NETLBLADDRMAX + 1];
  693. char *host = (char *)&newname.sin_addr.s_addr;
  694. int rc;
  695. struct netlbl_audit audit_info;
  696. struct in_addr mask;
  697. unsigned int m;
  698. int found;
  699. u32 mask_bits = (1<<31);
  700. __be32 nsa;
  701. u32 temp_mask;
  702. /*
  703. * Must have privilege.
  704. * No partial writes.
  705. * Enough data must be present.
  706. * "<addr/mask, as a.b.c.d/e><space><label>"
  707. * "<addr, as a.b.c.d><space><label>"
  708. */
  709. if (!capable(CAP_MAC_ADMIN))
  710. return -EPERM;
  711. if (*ppos != 0)
  712. return -EINVAL;
  713. if (count < SMK_NETLBLADDRMIN || count > SMK_NETLBLADDRMAX)
  714. return -EINVAL;
  715. if (copy_from_user(data, buf, count) != 0)
  716. return -EFAULT;
  717. data[count] = '\0';
  718. rc = sscanf(data, "%hhd.%hhd.%hhd.%hhd/%d %s",
  719. &host[0], &host[1], &host[2], &host[3], &m, smack);
  720. if (rc != 6) {
  721. rc = sscanf(data, "%hhd.%hhd.%hhd.%hhd %s",
  722. &host[0], &host[1], &host[2], &host[3], smack);
  723. if (rc != 5)
  724. return -EINVAL;
  725. m = BEBITS;
  726. }
  727. if (m > BEBITS)
  728. return -EINVAL;
  729. /* if smack begins with '-', its an option, don't import it */
  730. if (smack[0] != '-') {
  731. sp = smk_import(smack, 0);
  732. if (sp == NULL)
  733. return -EINVAL;
  734. } else {
  735. /* check known options */
  736. if (strcmp(smack, smack_cipso_option) == 0)
  737. sp = (char *)smack_cipso_option;
  738. else
  739. return -EINVAL;
  740. }
  741. for (temp_mask = 0; m > 0; m--) {
  742. temp_mask |= mask_bits;
  743. mask_bits >>= 1;
  744. }
  745. mask.s_addr = cpu_to_be32(temp_mask);
  746. newname.sin_addr.s_addr &= mask.s_addr;
  747. /*
  748. * Only allow one writer at a time. Writes should be
  749. * quite rare and small in any case.
  750. */
  751. mutex_lock(&smk_netlbladdr_lock);
  752. nsa = newname.sin_addr.s_addr;
  753. /* try to find if the prefix is already in the list */
  754. found = 0;
  755. list_for_each_entry_rcu(skp, &smk_netlbladdr_list, list) {
  756. if (skp->smk_host.sin_addr.s_addr == nsa &&
  757. skp->smk_mask.s_addr == mask.s_addr) {
  758. found = 1;
  759. break;
  760. }
  761. }
  762. smk_netlabel_audit_set(&audit_info);
  763. if (found == 0) {
  764. skp = kzalloc(sizeof(*skp), GFP_KERNEL);
  765. if (skp == NULL)
  766. rc = -ENOMEM;
  767. else {
  768. rc = 0;
  769. skp->smk_host.sin_addr.s_addr = newname.sin_addr.s_addr;
  770. skp->smk_mask.s_addr = mask.s_addr;
  771. skp->smk_label = sp;
  772. smk_netlbladdr_insert(skp);
  773. }
  774. } else {
  775. /* we delete the unlabeled entry, only if the previous label
  776. * wasnt the special CIPSO option */
  777. if (skp->smk_label != smack_cipso_option)
  778. rc = netlbl_cfg_unlbl_static_del(&init_net, NULL,
  779. &skp->smk_host.sin_addr, &skp->smk_mask,
  780. PF_INET, &audit_info);
  781. else
  782. rc = 0;
  783. skp->smk_label = sp;
  784. }
  785. /*
  786. * Now tell netlabel about the single label nature of
  787. * this host so that incoming packets get labeled.
  788. * but only if we didn't get the special CIPSO option
  789. */
  790. if (rc == 0 && sp != smack_cipso_option)
  791. rc = netlbl_cfg_unlbl_static_add(&init_net, NULL,
  792. &skp->smk_host.sin_addr, &skp->smk_mask, PF_INET,
  793. smack_to_secid(skp->smk_label), &audit_info);
  794. if (rc == 0)
  795. rc = count;
  796. mutex_unlock(&smk_netlbladdr_lock);
  797. return rc;
  798. }
  799. static const struct file_operations smk_netlbladdr_ops = {
  800. .open = smk_open_netlbladdr,
  801. .read = seq_read,
  802. .llseek = seq_lseek,
  803. .write = smk_write_netlbladdr,
  804. .release = seq_release,
  805. };
  806. /**
  807. * smk_read_doi - read() for /smack/doi
  808. * @filp: file pointer, not actually used
  809. * @buf: where to put the result
  810. * @count: maximum to send along
  811. * @ppos: where to start
  812. *
  813. * Returns number of bytes read or error code, as appropriate
  814. */
  815. static ssize_t smk_read_doi(struct file *filp, char __user *buf,
  816. size_t count, loff_t *ppos)
  817. {
  818. char temp[80];
  819. ssize_t rc;
  820. if (*ppos != 0)
  821. return 0;
  822. sprintf(temp, "%d", smk_cipso_doi_value);
  823. rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
  824. return rc;
  825. }
  826. /**
  827. * smk_write_doi - write() for /smack/doi
  828. * @file: file pointer, not actually used
  829. * @buf: where to get the data from
  830. * @count: bytes sent
  831. * @ppos: where to start
  832. *
  833. * Returns number of bytes written or error code, as appropriate
  834. */
  835. static ssize_t smk_write_doi(struct file *file, const char __user *buf,
  836. size_t count, loff_t *ppos)
  837. {
  838. char temp[80];
  839. int i;
  840. if (!capable(CAP_MAC_ADMIN))
  841. return -EPERM;
  842. if (count >= sizeof(temp) || count == 0)
  843. return -EINVAL;
  844. if (copy_from_user(temp, buf, count) != 0)
  845. return -EFAULT;
  846. temp[count] = '\0';
  847. if (sscanf(temp, "%d", &i) != 1)
  848. return -EINVAL;
  849. smk_cipso_doi_value = i;
  850. smk_cipso_doi();
  851. return count;
  852. }
  853. static const struct file_operations smk_doi_ops = {
  854. .read = smk_read_doi,
  855. .write = smk_write_doi,
  856. .llseek = default_llseek,
  857. };
  858. /**
  859. * smk_read_direct - read() for /smack/direct
  860. * @filp: file pointer, not actually used
  861. * @buf: where to put the result
  862. * @count: maximum to send along
  863. * @ppos: where to start
  864. *
  865. * Returns number of bytes read or error code, as appropriate
  866. */
  867. static ssize_t smk_read_direct(struct file *filp, char __user *buf,
  868. size_t count, loff_t *ppos)
  869. {
  870. char temp[80];
  871. ssize_t rc;
  872. if (*ppos != 0)
  873. return 0;
  874. sprintf(temp, "%d", smack_cipso_direct);
  875. rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
  876. return rc;
  877. }
  878. /**
  879. * smk_write_direct - write() for /smack/direct
  880. * @file: file pointer, not actually used
  881. * @buf: where to get the data from
  882. * @count: bytes sent
  883. * @ppos: where to start
  884. *
  885. * Returns number of bytes written or error code, as appropriate
  886. */
  887. static ssize_t smk_write_direct(struct file *file, const char __user *buf,
  888. size_t count, loff_t *ppos)
  889. {
  890. char temp[80];
  891. int i;
  892. if (!capable(CAP_MAC_ADMIN))
  893. return -EPERM;
  894. if (count >= sizeof(temp) || count == 0)
  895. return -EINVAL;
  896. if (copy_from_user(temp, buf, count) != 0)
  897. return -EFAULT;
  898. temp[count] = '\0';
  899. if (sscanf(temp, "%d", &i) != 1)
  900. return -EINVAL;
  901. smack_cipso_direct = i;
  902. return count;
  903. }
  904. static const struct file_operations smk_direct_ops = {
  905. .read = smk_read_direct,
  906. .write = smk_write_direct,
  907. .llseek = default_llseek,
  908. };
  909. /**
  910. * smk_read_ambient - read() for /smack/ambient
  911. * @filp: file pointer, not actually used
  912. * @buf: where to put the result
  913. * @cn: maximum to send along
  914. * @ppos: where to start
  915. *
  916. * Returns number of bytes read or error code, as appropriate
  917. */
  918. static ssize_t smk_read_ambient(struct file *filp, char __user *buf,
  919. size_t cn, loff_t *ppos)
  920. {
  921. ssize_t rc;
  922. int asize;
  923. if (*ppos != 0)
  924. return 0;
  925. /*
  926. * Being careful to avoid a problem in the case where
  927. * smack_net_ambient gets changed in midstream.
  928. */
  929. mutex_lock(&smack_ambient_lock);
  930. asize = strlen(smack_net_ambient) + 1;
  931. if (cn >= asize)
  932. rc = simple_read_from_buffer(buf, cn, ppos,
  933. smack_net_ambient, asize);
  934. else
  935. rc = -EINVAL;
  936. mutex_unlock(&smack_ambient_lock);
  937. return rc;
  938. }
  939. /**
  940. * smk_write_ambient - write() for /smack/ambient
  941. * @file: file pointer, not actually used
  942. * @buf: where to get the data from
  943. * @count: bytes sent
  944. * @ppos: where to start
  945. *
  946. * Returns number of bytes written or error code, as appropriate
  947. */
  948. static ssize_t smk_write_ambient(struct file *file, const char __user *buf,
  949. size_t count, loff_t *ppos)
  950. {
  951. char in[SMK_LABELLEN];
  952. char *oldambient;
  953. char *smack;
  954. if (!capable(CAP_MAC_ADMIN))
  955. return -EPERM;
  956. if (count >= SMK_LABELLEN)
  957. return -EINVAL;
  958. if (copy_from_user(in, buf, count) != 0)
  959. return -EFAULT;
  960. smack = smk_import(in, count);
  961. if (smack == NULL)
  962. return -EINVAL;
  963. mutex_lock(&smack_ambient_lock);
  964. oldambient = smack_net_ambient;
  965. smack_net_ambient = smack;
  966. smk_unlbl_ambient(oldambient);
  967. mutex_unlock(&smack_ambient_lock);
  968. return count;
  969. }
  970. static const struct file_operations smk_ambient_ops = {
  971. .read = smk_read_ambient,
  972. .write = smk_write_ambient,
  973. .llseek = default_llseek,
  974. };
  975. /**
  976. * smk_read_onlycap - read() for /smack/onlycap
  977. * @filp: file pointer, not actually used
  978. * @buf: where to put the result
  979. * @cn: maximum to send along
  980. * @ppos: where to start
  981. *
  982. * Returns number of bytes read or error code, as appropriate
  983. */
  984. static ssize_t smk_read_onlycap(struct file *filp, char __user *buf,
  985. size_t cn, loff_t *ppos)
  986. {
  987. char *smack = "";
  988. ssize_t rc = -EINVAL;
  989. int asize;
  990. if (*ppos != 0)
  991. return 0;
  992. if (smack_onlycap != NULL)
  993. smack = smack_onlycap;
  994. asize = strlen(smack) + 1;
  995. if (cn >= asize)
  996. rc = simple_read_from_buffer(buf, cn, ppos, smack, asize);
  997. return rc;
  998. }
  999. /**
  1000. * smk_write_onlycap - write() for /smack/onlycap
  1001. * @file: file pointer, not actually used
  1002. * @buf: where to get the data from
  1003. * @count: bytes sent
  1004. * @ppos: where to start
  1005. *
  1006. * Returns number of bytes written or error code, as appropriate
  1007. */
  1008. static ssize_t smk_write_onlycap(struct file *file, const char __user *buf,
  1009. size_t count, loff_t *ppos)
  1010. {
  1011. char in[SMK_LABELLEN];
  1012. char *sp = smk_of_task(current->cred->security);
  1013. if (!capable(CAP_MAC_ADMIN))
  1014. return -EPERM;
  1015. /*
  1016. * This can be done using smk_access() but is done
  1017. * explicitly for clarity. The smk_access() implementation
  1018. * would use smk_access(smack_onlycap, MAY_WRITE)
  1019. */
  1020. if (smack_onlycap != NULL && smack_onlycap != sp)
  1021. return -EPERM;
  1022. if (count >= SMK_LABELLEN)
  1023. return -EINVAL;
  1024. if (copy_from_user(in, buf, count) != 0)
  1025. return -EFAULT;
  1026. /*
  1027. * Should the null string be passed in unset the onlycap value.
  1028. * This seems like something to be careful with as usually
  1029. * smk_import only expects to return NULL for errors. It
  1030. * is usually the case that a nullstring or "\n" would be
  1031. * bad to pass to smk_import but in fact this is useful here.
  1032. */
  1033. smack_onlycap = smk_import(in, count);
  1034. return count;
  1035. }
  1036. static const struct file_operations smk_onlycap_ops = {
  1037. .read = smk_read_onlycap,
  1038. .write = smk_write_onlycap,
  1039. .llseek = default_llseek,
  1040. };
  1041. /**
  1042. * smk_read_logging - read() for /smack/logging
  1043. * @filp: file pointer, not actually used
  1044. * @buf: where to put the result
  1045. * @cn: maximum to send along
  1046. * @ppos: where to start
  1047. *
  1048. * Returns number of bytes read or error code, as appropriate
  1049. */
  1050. static ssize_t smk_read_logging(struct file *filp, char __user *buf,
  1051. size_t count, loff_t *ppos)
  1052. {
  1053. char temp[32];
  1054. ssize_t rc;
  1055. if (*ppos != 0)
  1056. return 0;
  1057. sprintf(temp, "%d\n", log_policy);
  1058. rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
  1059. return rc;
  1060. }
  1061. /**
  1062. * smk_write_logging - write() for /smack/logging
  1063. * @file: file pointer, not actually used
  1064. * @buf: where to get the data from
  1065. * @count: bytes sent
  1066. * @ppos: where to start
  1067. *
  1068. * Returns number of bytes written or error code, as appropriate
  1069. */
  1070. static ssize_t smk_write_logging(struct file *file, const char __user *buf,
  1071. size_t count, loff_t *ppos)
  1072. {
  1073. char temp[32];
  1074. int i;
  1075. if (!capable(CAP_MAC_ADMIN))
  1076. return -EPERM;
  1077. if (count >= sizeof(temp) || count == 0)
  1078. return -EINVAL;
  1079. if (copy_from_user(temp, buf, count) != 0)
  1080. return -EFAULT;
  1081. temp[count] = '\0';
  1082. if (sscanf(temp, "%d", &i) != 1)
  1083. return -EINVAL;
  1084. if (i < 0 || i > 3)
  1085. return -EINVAL;
  1086. log_policy = i;
  1087. return count;
  1088. }
  1089. static const struct file_operations smk_logging_ops = {
  1090. .read = smk_read_logging,
  1091. .write = smk_write_logging,
  1092. .llseek = default_llseek,
  1093. };
  1094. /**
  1095. * smk_fill_super - fill the /smackfs superblock
  1096. * @sb: the empty superblock
  1097. * @data: unused
  1098. * @silent: unused
  1099. *
  1100. * Fill in the well known entries for /smack
  1101. *
  1102. * Returns 0 on success, an error code on failure
  1103. */
  1104. static int smk_fill_super(struct super_block *sb, void *data, int silent)
  1105. {
  1106. int rc;
  1107. struct inode *root_inode;
  1108. static struct tree_descr smack_files[] = {
  1109. [SMK_LOAD] =
  1110. {"load", &smk_load_ops, S_IRUGO|S_IWUSR},
  1111. [SMK_CIPSO] =
  1112. {"cipso", &smk_cipso_ops, S_IRUGO|S_IWUSR},
  1113. [SMK_DOI] =
  1114. {"doi", &smk_doi_ops, S_IRUGO|S_IWUSR},
  1115. [SMK_DIRECT] =
  1116. {"direct", &smk_direct_ops, S_IRUGO|S_IWUSR},
  1117. [SMK_AMBIENT] =
  1118. {"ambient", &smk_ambient_ops, S_IRUGO|S_IWUSR},
  1119. [SMK_NETLBLADDR] =
  1120. {"netlabel", &smk_netlbladdr_ops, S_IRUGO|S_IWUSR},
  1121. [SMK_ONLYCAP] =
  1122. {"onlycap", &smk_onlycap_ops, S_IRUGO|S_IWUSR},
  1123. [SMK_LOGGING] =
  1124. {"logging", &smk_logging_ops, S_IRUGO|S_IWUSR},
  1125. /* last one */ {""}
  1126. };
  1127. rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
  1128. if (rc != 0) {
  1129. printk(KERN_ERR "%s failed %d while creating inodes\n",
  1130. __func__, rc);
  1131. return rc;
  1132. }
  1133. root_inode = sb->s_root->d_inode;
  1134. root_inode->i_security = new_inode_smack(smack_known_floor.smk_known);
  1135. return 0;
  1136. }
  1137. /**
  1138. * smk_mount - get the smackfs superblock
  1139. * @fs_type: passed along without comment
  1140. * @flags: passed along without comment
  1141. * @dev_name: passed along without comment
  1142. * @data: passed along without comment
  1143. *
  1144. * Just passes everything along.
  1145. *
  1146. * Returns what the lower level code does.
  1147. */
  1148. static struct dentry *smk_mount(struct file_system_type *fs_type,
  1149. int flags, const char *dev_name, void *data)
  1150. {
  1151. return mount_single(fs_type, flags, data, smk_fill_super);
  1152. }
  1153. static struct file_system_type smk_fs_type = {
  1154. .name = "smackfs",
  1155. .mount = smk_mount,
  1156. .kill_sb = kill_litter_super,
  1157. };
  1158. static struct vfsmount *smackfs_mount;
  1159. /**
  1160. * init_smk_fs - get the smackfs superblock
  1161. *
  1162. * register the smackfs
  1163. *
  1164. * Do not register smackfs if Smack wasn't enabled
  1165. * on boot. We can not put this method normally under the
  1166. * smack_init() code path since the security subsystem get
  1167. * initialized before the vfs caches.
  1168. *
  1169. * Returns true if we were not chosen on boot or if
  1170. * we were chosen and filesystem registration succeeded.
  1171. */
  1172. static int __init init_smk_fs(void)
  1173. {
  1174. int err;
  1175. if (!security_module_enable(&smack_ops))
  1176. return 0;
  1177. err = register_filesystem(&smk_fs_type);
  1178. if (!err) {
  1179. smackfs_mount = kern_mount(&smk_fs_type);
  1180. if (IS_ERR(smackfs_mount)) {
  1181. printk(KERN_ERR "smackfs: could not mount!\n");
  1182. err = PTR_ERR(smackfs_mount);
  1183. smackfs_mount = NULL;
  1184. }
  1185. }
  1186. smk_cipso_doi();
  1187. smk_unlbl_ambient(NULL);
  1188. return err;
  1189. }
  1190. __initcall(init_smk_fs);