LCOV - code coverage report
Current view: top level - security/apparmor/include - task.h (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 0 20 0.0 %
Date: 2020-09-30 20:25:40 Functions: 0 3 0.0 %
Branches: 0 2 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0-only */
       2                 :            : /*
       3                 :            :  * AppArmor security module
       4                 :            :  *
       5                 :            :  * This file contains AppArmor task related definitions and mediation
       6                 :            :  *
       7                 :            :  * Copyright 2017 Canonical Ltd.
       8                 :            :  */
       9                 :            : 
      10                 :            : #ifndef __AA_TASK_H
      11                 :            : #define __AA_TASK_H
      12                 :            : 
      13                 :            : static inline struct aa_task_ctx *task_ctx(struct task_struct *task)
      14                 :            : {
      15                 :          0 :         return task->security + apparmor_blob_sizes.lbs_task;
      16                 :            : }
      17                 :            : 
      18                 :            : /*
      19                 :            :  * struct aa_task_ctx - information for current task label change
      20                 :            :  * @nnp: snapshot of label at time of no_new_privs
      21                 :            :  * @onexec: profile to transition to on next exec  (MAY BE NULL)
      22                 :            :  * @previous: profile the task may return to     (MAY BE NULL)
      23                 :            :  * @token: magic value the task must know for returning to @previous_profile
      24                 :            :  */
      25                 :            : struct aa_task_ctx {
      26                 :            :         struct aa_label *nnp;
      27                 :            :         struct aa_label *onexec;
      28                 :            :         struct aa_label *previous;
      29                 :            :         u64 token;
      30                 :            : };
      31                 :            : 
      32                 :            : int aa_replace_current_label(struct aa_label *label);
      33                 :            : int aa_set_current_onexec(struct aa_label *label, bool stack);
      34                 :            : int aa_set_current_hat(struct aa_label *label, u64 token);
      35                 :            : int aa_restore_previous_label(u64 cookie);
      36                 :            : struct aa_label *aa_get_task_label(struct task_struct *task);
      37                 :            : 
      38                 :            : /**
      39                 :            :  * aa_free_task_ctx - free a task_ctx
      40                 :            :  * @ctx: task_ctx to free (MAYBE NULL)
      41                 :            :  */
      42                 :          0 : static inline void aa_free_task_ctx(struct aa_task_ctx *ctx)
      43                 :            : {
      44         [ #  # ]:          0 :         if (ctx) {
      45                 :          0 :                 aa_put_label(ctx->nnp);
      46                 :          0 :                 aa_put_label(ctx->previous);
      47                 :          0 :                 aa_put_label(ctx->onexec);
      48                 :            :         }
      49                 :          0 : }
      50                 :            : 
      51                 :            : /**
      52                 :            :  * aa_dup_task_ctx - duplicate a task context, incrementing reference counts
      53                 :            :  * @new: a blank task context      (NOT NULL)
      54                 :            :  * @old: the task context to copy  (NOT NULL)
      55                 :            :  */
      56                 :          0 : static inline void aa_dup_task_ctx(struct aa_task_ctx *new,
      57                 :            :                                    const struct aa_task_ctx *old)
      58                 :            : {
      59                 :          0 :         *new = *old;
      60                 :          0 :         aa_get_label(new->nnp);
      61                 :          0 :         aa_get_label(new->previous);
      62                 :          0 :         aa_get_label(new->onexec);
      63                 :          0 : }
      64                 :            : 
      65                 :            : /**
      66                 :            :  * aa_clear_task_ctx_trans - clear transition tracking info from the ctx
      67                 :            :  * @ctx: task context to clear (NOT NULL)
      68                 :            :  */
      69                 :          0 : static inline void aa_clear_task_ctx_trans(struct aa_task_ctx *ctx)
      70                 :            : {
      71                 :            :         AA_BUG(!ctx);
      72                 :            : 
      73                 :          0 :         aa_put_label(ctx->previous);
      74                 :          0 :         aa_put_label(ctx->onexec);
      75                 :          0 :         ctx->previous = NULL;
      76                 :          0 :         ctx->onexec = NULL;
      77                 :          0 :         ctx->token = 0;
      78                 :          0 : }
      79                 :            : 
      80                 :            : #endif /* __AA_TASK_H */

Generated by: LCOV version 1.14