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

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 2951 by kumaneko, Tue Aug 25 04:26:20 2009 UTC revision 3109 by kumaneko, Fri Oct 16 05:02:23 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.0-pre   2009/08/24   * Version: 1.7.1-pre   2009/10/16
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 12  Line 12 
12    
13  #include "internal.h"  #include "internal.h"
14    
15  /* Lock for protecting ccs_profile->comment  */  static struct ccs_profile ccs_default_profile = {
16  static DEFINE_SPINLOCK(ccs_profile_comment_lock);          .learning = &ccs_default_profile.preference,
17            .permissive = &ccs_default_profile.preference,
18  /* String table for functionality that takes 2 modes. */          .enforcing = &ccs_default_profile.preference,
19  static const char *ccs_mode_2[2] = {          .audit = &ccs_default_profile.preference,
20          "disabled", "enabled"  #ifdef CONFIG_CCSECURITY_AUDIT
21            .preference.audit_max_grant_log = CONFIG_CCSECURITY_MAX_GRANT_LOG,
22            .preference.audit_max_reject_log = CONFIG_CCSECURITY_MAX_REJECT_LOG,
23    #endif
24            .preference.audit_task_info = true,
25            .preference.audit_path_info = true,
26            .preference.enforcing_penalty = 0,
27            .preference.enforcing_verbose = true,
28            .preference.learning_max_entry = CONFIG_CCSECURITY_MAX_ACCEPT_ENTRY,
29            .preference.learning_verbose = false,
30            .preference.learning_exec_realpath = true,
31            .preference.learning_exec_argv0 = true,
32            .preference.learning_symlink_target = true,
33            .preference.permissive_verbose = true
34  };  };
35    
36    /* Profile table. Memory is allocated as needed. */
37    static struct ccs_profile *ccs_profile_ptr[CCS_MAX_PROFILES];
38    
39    /* Lock for protecting "struct ccs_profile"->comment  */
40    static DEFINE_SPINLOCK(ccs_profile_comment_lock);
41    
42  /* String table for functionality that takes 4 modes. */  /* String table for functionality that takes 4 modes. */
43  static const char *ccs_mode_4[4] = {  static const char *ccs_mode_4[4] = {
44          "disabled", "learning", "permissive", "enforcing"          "disabled", "learning", "permissive", "enforcing"
# Line 171  static const char *ccs_mac_keywords[CCS_ Line 190  static const char *ccs_mac_keywords[CCS_
190           + CCS_MAC_CATEGORY_CAPABILITY] = "capability",           + CCS_MAC_CATEGORY_CAPABILITY] = "capability",
191  };  };
192    
 /* Table for profile. */  
 static const struct {  
         const char *keyword;  
         unsigned int current_value;  
         const unsigned int max_value;  
 } ccs_control_array[CCS_MAX_CONTROL_INDEX] = {  
         [CCS_AUTOLEARN_EXEC_REALPATH] = { "AUTOLEARN_EXEC_REALPATH", 0, 1 },  
         [CCS_AUTOLEARN_EXEC_ARGV0] = { "AUTOLEARN_EXEC_ARGV0", 0, 1 },  
         [CCS_MAX_ACCEPT_ENTRY]  
         = { "MAX_ACCEPT_ENTRY", CONFIG_CCSECURITY_MAX_ACCEPT_ENTRY, INT_MAX },  
 #ifdef CONFIG_CCSECURITY_AUDIT  
         [CCS_MAX_GRANT_LOG]  
         = { "MAX_GRANT_LOG", CONFIG_CCSECURITY_MAX_GRANT_LOG, INT_MAX },  
         [CCS_MAX_REJECT_LOG]  
         = { "MAX_REJECT_LOG", CONFIG_CCSECURITY_MAX_REJECT_LOG, INT_MAX },  
 #endif  
         [CCS_VERBOSE] = { "PRINT_VIOLATION",      1, 1 },  
         [CCS_SLEEP_PERIOD] = { "SLEEP_PERIOD", 0, 3000 }, /* in 0.1 second */  
 };  
   
193  /* Permit policy management by non-root user? */  /* Permit policy management by non-root user? */
194  static bool ccs_manage_by_non_root;  static bool ccs_manage_by_non_root;
195    
 /* Disable VERBOSE mode by default? */  
 static bool ccs_no_verbose;  
   
196  /**  /**
197   * ccs_cap2keyword - Convert capability operation to capability name.   * ccs_cap2keyword - Convert capability operation to capability name.
198   *   *
# Line 211  const char *ccs_cap2keyword(const u8 ope Line 207  const char *ccs_cap2keyword(const u8 ope
207  }  }
208    
209  /**  /**
210   * ccs_quiet_setup - Set CCS_VERBOSE=0 by default.   * ccs_yesno - Return "yes" or "no".
  *  
  * @str: Unused.  
211   *   *
212   * Returns 0.   * @value: Bool value.
213   */   */
214  static int __init ccs_quiet_setup(char *str)  static const char *ccs_yesno(const unsigned int value)
215  {  {
216          ccs_no_verbose = true;          return value ? "yes" : "no";
         return 0;  
217  }  }
218    
 __setup("CCS_QUIET", ccs_quiet_setup);  
   
