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

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 3109 by kumaneko, Fri Oct 16 05:02:23 2009 UTC revision 3136 by kumaneko, Wed Nov 4 00:31:28 2009 UTC
# Line 3  Line 3 
3   *   *
4   * Copyright (C) 2005-2009  NTT DATA CORPORATION   * Copyright (C) 2005-2009  NTT DATA CORPORATION
5   *   *
6   * Version: 1.7.1-pre   2009/10/16   * Version: 1.7.1-pre   2009/11/03
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 36  static struct ccs_profile ccs_default_pr Line 36  static struct ccs_profile ccs_default_pr
36  /* Profile table. Memory is allocated as needed. */  /* Profile table. Memory is allocated as needed. */
37  static struct ccs_profile *ccs_profile_ptr[CCS_MAX_PROFILES];  static struct ccs_profile *ccs_profile_ptr[CCS_MAX_PROFILES];
38    
 /* Lock for protecting "struct ccs_profile"->comment  */  
 static DEFINE_SPINLOCK(ccs_profile_comment_lock);  
   
39  /* String table for functionality that takes 4 modes. */  /* String table for functionality that takes 4 modes. */
40  static const char *ccs_mode_4[4] = {  static const char *ccs_mode_4[4] = {
41          "disabled", "learning", "permissive", "enforcing"          "disabled", "learning", "permissive", "enforcing"
# Line 438  static int ccs_write_profile(struct ccs_ Line 435  static int ccs_write_profile(struct ccs_
435          if (profile == &ccs_default_profile)          if (profile == &ccs_default_profile)
436                  return -EINVAL;                  return -EINVAL;
437          if (!strcmp(data, "COMMENT")) {          if (!strcmp(data, "COMMENT")) {
438                  const struct ccs_path_info *new_comment = ccs_get_name(cp);                  const struct ccs_path_info *old_comment = profile->comment;
439                  const struct ccs_path_info *old_comment;                  profile->comment = ccs_get_name(cp);
                 /* Protect reader from ccs_put_name(). */  
                 spin_lock(&ccs_profile_comment_lock);  
                 old_comment = profile->comment;  
                 profile->comment = new_comment;  
                 spin_unlock(&ccs_profile_comment_lock);  
440                  ccs_put_name(old_comment);                  ccs_put_name(old_comment);
441                  return 0;                  return 0;
442          }          }
# Line 551  static void ccs_read_profile(struct ccs_ Line 543  static void ccs_read_profile(struct ccs_
543                  int i;                  int i;
544                  int pos;                  int pos;
545                  const struct ccs_profile *profile = ccs_profile_ptr[index];                  const struct ccs_profile *profile = ccs_profile_ptr[index];
546                    const struct ccs_path_info *comment;
547                  head->read_step = index;                  head->read_step = index;
548                  if (!profile)                  if (!profile)
549                          continue;                          continue;
550                  pos = head->read_avail;                  pos = head->read_avail;
551                  spin_lock(&ccs_profile_comment_lock);                  comment = profile->comment;
552                  done = ccs_io_printf(head, "%u-COMMENT=%s\n", index,                  done = ccs_io_printf(head, "%u-COMMENT=%s\n", index,
553                                       profile->comment ? profile->comment->name                                       comment ? comment->name : "");
                                      : "");  
                 spin_unlock(&ccs_profile_comment_lock);  
554                  if (!done)                  if (!done)
555                          goto out;                          goto out;
556                  config = profile->default_config;                  config = profile->default_config;
# Line 1796  static void ccs_read_pid(struct ccs_io_b Line 1787  static void ccs_read_pid(struct ccs_io_b
1787          struct ccs_domain_info *domain = NULL;          struct ccs_domain_info *domain = NULL;
1788          u32 ccs_flags = 0;          u32 ccs_flags = 0;
1789          /* Accessing write_buf is safe because head->io_sem is held. */          /* Accessing write_buf is safe because head->io_sem is held. */
1790          if (!buf)          if (!buf) {
1791                    head->read_eof = true;
1792                  return; /* Do nothing if open(O_RDONLY). */                  return; /* Do nothing if open(O_RDONLY). */
1793            }
1794          if (head->read_avail || head->read_eof)          if (head->read_avail || head->read_eof)
1795                  return;                  return;
1796          head->read_eof = true;          head->read_eof = true;

Legend:
Removed from v.3109  
changed lines
  Added in v.3136

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