Skip to content
Snippets Groups Projects
Select Git revision
  • 26b7899510ae243e392960704ebdba52d05fbb13
  • master default
  • android-container
  • nanopc-t4
  • for-kernelci
  • WIP-syscall
  • v4.16-rc5
  • v4.16-rc4
  • v4.16-rc3
  • v4.16-rc2
  • v4.16-rc1
  • v4.15
  • v4.15-rc9
  • v4.15-rc8
  • v4.15-rc7
  • v4.15-rc6
  • v4.15-rc5
  • v4.15-rc4
  • v4.15-rc3
  • v4.15-rc2
  • v4.15-rc1
  • v4.14
  • v4.14-rc8
  • v4.14-rc7
  • v4.14-rc6
  • v4.14-rc5
26 results

label.c

  • label.c 50.02 KiB
    /*
     * AppArmor security module
     *
     * This file contains AppArmor label definitions
     *
     * Copyright 2017 Canonical Ltd.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation, version 2 of the
     * License.
     */
    
    #include <linux/audit.h>
    #include <linux/seq_file.h>
    #include <linux/sort.h>
    
    #include "include/apparmor.h"
    #include "include/context.h"
    #include "include/label.h"
    #include "include/policy.h"
    #include "include/secid.h"
    
    
    /*
     * the aa_label represents the set of profiles confining an object
     *
     * Labels maintain a reference count to the set of pointers they reference
     * Labels are ref counted by
     *   tasks and object via the security field/security context off the field
     *   code - will take a ref count on a label if it needs the label
     *          beyond what is possible with an rcu_read_lock.
     *   profiles - each profile is a label
     *   secids - a pinned secid will keep a refcount of the label it is
     *          referencing
     *   objects - inode, files, sockets, ...
     *
     * Labels are not ref counted by the label set, so they maybe removed and
     * freed when no longer in use.
     *
     */
    
    #define PROXY_POISON 97
    #define LABEL_POISON 100
    
    static void free_proxy(struct aa_proxy *proxy)
    {
    	if (proxy) {
    		/* p->label will not updated any more as p is dead */
    		aa_put_label(rcu_dereference_protected(proxy->label, true));
    		memset(proxy, 0, sizeof(*proxy));
    		proxy->label = (struct aa_label *) PROXY_POISON;
    		kfree(proxy);
    	}
    }
    
    void aa_proxy_kref(struct kref *kref)
    {
    	struct aa_proxy *proxy = container_of(kref, struct aa_proxy, count);
    
    	free_proxy(proxy);
    }
    
    struct aa_proxy *aa_alloc_proxy(struct aa_label *label, gfp_t gfp)
    {
    	struct aa_proxy *new;
    
    	new = kzalloc(sizeof(struct aa_proxy), gfp);
    	if (new) {
    		kref_init(&new->count);