mls.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 from NetLabel
  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. #ifdef CONFIG_NETLABEL
  61. void mls_export_netlbl_lvl(struct context *context,
  62. struct netlbl_lsm_secattr *secattr);
  63. void mls_import_netlbl_lvl(struct context *context,
  64. struct netlbl_lsm_secattr *secattr);
  65. int mls_export_netlbl_cat(struct context *context,
  66. struct netlbl_lsm_secattr *secattr);
  67. int mls_import_netlbl_cat(struct context *context,
  68. struct netlbl_lsm_secattr *secattr);
  69. #else
  70. static inline void mls_export_netlbl_lvl(struct context *context,
  71. struct netlbl_lsm_secattr *secattr)
  72. {
  73. return;
  74. }
  75. static inline void mls_import_netlbl_lvl(struct context *context,
  76. struct netlbl_lsm_secattr *secattr)
  77. {
  78. return;
  79. }
  80. static inline int mls_export_netlbl_cat(struct context *context,
  81. struct netlbl_lsm_secattr *secattr)
  82. {
  83. return -ENOMEM;
  84. }
  85. static inline int mls_import_netlbl_cat(struct context *context,
  86. struct netlbl_lsm_secattr *secattr)
  87. {
  88. return -ENOMEM;
  89. }
  90. #endif
  91. #endif /* _SS_MLS_H */