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

Subversion リポジトリの参照

Diff of /trunk/1.8.x/ccs-patch/security/ccsecurity/policy_io.c

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

revision 3167 by kumaneko, Tue Nov 10 11:55:04 2009 UTC revision 3528 by kumaneko, Wed Mar 24 02:13:40 2010 UTC
# Line 1  Line 1 
1  /*  /*
2   * security/ccsecurity/policy_io.c   * security/ccsecurity/policy_io.c
3   *   *
4   * Copyright (C) 2005-2009  NTT DATA CORPORATION   * Copyright (C) 2005-2010  NTT DATA CORPORATION
5   *   *
6   * Version: 1.7.1   2009/11/11   * Version: 1.7.2-pre   2010/03/21
7   *   *
8   * This file is applicable to both 2.4.30 and 2.6.11 and later.   * This file is applicable to both 2.4.30 and 2.6.11 and later.
9   * See README.ccs for ChangeLog.   * See README.ccs for ChangeLog.
# Line 94  static const char *ccs_mac_keywords[CCS_ Line 94  static const char *ccs_mac_keywords[CCS_
94          = "file::umount",          = "file::umount",
95          [CCS_MAC_FILE_PIVOT_ROOT]          [CCS_MAC_FILE_PIVOT_ROOT]
96          = "file::pivot_root",          = "file::pivot_root",
97            [CCS_MAC_FILE_TRANSIT]
98            = "file::transit",
99          [CCS_MAC_ENVIRON]          [CCS_MAC_ENVIRON]
100          = "misc::env",          = "misc::env",
101          [CCS_MAC_NETWORK_UDP_BIND]          [CCS_MAC_NETWORK_UDP_BIND]
# Line 260  static struct ccs_profile *ccs_find_or_a Line 262  static struct ccs_profile *ccs_find_or_a
262          ptr = ccs_profile_ptr[profile];          ptr = ccs_profile_ptr[profile];
263          if (ptr)          if (ptr)
264                  return ptr;                  return ptr;
265          entry = kzalloc(sizeof(*entry), GFP_KERNEL);          entry = kzalloc(sizeof(*entry), CCS_GFP_FLAGS);
266          mutex_lock(&ccs_policy_lock);          mutex_lock(&ccs_policy_lock);
267          ptr = ccs_profile_ptr[profile];          ptr = ccs_profile_ptr[profile];
268          if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) {          if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) {
# Line 285  static struct ccs_profile *ccs_find_or_a Line 287  static struct ccs_profile *ccs_find_or_a
287  /**  /**
288   * ccs_check_profile - Check all profiles currently assigned to domains are defined.   * ccs_check_profile - Check all profiles currently assigned to domains are defined.
289   */   */
290  void ccs_check_profile(void)  static void ccs_check_profile(void)
291  {  {
292          struct ccs_domain_info *domain;          struct ccs_domain_info *domain;
293          ccs_policy_loaded = true;          ccs_policy_loaded = true;
# Line 299  void ccs_check_profile(void) Line 301  void ccs_check_profile(void)
301          if (ccs_profile_version != 20090903)          if (ccs_profile_version != 20090903)
302                  panic("Profile version %u is not supported.\n",                  panic("Profile version %u is not supported.\n",
303                        ccs_profile_version);                        ccs_profile_version);
304            printk(KERN_INFO "CCSecurity: 1.7.2-pre   2010/03/21\n");
305            printk(KERN_INFO "Mandatory Access Control activated.\n");
306  }  }
307    
308  /**  /**
# Line 665  LIST_HEAD(ccs_policy_manager_list); Line 669  LIST_HEAD(ccs_policy_manager_list);
669   */   */
670  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)
671  {  {
         struct ccs_policy_manager_entry *entry = NULL;  
672          struct ccs_policy_manager_entry *ptr;          struct ccs_policy_manager_entry *ptr;
673          struct ccs_policy_manager_entry e = { };          struct ccs_policy_manager_entry e = { };
674          int error = is_delete ? -ENOENT : -ENOMEM;          int error = is_delete ? -ENOENT : -ENOMEM;
# Line 680  static int ccs_update_manager_entry(cons Line 683  static int ccs_update_manager_entry(cons
683          e.manager = ccs_get_name(manager);          e.manager = ccs_get_name(manager);
684          if (!e.manager)          if (!e.manager)
685                  return -ENOMEM;                  return -ENOMEM;
         if (!is_delete)  
                 entry = kmalloc(sizeof(e), GFP_KERNEL);  
686          mutex_lock(&ccs_policy_lock);          mutex_lock(&ccs_policy_lock);
687          list_for_each_entry_rcu(ptr, &ccs_policy_manager_list, list) {          list_for_each_entry_rcu(ptr, &ccs_policy_manager_list, list) {
688                  if (ptr->manager != e.manager)                  if (ptr->manager != e.manager)
# Line 690  static int ccs_update_manager_entry(cons Line 691  static int ccs_update_manager_entry(cons
691                  error = 0;                  error = 0;
692                  break;                  break;
693          }          }
694          if (!is_delete && error && ccs_commit_ok(entry, &e, sizeof(e))) {          if (!is_delete && error) {
695                  list_add_tail_rcu(&entry->list, &ccs_policy_manager_list);                  struct ccs_policy_manager_entry *entry =
696                  entry = NULL;                          ccs_commit_ok(&e, sizeof(e));
697                  error = 0;                  if (entry) {
698                            list_add_tail_rcu(&entry->list,
699                                              &ccs_policy_manager_list);
700                            error = 0;
701                    }
702          }          }
703          mutex_unlock(&ccs_policy_lock);          mutex_unlock(&ccs_policy_lock);
704          ccs_put_name(e.manager);          ccs_put_name(e.manager);
         kfree(entry);  
705          return error;          return error;
706  }  }
707    
# Line 846  static bool ccs_is_select_one(struct ccs Line 850  static bool ccs_is_select_one(struct ccs
850          if (sscanf(data, "pid=%u", &pid) == 1 ||          if (sscanf(data, "pid=%u", &pid) == 1 ||
851              (global_pid = true, sscanf(data, "global-pid=%u", &pid) == 1)) {              (global_pid = true, sscanf(data, "global-pid=%u", &pid) == 1)) {
852                  struct task_struct *p;                  struct task_struct *p;
853                  read_lock(&tasklist_lock);                  ccs_tasklist_lock();
854  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
855                  if (global_pid)                  if (global_pid)
856                          p = find_task_by_pid_ns(pid, &init_pid_ns);                          p = ccsecurity_exports.find_task_by_pid_ns(pid,
857                                                                   &init_pid_ns);
858                  else                  else
859                          p = find_task_by_vpid(pid);                          p = ccsecurity_exports.find_task_by_vpid(pid);
860  #else  #else
861                  p = find_task_by_pid(pid);                  p = find_task_by_pid(pid);
862  #endif  #endif
863                  if (p)                  if (p)
864                          domain = ccs_task_domain(p);                          domain = ccs_task_domain(p);
865                  read_unlock(&tasklist_lock);                  ccs_tasklist_unlock();
866          } else if (!strncmp(data, "domain=", 7)) {          } else if (!strncmp(data, "domain=", 7)) {
867                  if (ccs_is_domain_def(data + 7))                  if (ccs_is_domain_def(data + 7))
868                          domain = ccs_find_domain(data + 7);                          domain = ccs_find_domain(data + 7);
# Line 960  static int ccs_write_domain_policy(struc Line 965  static int ccs_write_domain_policy(struc
965                  domain->ignore_global_allow_env = !is_delete;                  domain->ignore_global_allow_env = !is_delete;
966                  return 0;                  return 0;
967          }          }
968            if (!strcmp(data, CCS_KEYWORD_QUOTA_EXCEEDED)) {
969                    domain->quota_warned = !is_delete;
970                    return 0;
971            }
972            if (!strcmp(data, CCS_KEYWORD_TRANSITION_FAILED)) {
973                    domain->domain_transition_failed = !is_delete;
974                    return 0;
975            }
976          cp = ccs_find_condition_part(data);          cp = ccs_find_condition_part(data);
977          if (cp) {          if (cp) {
978                  cond = ccs_get_condition(cp);                  cond = ccs_get_condition(cp);
# Line 1219  static bool ccs_print_path_acl(struct cc Line 1232  static bool ccs_print_path_acl(struct cc
1232          for (bit = head->read_bit; bit < CCS_MAX_PATH_OPERATION; bit++) {          for (bit = head->read_bit; bit < CCS_MAX_PATH_OPERATION; bit++) {
1233                  if (!(perm & (1 << bit)))                  if (!(perm & (1 << bit)))
1234                          continue;                          continue;
1235                  if (head->read_execute_only && bit != CCS_TYPE_EXECUTE)                  if (head->read_execute_only && bit != CCS_TYPE_EXECUTE
1236                        && bit != CCS_TYPE_TRANSIT)
1237                          continue;                          continue;
1238                  /* Print "read/write" instead of "read" and "write". */                  /* Print "read/write" instead of "read" and "write". */
1239                  if ((bit == CCS_TYPE_READ || bit == CCS_TYPE_WRITE)                  if ((bit == CCS_TYPE_READ || bit == CCS_TYPE_WRITE)
# Line 1659  static void ccs_read_domain_policy(struc Line 1673  static void ccs_read_domain_policy(struc
1673                          continue;                          continue;
1674                  /* Print domainname and flags. */                  /* Print domainname and flags. */
1675                  if (domain->quota_warned)                  if (domain->quota_warned)
1676                          quota_exceeded = "quota_exceeded\n";                          quota_exceeded = CCS_KEYWORD_QUOTA_EXCEEDED "\n";
1677                  if (domain->domain_transition_failed)                  if (domain->domain_transition_failed)
1678                          transition_failed = "transition_failed\n";                          transition_failed = CCS_KEYWORD_TRANSITION_FAILED "\n";
1679                  if (domain->ignore_global_allow_read)                  if (domain->ignore_global_allow_read)
1680                          ignore_global_allow_read                          ignore_global_allow_read
1681                                  = CCS_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "\n";                                  = CCS_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "\n";
# Line 1807  static void ccs_read_pid(struct ccs_io_b Line 1821  static void ccs_read_pid(struct ccs_io_b
1821          if (ccs_str_starts(&buf, "global-pid "))          if (ccs_str_starts(&buf, "global-pid "))
1822                  global_pid = true;                  global_pid = true;
1823          pid = (unsigned int) simple_strtoul(buf, NULL, 10);          pid = (unsigned int) simple_strtoul(buf, NULL, 10);
1824          read_lock(&tasklist_lock);          ccs_tasklist_lock();
1825  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
1826          if (global_pid)          if (global_pid)
1827                  p = find_task_by_pid_ns(pid, &init_pid_ns);                  p = ccsecurity_exports.find_task_by_pid_ns(pid, &init_pid_ns);
1828          else          else
1829                  p = find_task_by_vpid(pid);                  p = ccsecurity_exports.find_task_by_vpid(pid);
1830  #else  #else
1831          p = find_task_by_pid(pid);          p = find_task_by_pid(pid);
1832  #endif  #endif
# Line 1820  static void ccs_read_pid(struct ccs_io_b Line 1834  static void ccs_read_pid(struct ccs_io_b
1834                  domain = ccs_task_domain(p);                  domain = ccs_task_domain(p);
1835                  ccs_flags = p->ccs_flags;                  ccs_flags = p->ccs_flags;
1836          }          }
1837          read_unlock(&tasklist_lock);          ccs_tasklist_unlock();
1838          if (!domain)          if (!domain)
1839                  return;                  return;
1840          if (!task_info)          if (!task_info)
# Line 2040  static struct ccs_condition *ccs_get_exe Line 2054  static struct ccs_condition *ccs_get_exe
2054                          len += strlen(argv0) + 16;                          len += strlen(argv0) + 16;
2055                  }                  }
2056          }          }
2057          buf = kmalloc(len, GFP_KERNEL);          buf = kmalloc(len, CCS_GFP_FLAGS);
2058          if (!buf) {          if (!buf) {
2059                  kfree(realpath);                  kfree(realpath);
2060                  return NULL;                  return NULL;
# Line 2086  static struct ccs_condition *ccs_get_sym Line 2100  static struct ccs_condition *ccs_get_sym
2100                  symlink = r->obj->symlink_target->name;                  symlink = r->obj->symlink_target->name;
2101                  len += strlen(symlink) + 18;                  len += strlen(symlink) + 18;
2102          }          }
2103          buf = kmalloc(len, GFP_KERNEL);          buf = kmalloc(len, CCS_GFP_FLAGS);
2104          if (!buf)          if (!buf)
2105                  return NULL;                  return NULL;
2106          snprintf(buf, len - 1, "if");          snprintf(buf, len - 1, "if");
# Line 2134  static atomic_t ccs_query_observers = AT Line 2148  static atomic_t ccs_query_observers = AT
2148   * @fmt:     The printf()'s format string, followed by parameters.   * @fmt:     The printf()'s format string, followed by parameters.
2149   *   *
2150   * Returns 0 if the supervisor decided to permit the access request which   * Returns 0 if the supervisor decided to permit the access request which
2151   * violated the policy in enforcing mode, 1 if the supervisor decided to   * violated the policy in enforcing mode, CCS_RETRY_REQUEST if the supervisor
2152   * retry the access request which violated the policy in enforcing mode,   * decided to retry the access request which violated the policy in enforcing
2153   * 0 if it is not in enforcing mode, -EPERM otherwise.   * mode, 0 if it is not in enforcing mode, -EPERM otherwise.
2154   */   */
2155  int ccs_supervisor(struct ccs_request_info *r, const char *fmt, ...)  int ccs_supervisor(struct ccs_request_info *r, const char *fmt, ...)
2156  {  {
# Line 2159  int ccs_supervisor(struct ccs_request_in Line 2173  int ccs_supervisor(struct ccs_request_in
2173                  va_start(args, fmt);                  va_start(args, fmt);
2174                  len = vsnprintf((char *) &pos, sizeof(pos) - 1, fmt, args) + 4;                  len = vsnprintf((char *) &pos, sizeof(pos) - 1, fmt, args) + 4;
2175                  va_end(args);                  va_end(args);
2176                  buffer = kmalloc(len, GFP_KERNEL);                  buffer = kmalloc(len, CCS_GFP_FLAGS);
2177                  if (!buffer)                  if (!buffer)
2178                          return 0;                          return 0;
2179                  va_start(args, fmt);                  va_start(args, fmt);
# Line 2199  int ccs_supervisor(struct ccs_request_in Line 2213  int ccs_supervisor(struct ccs_request_in
2213          header = ccs_init_audit_log(&len, r);          header = ccs_init_audit_log(&len, r);
2214          if (!header)          if (!header)
2215                  goto out;                  goto out;
2216          ccs_query_entry = kzalloc(sizeof(*ccs_query_entry), GFP_KERNEL);          ccs_query_entry = kzalloc(sizeof(*ccs_query_entry), CCS_GFP_FLAGS);
2217          if (!ccs_query_entry)          if (!ccs_query_entry)
2218                  goto out;                  goto out;
2219          len = ccs_round2(len);          len = ccs_round2(len);
2220          ccs_query_entry->query = kzalloc(len, GFP_KERNEL);          ccs_query_entry->query = kzalloc(len, CCS_GFP_FLAGS);
2221          if (!ccs_query_entry->query)          if (!ccs_query_entry->query)
2222                  goto out;                  goto out;
2223          INIT_LIST_HEAD(&ccs_query_entry->list);          INIT_LIST_HEAD(&ccs_query_entry->list);
# Line 2245  int ccs_supervisor(struct ccs_request_in Line 2259  int ccs_supervisor(struct ccs_request_in
2259          spin_unlock(&ccs_query_list_lock);          spin_unlock(&ccs_query_list_lock);
2260          switch (ccs_query_entry->answer) {          switch (ccs_query_entry->answer) {
2261          case 3: /* Asked to retry by administrator. */          case 3: /* Asked to retry by administrator. */
2262                  error = 1;                  error = CCS_RETRY_REQUEST;
2263                  r->retry++;                  r->retry++;
2264                  break;                  break;
2265          case 1:          case 1:
# Line 2336  static void ccs_read_query(struct ccs_io Line 2350  static void ccs_read_query(struct ccs_io
2350                  head->read_step = 0;                  head->read_step = 0;
2351                  return;                  return;
2352          }          }
2353          buf = kzalloc(len, GFP_KERNEL);          buf = kzalloc(len, CCS_GFP_FLAGS);
2354          if (!buf)          if (!buf)
2355                  return;                  return;
2356          pos = 0;          pos = 0;
# Line 2443  static void ccs_read_self_domain(struct Line 2457  static void ccs_read_self_domain(struct
2457   */   */
2458  int ccs_open_control(const u8 type, struct file *file)  int ccs_open_control(const u8 type, struct file *file)
2459  {  {
2460          struct ccs_io_buffer *head = kzalloc(sizeof(*head), GFP_KERNEL);          struct ccs_io_buffer *head = kzalloc(sizeof(*head), CCS_GFP_FLAGS);
2461          if (!head)          if (!head)
2462                  return -ENOMEM;                  return -ENOMEM;
2463          mutex_init(&head->io_sem);          mutex_init(&head->io_sem);
# Line 2459  int ccs_open_control(const u8 type, stru Line 2473  int ccs_open_control(const u8 type, stru
2473                  break;                  break;
2474  #ifdef CONFIG_CCSECURITY_AUDIT  #ifdef CONFIG_CCSECURITY_AUDIT
2475          case CCS_GRANTLOG: /* /proc/ccs/grant_log */          case CCS_GRANTLOG: /* /proc/ccs/grant_log */
                 head->poll = ccs_poll_grant_log;  
                 head->read = ccs_read_grant_log;  
                 break;  
2476          case CCS_REJECTLOG: /* /proc/ccs/reject_log */          case CCS_REJECTLOG: /* /proc/ccs/reject_log */
2477                  head->poll = ccs_poll_reject_log;                  head->poll = ccs_poll_audit_log;
2478                  head->read = ccs_read_reject_log;                  head->read = ccs_read_audit_log;
2479                  break;                  break;
2480  #endif  #endif
2481          case CCS_SELFDOMAIN: /* /proc/ccs/self_domain */          case CCS_SELFDOMAIN: /* /proc/ccs/self_domain */
# Line 2519  int ccs_open_control(const u8 type, stru Line 2530  int ccs_open_control(const u8 type, stru
2530                  /* Don't allocate read_buf for poll() access. */                  /* Don't allocate read_buf for poll() access. */
2531                  if (!head->readbuf_size)                  if (!head->readbuf_size)
2532                          head->readbuf_size = 4096;                          head->readbuf_size = 4096;
2533                  head->read_buf = kzalloc(head->readbuf_size, GFP_KERNEL);                  head->read_buf = kzalloc(head->readbuf_size, CCS_GFP_FLAGS);
2534                  if (!head->read_buf) {                  if (!head->read_buf) {
2535                          kfree(head);                          kfree(head);
2536                          return -ENOMEM;                          return -ENOMEM;
# Line 2533  int ccs_open_control(const u8 type, stru Line 2544  int ccs_open_control(const u8 type, stru
2544                  head->write = NULL;                  head->write = NULL;
2545          } else if (head->write) {          } else if (head->write) {
2546                  head->writebuf_size = 4096;                  head->writebuf_size = 4096;
2547                  head->write_buf = kzalloc(head->writebuf_size, GFP_KERNEL);                  head->write_buf = kzalloc(head->writebuf_size, CCS_GFP_FLAGS);
2548                  if (!head->write_buf) {                  if (!head->write_buf) {
2549                          kfree(head->read_buf);                          kfree(head->read_buf);
2550                          kfree(head);                          kfree(head);
# Line 2541  int ccs_open_control(const u8 type, stru Line 2552  int ccs_open_control(const u8 type, stru
2552                  }                  }
2553          }          }
2554          if (type != CCS_QUERY &&          if (type != CCS_QUERY &&
2555              type != CCS_GRANTLOG && type != CCS_REJECTLOG)              type != CCS_GRANTLOG && type != CCS_REJECTLOG) {
2556                  head->reader_idx = ccs_read_lock();                  spin_lock(&ccs_io_buffer_list_lock);
2557                    list_add(&head->list, &ccs_io_buffer_list);
2558                    spin_unlock(&ccs_io_buffer_list_lock);
2559            }
2560          file->private_data = head;          file->private_data = head;
2561          /*          /*
2562           * Call the handler now if the file is /proc/ccs/self_domain           * Call the handler now if the file is /proc/ccs/self_domain
# Line 2595  int ccs_read_control(struct file *file, Line 2609  int ccs_read_control(struct file *file,
2609          int len = 0;          int len = 0;
2610          struct ccs_io_buffer *head = file->private_data;          struct ccs_io_buffer *head = file->private_data;
2611          char *cp;          char *cp;
2612            int idx;
2613          if (!head->read)          if (!head->read)
2614                  return -ENOSYS;                  return -ENOSYS;
2615          if (!access_ok(VERIFY_WRITE, buffer, buffer_len))          if (!access_ok(VERIFY_WRITE, buffer, buffer_len))
2616                  return -EFAULT;                  return -EFAULT;
2617          if (mutex_lock_interruptible(&head->io_sem))          if (mutex_lock_interruptible(&head->io_sem))
2618                  return -EINTR;                  return -EINTR;
2619            idx = ccs_read_lock();
2620          while (1) {          while (1) {
2621                  /* Call the policy handler. */                  /* Call the policy handler. */
2622                  head->read(head);                  head->read(head);
# Line 2609  int ccs_read_control(struct file *file, Line 2625  int ccs_read_control(struct file *file,
2625                  if (len || head->poll || head->read_eof)                  if (len || head->poll || head->read_eof)
2626                          break;                          break;
2627                  len = head->readbuf_size * 2;                  len = head->readbuf_size * 2;
2628                  cp = kzalloc(len, GFP_KERNEL);                  cp = kzalloc(len, CCS_GFP_FLAGS);
2629                  if (!cp) {                  if (!cp) {
2630                          len = -ENOMEM;                          len = -ENOMEM;
2631                          goto out;                          goto out;
# Line 2631  int ccs_read_control(struct file *file, Line 2647  int ccs_read_control(struct file *file,
2647          head->read_avail -= len;          head->read_avail -= len;
2648          memmove(cp, cp + len, head->read_avail);          memmove(cp, cp + len, head->read_avail);
2649   out:   out:
2650            ccs_read_unlock(idx);
2651          mutex_unlock(&head->io_sem);          mutex_unlock(&head->io_sem);
2652          return len;          return len;
2653  }  }
# Line 2651  int ccs_write_control(struct file *file, Line 2668  int ccs_write_control(struct file *file,
2668          int error = buffer_len;          int error = buffer_len;
2669          int avail_len = buffer_len;          int avail_len = buffer_len;
2670          char *cp0 = head->write_buf;          char *cp0 = head->write_buf;
2671            int idx;
2672          if (!head->write)          if (!head->write)
2673                  return -ENOSYS;                  return -ENOSYS;
2674          if (!access_ok(VERIFY_READ, buffer, buffer_len))          if (!access_ok(VERIFY_READ, buffer, buffer_len))
# Line 2662  int ccs_write_control(struct file *file, Line 2680  int ccs_write_control(struct file *file,
2680                  return -EPERM;                  return -EPERM;
2681          if (mutex_lock_interruptible(&head->io_sem))          if (mutex_lock_interruptible(&head->io_sem))
2682                  return -EINTR;                  return -EINTR;
2683            idx = ccs_read_lock();
2684          /* Read a line and dispatch it to the policy handler. */          /* Read a line and dispatch it to the policy handler. */
2685          while (avail_len > 0) {          while (avail_len > 0) {
2686                  char c;                  char c;
2687                  if (head->write_avail >= head->writebuf_size - 1) {                  if (head->write_avail >= head->writebuf_size - 1) {
2688                          const int len = head->writebuf_size * 2;                          const int len = head->writebuf_size * 2;
2689                          char *cp = kzalloc(len, GFP_KERNEL);                          char *cp = kzalloc(len, CCS_GFP_FLAGS);
2690                          if (!cp) {                          if (!cp) {
2691                                  error = -ENOMEM;                                  error = -ENOMEM;
2692                                  break;                                  break;
# Line 2692  int ccs_write_control(struct file *file, Line 2711  int ccs_write_control(struct file *file,
2711                  ccs_normalize_line(cp0);                  ccs_normalize_line(cp0);
2712                  head->write(head);                  head->write(head);
2713          }          }
2714            ccs_read_unlock(idx);
2715          mutex_unlock(&head->io_sem);          mutex_unlock(&head->io_sem);
2716          return error;          return error;
2717  }  }
# Line 2714  int ccs_close_control(struct file *file) Line 2734  int ccs_close_control(struct file *file)
2734          if (type == CCS_QUERY)          if (type == CCS_QUERY)
2735                  atomic_dec(&ccs_query_observers);                  atomic_dec(&ccs_query_observers);
2736          if (type != CCS_QUERY &&          if (type != CCS_QUERY &&
2737              type != CCS_GRANTLOG && type != CCS_REJECTLOG)              type != CCS_GRANTLOG && type != CCS_REJECTLOG) {
2738                  ccs_read_unlock(head->reader_idx);                  spin_lock(&ccs_io_buffer_list_lock);
2739                    list_del(&head->list);
2740                    spin_unlock(&ccs_io_buffer_list_lock);
2741            }
2742          /* Release memory used for policy I/O. */          /* Release memory used for policy I/O. */
2743          kfree(head->read_buf);          kfree(head->read_buf);
2744          head->read_buf = NULL;          head->read_buf = NULL;
# Line 2724  int ccs_close_control(struct file *file) Line 2747  int ccs_close_control(struct file *file)
2747          kfree(head);          kfree(head);
2748          head = NULL;          head = NULL;
2749          file->private_data = NULL;          file->private_data = NULL;
2750          if (is_write)          if (is_write) {
2751                  ccs_run_gc();                  ccs_need_gc = 1;
2752                    wake_up(&ccs_gc_queue);
2753            }
2754          return 0;          return 0;
2755  }  }
2756    
2757    void __init ccs_policy_io_init(void)
2758    {
2759            ccsecurity_ops.check_profile = ccs_check_profile;
2760    }

Legend:
Removed from v.3167  
changed lines
  Added in v.3528

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