mls.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 *context);
  43. int mls_compute_sid(struct policydb *p,
  44. struct context *scontext,
  45. struct context *tcontext,
  46. u16 tclass,
  47. u32 specified,
  48. struct context *newcontext,
  49. bool sock);
  50. int mls_setup_user_range(struct policydb *p,
  51. struct context *fromcon, struct user_datum *user,
  52. struct context *usercon);
  53. #ifdef CONFIG_NETLABEL
  54. void mls_export_netlbl_lvl(struct policydb *p,
  55. struct context *context,
  56. struct netlbl_lsm_secattr *secattr);
  57. void mls_import_netlbl_lvl(struct policydb *p,
  58. struct context *context,
  59. struct netlbl_lsm_secattr *secattr);
  60. int mls_export_netlbl_cat(struct policydb *p,
  61. struct context *context,
  62. struct netlbl_lsm_secattr *secattr);
  63. int mls_import_netlbl_cat(struct policydb *p,
  64. struct context *context,
  65. struct netlbl_lsm_secattr *secattr);
  66. #else
  67. static inline void mls_export_netlbl_lvl(struct policydb *p,
  68. struct context *context,
  69. struct netlbl_lsm_secattr *secattr)
  70. {
  71. return;
  72. }
  73. static inline void mls_import_netlbl_lvl(struct policydb *p,
  74. struct context *context,
  75. struct netlbl_lsm_secattr *secattr)
  76. {
  77. return;
  78. }
  79. static inline int mls_export_netlbl_cat(struct policydb *p,
  80. struct context *context,
  81. struct netlbl_lsm_secattr *secattr)
  82. {
  83. return -ENOMEM;
  84. }
  85. static inline int mls_import_netlbl_cat(struct policydb *p,
  86. struct context *context,
  87. struct netlbl_lsm_secattr *secattr)
  88. {
  89. return -ENOMEM;
  90. }
  91. #endif
  92. #endif /* _SS_MLS_H */