mls.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Multi-level security (MLS) policy operations.
  4. *
  5. * Author : Stephen Smalley, <sds@tycho.nsa.gov>
  6. */
  7. /*
  8. * Updated: Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
  9. *
  10. * Support for enhanced MLS infrastructure.
  11. *
  12. * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc.
  13. */
  14. /*
  15. * Updated: Hewlett-Packard <paul@paul-moore.com>
  16. *
  17. * Added support to import/export the MLS label from NetLabel
  18. *
  19. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  20. */
  21. #ifndef _SS_MLS_H_
  22. #define _SS_MLS_H_
  23. #include "context.h"
  24. #include "policydb.h"
  25. int mls_compute_context_len(struct policydb *p, struct context *context);
  26. void mls_sid_to_context(struct policydb *p, struct context *context,
  27. char **scontext);
  28. int mls_context_isvalid(struct policydb *p, struct context *c);
  29. int mls_range_isvalid(struct policydb *p, struct mls_range *r);
  30. int mls_level_isvalid(struct policydb *p, struct mls_level *l);
  31. int mls_context_to_sid(struct policydb *p,
  32. char oldc,
  33. char *scontext,
  34. struct context *context,
  35. struct sidtab *s,
  36. u32 def_sid);
  37. int mls_from_string(struct policydb *p, char *str, struct context *context,
  38. gfp_t gfp_mask);
  39. int mls_range_set(struct context *context, struct mls_range *range);
  40. int mls_convert_context(struct policydb *oldp,
  41. struct policydb *newp,
  42. struct context *oldc,
  43. struct context *newc);
  44. int mls_compute_sid(struct policydb *p,
  45. struct context *scontext,
  46. struct context *tcontext,
  47. u16 tclass,
  48. u32 specified,
  49. struct context *newcontext,
  50. bool sock);
  51. int mls_setup_user_range(struct policydb *p,
  52. struct context *fromcon, struct user_datum *user,
  53. struct context *usercon);
  54. #ifdef CONFIG_NETLABEL
  55. void mls_export_netlbl_lvl(struct policydb *p,
  56. struct context *context,
  57. struct netlbl_lsm_secattr *secattr);
  58. void mls_import_netlbl_lvl(struct policydb *p,
  59. struct context *context,
  60. struct netlbl_lsm_secattr *secattr);
  61. int mls_export_netlbl_cat(struct policydb *p,
  62. struct context *context,
  63. struct netlbl_lsm_secattr *secattr);
  64. int mls_import_netlbl_cat(struct policydb *p,
  65. struct context *context,
  66. struct netlbl_lsm_secattr *secattr);
  67. #else
  68. static inline void mls_export_netlbl_lvl(struct policydb *p,
  69. struct context *context,
  70. struct netlbl_lsm_secattr *secattr)
  71. {
  72. return;
  73. }
  74. static inline void mls_import_netlbl_lvl(struct policydb *p,
  75. struct context *context,
  76. struct netlbl_lsm_secattr *secattr)
  77. {
  78. return;
  79. }
  80. static inline int mls_export_netlbl_cat(struct policydb *p,
  81. struct context *context,
  82. struct netlbl_lsm_secattr *secattr)
  83. {
  84. return -ENOMEM;
  85. }
  86. static inline int mls_import_netlbl_cat(struct policydb *p,
  87. struct context *context,
  88. struct netlbl_lsm_secattr *secattr)
  89. {
  90. return -ENOMEM;
  91. }
  92. #endif
  93. #endif /* _SS_MLS_H */