File rules
path and permissions for application developers
A file rule is a path pattern followed by permission letters. It has two spellings and an optional file keyword. The bare rule "file," allows every file permission on every path.
On the map: file access
▶ Watch this deck — 8 scenes, ~6 min
Worth seeing first
- The profile language at a glance — where rules sit in a whole profile
Part of journeys
- New to AppArmor, step 6 of 10 · previous: Profile attachment · next: File access modes
- File access in depth, step 1 of 12 · next: Globbing (AARE)
01 Which files may demo touch?
A file rule is PATH MODE,: a path pattern and permission letters. A request with no matching rule is refused.
Demo opens three files. Two it needs: its configuration and its state. The third is somebody's private SSH key, and that one is a bug. A profile is a list of what's allowed, so for every open the question is the same: is there a rule for this path, with this permission? The file rule is the line that answers it. Demo's profile has one for the configuration and one for the state. There's no line for the key, so that open is refused. A path, some letters, a comma: this deck is about the shape of that line, its two spellings, and the one-word rule that allows everything.
Details and sources
Details
- Syntax:
PATH MODE,as in/etc/demo/** r,: a path pattern, permission letters, a comma. The man page's grammar line for FILE RULE is at apparmor.d.pod:397. - A profile is an allow list: a request for a name and a permission that no rule grants is refused.
- Kernel, read and not run: an open reaches AppArmor through the LSM hook
file_open, implemented byapparmor_file_open(lsm.c:1808, lsm.c:465), which callsaa_path_permwith the operationopen. - The refusal: any requested permission that is not in the allowed set gives
-EACCES(file.c:244-247). - A refused open is logged like this record from the libapparmor test suite (avc_syslog_01.in):
apparmor="DENIED" operation="open" profile="/usr/sbin/cupsd" name="/boot/" pid=19651 comm="ls" requested_mask="r" denied_mask="r" fsuid=0 ouid=0. - The program
demo, its files and its profile are invented for the map. Nothing on this slide was observed on a running kernel.
Read more
for AppArmor developers for security researchers
In the code
- The path-first form of the rule in the grammar:
frule: id_or_var file_perms opt_named_transition TOK_END_OF_RULE(parser_yacc.y:1072).
02 The shape of a file rule
[QUALIFIERS] [file] [safe|unsafe] (PATH MODE | MODE [subset] PATH) [-> TARGET],. The order of the parts is fixed. A path starts with / or a variable, or is quoted.
Read the diagram from the middle: a path, the letters, a comma. That's the whole rule. You can write the letters first instead; it's the same rule. The word file in front is optional and changes nothing. Qualifiers such as deny and owner go before everything else, and safe or unsafe go right after the word file; those two only matter for exec rules. An arrow at the end names a target: a link target when the letters include l, otherwise the profile an exec switches to. Each of those parts has its own deck. What stays fixed is the order of the parts.
Details and sources
Details
- Form:
[QUALIFIERS] [file] [safe|unsafe] ( PATH MODE | MODE [subset] PATH ) [-> TARGET] ,withQUALIFIERSbeing[priority=N] [audit] [allow|deny|prompt] [owner|other]. The order of the slots is fixed. - apparmor.d(5) writes it as
FILE RULE = [ QUALIFIERS ] [ 'owner' ] ( 'file' | [ 'file' ] ( FILEGLOB ACCESS | ACCESS FILEGLOB ) [ '->' EXEC TARGET ] )(apparmor.d.pod:397) andACCESS = ( 'r' | 'w' | 'a' | 'l' | 'k' | 'm' | EXEC TRANSITION )+(apparmor.d.pod:408). PATHstarts with/or a variable@{...}, or is a quoted string (apparmor.d.pod:399-403).MODEis one word of permission letters, followed by white space or a comma.- Accepted by the parser built from the AppArmor tree at 836052d21 (
-Q -K --skip-kernel-load --warn=all, nothing loaded into a kernel):file /a r,,file r /a,,file /a px -> b,,file safe /a px,,file unsafe px /a,,file l /a -> /b,,deny file /a w,,audit deny owner /a rw,. safeorunsafeon a rule with no exec letters:unsafe rule missing exec permissions.fileis a reserved word only in rule position;/etc/file r,is an ordinary rule (read from the source).
Read more
for AppArmor developers for security researchers
In the code
- Qualifiers:
opt_prefix: opt_priority opt_audit_flag opt_rule_mode opt_owner_flag(parser_yacc.y:705-711). opt_exec_mode,opt_fileand the firstfrule(parser_yacc.y:1065-1072); the letters-firstfrule(parser_yacc.y:1085);file_rule: ... | opt_file file_rule_tail(parser_yacc.y:1114) andfile_rule_tail: opt_exec_mode frule(parser_yacc.y:1117).- A path is the scanner's
LABEL:/, a variable,:or&, then word characters (parser_lex.l:301). The keyword table mapsfiletoTOK_FILE(parser_misc.c:108).
03 Path first or letters first
/etc/demo/** r, and r /etc/demo/**, are the same rule. Rules with identical path text are merged by adding their permissions.
Most profiles put the path first. But the tree's own tests also write the letters first: r, then the path. The parser builds the same rule either way, so the two helper lines here are one rule. Add an arrow and a target, and the target comes after the path in both spellings. One more thing about identical paths: if two rules name exactly the same path, their letters are added together, so read on one line and write on another gives read and write. The one place the spellings differ, the letter l with an exec letter and an arrow, is in the link rules deck.
Details and sources
Details
/etc/demo/** r,andr /etc/demo/**,build the same rule (read from the source).- The parser's tests use the letters-first form: front_perms_ok_1.sd has
r /foo1,,w /foo1,,px /foo1,and more, expected result PASS. - With an arrow the target follows the path in both spellings:
/a px -> b,andpx /a -> b,(parser built from the AppArmor tree at 836052d21).px -> b /a,givessyntax error, unexpected TOK_ARROW, expecting TOK_ID or TOK_SET_VAR. subsetexists in the letters-first form only and only withl:r subset /a,givessubset can only be used with link rules.- Rules with identical path text are merged before compilation by adding their permissions:
/a r,and/a w,are/a rw,. Exec modes that disagree stop the parser:profile NAME: has merged rule PATH with conflicting x modifiers. - The one difference between the spellings,
lwith an exec letter and an arrow: path first gives the warningambiguous rule specifies both link target and exec transition target. Using as exec transition(classdeprecated, off by default); letters first gives the errorlink and exec perms conflict on a file rule using ->.
for AppArmor developers for security researchers
In the code
- The two alternatives: parser_yacc.y:1072 with the warning in its action, and parser_yacc.y:1085-1100 with the
subsetand link checks. Both calldo_file_rule. block_rules::merge_filesorts the entries and ORs the permissions of equal ones at block_rules.cc:329 (the function: block_rules.cc:285-343).
04 What the kernel does with the rule
The kernel matches the full name against the profile and refuses with EACCES when a requested permission is not allowed. Directory names end in /.
Here's what happens at one open. When demo opens its configuration, the kernel, here the kernel, works out the full name of the file and looks up what the profile's rules allow for that name. The open asked for read, the rule gives read, and the open goes ahead. Ask for write on the same file and one requested permission is missing, so the call fails with permission denied, EACCES. One detail catches people. For a directory, the kernel puts a slash on the end of the name before it matches. So a rule that should match the directory itself, to list it, has to end in a slash.
Details and sources
Details
All statements are from the kernel source, read and not run.
- Hooks:
file_openfor an open,file_permissionfor later reads and writes on the open file, and thepath_*hooks (path_unlink,path_mkdir,path_rename,path_chmodand others) for operations on names (lsm.c:1796-1816). aa_path_perm(op, subj_cred, label, path, flags, request, cond)runs the check once for each confined profile in the task's label (file.c:287-309).- The name is built from the path, then matched:
aa_str_permswalks the profile's file DFA over the name and looks up the permissions for the task's fsuid (file.c:221-231). if (request & ~perms->allow) e = -EACCES;(file.c:244-247). The result goes toaa_audit_file, which writes the log record.- Directory names get a trailing
/before matching, except the root (path.c:167-177)./etc/demo/ r,matches the directory itself;/etc/demo r,does not. - apparmor.d(5) says the same: "Only rules that match a trailing slash will match directories" (apparmor.d.pod:2507-2509).
- The buffer for a name is
path_maxbytes, by default twice PATH_MAX; readable by root in/sys/module/apparmor/parameters/path_max(lsm.c:1998-1999). - Which half of a rule applies, owner or other, is decided by comparing the task's fsuid with the owner of the object; the record shows both as
fsuid=andouid=.
Read more
- apparmor.d(5), Globbing (AARE): the paragraph on directories and the trailing slash.
- How AppArmor file permissions differ from DAC on apparmor.net.
- Matching in the kernel, owner, reading denials.
05 The bare rule: file,
file, equals the path /{**,} with rwalkm and ix. owner file, keeps the owner half only.
Sometimes you want a profile that limits networking or capabilities but leaves files alone. The bare rule does that: the word file, and a comma. The parser rewrites it into a pattern that matches every name starting with a slash, with every file letter: read, write, append, link, lock and memory map. For exec it adds ix, so programs demo starts stay in demo's profile. Qualifiers still work: owner in front limits it to files the task owns. And it says nothing about other kinds of rule. Network, capabilities and the rest are still checked.
Details and sources
Details
file,is rewritten by the parser to the path/{**,}with the lettersrwalkmand the exec modeix, for the owner half and the other half (read from the source).- In the rule dump of the parser built from the AppArmor tree at 836052d21 (
-D rule-exprs) the path is/([^\x00]*|):/followed by anything, and/alone. The permission word is0x9fc27f; forowner file,it is0x27f. owner file,keeps the owner half only: the same access, for files owned by the task's fsuid.- It covers file rules only.
network,capability,mountand the other rule classes are still checked against their own rules. - The pattern covers names that begin with
/. A name that does not, such as the name of a disconnected object, is not matched (read from the source). - Known discrepancy:
deny file,is rejected withInvalid perms, in deny rules 'x' must not be preceded by exec qualifier 'i', 'p', or 'u', because the bare rule carriesix. The test ok_bare_1.sd expects it to pass and is marked#=TODO https://launchpad.net/bugs/1215637.
for security researchers
Attack surface
- File rules match the name the kernel builds at the time of the check, not the object: a file that has a second name, such as a hard link, is checked against the rules for the name that was used. See link rules.
file,is the widest file rule there is: it compiles to the pattern/{**,}withrwalkmandixfor owner and other (parser_yacc.y:1103-1113; run with the parser built from the AppArmor tree at 836052d21, nothing loaded into a kernel). Every program the task can name is then executable under the same profile.- The bare rule cannot be turned into a denial:
deny file,is rejected because the bare rule carriesix(parser_misc.c:1093-1096).deny /** rwlkmx,anddeny /{**,} rwlkmx,are accepted by the same parser when a blanket denial is wanted. - A rule that ends in
/**does not cover the directory itself, and a rule without the trailing slash does not match a directory: check both forms when you review what a profile exposes (globbing).
Read more
for AppArmor developers for security researchers
In the code
file_rule: TOK_FILE TOK_END_OF_RULEbuilds the path"/{**,}"and the permissions(AA_BASE_PERMS & ~AA_EXEC_TYPE) | (AA_EXEC_INHERIT | AA_MAY_EXEC), copied to the other half with<< AA_OTHER_SHIFT(parser_yacc.y:1103-1113).AA_OTHER_SHIFTis 14 (immunix.h:25).- The owner qualifier masks one half in
entry_add_prefix, which ends withcheck_x_qualifier, the source of thedeny file,error (parser_misc.c:1147-1159, parser_misc.c:1090-1096).
06 From text to a cod_entry for AppArmor developers for security researchers
frule (parser/parser_yacc.y:1072,1085) builds a cod_entry; merge_file ORs entries with identical names; process_dfa_entry (parser/parser_regex.c:648) compiles each.
To the parser a file rule isn't a class like the newer rule types; it's a cod_entry. The lexer returns the path as an ID token and the letters as a mode token, but only when white space or a comma follows them. The grammar has two frule alternatives, one per spelling, and both call do_file_rule. By then parse_perms has filled both halves of the permission word, owner and other, which is why plain read is 0x10004. Prefixes are applied by entry_add_prefix, entries with identical names are merged by merge_file, and process_dfa_entry hands the pattern and the word to the DFA compiler.
Details and sources
for AppArmor developers for security researchers
Details
- Scanner: a path is
LABELorQUOTED_LABELand returnsTOK_ID; the letters returnTOK_MODEonly before white space or a comma,({MODES})/([[:space:],])(parser_lex.l:301, parser_lex.l:838-846). - Grammar: two
frulealternatives (parser_yacc.y:1072-1100);file_perms: TOK_MODEcallsparse_perms(parser_yacc.y:1640-1646). perm32_t parse_perms(const char *str_perms)shifts the parsed letters into both halves,AA_USER_SHIFT(0) andAA_OTHER_SHIFT(14) (parser_misc.c:736-745, immunix.h:24-25). WithAA_MAY_EXEC 1,AA_MAY_WRITE 2,AA_MAY_READ 4,AA_MAY_APPEND 8(immunix.h:35-38),ris0x10004andrwis0x3800e.struct cod_entry *do_file_rule(char *id, perm32_t perms, char *link_id, char *nt)callsnew_entryand stores the target innt_name(parser_yacc.y:1759-1769).bool entry_add_prefix(struct cod_entry *entry, const prefixes &p, const char *&error)applies audit, mode and priority, masks a half forownerorother, then runscheck_x_qualifier(parser_misc.c:1147-1159).block_rules::process_variablesexpands variables innameandlink_name(block_rules.cc:393-407).block_rules::merge_filesorts withfile_comp, checksis_merged_x_consistentand ORsperms(block_rules.cc:285-343).bool process_dfa_entry(aare_rules *dfarules, struct cod_entry *entry)callsfilter_slashes,convert_aaregex_to_pcreanddfarules->add_rule(pattern, priority, rule_mode, perms, audit, parseopts)(parser_regex.c:648-682).- Kernel: the compiled table is matched by
aa_str_permsfrom start staterules->file->start[AA_CLASS_FILE](file.c:221-247).
07 When the parser says no
Missing comma: "missing an end of line character? (entry: ...)". Paths start with / or @{; quote paths with spaces. Qualifiers precede file; safe/unsafe follow it.
Four slips account for most file rule errors. Forget the comma and the parser reads on into the next rule, then asks whether you're missing an end of line character, naming the rule that had no comma. A path has to start with a slash or a variable; anything else is just a word. A space ends the path, so a name with a space in it needs quotes. And the parts have an order: deny goes before the word file, while safe and unsafe go after it. The messages with TOK in them come straight from the grammar. Read them as: I expected the letters here.
Details and sources
Details
Messages from the parser built from the AppArmor tree at 836052d21 (-Q -K --skip-kernel-load --warn=all). The full form is AppArmor parser error for FILE in profile FILE at line N: MESSAGE.
/a rthen/b w,:missing an end of line character? (entry: PATH), reported at the line of the following rule and naming the rule without the comma./a b r,oretc/x r,:syntax error, unexpected TOK_ID, expecting TOK_MODE. A space inside an unquoted path, or a first word that is not a path. Fixture: bad_embedded_spaces_1.sd.a r,ormark r,:syntax error, unexpected TOK_MODE, expecting TOK_ID or TOK_SET_VAR. The first word consists only of mode letters, so it is read as a mode.file deny /a w,:syntax error, unexpected TOK_DENY, expecting TOK_ID or TOK_MODE or TOK_SET_VAR. Qualifiers go beforefile.safe file /a px,:syntax error, unexpected TOK_FILE, expecting TOK_ID or TOK_MODE or TOK_SET_VAR.safeandunsafego afterfile.file /a,:syntax error, unexpected TOK_END_OF_RULE, expecting TOK_MODE. A path with no mode.- Token names:
TOK_IDis a path or another word,TOK_MODEthe permission letters,TOK_SET_VARa variable,TOK_END_OF_RULEthe comma.
for AppArmor developers for security researchers
In the code
- The missing comma message is an error production,
file_rule_tail: opt_exec_mode id_or_var file_perms id_or_var(parser_yacc.y:1132-1139). - What counts as a path is the scanner's
LABEL(parser_lex.l:301); a word of mode letters before white space or a comma isTOK_MODE(parser_lex.l:843-846).
08 Where to go from here
Next: syn-access-modes (letters), syn-globbing (patterns), syn-exec-modes and syn-named-transitions (exec), syn-link-rules (links), syn-allow-deny and syn-owner (qualifiers).
Every part of this line has a deck of its own: the qualifier in front, the pattern, the letters, the arrow. Go to the owner and allow and deny decks for what stands in front. Globbing explains the stars. Access modes tells you what r and w really grant, and exec modes covers the letters that end in x. The arrow belongs to named transitions, or to link rules when the letters include l. And if you want to see the rule from the inside, follow it into the grammar deck or the kernel's matching deck.
Details and sources
Details
- A file rule is
PATH MODE,orMODE PATH,, optionally with qualifiers in front, the wordfile, and-> TARGETat the end. file,alone allows every file access andixfor exec.- In the kernel a request that the rules do not allow fails with EACCES (file.c:244-247), and directory names are matched with a trailing
/(path.c:167-177). - Commits read for this deck: AppArmor 836052d21 (6.0.0~alpha2), the kernel-rc2 (97d73c825).
Read more
Basis of the statements on this page: "tree" means the parser built from the AppArmor commit above was run on the fragment (-Q -K --skip-kernel-load --warn=all), with nothing loaded into a kernel; "code" means the parser source or the kernel source of mainline Linux 7.4 (7.4-rc2, 97d73c825) was read, not run. Nothing here was observed on a running kernel.
Grammar
FILE RULE: [QUALIFIERS] [file] [safe|unsafe] ( PATH MODE | MODE [subset] PATH ) [-> TARGET] , BARE RULE: [QUALIFIERS] file , QUALIFIERS: [priority=N] [audit] [allow|deny|prompt] [owner|other]
PATHstarts with/or a variable@{...}, or is a quoted string. It ends at white space; a path that contains a space or a comma is quoted.MODEis one word of permission letters followed by white space or a comma. The letters: syn-access-modes and syn-exec-modes.- The order of the parts is fixed: qualifiers, then
file, thensafeorunsafe, then the path and mode in either order, then the arrow and target, then the comma. - With an arrow, the target follows the path in both spellings:
/a px -> b,andpx /a -> b,(tree). - The two spellings build the same rule (code). They differ in one case,
ltogether with an exec mode and an arrow: see syn-link-rules.
Keywords
| Keyword | Where | Meaning |
|---|---|---|
file | before the rule, after the qualifiers | optional marker with no effect; alone with a comma it is the bare rule |
safe, unsafe | after file, before the path or mode | exec rules only: syn-safe-unsafe |
subset | letters-first spelling, between mode and path | link rules only: syn-link-rules |
-> | after the path and mode | a link target when the mode has l and no exec letters, otherwise an exec target: syn-named-transitions |
priority=N, audit, allow, deny, prompt | in front, in this order | syn-priority, syn-audit, syn-allow-deny |
owner, other | last qualifier | syn-owner |
file is a reserved word only in rule position. It stays usable inside a path, as in /etc/file r, (code).
Accepted forms
Each of these lines is accepted by the tree's parser (tree).
| Line | Note |
|---|---|
file /a r, | keyword, path first |
file r /a, | keyword, letters first |
file /a px -> b, | exec target |
file safe /a px, | safe after file |
file unsafe px /a, | unsafe with letters first |
file l /a -> /b, | link target |
deny file /a w, | qualifier before file |
audit deny owner /a rw, | qualifiers in order |
file, | the bare rule |
owner file, | the bare rule, owner half |
"/foobar," r, | a quoted path that contains a comma |
The bare rule
file,is rewritten by the parser to the path/{**,}with the lettersrwalkmand the exec modeix, for both the owner and the other half (code). In the parser's rule dump the path is/([^\x00]*|):/followed by anything, and/alone (tree).owner file,keeps the owner half only: the same access, for files owned by the task's fsuid.- It covers file rules only. Network, capability, mount and the other rule classes are still checked against their own rules.
- The pattern covers names that begin with
/. A name that does not, such as the name of a disconnected object, is not matched (code). file,outside a profile is an error.
What the kernel checks
All statements in this section are from the kernel source (code).
- At each access the kernel builds the full name of the object and matches it against the profile's file rules.
- The name of a directory gets a trailing
/before matching./etc/demo/ r,matches the directory itself;/etc/demo r,does not. - If any requested permission is not allowed for that name, the access fails with
EACCES. - Which half of the rule applies, owner or other, is decided by comparing the task's fsuid with the owner of the object: syn-owner.
- Rules with identical path text are merged before compilation by adding their permissions:
/a r,and/a w,are/a rw,.
Errors and warnings
The full form of a parser error is AppArmor parser error for FILE in profile FILE at line N: MESSAGE (tree). The table gives MESSAGE. All of them are fatal except the last row.
| Message | Example | When |
|---|---|---|
| missing an end of line character? (entry: PATH) | /a r then /b w, | a rule has no comma; reported at the line of the following rule, naming the rule without the comma |
| syntax error, unexpected TOK_ID, expecting TOK_MODE | /a b r, and etc/x r, | a space inside an unquoted path, or a first word that is not a path. When the word after the space is a keyword the message names its token: /a file r, gives unexpected TOK_FILE (tree) |
| syntax error, unexpected TOK_MODE, expecting TOK_ID or TOK_SET_VAR | a r, and mark r, | the first word consists only of mode letters, so it is read as a mode |
| syntax error, unexpected TOK_DENY, expecting TOK_ID or TOK_MODE or TOK_SET_VAR | file deny /a w, | a qualifier after file |
| syntax error, unexpected TOK_FILE, expecting TOK_ID or TOK_MODE or TOK_SET_VAR | safe file /a px, | safe or unsafe before file |
| syntax error, unexpected TOK_LINK, ... | file link /a -> /b, | the link rule does not take the keyword |
| syntax error, unexpected TOK_END_OF_RULE, expecting TOK_MODE | file /a, | a path with no mode |
| syntax error, unexpected TOK_ARROW, expecting TOK_ID or TOK_SET_VAR | px -> b /a, | the target written before the path |
| subset can only be used with link rules. | r subset /a, | subset with a mode other than l |
| link and exec perms conflict on a file rule using -> | lpx /link/** -> /target, | letters first, l with an exec mode and an arrow |
| link perms are not allowed on a named profile transition. | l /a -> :ns:b, | letters first, l with a target that names a namespace |
| conflicting mode prefix | two of allow, deny, prompt reach the same rule | |
| conflicting audit prefix | audit given twice for the same rule | |
| ambiguous rule specifies both link target and exec transition target. Using as exec transition | /a lpx -> b, | warning, path first only; its class deprecated is off by default |
In these messages TOK_ID is a path or another word, TOK_MODE is the permission letters, TOK_SET_VAR is a variable and TOK_END_OF_RULE is the comma.
Known discrepancies
deny file,is rejected with "Invalid perms, in deny rules 'x' must not be preceded by exec qualifier 'i', 'p', or 'u'" (tree). The bare rule is built withix, and a deny rule may not carry an exec qualifier. The tree's own testparser/tst/simple_tests/file/ok_bare_1.sdexpects the rule to pass and is marked as a known failure (launchpad 1215637).- An arrow on a rule with neither
xnorl, such as/a r -> b,, is accepted and takes a slot in the exec table. See syn-named-transitions.
for AppArmor developers for security researchers
Code map
| Step | Where |
|---|---|
path as TOK_ID, LABEL start characters | parser/parser_lex.l:301, parser/parser_lex.l:838-841 |
letters as TOK_MODE, only before white space or a comma | parser/parser_lex.l:843-846 |
file keyword to TOK_FILE | parser/parser_misc.c:108 |
qualifiers, opt_prefix | parser/parser_yacc.y:705-711 |
frule, path first | parser/parser_yacc.y:1072 |
frule, letters first, with the subset and link checks | parser/parser_yacc.y:1085-1100 |
bare rule, file_rule: TOK_FILE TOK_END_OF_RULE | parser/parser_yacc.y:1103-1113 |
file_rule: opt_file file_rule_tail, opt_exec_mode frule | parser/parser_yacc.y:1114, parser/parser_yacc.y:1117 |
| the missing-comma error | parser/parser_yacc.y:1132-1139 |
parse_perms | parser/parser_misc.c:736-745 |
do_file_rule, builds the cod_entry | parser/parser_yacc.y:1759-1769 |
entry_add_prefix, with check_x_qualifier | parser/parser_misc.c:1147-1159 |
process_variables | parser/block_rules.cc:393-407 |
merge_file, ORs the perms of identical names | parser/block_rules.cc:285-343 |
process_dfa_entry | parser/parser_regex.c:648-682 |
kernel: aa_path_perm, profile_path_perm, __aa_path_perm, aa_str_perms | linux:security/apparmor/file.c:221-309 |
kernel: request & ~perms->allow gives -EACCES | linux:security/apparmor/file.c:244-247 |
kernel: trailing / on directory names | linux:security/apparmor/path.c:167-177 |
Permission words in the parser's rule dump (tree). Each half has x 0x1, w 0x2, r 0x4, a 0x8; the other half is shifted left by 14.
| Rule | Word |
|---|---|
/a r, | 0x10004 |
/a rw, | 0x3800e |
file, | 0x9fc27f |
owner file, | 0x27f |
Roads from here
START HERE
- The profile language at a glance — every kind of line on one page
FILE ACCESS
- File access modes — what each permission letter allows
- Globbing (AARE) — the pattern language of the path
- Exec modes — the letters that end in x
- Link rules — what the arrow means when the letters include l
- Named exec transitions — what the arrow means on an exec rule
QUALIFIERS
- allow and deny — the qualifiers that go in front of the rule
- The owner qualifier — rules for files the task owns
IN PRACTICE · security-sensitive programs
- Symlinks: rules see through them — rules match the path after symlinks
- Hard links and name-based rules — a second name for the same file
IN THE KERNEL
- Matching at run time — how the kernel matches a name
INSIDE THE PARSER
- The grammar — how the parser reads a rule