summaryrefslogtreecommitdiff
path: root/security/apparmor/include
Commit message (Collapse)AuthorAge
...
* apparmor: switch from profiles to using labels on contextsJohn Johansen2017-06-10
| | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: add the base fns() for domain labelsJohn Johansen2017-06-10
| | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: revalidate files during execJohn Johansen2017-06-10
| | | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: cleanup rename XXX_file_context() to XXX_file_ctx()John Johansen2017-06-10
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: convert aa_change_XXX bool parameters to flagsJohn Johansen2017-06-10
| | | | | | | Instead of passing multiple booleans consolidate on a single flags field. Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: share profile name on replacementJohn Johansen2017-06-10
| | | | | | The profile names are the same, leverage this. Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: convert to profile block critical sectionsJohn Johansen2017-06-10
| | | | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: move bprm_committing_creds/committed_creds to lsm.cJohn Johansen2017-06-10
| | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: add namespace lookup fns()John Johansen2017-06-10
| | | | | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: switch from file_perms to aa_permsJohn Johansen2017-06-10
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: add gerneric permissions struct and support fnsJohn Johansen2017-06-10
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: add fn to test if profile supports a given mediation classJohn Johansen2017-06-10
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: add policy revision file interfaceJohn Johansen2017-06-10
| | | | | | | | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: provide finer control over policy managementJohn Johansen2017-06-10
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: rework perm mapping to a slightly broader setJohn Johansen2017-06-09
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: move permissions into their own file to be more easily sharedJohn Johansen2017-06-08
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: allow specifying an already created dir to create ns entries inJohn Johansen2017-06-08
| | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com> Reviewed-by: Seth Arnold <seth.arnold@canonical.com> Reviewed-by: Kees Cook <keescook@chromium.org>
* apparmor: rename apparmor file fns and data to indicate useJohn Johansen2017-06-08
| | | | | | | | | | | | | 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 <john.johansen@canonical.com> Reviewed-by: Seth Arnold <seth.arnold@canonical.com> Reviewed-by: Kees Cook <keescook@chromium.org>
* apparmor: move to per loaddata files, instead of replicating in profilesJohn Johansen2017-06-08
| | | | | | | | | | 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 <john.johansen@canonical.com> Reviewed-by: Seth Arnold <seth.arnold@canonical.com> Reviewed-by: Kees Cook <keescook@chromium.org>
* apparmor: Move path lookup to using preallocated buffersJohn Johansen2017-06-08
| | | | | | | | 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 <john.johansen@canonical.com>
* apparmor: allow profiles to provide info to disconnected pathsJohn Johansen2017-06-08
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: make internal lib fn skipn_spaces available to the rest of apparmorJohn Johansen2017-06-08
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* apparmor: move file context into file.hJohn Johansen2017-06-08
| | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
* mm: introduce kv[mz]alloc helpersMichal Hocko2017-05-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch series "kvmalloc", v5. There are many open coded kmalloc with vmalloc fallback instances in the tree. Most of them are not careful enough or simply do not care about the underlying semantic of the kmalloc/page allocator which means that a) some vmalloc fallbacks are basically unreachable because the kmalloc part will keep retrying until it succeeds b) the page allocator can invoke a really disruptive steps like the OOM killer to move forward which doesn't sound appropriate when we consider that the vmalloc fallback is available. As it can be seen implementing kvmalloc requires quite an intimate knowledge if the page allocator and the memory reclaim internals which strongly suggests that a helper should be implemented in the memory subsystem proper. Most callers, I could find, have been converted to use the helper instead. This is patch 6. There are some more relying on __GFP_REPEAT in the networking stack which I have converted as well and Eric Dumazet was not opposed [2] to convert them as well. [1] http://lkml.kernel.org/r/20170130094940.13546-1-mhocko@kernel.org [2] http://lkml.kernel.org/r/1485273626.16328.301.camel@edumazet-glaptop3.roam.corp.google.com This patch (of 9): Using kmalloc with the vmalloc fallback for larger allocations is a common pattern in the kernel code. Yet we do not have any common helper for that and so users have invented their own helpers. Some of them are really creative when doing so. Let's just add kv[mz]alloc and make sure it is implemented properly. This implementation makes sure to not make a large memory pressure for > PAGE_SZE requests (__GFP_NORETRY) and also to not warn about allocation failures. This also rules out the OOM killer as the vmalloc is a more approapriate fallback than a disruptive user visible action. This patch also changes some existing users and removes helpers which are specific for them. In some cases this is not possible (e.g. ext4_kvmalloc, libcfs_kvzalloc) because those seems to be broken and require GFP_NO{FS,IO} context which is not vmalloc compatible in general (note that the page table allocation is GFP_KERNEL). Those need to be fixed separately. While we are at it, document that __vmalloc{_node} about unsupported gfp mask because there seems to be a lot of confusion out there. kvmalloc_node will warn about GFP_KERNEL incompatible (which are not superset) flags to catch new abusers. Existing ones would have to die slowly. [sfr@canb.auug.org.au: f2fs fixup] Link: http://lkml.kernel.org/r/20170320163735.332e64b7@canb.auug.org.au Link: http://lkml.kernel.org/r/20170306103032.2540-2-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Reviewed-by: Andreas Dilger <adilger@dilger.ca> [ext4 part] Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: John Hubbard <jhubbard@nvidia.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* apparmor: fix parameters so that the permission test is bypassed at bootJohn Johansen2017-04-07
| | | | | | | | | | | | | Boot parameters are written before apparmor is ready to answer whether the user is policy_view_capable(). Setting the parameters at boot results in an oops and failure to boot. Setting the parameters at boot is obviously allowed so skip the permission check when apparmor is not initialized. While we are at it move the more complicated check to last. Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
* Merge branch 'next' of ↵Linus Torvalds2017-02-21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security Pull security layer updates from James Morris: "Highlights: - major AppArmor update: policy namespaces & lots of fixes - add /sys/kernel/security/lsm node for easy detection of loaded LSMs - SELinux cgroupfs labeling support - SELinux context mounts on tmpfs, ramfs, devpts within user namespaces - improved TPM 2.0 support" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (117 commits) tpm: declare tpm2_get_pcr_allocation() as static tpm: Fix expected number of response bytes of TPM1.2 PCR Extend tpm xen: drop unneeded chip variable tpm: fix misspelled "facilitate" in module parameter description tpm_tis: fix the error handling of init_tis() KEYS: Use memzero_explicit() for secret data KEYS: Fix an error code in request_master_key() sign-file: fix build error in sign-file.c with libressl selinux: allow changing labels for cgroupfs selinux: fix off-by-one in setprocattr tpm: silence an array overflow warning tpm: fix the type of owned field in cap_t tpm: add securityfs support for TPM 2.0 firmware event log tpm: enhance read_log_of() to support Physical TPM event log tpm: enhance TPM 2.0 PCR extend to support multiple banks tpm: implement TPM 2.0 capability to get active PCR banks tpm: fix RC value check in tpm2_seal_trusted tpm_tis: fix iTPM probe via probe_itpm() function tpm: Begin the process to deprecate user_read_timer tpm: remove tpm_read_index and tpm_write_index from tpm.h ...
| * apparmor: fix restricted endian type warnings for dfa unpackJohn Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add per cpu work buffers to avoid allocating buffers at every hookJohn Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: support querying extended trusted helper extra dataWilliam Hua2017-01-16
| | | | | | | | | | | | | | | | | | Allow a profile to carry extra data that can be queried via userspace. This provides a means to store extra data in a profile that a trusted helper can extract and use from live policy. Signed-off-by: William Hua <william.hua@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: convert change_profile to use fqname later to give better controlJohn Johansen2017-01-16
| | | | | | | | | | | | | | | | | | Moving the use of fqname to later allows learning profiles to be based on the fqname request instead of just the hname. It also allows cleaning up some of the name parsing and lookup by allowing the use of the fqlookupn_profile() lib fn. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: change aad apparmor_audit_data macro to a fn macroJohn Johansen2017-01-16
| | | | | | | | | | | | | | | | | | | | | | The aad macro can replace aad strings when it is not intended to. Switch to a fn macro so it is only applied when intended. Also at the same time cleanup audit_data initialization by putting common boiler plate behind a macro, and dropping the gfp_t parameter which will become useless. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: change op from int to const char *John Johansen2017-01-16
| | | | | | | | | | | | | | | | | | | | Having ops be an integer that is an index into an op name table is awkward and brittle. Every op change requires an edit for both the op constant and a string in the table. Instead switch to using const strings directly, eliminating the need for the table that needs to be kept in sync. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: rename context abreviation cxt to the more standard ctxJohn Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add per policy ns .load, .replace, .remove interface filesJohn Johansen2017-01-16
| | | | | | | | | | | | | | Having per policy ns interface files helps with containers restoring policy. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: pass the subject profile into profile replace/removeJohn Johansen2017-01-16
| | | | | | | | | | | | | | This is just setup for new ns specific .load, .replace, .remove interface files. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: audit policy ns specified in policy loadJohn Johansen2017-01-16
| | | | | | | | | | | | | | Verify that profiles in a load set specify the same policy ns and audit the name of the policy ns that policy is being loaded for. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: allow introspecting the loaded policy pre internal transformJohn Johansen2017-01-16
| | | | | | | | | | | | | | | | Store loaded policy and allow introspecting it through apparmorfs. This has several uses from debugging, policy validation, and policy checkpoint and restore for containers. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add ns name to the audit data for policy loadsJohn Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add profile and ns params to aa_may_manage_policy()John Johansen2017-01-16
| | | | | | | | | | | | | | | | Policy management will be expanded beyond traditional unconfined root. This will require knowning the profile of the task doing the management and the ns view. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add ns being viewed as a param to policy_admin_capable()John Johansen2017-01-16
| | | | | | | | | | | | | | Prepare for a tighter pairing of user namespaces and apparmor policy namespaces, by making the ns to be viewed available. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add ns being viewed as a param to policy_view_capable()John Johansen2017-01-16
| | | | | | | | | | | | | | | | | | | | | | Prepare for a tighter pairing of user namespaces and apparmor policy namespaces, by making the ns to be viewed available and checking that the user namespace level is the same as the policy ns level. This strict pairing will be relaxed once true support of user namespaces lands. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: Make aa_remove_profile() callable from a different viewJohn Johansen2017-01-16
| | | | | | | | | | | | This is prep work for fs operations being able to remove namespaces. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add special .null file used to "close" fds at execJohn Johansen2017-01-16
| | | | | | | | | | | | | | Borrow the special null device file from selinux to "close" fds that don't have sufficient permissions at exec time. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add a default null dfaJohn Johansen2017-01-16
| | | | | | | | | | | | | | | | | | | | | | Instead of testing whether a given dfa exists in every code path, have a default null dfa that is used when loaded policy doesn't provide a dfa. This will let us get rid of special casing and avoid dereference bugs when special casing is missed. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: add get_dfa() fnJohn Johansen2017-01-16
| | | | | | | | | | | | | | The dfa is currently setup to be shared (has the basis of refcounting) but currently can't be because the count can't be increased. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: name null-XXX profiles after the executableJohn Johansen2017-01-16
| | | | | | | | | | | | | | | | When possible its better to name a learning profile after the missing profile in question. This allows for both more informative names and for profile reuse. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: pass gfp_t parameter into profile allocationJohn Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: refactor prepare_ns() and make usable from different viewsJohn Johansen2017-01-16
| | | | | | | | | | | | | | | | prepare_ns() will need to be called from alternate views, and namespaces will need to be created via different interfaces. So refactor and allow specifying the view ns. Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: pass gfp param into aa_policy_init()John Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>
| * apparmor: constify policy name and hnameJohn Johansen2017-01-16
| | | | | | | | Signed-off-by: John Johansen <john.johansen@canonical.com>