~ubuntu-branches/ubuntu/wily/linux-ti-omap4/wily

« back to all changes in this revision

Viewing changes to kernel/printk.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2013-07-11 18:35:20 UTC
  • Revision ID: package-import@ubuntu.com-20130711183520-htnf1x4y5r11hndr
Tags: 3.5.0-229.42
* Release Tracking Bug
  - LP: #1199276

[ Paolo Pisati ]

* [Config] CONFIG_ATH9K_LEGACY_RATE_CONTROL is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
357
357
        log_next_seq++;
358
358
}
359
359
 
 
360
#ifdef CONFIG_SECURITY_DMESG_RESTRICT
 
361
int dmesg_restrict = 1;
 
362
#else
 
363
int dmesg_restrict;
 
364
#endif
 
365
 
 
366
static int syslog_action_restricted(int type)
 
367
{
 
368
        if (dmesg_restrict)
 
369
                return 1;
 
370
        /*
 
371
         * Unless restricted, we allow "read all" and "get buffer size"
 
372
         * for everybody.
 
373
         */
 
374
        return type != SYSLOG_ACTION_READ_ALL &&
 
375
               type != SYSLOG_ACTION_SIZE_BUFFER;
 
376
}
 
377
 
 
378
static int check_syslog_permissions(int type, bool from_file)
 
379
{
 
380
        /*
 
381
         * If this is from /proc/kmsg and we've already opened it, then we've
 
382
         * already done the capabilities checks at open time.
 
383
         */
 
384
        if (from_file && type != SYSLOG_ACTION_OPEN)
 
385
                return 0;
 
386
 
 
387
        if (syslog_action_restricted(type)) {
 
388
                if (capable(CAP_SYSLOG))
 
389
                        return 0;
 
390
                /*
 
391
                 * For historical reasons, accept CAP_SYS_ADMIN too, with
 
392
                 * a warning.
 
393
                 */
 
394
                if (capable(CAP_SYS_ADMIN)) {
 
395
                        pr_warn_once("%s (%d): Attempt to access syslog with "
 
396
                                     "CAP_SYS_ADMIN but no CAP_SYSLOG "
 
397
                                     "(deprecated).\n",
 
398
                                 current->comm, task_pid_nr(current));
 
399
                        return 0;
 
400
                }
 
401
                return -EPERM;
 
402
        }
 
403
        return security_syslog(type);
 
404
}
 
405
 
 
406
 
360
407
/* /dev/kmsg - userspace message inject/listen interface */
361
408
struct devkmsg_user {
362
409
        u64 seq;
592
639
        if ((file->f_flags & O_ACCMODE) == O_WRONLY)
593
640
                return 0;
594
641
 
595
 
        err = security_syslog(SYSLOG_ACTION_READ_ALL);
 
642
        err = check_syslog_permissions(SYSLOG_ACTION_READ_ALL,
 
643
                                       SYSLOG_FROM_READER);
596
644
        if (err)
597
645
                return err;
598
646
 
765
813
int dmesg_restrict;
766
814
#endif
767
815
 
768
 
static int syslog_action_restricted(int type)
769
 
{
770
 
        if (dmesg_restrict)
771
 
                return 1;
772
 
        /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
773
 
        return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
774
 
}
775
 
 
776
 
static int check_syslog_permissions(int type, bool from_file)
777
 
{
778
 
        /*
779
 
         * If this is from /proc/kmsg and we've already opened it, then we've
780
 
         * already done the capabilities checks at open time.
781
 
         */
782
 
        if (from_file && type != SYSLOG_ACTION_OPEN)
783
 
                return 0;
784
 
 
785
 
        if (syslog_action_restricted(type)) {
786
 
                if (capable(CAP_SYSLOG))
787
 
                        return 0;
788
 
                /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
789
 
                if (capable(CAP_SYS_ADMIN)) {
790
 
                        printk_once(KERN_WARNING "%s (%d): "
791
 
                                 "Attempt to access syslog with CAP_SYS_ADMIN "
792
 
                                 "but no CAP_SYSLOG (deprecated).\n",
793
 
                                 current->comm, task_pid_nr(current));
794
 
                        return 0;
795
 
                }
796
 
                return -EPERM;
797
 
        }
798
 
        return 0;
799
 
}
800
 
 
801
816
#if defined(CONFIG_PRINTK_TIME)
802
817
static bool printk_time = 1;
803
818
#else
1195
1210
 
1196
1211
SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
1197
1212
{
1198
 
        return do_syslog(type, buf, len, SYSLOG_FROM_CALL);
 
1213
        return do_syslog(type, buf, len, SYSLOG_FROM_READER);
1199
1214
}
1200
1215
 
1201
1216
static bool __read_mostly ignore_loglevel;