219  /**  /**
220   * ccs_io_printf - Transactional printf() to "struct ccs_io_buffer" structure.   * ccs_io_printf - Transactional printf() to "struct ccs_io_buffer" structure.
221   *   *
# Line 264  static struct ccs_profile *ccs_find_or_a Line 255  static struct ccs_profile *ccs_find_or_a
255  {  {
256          struct ccs_profile *ptr;          struct ccs_profile *ptr;
257          struct ccs_profile *entry;          struct ccs_profile *entry;
         int i;  
258          if (profile >= CCS_MAX_PROFILES)          if (profile >= CCS_MAX_PROFILES)
259                  return NULL;                  return NULL;
260          ptr = ccs_profile_ptr[profile];          ptr = ccs_profile_ptr[profile];
# Line 275  static struct ccs_profile *ccs_find_or_a Line 265  static struct ccs_profile *ccs_find_or_a
265          ptr = ccs_profile_ptr[profile];          ptr = ccs_profile_ptr[profile];
266          if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) {          if (!ptr && ccs_memory_ok(entry, sizeof(*entry))) {
267                  ptr = entry;                  ptr = entry;
268                  for (i = 0; i < CCS_MAX_CONTROL_INDEX; i++)                  ptr->audit = &ccs_default_profile.preference;
269                          ptr->value[i] = ccs_control_array[i].current_value;                  ptr->learning = &ccs_default_profile.preference;
270                  ptr->value[CCS_VERBOSE] = !ccs_no_verbose;                  ptr->permissive = &ccs_default_profile.preference;
271                  ptr->default_config = CCS_MAC_MODE_DISABLED;                  ptr->enforcing = &ccs_default_profile.preference;
272                  memset(ptr->config, CCS_MAC_MODE_USE_DEFAULT,                  ptr->default_config = CCS_CONFIG_DISABLED |
273                            CCS_CONFIG_WANT_GRANT_LOG | CCS_CONFIG_WANT_REJECT_LOG;
274                    memset(ptr->config, CCS_CONFIG_USE_DEFAULT,
275                         sizeof(ptr->config));                         sizeof(ptr->config));
276                  mb(); /* Avoid out-of-order execution. */                  mb(); /* Avoid out-of-order execution. */
277                  ccs_profile_ptr[profile] = ptr;                  ccs_profile_ptr[profile] = ptr;
# Line 291  static struct ccs_profile *ccs_find_or_a Line 283  static struct ccs_profile *ccs_find_or_a
283  }  }
284    
285  /**  /**
286     * ccs_check_profile - Check all profiles currently assigned to domains are defined.
287     */
288    void ccs_check_profile(void)
289    {
290            struct ccs_domain_info *domain;
291            ccs_policy_loaded = true;
292            list_for_each_entry_rcu(domain, &ccs_domain_list, list) {
293                    const u8 profile = domain->profile;
294                    if (ccs_profile_ptr[profile])
295                            continue;
296                    panic("Profile %u (used by '%s') not defined.\n",
297                          profile, domain->domainname->name);
298            }
299    }
300    
301    /**
302     * ccs_profile - Find a profile.
303     *
304     * @profile: Profile number to find.
305     *
306     * Returns pointer to "struct ccs_profile".
307     */
308    struct ccs_profile *ccs_profile(const u8 profile)
309    {
310            struct ccs_profile *ptr = ccs_profile_ptr[profile];
311            if (!ccs_policy_loaded)
312                    return &ccs_default_profile;
313            BUG_ON(!ptr);
314            return ptr;
315    }
316    
317    /**
318   * ccs_write_profile - Write profile table.   * ccs_write_profile - Write profile table.
319   *   *
320   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
# Line 301  static int ccs_write_profile(struct ccs_ Line 325  static int ccs_write_profile(struct ccs_
325  {  {
326          char *data = head->write_buf;          char *data = head->write_buf;
327          unsigned int i;          unsigned int i;
328          unsigned int value;          int value;
329          int mode;          int mode;
330          u8 config;          u8 config;
331            bool use_default = false;
332          char *cp;          char *cp;
333          struct ccs_profile *ccs_profile;          struct ccs_profile *profile;
334          i = simple_strtoul(data, &cp, 10);          i = simple_strtoul(data, &cp, 10);
335          if (data != cp) {          if (data == cp) {
336                    profile = &ccs_default_profile;
337            } else {
338                  if (*cp != '-')                  if (*cp != '-')
339                          return -EINVAL;                          return -EINVAL;
340                  data = cp + 1;                  data = cp + 1;
341                    profile = ccs_find_or_assign_new_profile(i);
342                    if (!profile)
343                            return -EINVAL;
344          }          }
         ccs_profile = ccs_find_or_assign_new_profile(i);  
         if (!ccs_profile)  
                 return -EINVAL;  
345          cp = strchr(data, '=');          cp = strchr(data, '=');
346          if (!cp)          if (!cp)
347                  return -EINVAL;                  return -EINVAL;
348          *cp++ = '\0';          *cp++ = '\0';
349            if (profile != &ccs_default_profile)
350                    use_default = strstr(cp, "use_default") != NULL;
351            if (strstr(cp, "verbose=yes"))
352                    value = 1;
353            else if (strstr(cp, "verbose=no"))
354                    value = 0;
355            else
356                    value = -1;
357            if (!strcmp(data, "PREFERENCE::audit")) {
358    #ifdef CONFIG_CCSECURITY_AUDIT
359                    char *cp2;
360    #endif
361                    if (use_default) {
362                            profile->audit = &ccs_default_profile.preference;
363                            return 0;
364                    }
365                    profile->audit = &profile->preference;
366    #ifdef CONFIG_CCSECURITY_AUDIT
367                    cp2 = strstr(cp, "max_grant_log=");
368                    if (cp2)
369                            sscanf(cp2 + 14, "%u",
370                                   &profile->preference.audit_max_grant_log);
371                    cp2 = strstr(cp, "max_reject_log=");
372                    if (cp2)
373                            sscanf(cp2 + 15, "%u",
374                                   &profile->preference.audit_max_reject_log);
375    #endif
376                    if (strstr(cp, "task_info=yes"))
377                            profile->preference.audit_task_info = true;
378                    else if (strstr(cp, "task_info=no"))
379                            profile->preference.audit_task_info = false;
380                    if (strstr(cp, "path_info=yes"))
381                            profile->preference.audit_path_info = true;
382                    else if (strstr(cp, "path_info=no"))
383                            profile->preference.audit_path_info = false;
384                    return 0;
385            }
386            if (!strcmp(data, "PREFERENCE::enforcing")) {
387                    char *cp2;
388                    if (use_default) {
389                            profile->enforcing = &ccs_default_profile.preference;
390                            return 0;
391                    }
392                    profile->enforcing = &profile->preference;
393                    if (value >= 0)
394                            profile->preference.enforcing_verbose = value;
395                    cp2 = strstr(cp, "penalty=");
396                    if (cp2)
397                            sscanf(cp2 + 8, "%u",
398                                   &profile->preference.enforcing_penalty);
399                    return 0;
400            }
401            if (!strcmp(data, "PREFERENCE::permissive")) {
402                    if (use_default) {
403                            profile->permissive = &ccs_default_profile.preference;
404                            return 0;
405                    }
406                    profile->permissive = &profile->preference;
407                    if (value >= 0)
408                            profile->preference.permissive_verbose = value;
409                    return 0;
410            }
411            if (!strcmp(data, "PREFERENCE::learning")) {
412                    char *cp2;
413                    if (use_default) {
414                            profile->learning = &ccs_default_profile.preference;
415                            return 0;
416                    }
417                    profile->learning = &profile->preference;
418                    if (value >= 0)
419                            profile->preference.learning_verbose = value;
420                    cp2 = strstr(cp, "max_entry=");
421                    if (cp2)
422                            sscanf(cp2 + 10, "%u",
423                                   &profile->preference.learning_max_entry);
424                    if (strstr(cp, "exec.realpath=yes"))
425                            profile->preference.learning_exec_realpath = true;
426                    else if (strstr(cp, "exec.realpath=no"))
427                            profile->preference.learning_exec_realpath = false;
428                    if (strstr(cp, "exec.argv0=yes"))
429                            profile->preference.learning_exec_argv0 = true;
430                    else if (strstr(cp, "exec.argv0=no"))
431                            profile->preference.learning_exec_argv0 = false;
432                    if (strstr(cp, "symlink.target=yes"))
433                            profile->preference.learning_symlink_target = true;
434                    else if (strstr(cp, "symlink.target=no"))
435                            profile->preference.learning_symlink_target = false;
436                    return 0;
437            }
438            if (profile == &ccs_default_profile)
439                    return -EINVAL;
440          if (!strcmp(data, "COMMENT")) {          if (!strcmp(data, "COMMENT")) {
441                  const struct ccs_path_info *new_comment = ccs_get_name(cp);                  const struct ccs_path_info *new_comment = ccs_get_name(cp);
442                  const struct ccs_path_info *old_comment;                  const struct ccs_path_info *old_comment;
443                  /* Protect reader from ccs_put_name(). */                  /* Protect reader from ccs_put_name(). */
444                  spin_lock(&ccs_profile_comment_lock);                  spin_lock(&ccs_profile_comment_lock);
445                  old_comment = ccs_profile->comment;                  old_comment = profile->comment;
446                  ccs_profile->comment = new_comment;                  profile->comment = new_comment;
447                  spin_unlock(&ccs_profile_comment_lock);                  spin_unlock(&ccs_profile_comment_lock);
448                  ccs_put_name(old_comment);                  ccs_put_name(old_comment);
449                  return 0;                  return 0;
450          }          }
451          for (i = 0; i < CCS_MAX_CONTROL_INDEX; i++) {          if (!strcmp(data, "CONFIG")) {
452                  if (strcmp(data, ccs_control_array[i].keyword))                  i = CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX
453                          continue;                          + CCS_MAX_MAC_CATEGORY_INDEX;
454                  if (sscanf(cp, "%u", &value) != 1) {                  config = profile->default_config;
455                          int j;          } else if (ccs_str_starts(&data, "CONFIG::")) {
456                          for (j = 0; j < 2; j++) {                  config = 0;
                                 if (strcmp(cp, ccs_mode_2[j]))  
                                         continue;  
                                 value = j;  
                                 break;  
                         }  
                         if (j == 2)  
                                 return -EINVAL;  
                 } else if (value > ccs_control_array[i].max_value) {  
                         value = ccs_control_array[i].max_value;  
                 }  
                 ccs_profile->value[i] = value;  
                 return 0;  
         }  
         config = 0;  
         if (strstr(cp, "no_grant_log"))  
                 config |= CCS_MAC_MODE_NO_GRANT_LOG;  
         if (strstr(cp, "no_reject_log"))  
                 config |= CCS_MAC_MODE_NO_REJECT_LOG;  
         for (mode = 3; mode >= 0; mode--)  
                 if (strstr(cp, ccs_mode_4[mode]))  
                         break;  
         if (mode < 0)  
                 sscanf(cp, "%u", &mode);  
         if (!strcmp(cp, "default"))  
                 config = CCS_MAC_MODE_USE_DEFAULT;  
         else if (mode < 0 || mode > 3)  
                 return -EINVAL;  
         else  
                 config |= mode;  
         if (!strcmp(data, "MAC") && config != CCS_MAC_MODE_USE_DEFAULT)  
                 ccs_profile->default_config = config;  
         else if (ccs_str_starts(&data, "MAC::"))  
457                  for (i = 0; i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX                  for (i = 0; i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX
458                               + CCS_MAX_MAC_CATEGORY_INDEX; i++) {                               + CCS_MAX_MAC_CATEGORY_INDEX; i++) {
459                          if (strcmp(data, ccs_mac_keywords[i]))                          if (strcmp(data, ccs_mac_keywords[i]))
460                                  continue;                                  continue;
461                          ccs_profile->config[i] = config;                          config = profile->config[i];
462                          break;                          break;
463                  }                  }
464          return 0;                  if (i == CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX
465  }                      + CCS_MAX_MAC_CATEGORY_INDEX)
466                            return -EINVAL;
467  static bool ccs_print_mac_mode(struct ccs_io_buffer *head, u8 index)          } else {
468  {                  return -EINVAL;
         const int pos = head->read_avail;  
         int i;  
         const struct ccs_profile *ccs_profile = ccs_profile_ptr[index];  
         u8 config = ccs_profile->default_config;  
         if (!ccs_io_printf(head, "%u-MAC=%s %s %s\n", index,  
                            ccs_mode_4[config & 3],  
                            config & CCS_MAC_MODE_NO_GRANT_LOG ?  
                            "no_grant_log" : "",  
                            config & CCS_MAC_MODE_NO_REJECT_LOG ?  
                            "no_reject_log" : ""))  
                 goto out;  
         for (i = 0; i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX  
                      + CCS_MAX_MAC_CATEGORY_INDEX; i++) {  
                 config = ccs_profile->config[i];  
                 if (config == CCS_MAC_MODE_USE_DEFAULT)  
                         continue;  
                 if (!ccs_io_printf(head, "%u-MAC::%s=%s %s %s\n", index,  
                                    ccs_mac_keywords[i],  
                                    ccs_mode_4[config & 3],  
                                    config & CCS_MAC_MODE_NO_GRANT_LOG ?  
                                    "no_grant_log" : "",  
                                    config & CCS_MAC_MODE_NO_REJECT_LOG ?  
                                    "no_reject_log" : ""))  
                         goto out;  
469          }          }
470          return true;          if (use_default) {
471   out:                  config = CCS_CONFIG_USE_DEFAULT;
472          head->read_avail = pos;          } else {
473          return false;                  for (mode = 3; mode >= 0; mode--)
474                            if (strstr(cp, ccs_mode_4[mode]))
475                                    /*
476                                     * Update lower 3 bits in order to distinguish
477                                     * 'config' from 'CCS_CONFIG_USE_DEAFULT'.
478                                     */
479                                    config = (config & ~7) | mode;
480    #ifdef CONFIG_CCSECURITY_AUDIT
481                    if (config != CCS_CONFIG_USE_DEFAULT) {
482                            if (strstr(cp, "grant_log=yes"))
483                                    config |= CCS_CONFIG_WANT_GRANT_LOG;
484                            else if (strstr(cp, "grant_log=no"))
485                                    config &= ~CCS_CONFIG_WANT_GRANT_LOG;
486                            if (strstr(cp, "reject_log=yes"))
487                                    config |= CCS_CONFIG_WANT_REJECT_LOG;
488                            else if (strstr(cp, "reject_log=no"))
489                                    config &= ~CCS_CONFIG_WANT_REJECT_LOG;
490                    }
491    #endif
492            }
493            if (i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX
494                + CCS_MAX_MAC_CATEGORY_INDEX)
495                    profile->config[i] = config;
496            else if (config != CCS_CONFIG_USE_DEFAULT)
497                    profile->default_config = config;
498            return 0;
499  }  }
500    
501  /**  /**
# Line 418  static bool ccs_print_mac_mode(struct cc Line 505  static bool ccs_print_mac_mode(struct cc
505   */   */
506  static void ccs_read_profile(struct ccs_io_buffer *head)  static void ccs_read_profile(struct ccs_io_buffer *head)
507  {  {
508          static const int ccs_total = CCS_MAX_CONTROL_INDEX + 2;          int index;
         int step;  
509          if (head->read_eof)          if (head->read_eof)
510                  return;                  return;
511          for (step = head->read_step; step < CCS_MAX_PROFILES * ccs_total;          if (head->read_bit)
512               step++) {                  goto body;
513                  const u8 index = step / ccs_total;          ccs_io_printf(head, "PROFILE_VERSION=%s\n", "20090903");
514                  u8 type = step % ccs_total;          ccs_io_printf(head, "PREFERENCE::audit={ "
515                  const struct ccs_profile *ccs_profile = ccs_profile_ptr[index];  #ifdef CONFIG_CCSECURITY_AUDIT
516                  head->read_step = step;                        "max_grant_log=%u max_reject_log=%u "
517                  if (!ccs_profile)  #endif
518                          continue;                        "task_info=%s path_info=%s }\n",
519                  if (!type) { /* Print profile' comment tag. */  #ifdef CONFIG_CCSECURITY_AUDIT
520                          bool done;                        ccs_default_profile.preference.audit_max_grant_log,
521                          spin_lock(&ccs_profile_comment_lock);                        ccs_default_profile.preference.audit_max_reject_log,
522                          done = ccs_io_printf(head, "%u-COMMENT=%s\n",  #endif
523                                               index, ccs_profile->comment ?                        ccs_yesno(ccs_default_profile.preference.
524                                               ccs_profile->comment->name : "");                                  audit_task_info),
525                          spin_unlock(&ccs_profile_comment_lock);                        ccs_yesno(ccs_default_profile.preference.
526                          if (!done)                                  audit_path_info));
527                                  break;          ccs_io_printf(head, "PREFERENCE::learning={ verbose=%s max_entry=%u "
528                          continue;                        "exec.realpath=%s exec.argv0=%s symlink.target=%s }\n",
529                  } else if (type == 1) {                        ccs_yesno(ccs_default_profile.preference.
530                          if (!ccs_print_mac_mode(head, index))                                  learning_verbose),
531                                  break;                        ccs_default_profile.preference.learning_max_entry,
532                          ccs_yesno(ccs_default_profile.preference.
533                                    learning_exec_realpath),
534                          ccs_yesno(ccs_default_profile.preference.
535                                    learning_exec_argv0),
536                          ccs_yesno(ccs_default_profile.preference.
537                                    learning_symlink_target));
538            ccs_io_printf(head, "PREFERENCE::permissive={ verbose=%s }\n",
539                          ccs_yesno(ccs_default_profile.preference.
540                                    permissive_verbose));
541            ccs_io_printf(head, "PREFERENCE::enforcing={ verbose=%s penalty=%u "
542                          "}\n",
543                          ccs_yesno(ccs_default_profile.preference.
544                                    enforcing_verbose),
545                          ccs_default_profile.preference.enforcing_penalty);
546            head->read_bit = 1;
547     body:
548            for (index = head->read_step; index < CCS_MAX_PROFILES; index++) {
549                    bool done;
550                    u8 config;
551                    int i;
552                    int pos;
553                    const struct ccs_profile *profile = ccs_profile_ptr[index];
554                    head->read_step = index;
555                    if (!profile)
556                          continue;                          continue;
557                    pos = head->read_avail;
558                    spin_lock(&ccs_profile_comment_lock);
559                    done = ccs_io_printf(head, "%u-COMMENT=%s\n", index,
560                                         profile->comment ? profile->comment->name
561                                         : "");
562                    spin_unlock(&ccs_profile_comment_lock);
563                    if (!done)
564                            goto out;
565                    config = profile->default_config;
566    #ifdef CONFIG_CCSECURITY_AUDIT
567                    if (!ccs_io_printf(head, "%u-CONFIG={ mode=%s grant_log=%s "
568                                       "reject_log=%s }\n", index,
569                                       ccs_mode_4[config & 3],
570                                       ccs_yesno(config &
571                                                 CCS_CONFIG_WANT_GRANT_LOG),
572                                       ccs_yesno(config &
573                                                 CCS_CONFIG_WANT_REJECT_LOG)))
574                            goto out;
575    #else
576                    if (!ccs_io_printf(head, "%u-CONFIG={ mode=%s }\n", index,
577                                       ccs_mode_4[config & 3]))
578                            goto out;
579    #endif
580                    for (i = 0; i < CCS_MAX_MAC_INDEX + CCS_MAX_CAPABILITY_INDEX
581                                 + CCS_MAX_MAC_CATEGORY_INDEX; i++) {
582    #ifdef CONFIG_CCSECURITY_AUDIT
583                            const char *g;
584                            const char *r;
585    #endif
586                            config = profile->config[i];
587                            if (config == CCS_CONFIG_USE_DEFAULT)
588                                    continue;
589    #ifdef CONFIG_CCSECURITY_AUDIT
590                            g = ccs_yesno(config & CCS_CONFIG_WANT_GRANT_LOG);
591                            r = ccs_yesno(config & CCS_CONFIG_WANT_REJECT_LOG);
592                            if (!ccs_io_printf(head, "%u-CONFIG::%s={ mode=%s "
593                                               "grant_log=%s reject_log=%s }\n",
594                                               index, ccs_mac_keywords[i],
595                                               ccs_mode_4[config & 3], g, r))
596                                    goto out;
597    #else
598                            if (!ccs_io_printf(head, "%u-CONFIG::%s={ mode=%s }\n",
599                                               index, ccs_mac_keywords[i],
600                                               ccs_mode_4[config & 3]))
601                                    goto out;
602    #endif
603                  }                  }
604                  type -= 2;                  if (profile->audit != &ccs_default_profile.preference &&
605                  {                      !ccs_io_printf(head, "%u-PREFERENCE::audit={ "
606                          const unsigned int value = ccs_profile->value[type];  #ifdef CONFIG_CCSECURITY_AUDIT
607                          const char *keyword = ccs_control_array[type].keyword;                                     "max_grant_log=%u max_reject_log=%u "
608                          if (ccs_control_array[type].max_value == 1) {  #endif
609                                  if (!ccs_io_printf(head, "%u-%s=%s\n", index,                                     "task_info=%s path_info=%s }\n", index,
610                                                     keyword, ccs_mode_2[value]))  #ifdef CONFIG_CCSECURITY_AUDIT
611                                          break;                                     profile->preference.audit_max_grant_log,
612                          } else {                                     profile->preference.audit_max_reject_log,
613                                  if (!ccs_io_printf(head, "%u-%s=%u\n", index,  #endif
614                                                     keyword, value))                                     ccs_yesno(profile->preference.
615                                          break;                                               audit_task_info),
616                          }                                     ccs_yesno(profile->preference.
617                  }                                               audit_path_info)))
618                            goto out;
619                    if (profile->learning != &ccs_default_profile.preference &&
620                        !ccs_io_printf(head, "%u-PREFERENCE::learning={ "
621                                       "verbose=%s max_entry=%u exec.realpath=%s "
622                                       "exec.argv0=%s symlink.target=%s }\n",
623                                       index,
624                                       ccs_yesno(profile->preference.
625                                                 learning_verbose),
626                                       profile->preference.learning_max_entry,
627                                       ccs_yesno(profile->preference.
628                                                 learning_exec_realpath),
629                                       ccs_yesno(profile->preference.
630                                                 learning_exec_argv0),
631                                       ccs_yesno(profile->preference.
632                                                 learning_symlink_target)))
633                            goto out;
634                    if (profile->permissive != &ccs_default_profile.preference &&
635                        !ccs_io_printf(head, "%u-PREFERENCE::permissive={ "
636                                       "verbose=%s }\n", index,
637                                       ccs_yesno(profile->preference.
638                                                 permissive_verbose)))
639                            goto out;
640                    if (profile->enforcing != &ccs_default_profile.preference &&
641                        !ccs_io_printf(head, "%u-PREFERENCE::enforcing={ "
642                                       "verbose=%s penalty=%u }\n", index,
643                                       ccs_yesno(profile->preference.
644                                                 enforcing_verbose),
645                                       profile->preference.enforcing_penalty))
646                            goto out;
647                    continue;
648     out:
649                    head->read_avail = pos;
650                    break;
651          }          }
652          if (step == CCS_MAX_PROFILES * ccs_total)          if (index == CCS_MAX_PROFILES)
653                  head->read_eof = true;                  head->read_eof = true;
654  }  }
655    
# Line 650  static bool ccs_is_select_one(struct ccs Line 839  static bool ccs_is_select_one(struct ccs
839  {  {
840          unsigned int pid;          unsigned int pid;
841          struct ccs_domain_info *domain = NULL;          struct ccs_domain_info *domain = NULL;
842            bool global_pid = false;
843          if (!strcmp(data, "allow_execute")) {          if (!strcmp(data, "allow_execute")) {
844                  head->read_execute_only = true;                  head->read_execute_only = true;
845                  return true;                  return true;
846          }          }
847          if (sscanf(data, "pid=%u", &pid) == 1) {          if (sscanf(data, "pid=%u", &pid) == 1 ||
848                (global_pid = true, sscanf(data, "global-pid=%u", &pid) == 1)) {
849                  struct task_struct *p;                  struct task_struct *p;
850                  read_lock(&tasklist_lock);                  read_lock(&tasklist_lock);
851    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
852                    if (global_pid)
853                            p = find_task_by_pid_ns(pid, &init_pid_ns);
854                    else
855                            p = find_task_by_vpid(pid);
856    #else
857                  p = find_task_by_pid(pid);                  p = find_task_by_pid(pid);
858    #endif
859                  if (p)                  if (p)
860                          domain = ccs_task_domain(p);                          domain = ccs_task_domain(p);
861                  read_unlock(&tasklist_lock);                  read_unlock(&tasklist_lock);
# Line 706  static int ccs_write_domain_policy2(char Line 904  static int ccs_write_domain_policy2(char
904                  return ccs_write_env_policy(data, domain, cond, is_delete);                  return ccs_write_env_policy(data, domain, cond, is_delete);
905          if (ccs_str_starts(&data, CCS_KEYWORD_ALLOW_MOUNT))          if (ccs_str_starts(&data, CCS_KEYWORD_ALLOW_MOUNT))
906                  return ccs_write_mount_policy(data, domain, cond, is_delete);                  return ccs_write_mount_policy(data, domain, cond, is_delete);
         if (ccs_str_starts(&data, CCS_KEYWORD_ALLOW_UNMOUNT))  
                 return ccs_write_umount_policy(data, domain, cond, is_delete);  
         if (ccs_str_starts(&data, CCS_KEYWORD_ALLOW_CHROOT))  
                 return ccs_write_chroot_policy(data, domain, cond, is_delete);  
         if (ccs_str_starts(&data, CCS_KEYWORD_ALLOW_PIVOT_ROOT))  
                 return ccs_write_pivot_root_policy(data, domain, cond,  
                                                    is_delete);  
907          return ccs_write_file_policy(data, domain, cond, is_delete);          return ccs_write_file_policy(data, domain, cond, is_delete);
908  }  }
909    
# Line 758  static int ccs_write_domain_policy(struc Line 949  static int ccs_write_domain_policy(struc
949    
950          if (sscanf(data, CCS_KEYWORD_USE_PROFILE "%u", &profile) == 1          if (sscanf(data, CCS_KEYWORD_USE_PROFILE "%u", &profile) == 1
951              && profile < CCS_MAX_PROFILES) {              && profile < CCS_MAX_PROFILES) {
952                  if (ccs_profile_ptr[profile] || !ccs_policy_loaded)                  if (!ccs_policy_loaded || ccs_profile_ptr[(u8) profile])
953                          domain->profile = (u8) profile;                          domain->profile = (u8) profile;
954                  return 0;                  return 0;
955          }          }
# Line 1011  static bool ccs_print_condition(struct c Line 1202  static bool ccs_print_condition(struct c
1202  }  }
1203    
1204  /**  /**
1205   * ccs_print_path_acl - Print a single path ACL entry.   * ccs_print_path_acl - Print a path ACL entry.
1206   *   *
1207   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
1208   * @ptr:  Pointer to "struct ccs_path_acl".   * @ptr:  Pointer to "struct ccs_path_acl".
# Line 1362  static bool ccs_print_mount_acl(struct c Line 1553  static bool ccs_print_mount_acl(struct c
1553  }  }
1554    
1555  /**  /**
  * ccs_print_umount_acl - Print a mount ACL entry.  
  *  
  * @head: Pointer to "struct ccs_io_buffer".  
  * @ptr:  Pointer to "struct ccs_umount_acl".  
  * @cond: Pointer to "struct ccs_condition". May be NULL.  
  *  
  * Returns true on success, false otherwise.  
  */  
 static bool ccs_print_umount_acl(struct ccs_io_buffer *head,  
                                  struct ccs_umount_acl *ptr,  
                                  const struct ccs_condition *cond)  
 {  
         const int pos = head->read_avail;  
         if (!ccs_io_printf(head, CCS_KEYWORD_ALLOW_UNMOUNT) ||  
             !ccs_print_name_union(head, &ptr->dir) ||  
             !ccs_print_condition(head, cond)) {  
                 head->read_avail = pos;  
                 return false;  
         }  
         return true;  
 }  
   
 /**  
  * ccs_print_chroot_acl - Print a chroot ACL entry.  
  *  
  * @head: Pointer to "struct ccs_io_buffer".  
  * @ptr:  Pointer to "struct ccs_chroot_acl".  
  * @cond: Pointer to "struct ccs_condition". May be NULL.  
  *  
  * Returns true on success, false otherwise.  
  */  
 static bool ccs_print_chroot_acl(struct ccs_io_buffer *head,  
                                  struct ccs_chroot_acl *ptr,  
                                  const struct ccs_condition *cond)  
 {  
         const int pos = head->read_avail;  
         if (!ccs_io_printf(head, CCS_KEYWORD_ALLOW_CHROOT) ||  
             !ccs_print_name_union(head, &ptr->dir) ||  
             !ccs_print_condition(head, cond)) {  
                 head->read_avail = pos;  
                 return false;  
         }  
         return true;  
 }  
   
 /**  
  * ccs_print_pivot_root_acl - Print a pivot_root ACL entry.  
  *  
  * @head: Pointer to "struct ccs_io_buffer".  
  * @ptr:  Pointer to "struct ccs_pivot_root_acl".  
  * @cond: Pointer to "struct ccs_condition". May be NULL.  
  *  
  * Returns true on success, false otherwise.  
  */  
 static bool ccs_print_pivot_root_acl(struct ccs_io_buffer *head,  
                                      struct ccs_pivot_root_acl *ptr,  
                                      const struct ccs_condition *cond)  
 {  
         const int pos = head->read_avail;  
         if (!ccs_io_printf(head, CCS_KEYWORD_ALLOW_PIVOT_ROOT) ||  
             !ccs_print_name_union(head, &ptr->new_root) ||  
             !ccs_print_name_union(head, &ptr->old_root) ||  
             !ccs_print_condition(head, cond)) {  
                 head->read_avail = pos;  
                 return false;  
         }  
         return true;  
 }  
   
 /**  
1556   * ccs_print_entry - Print an ACL entry.   * ccs_print_entry - Print an ACL entry.
1557   *   *
1558   * @head: Pointer to "struct ccs_io_buffer".   * @head: Pointer to "struct ccs_io_buffer".
# Line 1448  static bool ccs_print_entry(struct ccs_i Line 1569  static bool ccs_print_entry(struct ccs_i
1569                  return true;                  return true;
1570          if (acl_type == CCS_TYPE_PATH_ACL) {          if (acl_type == CCS_TYPE_PATH_ACL) {
1571                  struct ccs_path_acl *acl                  struct ccs_path_acl *acl
1572                          = container_of(ptr, struct ccs_path_acl,                          = container_of(ptr, struct ccs_path_acl, head);
                                        head);  
1573                  return ccs_print_path_acl(head, acl, cond);                  return ccs_print_path_acl(head, acl, cond);
1574          }          }
1575          if (acl_type == CCS_TYPE_EXECUTE_HANDLER) {          if (acl_type == CCS_TYPE_EXECUTE_HANDLER) {
# Line 1475  static bool ccs_print_entry(struct ccs_i Line 1595  static bool ccs_print_entry(struct ccs_i
1595          }          }
1596          if (acl_type == CCS_TYPE_PATH2_ACL) {          if (acl_type == CCS_TYPE_PATH2_ACL) {
1597                  struct ccs_path2_acl *acl                  struct ccs_path2_acl *acl
1598                          = container_of(ptr, struct ccs_path2_acl,                          = container_of(ptr, struct ccs_path2_acl, head);
                                        head);  
1599                  return ccs_print_path2_acl(head, acl, cond);                  return ccs_print_path2_acl(head, acl, cond);
1600          }          }
1601          if (acl_type == CCS_TYPE_PATH_NUMBER_ACL) {          if (acl_type == CCS_TYPE_PATH_NUMBER_ACL) {
1602                  struct ccs_path_number_acl *acl                  struct ccs_path_number_acl *acl
1603                          = container_of(ptr, struct ccs_path_number_acl,                          = container_of(ptr, struct ccs_path_number_acl, head);
                                        head);  
1604                  return ccs_print_path_number_acl(head, acl, cond);                  return ccs_print_path_number_acl(head, acl, cond);
1605          }          }
1606          if (acl_type == CCS_TYPE_ENV_ACL) {          if (acl_type == CCS_TYPE_ENV_ACL) {
# Line 1492  static bool ccs_print_entry(struct ccs_i Line 1610  static bool ccs_print_entry(struct ccs_i
1610          }          }
1611          if (acl_type == CCS_TYPE_CAPABILITY_ACL) {          if (acl_type == CCS_TYPE_CAPABILITY_ACL) {
1612                  struct ccs_capability_acl *acl                  struct ccs_capability_acl *acl
1613                          = container_of(ptr, struct ccs_capability_acl,                          = container_of(ptr, struct ccs_capability_acl, head);
                                        head);  
1614                  return ccs_print_capability_acl(head, acl, cond);                  return ccs_print_capability_acl(head, acl, cond);
1615          }          }
1616          if (acl_type == CCS_TYPE_IP_NETWORK_ACL) {          if (acl_type == CCS_TYPE_IP_NETWORK_ACL) {
1617                  struct ccs_ip_network_acl *acl                  struct ccs_ip_network_acl *acl
1618                          = container_of(ptr, struct ccs_ip_network_acl,                          = container_of(ptr, struct ccs_ip_network_acl, head);
                                        head);  
1619                  return ccs_print_network_acl(head, acl, cond);                  return ccs_print_network_acl(head, acl, cond);
1620          }          }
1621          if (acl_type == CCS_TYPE_SIGNAL_ACL) {          if (acl_type == CCS_TYPE_SIGNAL_ACL) {
# Line 1512  static bool ccs_print_entry(struct ccs_i Line 1628  static bool ccs_print_entry(struct ccs_i
1628                          = container_of(ptr, struct ccs_mount_acl, head);                          = container_of(ptr, struct ccs_mount_acl, head);
1629                  return ccs_print_mount_acl(head, acl, cond);                  return ccs_print_mount_acl(head, acl, cond);
1630          }          }
         if (acl_type == CCS_TYPE_UMOUNT_ACL) {  
                 struct ccs_umount_acl *acl  
                         = container_of(ptr, struct ccs_umount_acl, head);  
                 return ccs_print_umount_acl(head, acl, cond);  
         }  
         if (acl_type == CCS_TYPE_CHROOT_ACL) {  
                 struct ccs_chroot_acl *acl  
                         = container_of(ptr, struct ccs_chroot_acl, head);  
                 return ccs_print_chroot_acl(head, acl, cond);  
         }  
         if (acl_type == CCS_TYPE_PIVOT_ROOT_ACL) {  
                 struct ccs_pivot_root_acl *acl  
                         = container_of(ptr, struct ccs_pivot_root_acl,  
                                        head);  
                 return ccs_print_pivot_root_acl(head, acl, cond);  
         }  
1631          BUG(); /* This must not happen. */          BUG(); /* This must not happen. */
1632          return false;          return false;
1633  }  }
# Line 1626  static int ccs_write_domain_profile(stru Line 1726  static int ccs_write_domain_profile(stru
1726          if (profile >= CCS_MAX_PROFILES)          if (profile >= CCS_MAX_PROFILES)
1727                  return -EINVAL;                  return -EINVAL;
1728          domain = ccs_find_domain(cp + 1);          domain = ccs_find_domain(cp + 1);
1729          if (domain && (ccs_profile_ptr[profile] || !ccs_policy_loaded))          if (domain && (!ccs_policy_loaded || ccs_profile_ptr[(u8) profile]))
1730                  domain->profile = (u8) profile;                  domain->profile = (u8) profile;
1731          return 0;          return 0;
1732  }  }
# Line 1690  static void ccs_read_pid(struct ccs_io_b Line 1790  static void ccs_read_pid(struct ccs_io_b
1790  {  {
1791          char *buf = head->write_buf;          char *buf = head->write_buf;
1792          bool task_info = false;          bool task_info = false;
1793            bool global_pid = false;
1794          unsigned int pid;          unsigned int pid;
1795          struct task_struct *p;          struct task_struct *p;
1796          struct ccs_domain_info *domain = NULL;          struct ccs_domain_info *domain = NULL;
# Line 1702  static void ccs_read_pid(struct ccs_io_b Line 1803  static void ccs_read_pid(struct ccs_io_b
1803          head->read_eof = true;          head->read_eof = true;
1804          if (ccs_str_starts(&buf, "info "))          if (ccs_str_starts(&buf, "info "))
1805                  task_info = true;                  task_info = true;
1806            if (ccs_str_starts(&buf, "global-pid "))
1807                    global_pid = true;
1808          pid = (unsigned int) simple_strtoul(buf, NULL, 10);          pid = (unsigned int) simple_strtoul(buf, NULL, 10);
1809          read_lock(&tasklist_lock);          read_lock(&tasklist_lock);
1810    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
1811            if (global_pid)
1812                    p = find_task_by_pid_ns(pid, &init_pid_ns);
1813            else
1814                    p = find_task_by_vpid(pid);
1815    #else
1816          p = find_task_by_pid(pid);          p = find_task_by_pid(pid);
1817    #endif
1818          if (p) {          if (p) {
1819                  domain = ccs_task_domain(p);                  domain = ccs_task_domain(p);
1820                  ccs_flags = p->ccs_flags;                  ccs_flags = p->ccs_flags;
# Line 1718  static void ccs_read_pid(struct ccs_io_b Line 1828  static void ccs_read_pid(struct ccs_io_b
1828          else          else
1829                  ccs_io_printf(head, "%u manager=%s execute_handler=%s "                  ccs_io_printf(head, "%u manager=%s execute_handler=%s "
1830                                "state[0]=%u state[1]=%u state[2]=%u", pid,                                "state[0]=%u state[1]=%u state[2]=%u", pid,
1831                                ccs_flags & CCS_TASK_IS_POLICY_MANAGER ?                                ccs_yesno(ccs_flags &
1832                                "yes" : "no",                                          CCS_TASK_IS_POLICY_MANAGER),
1833                                ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER ?                                ccs_yesno(ccs_flags &
1834                                "yes" : "no",                                          CCS_TASK_IS_EXECUTE_HANDLER),
1835                                (u8) (ccs_flags >> 24),                                (u8) (ccs_flags >> 24),
1836                                (u8) (ccs_flags >> 16),                                (u8) (ccs_flags >> 16),
1837                                (u8) (ccs_flags >> 8));                                (u8) (ccs_flags >> 8));
# Line 1872  static bool ccs_get_argv0(struct ccs_exe Line 1982  static bool ccs_get_argv0(struct ccs_exe
1982                                  if (c == '\\') {                                  if (c == '\\') {
1983                                          arg_ptr[arg_len++] = '\\';                                          arg_ptr[arg_len++] = '\\';
1984                                          arg_ptr[arg_len++] = '\\';                                          arg_ptr[arg_len++] = '\\';
                                 } else if (c == '/') {  
                                         arg_len = 0;  
1985                                  } else if (c > ' ' && c < 127) {                                  } else if (c > ' ' && c < 127) {
1986                                          arg_ptr[arg_len++] = c;                                          arg_ptr[arg_len++] = c;
1987                                  } else {                                  } else {
# Line 1913  static struct ccs_condition *ccs_get_exe Line 2021  static struct ccs_condition *ccs_get_exe
2021          int len = 256;          int len = 256;
2022          char *realpath = NULL;          char *realpath = NULL;
2023          char *argv0 = NULL;          char *argv0 = NULL;
2024          if (ccs_flags(NULL, CCS_AUTOLEARN_EXEC_REALPATH)) {          const struct ccs_profile *profile = ccs_profile(ee->r.domain->profile);
2025            if (profile->learning->learning_exec_realpath) {
2026                  struct file *file = ee->bprm->file;                  struct file *file = ee->bprm->file;
2027  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
2028                  struct path path = { file->f_vfsmnt, file->f_dentry };                  struct path path = { file->f_vfsmnt, file->f_dentry };
# Line 1924  static struct ccs_condition *ccs_get_exe Line 2033  static struct ccs_condition *ccs_get_exe
2033                  if (realpath)                  if (realpath)
2034                          len += strlen(realpath) + 17;                          len += strlen(realpath) + 17;
2035          }          }
2036          if (ccs_flags(NULL, CCS_AUTOLEARN_EXEC_ARGV0)) {          if (profile->learning->learning_exec_argv0) {
2037                  if (ccs_get_argv0(ee)) {                  if (ccs_get_argv0(ee)) {
2038                          argv0 = ee->tmp;                          argv0 = ee->tmp;
2039                          len += strlen(argv0) + 16;                          len += strlen(argv0) + 16;
2040                  }                  }
2041          }          }
2042          buf = kmalloc(len, GFP_KERNEL);          buf = kmalloc(len, GFP_KERNEL);
2043          if (!buf)          if (!buf) {
2044                    kfree(realpath);
2045                  return NULL;                  return NULL;
2046            }
2047          snprintf(buf, len - 1, "if");          snprintf(buf, len - 1, "if");
2048          if (current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER) {          if (current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER) {
2049                  const int pos = strlen(buf);                  const int pos = strlen(buf);
# Line 1955  static struct ccs_condition *ccs_get_exe Line 2066  static struct ccs_condition *ccs_get_exe
2066          return cond;          return cond;
2067  }  }
2068    
2069    /**
2070     * ccs_get_symlink_condition - Get condition part for symlink requests.
2071     *
2072     * @r: Pointer to "struct ccs_request_info".
2073     *
2074     * Returns pointer to "struct ccs_condition" on success, NULL otherwise.
2075     */
2076    static struct ccs_condition *ccs_get_symlink_condition(struct ccs_request_info
2077                                                           *r)
2078    {
2079            struct ccs_condition *cond;
2080            char *buf;
2081            int len = 256;
2082            const char *symlink = NULL;
2083            const struct ccs_profile *profile = ccs_profile(r->profile);
2084            if (profile->learning->learning_symlink_target) {
2085                    symlink = r->obj->symlink_target->name;
2086                    len += strlen(symlink) + 18;
2087            }
2088            buf = kmalloc(len, GFP_KERNEL);
2089            if (!buf)
2090                    return NULL;
2091            snprintf(buf, len - 1, "if");
2092            if (current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER) {
2093                    const int pos = strlen(buf);
2094                    snprintf(buf + pos, len - pos - 1,
2095                             " task.type=execute_handler");
2096            }
2097            if (symlink) {
2098                    const int pos = strlen(buf);
2099                    snprintf(buf + pos, len - pos - 1, " symlink.target=\"%s\"",
2100                             symlink);
2101            }
2102            cond = ccs_get_condition(buf);
2103            kfree(buf);
2104            return cond;
2105    }
2106    
2107  /* Wait queue for ccs_query_list. */  /* Wait queue for ccs_query_list. */
2108  static DECLARE_WAIT_QUEUE_HEAD(ccs_query_wait);  static DECLARE_WAIT_QUEUE_HEAD(ccs_query_wait);
2109    
# Line 2003  int ccs_supervisor(struct ccs_request_in Line 2152  int ccs_supervisor(struct ccs_request_in
2152          switch (r->mode) {          switch (r->mode) {
2153                  char *buffer;                  char *buffer;
2154                  struct ccs_condition *cond;                  struct ccs_condition *cond;
2155          case CCS_MAC_MODE_LEARNING:          case CCS_CONFIG_LEARNING:
2156                  if (!ccs_domain_quota_ok(r))                  if (!ccs_domain_quota_ok(r))
2157                          return 0;                          return 0;
2158                  va_start(args, fmt);                  va_start(args, fmt);
# Line 2018  int ccs_supervisor(struct ccs_request_in Line 2167  int ccs_supervisor(struct ccs_request_in
2167                  ccs_normalize_line(buffer);                  ccs_normalize_line(buffer);
2168                  if (r->ee && !strncmp(buffer, "allow_execute ", 14))                  if (r->ee && !strncmp(buffer, "allow_execute ", 14))
2169                          cond = ccs_get_execute_condition(r->ee);                          cond = ccs_get_execute_condition(r->ee);
2170                    else if (r->obj && r->obj->symlink_target)
2171                            cond = ccs_get_symlink_condition(r);
2172                  else if ((current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER)) {                  else if ((current->ccs_flags & CCS_TASK_IS_EXECUTE_HANDLER)) {
2173                          char str[] = "if task.type=execute_handler";                          char str[] = "if task.type=execute_handler";
2174                          cond = ccs_get_condition(str);                          cond = ccs_get_condition(str);
# Line 2027  int ccs_supervisor(struct ccs_request_in Line 2178  int ccs_supervisor(struct ccs_request_in
2178                  ccs_put_condition(cond);                  ccs_put_condition(cond);
2179                  kfree(buffer);                  kfree(buffer);
2180                  /* fall through */                  /* fall through */
2181          case CCS_MAC_MODE_PERMISSIVE:          case CCS_CONFIG_PERMISSIVE:
2182                  return 0;                  return 0;
2183          }          }
2184          if (!atomic_read(&ccs_query_observers)) {          if (!atomic_read(&ccs_query_observers)) {
2185                  int i;                  int i;
2186                  if (current->ccs_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR)                  if (current->ccs_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR)
2187                          return -EPERM;                          return -EPERM;
2188                  for (i = 0; i < ccs_flags(r->domain, CCS_SLEEP_PERIOD);                  for (i = 0; i < ccs_profile(r->domain->profile)->enforcing->
2189                       i++) {                               enforcing_penalty; i++) {
2190                          set_current_state(TASK_INTERRUPTIBLE);                          set_current_state(TASK_INTERRUPTIBLE);
2191                          schedule_timeout(HZ / 10);                          schedule_timeout(HZ / 10);
2192                  }                  }
# Line 2260  static void ccs_read_version(struct ccs_ Line 2411  static void ccs_read_version(struct ccs_
2411  {  {
2412          if (head->read_eof)          if (head->read_eof)
2413                  return;                  return;
2414          ccs_io_printf(head, "1.7.0-pre");          ccs_io_printf(head, "1.7.1-pre");
2415          head->read_eof = true;          head->read_eof = true;
2416  }  }
2417    
# Line 2418  int ccs_open_control(const u8 type, stru Line 2569  int ccs_open_control(const u8 type, stru
2569   * Waits for read readiness.   * Waits for read readiness.
2570   * /proc/ccs/query is handled by /usr/sbin/ccs-queryd and   * /proc/ccs/query is handled by /usr/sbin/ccs-queryd and
2571   * /proc/ccs/grant_log and /proc/ccs/reject_log are handled by   * /proc/ccs/grant_log and /proc/ccs/reject_log are handled by
2572   * /usr/sbin/ccs-auditd.   * /usr/sbin/ccs-auditd .
2573   */   */
2574  int ccs_poll_control(struct file *file, poll_table *wait)  int ccs_poll_control(struct file *file, poll_table *wait)
2575  {  {

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

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