オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Diff of /branches/ccs-patch/security/ccsecurity/policy_io.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3692 by kumaneko, Sun May 23 07:27:24 2010 UTC revision 3693 by kumaneko, Sun May 23 08:05:44 2010 UTC
# Line 653  static void ccs_read_profile(struct ccs_ Line 653  static void ccs_read_profile(struct ccs_
653                  head->read_eof = true;                  head->read_eof = true;
654  }  }
655    
656  static bool ccs_is_same_manager_entry(const struct ccs_acl_head *a,  static bool ccs_same_manager_entry(const struct ccs_acl_head *a,
657                                        const struct ccs_acl_head *b)                                        const struct ccs_acl_head *b)
658  {  {
659          return container_of(a, struct ccs_policy_manager_entry, head)->manager          return container_of(a, struct ccs_manager, head)->manager
660                  == container_of(b, struct ccs_policy_manager_entry, head)                  == container_of(b, struct ccs_manager, head)->manager;
                 ->manager;  
661  }  }
662    
663  /**  /**
# Line 671  static bool ccs_is_same_manager_entry(co Line 670  static bool ccs_is_same_manager_entry(co
670   */   */
671  static int ccs_update_manager_entry(const char *manager, const bool is_delete)  static int ccs_update_manager_entry(const char *manager, const bool is_delete)
672  {  {
673          struct ccs_policy_manager_entry e = { };          struct ccs_manager e = { };
674          int error = is_delete ? -ENOENT : -ENOMEM;          int error = is_delete ? -ENOENT : -ENOMEM;
675          if (ccs_is_domain_def(manager)) {          if (ccs_domain_def(manager)) {
676                  if (!ccs_is_correct_domain(manager))                  if (!ccs_correct_domain(manager))
677                          return -EINVAL;                          return -EINVAL;
678                  e.is_domain = true;                  e.is_domain = true;
679          } else {          } else {
680                  if (!ccs_is_correct_path(manager, 1, -1, -1))                  if (!ccs_correct_path(manager, 1, -1, -1))
681                          return -EINVAL;                          return -EINVAL;
682          }          }
683          e.manager = ccs_get_name(manager);          e.manager = ccs_get_name(manager);
684          if (!e.manager)          if (!e.manager)
685                  return error;                  return error;
686          error = ccs_update_policy(&e.head, sizeof(e), is_delete,          error = ccs_update_policy(&e.head, sizeof(e), is_delete,
687                                    CCS_ID_MANAGER, ccs_is_same_manager_entry);                                    CCS_ID_MANAGER, ccs_same_manager_entry);
688          ccs_put_name(e.manager);          ccs_put_name(e.manager);
689          return error;          return error;
690  }  }
691    
692  /**  /**
693   * ccs_write_manager_policy - Write manager policy.   * ccs_write_manager - Write manager policy.
694   *   *
695   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
696   *   *
697   * Returns 0 on success, negative value otherwise.   * Returns 0 on success, negative value otherwise.
698   */   */
699  static int ccs_write_manager_policy(struct ccs_io_buffer *head)  static int ccs_write_manager(struct ccs_io_buffer *head)
700  {  {
701          char *data = head->write_buf;          char *data = head->write_buf;
702          bool is_delete = ccs_str_starts(&data, CCS_KEYWORD_DELETE);          bool is_delete = ccs_str_starts(&data, CCS_KEYWORD_DELETE);
# Line 709  static int ccs_write_manager_policy(stru Line 708  static int ccs_write_manager_policy(stru
708  }  }
709    
710  /**  /**
711   * ccs_read_manager_policy - Read manager policy.   * ccs_read_manager - Read manager policy.
712   *   *
713   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
714   *   *
715   * Caller holds ccs_read_lock().   * Caller holds ccs_read_lock().
716   */   */
717  static void ccs_read_manager_policy(struct ccs_io_buffer *head)  static void ccs_read_manager(struct ccs_io_buffer *head)
718  {  {
719          struct list_head *pos;          struct list_head *pos;
720          if (head->read_eof)          if (head->read_eof)
721                  return;                  return;
722          list_for_each_cookie(pos, head->read_var2,          list_for_each_cookie(pos, head->read_var2,
723                               &ccs_policy_list[CCS_ID_MANAGER]) {                               &ccs_policy_list[CCS_ID_MANAGER]) {
724                  struct ccs_policy_manager_entry *ptr;                  struct ccs_manager *ptr
725                  ptr = list_entry(pos, struct ccs_policy_manager_entry,                          = list_entry(pos, typeof(*ptr), head.list);
                                  head.list);  
726                  if (ptr->head.is_deleted)                  if (ptr->head.is_deleted)
727                          continue;                          continue;
728                  if (!ccs_io_printf(head, "%s\n", ptr->manager->name))                  if (!ccs_io_printf(head, "%s\n", ptr->manager->name))
# Line 734  static void ccs_read_manager_policy(stru Line 732  static void ccs_read_manager_policy(stru
732  }  }
733    
734  /**  /**
735   * ccs_is_policy_manager - Check whether the current process is a policy manager.   * ccs_manager - Check whether the current process is a policy manager.
736   *   *
737   * Returns true if the current process is permitted to modify policy   * Returns true if the current process is permitted to modify policy
738   * via /proc/ccs/ interface.   * via /proc/ccs/ interface.
739   *   *
740   * Caller holds ccs_read_lock().   * Caller holds ccs_read_lock().
741   */   */
742  static bool ccs_is_policy_manager(void)  static bool ccs_manager(void)
743  {  {
744          struct ccs_policy_manager_entry *ptr;          struct ccs_manager *ptr;
745          const char *exe;          const char *exe;
746          struct task_struct *task = current;          struct task_struct *task = current;
747          const struct ccs_path_info *domainname          const struct ccs_path_info *domainname
# Line 751  static bool ccs_is_policy_manager(void) Line 749  static bool ccs_is_policy_manager(void)
749          bool found = false;          bool found = false;
750          if (!ccs_policy_loaded)          if (!ccs_policy_loaded)
751                  return true;                  return true;
752          if (task->ccs_flags & CCS_TASK_IS_POLICY_MANAGER)          if (task->ccs_flags & CCS_TASK_IS_MANAGER)
753                  return true;                  return true;
754          if (!ccs_manage_by_non_root && (current_uid() || current_euid()))          if (!ccs_manage_by_non_root && (current_uid() || current_euid()))
755                  return false;                  return false;
# Line 760  static bool ccs_is_policy_manager(void) Line 758  static bool ccs_is_policy_manager(void)
758                  if (!ptr->head.is_deleted && ptr->is_domain                  if (!ptr->head.is_deleted && ptr->is_domain
759                      && !ccs_pathcmp(domainname, ptr->manager)) {                      && !ccs_pathcmp(domainname, ptr->manager)) {
760                          /* Set manager flag. */                          /* Set manager flag. */
761                          task->ccs_flags |= CCS_TASK_IS_POLICY_MANAGER;                          task->ccs_flags |= CCS_TASK_IS_MANAGER;
762                          return true;                          return true;
763                  }                  }
764          }          }
# Line 773  static bool ccs_is_policy_manager(void) Line 771  static bool ccs_is_policy_manager(void)
771                      && !strcmp(exe, ptr->manager->name)) {                      && !strcmp(exe, ptr->manager->name)) {
772                          found = true;                          found = true;
773                          /* Set manager flag. */                          /* Set manager flag. */
774                          task->ccs_flags |= CCS_TASK_IS_POLICY_MANAGER;                          task->ccs_flags |= CCS_TASK_IS_MANAGER;
775                          break;                          break;
776                  }                  }
777          }          }
# Line 818  static char *ccs_find_condition_part(cha Line 816  static char *ccs_find_condition_part(cha
816  }  }
817    
818  /**  /**
819   * ccs_is_select_one - Parse select command.   * ccs_select_one - Parse select command.
820   *   *
821   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
822   * @data: String to parse.   * @data: String to parse.
# Line 827  static char *ccs_find_condition_part(cha Line 825  static char *ccs_find_condition_part(cha
825   *   *
826   * Caller holds ccs_read_lock().   * Caller holds ccs_read_lock().
827   */   */
828  static bool ccs_is_select_one(struct ccs_io_buffer *head, const char *data)  static bool ccs_select_one(struct ccs_io_buffer *head, const char *data)
829  {  {
830          unsigned int pid;          unsigned int pid;
831          struct ccs_domain_info *domain = NULL;          struct ccs_domain_info *domain = NULL;
# Line 853  static bool ccs_is_select_one(struct ccs Line 851  static bool ccs_is_select_one(struct ccs
851                          domain = ccs_task_domain(p);                          domain = ccs_task_domain(p);
852                  ccs_tasklist_unlock();                  ccs_tasklist_unlock();
853          } else if (!strncmp(data, "domain=", 7)) {          } else if (!strncmp(data, "domain=", 7)) {
854                  if (ccs_is_domain_def(data + 7))                  if (ccs_domain_def(data + 7))
855                          domain = ccs_find_domain(data + 7);                          domain = ccs_find_domain(data + 7);
856          } else          } else
857                  return false;                  return false;
# Line 882  static bool ccs_is_select_one(struct ccs Line 880  static bool ccs_is_select_one(struct ccs
880          return true;          return true;
881  }  }
882    
883  static int ccs_write_domain_policy2(char *data, struct ccs_domain_info *domain,  static int ccs_write_domain2(char *data, struct ccs_domain_info *domain,
884                                      struct ccs_condition *cond,                               struct ccs_condition *cond, const bool is_delete)
                                     const bool is_delete)  
