mls.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * Updated: Hewlett-Packard <paul.moore@hp.com>
  15. *
  16. * Added support to import/export the MLS label
  17. *
  18. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  19. */
  20. #ifndef _SS_MLS_H_
  21. #define _SS_MLS_H_
  22. #include "context.h"
  23. #include "policydb.h"
  24. /*
  25. * Copies the MLS range from `src' into `dst'.
  26. */
  27. static inline int mls_copy_context(struct context *dst,
  28. struct context *src)
  29. {
  30. int l, rc = 0;
  31. /* Copy the MLS range from the source context */
  32. for (l = 0; l < 2; l++) {
  33. dst->range.level[l].sens = src->range.level[l].sens;
  34. rc = ebitmap_cpy(&dst->range.level[l].cat,
  35. &src->range.level[l].cat);
  36. if (rc)
  37. break;
  38. }
  39. return rc;
  40. }
  41. int mls_compute_context_len(struct context *context);
  42. void mls_sid_to_context(struct context *context, char **scontext);
  43. int mls_context_isvalid(struct policydb *p, struct context *c);
  44. int mls_context_to_sid(char oldc,
  45. char **scontext,
  46. struct context *context,
  47. struct sidtab *s,
  48. u32 def_sid);
  49. int mls_from_string(char *str, struct context *context, gfp_t gfp_mask);
  50. int mls_convert_context(struct policydb *oldp,
  51. struct policydb *newp,
  52. struct context *context);
  53. int mls_compute_sid(struct context *scontext,
  54. struct context *tcontext,
  55. u16 tclass,
  56. u32 specified,
  57. struct context *newcontext);
  58. int mls_setup_user_range(struct context *fromcon, struct user_datum *user,
  59. struct context *usercon);
  60. void mls_export_lvl(const struct context *context, u32 *low, u32 *high);
  61. void mls_import_lvl(struct context *context, u32 low, u32 high);
  62. int mls_export_cat(const struct context *context,
  63. unsigned char **low,
  64. size_t *low_len,
  65. unsigned char **high,
  66. size_t *high_len);
  67. int mls_import_cat(struct context *context,
  68. const unsigned char *low,
  69. size_t low_len,
  70. const unsigned char *high,
  71. size_t high_len);
  72. #endif /* _SS_MLS_H */