[MLSXFRM]: Define new SELinux service routine
[safe/jmp/linux-2.6] / security / selinux / ss / mls.h
1 /*
2  * Multi-level security (MLS) policy operations.
3  *
4  * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
5  */
6 /*
7  * Updated: Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
8  *
9  *      Support for enhanced MLS infrastructure.
10  *
11  * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc.
12  */
13
14 #ifndef _SS_MLS_H_
15 #define _SS_MLS_H_
16
17 #include "context.h"
18 #include "policydb.h"
19
20 /*
21  * Copies the MLS range from `src' into `dst'.
22  */
23 static inline int mls_copy_context(struct context *dst,
24                                    struct context *src)
25 {
26         int l, rc = 0;
27
28         /* Copy the MLS range from the source context */
29         for (l = 0; l < 2; l++) {
30                 dst->range.level[l].sens = src->range.level[l].sens;
31                 rc = ebitmap_cpy(&dst->range.level[l].cat,
32                                  &src->range.level[l].cat);
33                 if (rc)
34                         break;
35         }
36
37         return rc;
38 }
39
40 int mls_compute_context_len(struct context *context);
41 void mls_sid_to_context(struct context *context, char **scontext);
42 int mls_context_isvalid(struct policydb *p, struct context *c);
43
44 int mls_context_to_sid(char oldc,
45                        char **scontext,
46                        struct context *context,
47                        struct sidtab *s,
48                        u32 def_sid);
49
50 int mls_from_string(char *str, struct context *context, gfp_t gfp_mask);
51
52 int mls_convert_context(struct policydb *oldp,
53                         struct policydb *newp,
54                         struct context *context);
55
56 int mls_compute_sid(struct context *scontext,
57                     struct context *tcontext,
58                     u16 tclass,
59                     u32 specified,
60                     struct context *newcontext);
61
62 int mls_setup_user_range(struct context *fromcon, struct user_datum *user,
63                          struct context *usercon);
64
65 #endif  /* _SS_MLS_H */
66