aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-06-10apparmor: switch getprocattr to using label_print fns()John Johansen3-37/+27
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: switch from profiles to using labels on contextsJohn Johansen20-529/+686
Begin the actual switch to using domain labels by storing them on the context and converting the label to a singular profile where possible. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add the base fns() for domain labelsJohn Johansen2-0/+2561
Begin moving apparmor to using broader domain labels, that will allow run time computation of domain type splitting via "stacking" of profiles into a domain label vec. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: revalidate files during execJohn Johansen4-0/+81
Instead of running file revalidation lazily when read/write are called copy selinux and revalidate the file table on exec. This avoids extra mediation overhead in read/write and also prevents file handles being passed through to a grand child unchecked. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: cleanup rename XXX_file_context() to XXX_file_ctx()John Johansen2-11/+16
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: convert aa_change_XXX bool parameters to flagsJohn Johansen5-32/+29
Instead of passing multiple booleans consolidate on a single flags field. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: cleanup remove unused and not fully implemented profile renameJohn Johansen1-37/+2
Remove the partially implemented code, until this can be properly implemented. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: refactor updating profiles to the newest parentJohn Johansen1-4/+31
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: share profile name on replacementJohn Johansen3-9/+72
The profile names are the same, leverage this. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: convert to profile block critical sectionsJohn Johansen8-56/+162
There are still a few places where profile replacement fails to update and a stale profile is used for mediation. Fix this by moving to accessing the current label through a critical section that will always ensure mediation is using the current label regardless of whether the tasks cred has been updated or not. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: move bprm_committing_creds/committed_creds to lsm.cJohn Johansen3-32/+30
There is no reason to have the small stubs that don't use domain private functions in domain.c, instead move them to lsm.c and make them static. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: fix display of ns nameJohn Johansen1-1/+1
The ns name being displayed should go through an ns view lookup. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: fix apparmor_query dataJohn Johansen1-2/+6
The data being queried isn't always the current profile and a lookup relative to the current profile should be done. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: fix policy load/remove semanticsJohn Johansen2-15/+13
The namespace being passed into the replace/remove profiles fns() is not the view, but the namespace specified by the inode from the file hook (if present) or the loading tasks ns, if accessing the top level virtualized load/replace file interface. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add namespace lookup fns()John Johansen3-4/+73
Currently lookups are restricted to a single ns component in the path. However when namespaces are allowed to have separate views, and scopes this will not be sufficient, as it will be possible to have a multiple component ns path in scope. Add some ns lookup fns() to allow this and use them. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: cleanup __find_child()John Johansen1-8/+8
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: provide information about path buffer size at bootJohn Johansen1-2/+9
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add profile permission query abilityJohn Johansen1-1/+102
Allow userspace to query a profile about permissions, through the transaction interface that is already used to allow userspace to query about key,value data. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: switch from file_perms to aa_permsJohn Johansen5-48/+29
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add gerneric permissions struct and support fnsJohn Johansen4-17/+153
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add fn to test if profile supports a given mediation classJohn Johansen1-0/+10
Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: speed up transactional queriesJohn Johansen1-11/+114
The simple_transaction interface is slow. It requires 4 syscalls (open, write, read, close) per query and shares a single lock for each queries. So replace its use with a compatible in multi_transaction interface. It allows for a faster 2 syscall pattern per query. After an initial open, an arbitrary number of writes and reads can be issued. Each write will reset the query with new data that can be read. Reads do not clear the data, and can be issued multiple times, and used with seek, until a new write is performed which will reset the data available and the seek position. Note: this keeps the single lock design, if needed moving to a per file lock will have to come later. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add label data availability to the feature setJohn Johansen1-0/+10
gsettings mediation needs to be able to determine if apparmor supports label data queries. A label data query can be done to test for support but its failure is indistinguishable from other failures, making it an unreliable indicator. Fix by making support of label data queries available as a flag in the apparmorfs features dir tree. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add mkdir/rmdir interface to manage policy namespacesJohn Johansen1-1/+94
When setting up namespaces for containers its easier for them to use an fs interface to create the namespace for the containers policy. Allow mkdir/rmdir under the policy/namespaces/ dir to be used to create and remove namespaces. BugLink: http://bugs.launchpad.net/bugs/1611078 Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: add policy revision file interfaceJohn Johansen4-1/+116
Add a policy revision file to find the current revision of a ns's policy. There is a revision file per ns, as well as a virtualized global revision file in the base apparmor fs directory. The global revision file when opened will provide the revision of the opening task namespace. The revision file can be waited on via select/poll to detect apparmor policy changes from the last read revision of the opened file. This means that the revision file must be read after the select/poll other wise update data will remain ready for reading. Signed-off-by: John Johansen <[email protected]>
2017-06-10apparmor: provide finer control over policy managementJohn Johansen3-23/+35
Signed-off-by: John Johansen <[email protected]>
2017-06-09apparmor: rework perm mapping to a slightly broader setJohn Johansen5-53/+133
Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmor: move permissions into their own file to be more easily sharedJohn Johansen4-19/+43
Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmor: convert from securityfs to apparmorfs for policy ns filesJohn Johansen1-26/+37
Virtualize the apparmor policy/ directory so that the current namespace affects what part of policy is seen. To do this convert to using apparmorfs for policy namespace files and setup a magic symlink in the securityfs apparmor dir to access those files. Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08apparmor: allow specifying an already created dir to create ns entries inJohn Johansen3-7/+8
Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08apparmor: rename apparmor file fns and data to indicate useJohn Johansen9-127/+172
prefixes are used for fns/data that are not static to apparmorfs.c with the prefixes being aafs - special magic apparmorfs for policy namespace data aa_sfs - for fns/data that go into securityfs aa_fs - for fns/data that may be used in the either of aafs or securityfs Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08apparmor: add custom apparmorfs that will be used by policy namespace filesJohn Johansen2-17/+338
AppArmor policy needs to be able to be resolved based on the policy namespace a task is confined by. Add a base apparmorfs filesystem that (like nsfs) will exist as a kern mount and be accessed via jump_link through a securityfs file. Setup the base apparmorfs fns and data, but don't use it yet. Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08apparmor: use macro template to simplify namespace seq_filesJohn Johansen1-29/+24
Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08apparmor: use macro template to simplify profile seq_filesJohn Johansen1-61/+36
Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08apparmor: move to per loaddata files, instead of replicating in profilesJohn Johansen7-69/+409
The loaddata sets cover more than just a single profile and should be tracked at the ns level. Move the load data files under the namespace and reference the files from the profiles via a symlink. Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Reviewed-by: Kees Cook <[email protected]>
2017-06-08securityfs: add the ability to support symlinksJohn Johansen2-21/+135
Signed-off-by: John Johansen <[email protected]> Reviewed-by: Seth Arnold <[email protected]> Acked-by: Kees Cook <[email protected]>
2017-06-08apparmor: Move path lookup to using preallocated buffersJohn Johansen4-86/+53
Dynamically allocating buffers is problematic and is an extra layer that is a potntial point of failure and can slow down mediation. Change path lookup to use the preallocated per cpu buffers. Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmor: allow profiles to provide info to disconnected pathsJohn Johansen6-17/+34
Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmor: make internal lib fn skipn_spaces available to the rest of apparmorJohn Johansen2-1/+2
Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmor: move file context into file.hJohn Johansen2-32/+32
Signed-off-by: John Johansen <[email protected]>
2017-06-08security/apparmor: Use POSIX-compatible "printf '%s'"Thomas Schneider1-2/+2
When using a strictly POSIX-compliant shell, "-n #define ..." gets written into the file. Use "printf '%s'" to avoid this. Signed-off-by: Thomas Schneider <[email protected]> Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmor: Fix error cod in __aa_fs_profile_mkdir()Dan Carpenter1-2/+4
We can either return PTR_ERR(NULL) or a PTR_ERR(a valid pointer) here. Returning NULL is probably not good, but since this happens at boot then we are probably already toasted if we were to hit this bug in real life. In other words, it seems like a very low severity bug to me. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmorfs: Use seq_putc() in two functionsMarkus Elfring1-2/+2
Two single characters (line breaks) should be put into a sequence. Thus use the corresponding function "seq_putc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <[email protected]> Signed-off-by: John Johansen <[email protected]>
2017-06-08apparmorfs: Combine two function calls into one in aa_fs_seq_raw_abi_show()Markus Elfring1-4/+3
A bit of data was put into a sequence by two separate function calls. Print the same data by a single function call instead. Signed-off-by: Markus Elfring <[email protected]> Signed-off-by: John Johansen <[email protected]>
2017-06-01Smack: Use cap_capable in privilege checkCasey Schaufler2-9/+12
Use cap_capable() rather than capable() in the Smack privilege check as the former does not invoke other security module privilege check, while the later does. This becomes important when stacking. It may be a problem even with minor modules. Signed-off-by: Casey Schaufler <[email protected]>
2017-06-01Smack: Safer check for a socket in file_receiveCasey Schaufler1-1/+1
The check of S_ISSOCK() in smack_file_receive() is not appropriate if the passed descriptor is a socket. Reported-by: Stephen Smalley <[email protected]> Signed-off-by: Casey Schaufler <[email protected]>
2017-06-01smack: use pernet operations for hook registrationFlorian Westphal1-8/+18
It will allow us to remove the old netfilter hook api in the near future. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Casey Schaufler <[email protected]>
2017-05-22Sync to mainline for security submaintainers to work againstJames Morris12277-282005/+1313528
2017-05-21Linux 4.12-rc2Linus Torvalds1-1/+1
2017-05-21x86: fix 32-bit case of __get_user_asm_u64()Linus Torvalds1-3/+3
The code to fetch a 64-bit value from user space was entirely buggered, and has been since the code was merged in early 2016 in commit b2f680380ddf ("x86/mm/32: Add support for 64-bit __get_user() on 32-bit kernels"). Happily the buggered routine is almost certainly entirely unused, since the normal way to access user space memory is just with the non-inlined "get_user()", and the inlined version didn't even historically exist. The normal "get_user()" case is handled by external hand-written asm in arch/x86/lib/getuser.S that doesn't have either of these issues. There were two independent bugs in __get_user_asm_u64(): - it still did the STAC/CLAC user space access marking, even though that is now done by the wrapper macros, see commit 11f1a4b9755f ("x86: reorganize SMAP handling in user space accesses"). This didn't result in a semantic error, it just means that the inlined optimized version was hugely less efficient than the allegedly slower standard version, since the CLAC/STAC overhead is quite high on modern Intel CPU's. - the double register %eax/%edx was marked as an output, but the %eax part of it was touched early in the asm, and could thus clobber other inputs to the asm that gcc didn't expect it to touch. In particular, that meant that the generated code could look like this: mov (%eax),%eax mov 0x4(%eax),%edx where the load of %edx obviously was _supposed_ to be from the 32-bit word that followed the source of %eax, but because %eax was overwritten by the first instruction, the source of %edx was basically random garbage. The fixes are trivial: remove the extraneous STAC/CLAC entries, and mark the 64-bit output as early-clobber to let gcc know that no inputs should alias with the output register. Cc: Al Viro <[email protected]> Cc: Benjamin LaHaise <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: [email protected] # v4.8+ Signed-off-by: Linus Torvalds <[email protected]>