Smack.txt 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. "Good for you, you've decided to clean the elevator!"
  2. - The Elevator, from Dark Star
  3. Smack is the the Simplified Mandatory Access Control Kernel.
  4. Smack is a kernel based implementation of mandatory access
  5. control that includes simplicity in its primary design goals.
  6. Smack is not the only Mandatory Access Control scheme
  7. available for Linux. Those new to Mandatory Access Control
  8. are encouraged to compare Smack with the other mechanisms
  9. available to determine which is best suited to the problem
  10. at hand.
  11. Smack consists of three major components:
  12. - The kernel
  13. - Basic utilities, which are helpful but not required
  14. - Configuration data
  15. The kernel component of Smack is implemented as a Linux
  16. Security Modules (LSM) module. It requires netlabel and
  17. works best with file systems that support extended attributes,
  18. although xattr support is not strictly required.
  19. It is safe to run a Smack kernel under a "vanilla" distribution.
  20. Smack kernels use the CIPSO IP option. Some network
  21. configurations are intolerant of IP options and can impede
  22. access to systems that use them as Smack does.
  23. The current git repository for Smack user space is:
  24. git://github.com/smack-team/smack.git
  25. This should make and install on most modern distributions.
  26. There are three commands included in smackutil:
  27. smackload - properly formats data for writing to /smack/load
  28. smackcipso - properly formats data for writing to /smack/cipso
  29. chsmack - display or set Smack extended attribute values
  30. In keeping with the intent of Smack, configuration data is
  31. minimal and not strictly required. The most important
  32. configuration step is mounting the smackfs pseudo filesystem.
  33. If smackutil is installed the startup script will take care
  34. of this, but it can be manually as well.
  35. Add this line to /etc/fstab:
  36. smackfs /smack smackfs smackfsdef=* 0 0
  37. and create the /smack directory for mounting.
  38. Smack uses extended attributes (xattrs) to store labels on filesystem
  39. objects. The attributes are stored in the extended attribute security
  40. name space. A process must have CAP_MAC_ADMIN to change any of these
  41. attributes.
  42. The extended attributes that Smack uses are:
  43. SMACK64
  44. Used to make access control decisions. In almost all cases
  45. the label given to a new filesystem object will be the label
  46. of the process that created it.
  47. SMACK64EXEC
  48. The Smack label of a process that execs a program file with
  49. this attribute set will run with this attribute's value.
  50. SMACK64MMAP
  51. Don't allow the file to be mmapped by a process whose Smack
  52. label does not allow all of the access permitted to a process
  53. with the label contained in this attribute. This is a very
  54. specific use case for shared libraries.
  55. SMACK64TRANSMUTE
  56. Can only have the value "TRUE". If this attribute is present
  57. on a directory when an object is created in the directory and
  58. the Smack rule (more below) that permitted the write access
  59. to the directory includes the transmute ("t") mode the object
  60. gets the label of the directory instead of the label of the
  61. creating process. If the object being created is a directory
  62. the SMACK64TRANSMUTE attribute is set as well.
  63. SMACK64IPIN
  64. This attribute is only available on file descriptors for sockets.
  65. Use the Smack label in this attribute for access control
  66. decisions on packets being delivered to this socket.
  67. SMACK64IPOUT
  68. This attribute is only available on file descriptors for sockets.
  69. Use the Smack label in this attribute for access control
  70. decisions on packets coming from this socket.
  71. There are multiple ways to set a Smack label on a file:
  72. # attr -S -s SMACK64 -V "value" path
  73. # chsmack -a value path
  74. A process can see the smack label it is running with by
  75. reading /proc/self/attr/current. A process with CAP_MAC_ADMIN
  76. can set the process smack by writing there.
  77. Most Smack configuration is accomplished by writing to files
  78. in the smackfs filesystem. This pseudo-filesystem is usually
  79. mounted on /smack.
  80. access
  81. This interface reports whether a subject with the specified
  82. Smack label has a particular access to an object with a
  83. specified Smack label. Write a fixed format access rule to
  84. this file. The next read will indicate whether the access
  85. would be permitted. The text will be either "1" indicating
  86. access, or "0" indicating denial.
  87. access2
  88. This interface reports whether a subject with the specified
  89. Smack label has a particular access to an object with a
  90. specified Smack label. Write a long format access rule to
  91. this file. The next read will indicate whether the access
  92. would be permitted. The text will be either "1" indicating
  93. access, or "0" indicating denial.
  94. ambient
  95. This contains the Smack label applied to unlabeled network
  96. packets.
  97. cipso
  98. This interface allows a specific CIPSO header to be assigned
  99. to a Smack label. The format accepted on write is:
  100. "%24s%4d%4d"["%4d"]...
  101. The first string is a fixed Smack label. The first number is
  102. the level to use. The second number is the number of categories.
  103. The following numbers are the categories.
  104. "level-3-cats-5-19 3 2 5 19"
  105. cipso2
  106. This interface allows a specific CIPSO header to be assigned
  107. to a Smack label. The format accepted on write is:
  108. "%s%4d%4d"["%4d"]...
  109. The first string is a long Smack label. The first number is
  110. the level to use. The second number is the number of categories.
  111. The following numbers are the categories.
  112. "level-3-cats-5-19 3 2 5 19"
  113. direct
  114. This contains the CIPSO level used for Smack direct label
  115. representation in network packets.
  116. doi
  117. This contains the CIPSO domain of interpretation used in
  118. network packets.
  119. load
  120. This interface allows access control rules in addition to
  121. the system defined rules to be specified. The format accepted
  122. on write is:
  123. "%24s%24s%5s"
  124. where the first string is the subject label, the second the
  125. object label, and the third the requested access. The access
  126. string may contain only the characters "rwxat-", and specifies
  127. which sort of access is allowed. The "-" is a placeholder for
  128. permissions that are not allowed. The string "r-x--" would
  129. specify read and execute access. Labels are limited to 23
  130. characters in length.
  131. load2
  132. This interface allows access control rules in addition to
  133. the system defined rules to be specified. The format accepted
  134. on write is:
  135. "%s %s %s"
  136. where the first string is the subject label, the second the
  137. object label, and the third the requested access. The access
  138. string may contain only the characters "rwxat-", and specifies
  139. which sort of access is allowed. The "-" is a placeholder for
  140. permissions that are not allowed. The string "r-x--" would
  141. specify read and execute access.
  142. load-self
  143. This interface allows process specific access rules to be
  144. defined. These rules are only consulted if access would
  145. otherwise be permitted, and are intended to provide additional
  146. restrictions on the process. The format is the same as for
  147. the load interface.
  148. load-self2
  149. This interface allows process specific access rules to be
  150. defined. These rules are only consulted if access would
  151. otherwise be permitted, and are intended to provide additional
  152. restrictions on the process. The format is the same as for
  153. the load2 interface.
  154. logging
  155. This contains the Smack logging state.
  156. mapped
  157. This contains the CIPSO level used for Smack mapped label
  158. representation in network packets.
  159. netlabel
  160. This interface allows specific internet addresses to be
  161. treated as single label hosts. Packets are sent to single
  162. label hosts without CIPSO headers, but only from processes
  163. that have Smack write access to the host label. All packets
  164. received from single label hosts are given the specified
  165. label. The format accepted on write is:
  166. "%d.%d.%d.%d label" or "%d.%d.%d.%d/%d label".
  167. onlycap
  168. This contains the label processes must have for CAP_MAC_ADMIN
  169. and CAP_MAC_OVERRIDE to be effective. If this file is empty
  170. these capabilities are effective at for processes with any
  171. label. The value is set by writing the desired label to the
  172. file or cleared by writing "-" to the file.
  173. revoke-subject
  174. Writing a Smack label here sets the access to '-' for all access
  175. rules with that subject label.
  176. You can add access rules in /etc/smack/accesses. They take the form:
  177. subjectlabel objectlabel access
  178. access is a combination of the letters rwxa which specify the
  179. kind of access permitted a subject with subjectlabel on an
  180. object with objectlabel. If there is no rule no access is allowed.
  181. Look for additional programs on http://schaufler-ca.com
  182. From the Smack Whitepaper:
  183. The Simplified Mandatory Access Control Kernel
  184. Casey Schaufler
  185. casey@schaufler-ca.com
  186. Mandatory Access Control
  187. Computer systems employ a variety of schemes to constrain how information is
  188. shared among the people and services using the machine. Some of these schemes
  189. allow the program or user to decide what other programs or users are allowed
  190. access to pieces of data. These schemes are called discretionary access
  191. control mechanisms because the access control is specified at the discretion
  192. of the user. Other schemes do not leave the decision regarding what a user or
  193. program can access up to users or programs. These schemes are called mandatory
  194. access control mechanisms because you don't have a choice regarding the users
  195. or programs that have access to pieces of data.
  196. Bell & LaPadula
  197. From the middle of the 1980's until the turn of the century Mandatory Access
  198. Control (MAC) was very closely associated with the Bell & LaPadula security
  199. model, a mathematical description of the United States Department of Defense
  200. policy for marking paper documents. MAC in this form enjoyed a following
  201. within the Capital Beltway and Scandinavian supercomputer centers but was
  202. often sited as failing to address general needs.
  203. Domain Type Enforcement
  204. Around the turn of the century Domain Type Enforcement (DTE) became popular.
  205. This scheme organizes users, programs, and data into domains that are
  206. protected from each other. This scheme has been widely deployed as a component
  207. of popular Linux distributions. The administrative overhead required to
  208. maintain this scheme and the detailed understanding of the whole system
  209. necessary to provide a secure domain mapping leads to the scheme being
  210. disabled or used in limited ways in the majority of cases.
  211. Smack
  212. Smack is a Mandatory Access Control mechanism designed to provide useful MAC
  213. while avoiding the pitfalls of its predecessors. The limitations of Bell &
  214. LaPadula are addressed by providing a scheme whereby access can be controlled
  215. according to the requirements of the system and its purpose rather than those
  216. imposed by an arcane government policy. The complexity of Domain Type
  217. Enforcement and avoided by defining access controls in terms of the access
  218. modes already in use.
  219. Smack Terminology
  220. The jargon used to talk about Smack will be familiar to those who have dealt
  221. with other MAC systems and shouldn't be too difficult for the uninitiated to
  222. pick up. There are four terms that are used in a specific way and that are
  223. especially important:
  224. Subject: A subject is an active entity on the computer system.
  225. On Smack a subject is a task, which is in turn the basic unit
  226. of execution.
  227. Object: An object is a passive entity on the computer system.
  228. On Smack files of all types, IPC, and tasks can be objects.
  229. Access: Any attempt by a subject to put information into or get
  230. information from an object is an access.
  231. Label: Data that identifies the Mandatory Access Control
  232. characteristics of a subject or an object.
  233. These definitions are consistent with the traditional use in the security
  234. community. There are also some terms from Linux that are likely to crop up:
  235. Capability: A task that possesses a capability has permission to
  236. violate an aspect of the system security policy, as identified by
  237. the specific capability. A task that possesses one or more
  238. capabilities is a privileged task, whereas a task with no
  239. capabilities is an unprivileged task.
  240. Privilege: A task that is allowed to violate the system security
  241. policy is said to have privilege. As of this writing a task can
  242. have privilege either by possessing capabilities or by having an
  243. effective user of root.
  244. Smack Basics
  245. Smack is an extension to a Linux system. It enforces additional restrictions
  246. on what subjects can access which objects, based on the labels attached to
  247. each of the subject and the object.
  248. Labels
  249. Smack labels are ASCII character strings, one to twenty-three characters in
  250. length. Single character labels using special characters, that being anything
  251. other than a letter or digit, are reserved for use by the Smack development
  252. team. Smack labels are unstructured, case sensitive, and the only operation
  253. ever performed on them is comparison for equality. Smack labels cannot
  254. contain unprintable characters, the "/" (slash), the "\" (backslash), the "'"
  255. (quote) and '"' (double-quote) characters.
  256. Smack labels cannot begin with a '-'. This is reserved for special options.
  257. There are some predefined labels:
  258. _ Pronounced "floor", a single underscore character.
  259. ^ Pronounced "hat", a single circumflex character.
  260. * Pronounced "star", a single asterisk character.
  261. ? Pronounced "huh", a single question mark character.
  262. @ Pronounced "web", a single at sign character.
  263. Every task on a Smack system is assigned a label. System tasks, such as
  264. init(8) and systems daemons, are run with the floor ("_") label. User tasks
  265. are assigned labels according to the specification found in the
  266. /etc/smack/user configuration file.
  267. Access Rules
  268. Smack uses the traditional access modes of Linux. These modes are read,
  269. execute, write, and occasionally append. There are a few cases where the
  270. access mode may not be obvious. These include:
  271. Signals: A signal is a write operation from the subject task to
  272. the object task.
  273. Internet Domain IPC: Transmission of a packet is considered a
  274. write operation from the source task to the destination task.
  275. Smack restricts access based on the label attached to a subject and the label
  276. attached to the object it is trying to access. The rules enforced are, in
  277. order:
  278. 1. Any access requested by a task labeled "*" is denied.
  279. 2. A read or execute access requested by a task labeled "^"
  280. is permitted.
  281. 3. A read or execute access requested on an object labeled "_"
  282. is permitted.
  283. 4. Any access requested on an object labeled "*" is permitted.
  284. 5. Any access requested by a task on an object with the same
  285. label is permitted.
  286. 6. Any access requested that is explicitly defined in the loaded
  287. rule set is permitted.
  288. 7. Any other access is denied.
  289. Smack Access Rules
  290. With the isolation provided by Smack access separation is simple. There are
  291. many interesting cases where limited access by subjects to objects with
  292. different labels is desired. One example is the familiar spy model of
  293. sensitivity, where a scientist working on a highly classified project would be
  294. able to read documents of lower classifications and anything she writes will
  295. be "born" highly classified. To accommodate such schemes Smack includes a
  296. mechanism for specifying rules allowing access between labels.
  297. Access Rule Format
  298. The format of an access rule is:
  299. subject-label object-label access
  300. Where subject-label is the Smack label of the task, object-label is the Smack
  301. label of the thing being accessed, and access is a string specifying the sort
  302. of access allowed. The access specification is searched for letters that
  303. describe access modes:
  304. a: indicates that append access should be granted.
  305. r: indicates that read access should be granted.
  306. w: indicates that write access should be granted.
  307. x: indicates that execute access should be granted.
  308. t: indicates that the rule requests transmutation.
  309. Uppercase values for the specification letters are allowed as well.
  310. Access mode specifications can be in any order. Examples of acceptable rules
  311. are:
  312. TopSecret Secret rx
  313. Secret Unclass R
  314. Manager Game x
  315. User HR w
  316. New Old rRrRr
  317. Closed Off -
  318. Examples of unacceptable rules are:
  319. Top Secret Secret rx
  320. Ace Ace r
  321. Odd spells waxbeans
  322. Spaces are not allowed in labels. Since a subject always has access to files
  323. with the same label specifying a rule for that case is pointless. Only
  324. valid letters (rwxatRWXAT) and the dash ('-') character are allowed in
  325. access specifications. The dash is a placeholder, so "a-r" is the same
  326. as "ar". A lone dash is used to specify that no access should be allowed.
  327. Applying Access Rules
  328. The developers of Linux rarely define new sorts of things, usually importing
  329. schemes and concepts from other systems. Most often, the other systems are
  330. variants of Unix. Unix has many endearing properties, but consistency of
  331. access control models is not one of them. Smack strives to treat accesses as
  332. uniformly as is sensible while keeping with the spirit of the underlying
  333. mechanism.
  334. File system objects including files, directories, named pipes, symbolic links,
  335. and devices require access permissions that closely match those used by mode
  336. bit access. To open a file for reading read access is required on the file. To
  337. search a directory requires execute access. Creating a file with write access
  338. requires both read and write access on the containing directory. Deleting a
  339. file requires read and write access to the file and to the containing
  340. directory. It is possible that a user may be able to see that a file exists
  341. but not any of its attributes by the circumstance of having read access to the
  342. containing directory but not to the differently labeled file. This is an
  343. artifact of the file name being data in the directory, not a part of the file.
  344. If a directory is marked as transmuting (SMACK64TRANSMUTE=TRUE) and the
  345. access rule that allows a process to create an object in that directory
  346. includes 't' access the label assigned to the new object will be that
  347. of the directory, not the creating process. This makes it much easier
  348. for two processes with different labels to share data without granting
  349. access to all of their files.
  350. IPC objects, message queues, semaphore sets, and memory segments exist in flat
  351. namespaces and access requests are only required to match the object in
  352. question.
  353. Process objects reflect tasks on the system and the Smack label used to access
  354. them is the same Smack label that the task would use for its own access
  355. attempts. Sending a signal via the kill() system call is a write operation
  356. from the signaler to the recipient. Debugging a process requires both reading
  357. and writing. Creating a new task is an internal operation that results in two
  358. tasks with identical Smack labels and requires no access checks.
  359. Sockets are data structures attached to processes and sending a packet from
  360. one process to another requires that the sender have write access to the
  361. receiver. The receiver is not required to have read access to the sender.
  362. Setting Access Rules
  363. The configuration file /etc/smack/accesses contains the rules to be set at
  364. system startup. The contents are written to the special file /smack/load.
  365. Rules can be written to /smack/load at any time and take effect immediately.
  366. For any pair of subject and object labels there can be only one rule, with the
  367. most recently specified overriding any earlier specification.
  368. The program smackload is provided to ensure data is formatted
  369. properly when written to /smack/load. This program reads lines
  370. of the form
  371. subjectlabel objectlabel mode.
  372. Task Attribute
  373. The Smack label of a process can be read from /proc/<pid>/attr/current. A
  374. process can read its own Smack label from /proc/self/attr/current. A
  375. privileged process can change its own Smack label by writing to
  376. /proc/self/attr/current but not the label of another process.
  377. File Attribute
  378. The Smack label of a filesystem object is stored as an extended attribute
  379. named SMACK64 on the file. This attribute is in the security namespace. It can
  380. only be changed by a process with privilege.
  381. Privilege
  382. A process with CAP_MAC_OVERRIDE is privileged.
  383. Smack Networking
  384. As mentioned before, Smack enforces access control on network protocol
  385. transmissions. Every packet sent by a Smack process is tagged with its Smack
  386. label. This is done by adding a CIPSO tag to the header of the IP packet. Each
  387. packet received is expected to have a CIPSO tag that identifies the label and
  388. if it lacks such a tag the network ambient label is assumed. Before the packet
  389. is delivered a check is made to determine that a subject with the label on the
  390. packet has write access to the receiving process and if that is not the case
  391. the packet is dropped.
  392. CIPSO Configuration
  393. It is normally unnecessary to specify the CIPSO configuration. The default
  394. values used by the system handle all internal cases. Smack will compose CIPSO
  395. label values to match the Smack labels being used without administrative
  396. intervention. Unlabeled packets that come into the system will be given the
  397. ambient label.
  398. Smack requires configuration in the case where packets from a system that is
  399. not smack that speaks CIPSO may be encountered. Usually this will be a Trusted
  400. Solaris system, but there are other, less widely deployed systems out there.
  401. CIPSO provides 3 important values, a Domain Of Interpretation (DOI), a level,
  402. and a category set with each packet. The DOI is intended to identify a group
  403. of systems that use compatible labeling schemes, and the DOI specified on the
  404. smack system must match that of the remote system or packets will be
  405. discarded. The DOI is 3 by default. The value can be read from /smack/doi and
  406. can be changed by writing to /smack/doi.
  407. The label and category set are mapped to a Smack label as defined in
  408. /etc/smack/cipso.
  409. A Smack/CIPSO mapping has the form:
  410. smack level [category [category]*]
  411. Smack does not expect the level or category sets to be related in any
  412. particular way and does not assume or assign accesses based on them. Some
  413. examples of mappings:
  414. TopSecret 7
  415. TS:A,B 7 1 2
  416. SecBDE 5 2 4 6
  417. RAFTERS 7 12 26
  418. The ":" and "," characters are permitted in a Smack label but have no special
  419. meaning.
  420. The mapping of Smack labels to CIPSO values is defined by writing to
  421. /smack/cipso. Again, the format of data written to this special file
  422. is highly restrictive, so the program smackcipso is provided to
  423. ensure the writes are done properly. This program takes mappings
  424. on the standard input and sends them to /smack/cipso properly.
  425. In addition to explicit mappings Smack supports direct CIPSO mappings. One
  426. CIPSO level is used to indicate that the category set passed in the packet is
  427. in fact an encoding of the Smack label. The level used is 250 by default. The
  428. value can be read from /smack/direct and changed by writing to /smack/direct.
  429. Socket Attributes
  430. There are two attributes that are associated with sockets. These attributes
  431. can only be set by privileged tasks, but any task can read them for their own
  432. sockets.
  433. SMACK64IPIN: The Smack label of the task object. A privileged
  434. program that will enforce policy may set this to the star label.
  435. SMACK64IPOUT: The Smack label transmitted with outgoing packets.
  436. A privileged program may set this to match the label of another
  437. task with which it hopes to communicate.
  438. Smack Netlabel Exceptions
  439. You will often find that your labeled application has to talk to the outside,
  440. unlabeled world. To do this there's a special file /smack/netlabel where you can
  441. add some exceptions in the form of :
  442. @IP1 LABEL1 or
  443. @IP2/MASK LABEL2
  444. It means that your application will have unlabeled access to @IP1 if it has
  445. write access on LABEL1, and access to the subnet @IP2/MASK if it has write
  446. access on LABEL2.
  447. Entries in the /smack/netlabel file are matched by longest mask first, like in
  448. classless IPv4 routing.
  449. A special label '@' and an option '-CIPSO' can be used there :
  450. @ means Internet, any application with any label has access to it
  451. -CIPSO means standard CIPSO networking
  452. If you don't know what CIPSO is and don't plan to use it, you can just do :
  453. echo 127.0.0.1 -CIPSO > /smack/netlabel
  454. echo 0.0.0.0/0 @ > /smack/netlabel
  455. If you use CIPSO on your 192.168.0.0/16 local network and need also unlabeled
  456. Internet access, you can have :
  457. echo 127.0.0.1 -CIPSO > /smack/netlabel
  458. echo 192.168.0.0/16 -CIPSO > /smack/netlabel
  459. echo 0.0.0.0/0 @ > /smack/netlabel
  460. Writing Applications for Smack
  461. There are three sorts of applications that will run on a Smack system. How an
  462. application interacts with Smack will determine what it will have to do to
  463. work properly under Smack.
  464. Smack Ignorant Applications
  465. By far the majority of applications have no reason whatever to care about the
  466. unique properties of Smack. Since invoking a program has no impact on the
  467. Smack label associated with the process the only concern likely to arise is
  468. whether the process has execute access to the program.
  469. Smack Relevant Applications
  470. Some programs can be improved by teaching them about Smack, but do not make
  471. any security decisions themselves. The utility ls(1) is one example of such a
  472. program.
  473. Smack Enforcing Applications
  474. These are special programs that not only know about Smack, but participate in
  475. the enforcement of system policy. In most cases these are the programs that
  476. set up user sessions. There are also network services that provide information
  477. to processes running with various labels.
  478. File System Interfaces
  479. Smack maintains labels on file system objects using extended attributes. The
  480. Smack label of a file, directory, or other file system object can be obtained
  481. using getxattr(2).
  482. len = getxattr("/", "security.SMACK64", value, sizeof (value));
  483. will put the Smack label of the root directory into value. A privileged
  484. process can set the Smack label of a file system object with setxattr(2).
  485. len = strlen("Rubble");
  486. rc = setxattr("/foo", "security.SMACK64", "Rubble", len, 0);
  487. will set the Smack label of /foo to "Rubble" if the program has appropriate
  488. privilege.
  489. Socket Interfaces
  490. The socket attributes can be read using fgetxattr(2).
  491. A privileged process can set the Smack label of outgoing packets with
  492. fsetxattr(2).
  493. len = strlen("Rubble");
  494. rc = fsetxattr(fd, "security.SMACK64IPOUT", "Rubble", len, 0);
  495. will set the Smack label "Rubble" on packets going out from the socket if the
  496. program has appropriate privilege.
  497. rc = fsetxattr(fd, "security.SMACK64IPIN, "*", strlen("*"), 0);
  498. will set the Smack label "*" as the object label against which incoming
  499. packets will be checked if the program has appropriate privilege.
  500. Administration
  501. Smack supports some mount options:
  502. smackfsdef=label: specifies the label to give files that lack
  503. the Smack label extended attribute.
  504. smackfsroot=label: specifies the label to assign the root of the
  505. file system if it lacks the Smack extended attribute.
  506. smackfshat=label: specifies a label that must have read access to
  507. all labels set on the filesystem. Not yet enforced.
  508. smackfsfloor=label: specifies a label to which all labels set on the
  509. filesystem must have read access. Not yet enforced.
  510. These mount options apply to all file system types.
  511. Smack auditing
  512. If you want Smack auditing of security events, you need to set CONFIG_AUDIT
  513. in your kernel configuration.
  514. By default, all denied events will be audited. You can change this behavior by
  515. writing a single character to the /smack/logging file :
  516. 0 : no logging
  517. 1 : log denied (default)
  518. 2 : log accepted
  519. 3 : log denied & accepted
  520. Events are logged as 'key=value' pairs, for each event you at least will get
  521. the subject, the object, the rights requested, the action, the kernel function
  522. that triggered the event, plus other pairs depending on the type of event
  523. audited.