885  {  {
886          u8 i;          u8 i;
887          static const struct {          static const struct {
# Line 892  static int ccs_write_domain_policy2(char Line 889  static int ccs_write_domain_policy2(char
889                  int (*write) (char *, struct ccs_domain_info *,                  int (*write) (char *, struct ccs_domain_info *,
890                                struct ccs_condition *, const bool);                                struct ccs_condition *, const bool);
891          } ccs_callback[5] = {          } ccs_callback[5] = {
892                  { CCS_KEYWORD_ALLOW_NETWORK, ccs_write_network_policy },                  { CCS_KEYWORD_ALLOW_NETWORK, ccs_write_network },
893                  { CCS_KEYWORD_ALLOW_ENV, ccs_write_env_policy },                  { CCS_KEYWORD_ALLOW_ENV, ccs_write_env },
894                  { CCS_KEYWORD_ALLOW_CAPABILITY, ccs_write_capability_policy },                  { CCS_KEYWORD_ALLOW_CAPABILITY, ccs_write_capability },
895                  { CCS_KEYWORD_ALLOW_SIGNAL, ccs_write_signal_policy },                  { CCS_KEYWORD_ALLOW_SIGNAL, ccs_write_signal },
896                  { CCS_KEYWORD_ALLOW_MOUNT, ccs_write_mount_policy }                  { CCS_KEYWORD_ALLOW_MOUNT, ccs_write_mount }
897          };          };
898          int (*write) (char *, struct ccs_domain_info *,          int (*write) (char *, struct ccs_domain_info *, struct ccs_condition *,
899                       struct ccs_condition *, const bool) =                        const bool) = ccs_write_file;
                 ccs_write_file_policy;  
900          for (i = 0; i < 5; i++) {          for (i = 0; i < 5; i++) {
901                  if (!ccs_str_starts(&data, ccs_callback[i].keyword))                  if (!ccs_str_starts(&data, ccs_callback[i].keyword))
902                          continue;                          continue;
# Line 911  static int ccs_write_domain_policy2(char Line 907  static int ccs_write_domain_policy2(char
907  }  }
908    
909  /**  /**
910   * ccs_write_domain_policy - Write domain policy.   * ccs_write_domain - Write domain policy.
911   *   *
912   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
913   *   *
914   * Returns 0 on success, negative value otherwise.   * Returns 0 on success, negative value otherwise.
915   */   */
916  static int ccs_write_domain_policy(struct ccs_io_buffer *head)  static int ccs_write_domain(struct ccs_io_buffer *head)
917  {  {
918          char *data = head->write_buf;          char *data = head->write_buf;
919          struct ccs_domain_info *domain = head->write_var1;          struct ccs_domain_info *domain = head->write_var1;
# Line 931  static int ccs_write_domain_policy(struc Line 927  static int ccs_write_domain_policy(struc
927                  is_delete = true;                  is_delete = true;
928          else if (ccs_str_starts(&data, CCS_KEYWORD_SELECT))          else if (ccs_str_starts(&data, CCS_KEYWORD_SELECT))
929                  is_select = true;                  is_select = true;
930          if (is_select && ccs_is_select_one(head, data))          if (is_select && ccs_select_one(head, data))
931                  return 0;                  return 0;
932          /* Don't allow updating policies by non manager programs. */          /* Don't allow updating policies by non manager programs. */
933          if (!ccs_is_policy_manager())          if (!ccs_manager())
934                  return -EPERM;                  return -EPERM;
935          if (ccs_is_domain_def(data)) {          if (ccs_domain_def(data)) {
936                  domain = NULL;                  domain = NULL;
937                  if (is_delete)                  if (is_delete)
938                          ccs_delete_domain(data);                          ccs_delete_domain(data);
# Line 978  static int ccs_write_domain_policy(struc Line 974  static int ccs_write_domain_policy(struc
974                  if (!cond)                  if (!cond)
975                          return -EINVAL;                          return -EINVAL;
976          }          }
977          error = ccs_write_domain_policy2(data, domain, cond, is_delete);          error = ccs_write_domain2(data, domain, cond, is_delete);
978          if (cond)          if (cond)
979                  ccs_put_condition(cond);                  ccs_put_condition(cond);
980          return error;          return error;
# Line 1120  static bool ccs_print_condition(struct c Line 1116  static bool ccs_print_condition(struct c
1116          const struct ccs_condition_element *condp;          const struct ccs_condition_element *condp;
1117          const struct ccs_number_union *numbers_p;          const struct ccs_number_union *numbers_p;
1118          const struct ccs_name_union *names_p;          const struct ccs_name_union *names_p;
1119          const struct ccs_argv_entry *argv;          const struct ccs_argv *argv;
1120          const struct ccs_envp_entry *envp;          const struct ccs_envp *envp;
1121          u16 condc;          u16 condc;
1122          u16 i;          u16 i;
1123          u16 j;          u16 j;
# Line 1133  static bool ccs_print_condition(struct c Line 1129  static bool ccs_print_condition(struct c
1129          numbers_p = (const struct ccs_number_union *) (condp + condc);          numbers_p = (const struct ccs_number_union *) (condp + condc);
1130          names_p = (const struct ccs_name_union *)          names_p = (const struct ccs_name_union *)
1131                  (numbers_p + cond->numbers_count);                  (numbers_p + cond->numbers_count);
1132          argv = (const struct ccs_argv_entry *) (names_p + cond->names_count);          argv = (const struct ccs_argv *) (names_p + cond->names_count);
1133          envp = (const struct ccs_envp_entry *) (argv + cond->argc);          envp = (const struct ccs_envp *) (argv + cond->argc);
1134          memset(buffer, 0, sizeof(buffer));          memset(buffer, 0, sizeof(buffer));
1135          if (condc && !ccs_io_printf(head, "%s", " if"))          if (condc && !ccs_io_printf(head, "%s", " if"))
1136                  goto out;                  goto out;
# Line 1606  static bool ccs_print_entry(struct ccs_i Line 1602  static bool ccs_print_entry(struct ccs_i
1602  }  }
1603    
1604  /**  /**
1605   * ccs_read_domain_policy - Read domain policy.   * ccs_read_domain - Read domain policy.
1606   *   *
1607   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
1608   *   *
1609   * Caller holds ccs_read_lock().   * Caller holds ccs_read_lock().
1610   */   */
1611  static void ccs_read_domain_policy(struct ccs_io_buffer *head)  static void ccs_read_domain(struct ccs_io_buffer *head)
1612  {  {
1613          struct list_head *dpos;          struct list_head *dpos;
1614          struct list_head *apos;          struct list_head *apos;
# Line 1804  static void ccs_read_pid(struct ccs_io_b Line 1800  static void ccs_read_pid(struct ccs_io_b
1800                  ccs_io_printf(head, "%u manager=%s execute_handler=%s "                  ccs_io_printf(head, "%u manager=%s execute_handler=%s "
1801                                "state[0]=%u state[1]=%u state[2]=%u", pid,                                "state[0]=%u state[1]=%u state[2]=%u", pid,
1802                                ccs_yesno(ccs_flags &                                ccs_yesno(ccs_flags &
1803                                          CCS_TASK_IS_POLICY_MANAGER),                                          CCS_TASK_IS_MANAGER),
1804                                ccs_yesno(ccs_flags &                                ccs_yesno(ccs_flags &
1805                                          CCS_TASK_IS_EXECUTE_HANDLER),                                          CCS_TASK_IS_EXECUTE_HANDLER),
1806                                (u8) (ccs_flags >> 24),                                (u8) (ccs_flags >> 24),
# Line 1813  static void ccs_read_pid(struct ccs_io_b Line 1809  static void ccs_read_pid(struct ccs_io_b
1809  }  }
1810    
1811  /**  /**
1812   * ccs_write_exception_policy - Write exception policy.   * ccs_write_exception - Write exception policy.
1813   *   *
1814   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
1815   *   *
1816   * Returns 0 on success, negative value otherwise.   * Returns 0 on success, negative value otherwise.
1817   */   */
1818  static int ccs_write_exception_policy(struct ccs_io_buffer *head)  static int ccs_write_exception(struct ccs_io_buffer *head)
1819  {  {
1820          char *data = head->write_buf;          char *data = head->write_buf;
1821          const bool is_delete = ccs_str_starts(&data, CCS_KEYWORD_DELETE);          const bool is_delete = ccs_str_starts(&data, CCS_KEYWORD_DELETE);
# Line 1828  static int ccs_write_exception_policy(st Line 1824  static int ccs_write_exception_policy(st
1824                  const char *keyword;                  const char *keyword;
1825                  int (*write) (char *, const bool, const u8);                  int (*write) (char *, const bool, const u8);
1826          } ccs_callback[10] = {          } ccs_callback[10] = {
1827                  { CCS_KEYWORD_NO_KEEP_DOMAIN, ccs_write_domain_keeper_policy },                  { CCS_KEYWORD_NO_KEEP_DOMAIN, ccs_write_domain_keeper },
1828                  { CCS_KEYWORD_NO_INITIALIZE_DOMAIN,                  { CCS_KEYWORD_NO_INITIALIZE_DOMAIN,
1829                    ccs_write_domain_initializer_policy },                    ccs_write_domain_initializer },
1830                  { CCS_KEYWORD_KEEP_DOMAIN, ccs_write_domain_keeper_policy },                  { CCS_KEYWORD_KEEP_DOMAIN, ccs_write_domain_keeper },
1831                  { CCS_KEYWORD_INITIALIZE_DOMAIN,                  { CCS_KEYWORD_INITIALIZE_DOMAIN,
1832                    ccs_write_domain_initializer_policy },                    ccs_write_domain_initializer },
1833                  { CCS_KEYWORD_AGGREGATOR, ccs_write_aggregator_policy },                  { CCS_KEYWORD_AGGREGATOR, ccs_write_aggregator },
1834                  { CCS_KEYWORD_ALLOW_READ, ccs_write_globally_readable_policy },                  { CCS_KEYWORD_ALLOW_READ, ccs_write_global_read },
1835                  { CCS_KEYWORD_ALLOW_ENV,                  { CCS_KEYWORD_ALLOW_ENV, ccs_write_global_env },
1836                    ccs_write_globally_usable_env_policy },                  { CCS_KEYWORD_FILE_PATTERN, ccs_write_pattern },
1837                  { CCS_KEYWORD_FILE_PATTERN, ccs_write_pattern_policy },                  { CCS_KEYWORD_DENY_REWRITE, ccs_write_no_rewrite },
1838                  { CCS_KEYWORD_DENY_REWRITE, ccs_write_no_rewrite_policy },                  { CCS_KEYWORD_DENY_AUTOBIND, ccs_write_reserved_port }
                 { CCS_KEYWORD_DENY_AUTOBIND, ccs_write_reserved_port_policy }  
1839          };          };
1840          static const char *ccs_name[CCS_MAX_GROUP] = {          static const char *ccs_name[CCS_MAX_GROUP] = {
1841                  [CCS_PATH_GROUP] = CCS_KEYWORD_PATH_GROUP,                  [CCS_PATH_GROUP] = CCS_KEYWORD_PATH_GROUP,
# Line 1853  static int ccs_write_exception_policy(st Line 1848  static int ccs_write_exception_policy(st
1848          }          }
1849          for (i = 0; i < CCS_MAX_GROUP; i++) {          for (i = 0; i < CCS_MAX_GROUP; i++) {
1850                  if (ccs_str_starts(&data, ccs_name[i]))                  if (ccs_str_starts(&data, ccs_name[i]))
1851                          return ccs_write_group_policy(data, is_delete, i);                          return ccs_write_group(data, is_delete, i);
1852          }          }
1853          return -EINVAL;          return -EINVAL;
1854  }  }
# Line 1944  static bool ccs_read_policy(struct ccs_i Line 1939  static bool ccs_read_policy(struct ccs_i
1939                  switch (idx) {                  switch (idx) {
1940                  case CCS_ID_DOMAIN_KEEPER:                  case CCS_ID_DOMAIN_KEEPER:
1941                          {                          {
1942                                  struct ccs_domain_keeper_entry *ptr =                                  struct ccs_domain_keeper *ptr =
1943                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
1944                                  w[0] = ptr->is_not ?                                  w[0] = ptr->is_not ?
1945                                          CCS_KEYWORD_NO_KEEP_DOMAIN :                                          CCS_KEYWORD_NO_KEEP_DOMAIN :
# Line 1958  static bool ccs_read_policy(struct ccs_i Line 1953  static bool ccs_read_policy(struct ccs_i
1953                          break;                          break;
1954                  case CCS_ID_DOMAIN_INITIALIZER:                  case CCS_ID_DOMAIN_INITIALIZER:
1955                          {                          {
1956                                  struct ccs_domain_initializer_entry *ptr =                                  struct ccs_domain_initializer *ptr =
1957                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
1958                                  w[0] = ptr->is_not ?                                  w[0] = ptr->is_not ?
1959                                          CCS_KEYWORD_NO_INITIALIZE_DOMAIN :                                          CCS_KEYWORD_NO_INITIALIZE_DOMAIN :
# Line 1972  static bool ccs_read_policy(struct ccs_i Line 1967  static bool ccs_read_policy(struct ccs_i
1967                          break;                          break;
1968                  case CCS_ID_AGGREGATOR:                  case CCS_ID_AGGREGATOR:
1969                          {                          {
1970                                  struct ccs_aggregator_entry *ptr =                                  struct ccs_aggregator *ptr =
1971                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
1972                                  w[0] = CCS_KEYWORD_AGGREGATOR;                                  w[0] = CCS_KEYWORD_AGGREGATOR;
1973                                  w[1] = ptr->original_name->name;                                  w[1] = ptr->original_name->name;
# Line 1980  static bool ccs_read_policy(struct ccs_i Line 1975  static bool ccs_read_policy(struct ccs_i
1975                                  w[3] = ptr->aggregated_name->name;                                  w[3] = ptr->aggregated_name->name;
1976                          }                          }
1977                          break;                          break;
1978                  case CCS_ID_GLOBALLY_READABLE:                  case CCS_ID_GLOBAL_READ:
1979                          {                          {
1980                                  struct ccs_globally_readable_file_entry *ptr =                                  struct ccs_global_read *ptr =
1981                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
1982                                  w[0] = CCS_KEYWORD_ALLOW_READ;                                  w[0] = CCS_KEYWORD_ALLOW_READ;
1983                                  w[1] = ptr->filename->name;                                  w[1] = ptr->filename->name;
# Line 1990  static bool ccs_read_policy(struct ccs_i Line 1985  static bool ccs_read_policy(struct ccs_i
1985                          break;                          break;
1986                  case CCS_ID_PATTERN:                  case CCS_ID_PATTERN:
1987                          {                          {
1988                                  struct ccs_pattern_entry *ptr =                                  struct ccs_pattern *ptr =
1989                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
1990                                  w[0] = CCS_KEYWORD_FILE_PATTERN;                                  w[0] = CCS_KEYWORD_FILE_PATTERN;
1991                                  w[1] = ptr->pattern->name;                                  w[1] = ptr->pattern->name;
# Line 1998  static bool ccs_read_policy(struct ccs_i Line 1993  static bool ccs_read_policy(struct ccs_i
1993                          break;                          break;
1994                  case CCS_ID_NO_REWRITE:                  case CCS_ID_NO_REWRITE:
1995                          {                          {
1996                                  struct ccs_no_rewrite_entry *ptr =                                  struct ccs_no_rewrite *ptr =
1997                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
1998                                  w[0] = CCS_KEYWORD_DENY_REWRITE;                                  w[0] = CCS_KEYWORD_DENY_REWRITE;
1999                                  w[1] = ptr->pattern->name;                                  w[1] = ptr->pattern->name;
# Line 2006  static bool ccs_read_policy(struct ccs_i Line 2001  static bool ccs_read_policy(struct ccs_i
2001                          break;                          break;
2002                  case CCS_ID_GLOBAL_ENV:                  case CCS_ID_GLOBAL_ENV:
2003                          {                          {
2004                                  struct ccs_globally_usable_env_entry *ptr =                                  struct ccs_global_env *ptr =
2005                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
2006                                  w[0] = CCS_KEYWORD_ALLOW_ENV;                                  w[0] = CCS_KEYWORD_ALLOW_ENV;
2007                                  w[1] = ptr->env->name;                                  w[1] = ptr->env->name;
# Line 2014  static bool ccs_read_policy(struct ccs_i Line 2009  static bool ccs_read_policy(struct ccs_i
2009                          break;                          break;
2010                  case CCS_ID_RESERVEDPORT:                  case CCS_ID_RESERVEDPORT:
2011                          {                          {
2012                                  struct ccs_reserved_entry *ptr =                                  struct ccs_reserved *ptr =
2013                                          container_of(acl, typeof(*ptr), head);                                          container_of(acl, typeof(*ptr), head);
2014                                  const u16 min_port = ptr->min_port;                                  const u16 min_port = ptr->min_port;
2015                                  const u16 max_port = ptr->max_port;                                  const u16 max_port = ptr->max_port;
# Line 2034  static bool ccs_read_policy(struct ccs_i Line 2029  static bool ccs_read_policy(struct ccs_i
2029  }  }
2030    
2031  /**  /**
2032   * ccs_read_exception_policy - Read exception policy.   * ccs_read_exception - Read exception policy.
2033   *   *
2034   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
2035   *   *
2036   * Caller holds ccs_read_lock().   * Caller holds ccs_read_lock().
2037   */   */
2038  static void ccs_read_exception_policy(struct ccs_io_buffer *head)  static void ccs_read_exception(struct ccs_io_buffer *head)
2039  {  {
2040          if (head->read_eof)          if (head->read_eof)
2041                  return;                  return;
# Line 2058  static void ccs_read_exception_policy(st Line 2053  static void ccs_read_exception_policy(st
2053  /**  /**
2054   * ccs_get_argv0 - Get argv[0].   * ccs_get_argv0 - Get argv[0].
2055   *   *
2056   * @ee: Pointer to "struct ccs_execve_entry".   * @ee: Pointer to "struct ccs_execve".
2057   *   *
2058   * Returns true on success, false otherwise.   * Returns true on success, false otherwise.
2059   */   */
2060  static bool ccs_get_argv0(struct ccs_execve_entry *ee)  static bool ccs_get_argv0(struct ccs_execve *ee)
2061  {  {
2062          struct linux_binprm *bprm = ee->bprm;          struct linux_binprm *bprm = ee->bprm;
2063          char *arg_ptr = ee->tmp;          char *arg_ptr = ee->tmp;
# Line 2111  static bool ccs_get_argv0(struct ccs_exe Line 2106  static bool ccs_get_argv0(struct ccs_exe
2106  /**  /**
2107   * ccs_get_execute_condition - Get condition part for execute requests.   * ccs_get_execute_condition - Get condition part for execute requests.
2108   *   *
2109   * @ee: Pointer to "struct ccs_execve_entry".   * @ee: Pointer to "struct ccs_execve".
2110   *   *
2111   * Returns pointer to "struct ccs_condition" on success, NULL otherwise.   * Returns pointer to "struct ccs_condition" on success, NULL otherwise.
2112   */   */
2113  static struct ccs_condition *ccs_get_execute_condition(struct ccs_execve_entry  static struct ccs_condition *ccs_get_execute_condition(struct ccs_execve
2114                                                         *ee)                                                         *ee)
2115  {  {
2116          struct ccs_condition *cond;          struct ccs_condition *cond;
# Line 2276  int ccs_supervisor(struct ccs_request_in Line 2271  int ccs_supervisor(struct ccs_request_in
2271                          cond = ccs_get_condition(str);                          cond = ccs_get_condition(str);
2272                  } else                  } else
2273                          cond = NULL;                          cond = NULL;
2274                  ccs_write_domain_policy2(buffer, domain, cond, false);                  ccs_write_domain2(buffer, domain, cond, false);
2275                  ccs_put_condition(cond);                  ccs_put_condition(cond);
2276                  kfree(buffer);                  kfree(buffer);
2277                  /* fall through */                  /* fall through */
# Line 2551  int ccs_open_control(const u8 type, stru Line 2546  int ccs_open_control(const u8 type, stru
2546          head->type = type;          head->type = type;
2547          switch (type) {          switch (type) {
2548          case CCS_DOMAINPOLICY: /* /proc/ccs/domain_policy */          case CCS_DOMAINPOLICY: /* /proc/ccs/domain_policy */
2549                  head->write = ccs_write_domain_policy;                  head->write = ccs_write_domain;
2550                  head->read = ccs_read_domain_policy;                  head->read = ccs_read_domain;
2551                  break;                  break;
2552          case CCS_EXCEPTIONPOLICY: /* /proc/ccs/exception_policy */          case CCS_EXCEPTIONPOLICY: /* /proc/ccs/exception_policy */
2553                  head->write = ccs_write_exception_policy;                  head->write = ccs_write_exception;
2554                  head->read = ccs_read_exception_policy;                  head->read = ccs_read_exception;
2555                  break;                  break;
2556  #ifdef CONFIG_CCSECURITY_AUDIT  #ifdef CONFIG_CCSECURITY_AUDIT
2557          case CCS_GRANTLOG: /* /proc/ccs/grant_log */          case CCS_GRANTLOG: /* /proc/ccs/grant_log */
# Line 2602  int ccs_open_control(const u8 type, stru Line 2597  int ccs_open_control(const u8 type, stru
2597                  head->read = ccs_read_query;                  head->read = ccs_read_query;
2598                  break;                  break;
2599          case CCS_MANAGER: /* /proc/ccs/manager */          case CCS_MANAGER: /* /proc/ccs/manager */
2600                  head->write = ccs_write_manager_policy;                  head->write = ccs_write_manager;
2601                  head->read = ccs_read_manager_policy;                  head->read = ccs_read_manager;
2602                  break;                  break;
2603          }          }
2604          if (!(file->f_mode & FMODE_READ)) {          if (!(file->f_mode & FMODE_READ)) {
# Line 2761  int ccs_write_control(struct file *file, Line 2756  int ccs_write_control(struct file *file,
2756                  return -EINTR;                  return -EINTR;
2757          idx = ccs_read_lock();          idx = ccs_read_lock();
2758          /* Don't allow updating policies by non manager programs. */          /* Don't allow updating policies by non manager programs. */
2759          if (head->write != ccs_write_pid &&          if (head->write != ccs_write_pid && head->write != ccs_write_domain &&
2760              head->write != ccs_write_domain_policy &&              !ccs_manager()) {
             !ccs_is_policy_manager()) {  
2761                  ccs_read_unlock(idx);                  ccs_read_unlock(idx);
2762                  mutex_unlock(&head->io_sem);                  mutex_unlock(&head->io_sem);
2763                  return -EPERM;                  return -EPERM;

Legend:
Removed from v.3692  
changed lines
  Added in v.3693

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26