+ printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patch added to -mm tree
Subsystems (3)
[email protected]
tree noticeThe patch titled
Subject: printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes
has been added to the -mm tree. Its filename is
printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes
ERROR: else should follow close brace '}'
#160: FILE: kernel/printk/printk.c:120:
+ }
+ else
WARNING: line over 80 characters
#263: FILE: kernel/printk/printk.c:745:
+ if ((system_state != SYSTEM_BOOTING) && !(devkmsg_log & DEVKMSG_LOG_MASK_ON)) {
total: 1 errors, 1 warnings, 250 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
./patches/printk-add-kernel-parameter-to-control-writes-to-dev-kmsg.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
Please run checkpatch prior to sending patches
---
kernel/printk/printk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/printk/printk.c renamed from kernel/printk/printk.c~printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes +1 -2
@@ -117,8 +117,7 @@ static int __control_devkmsg(char *str) devkmsg_log =DEVKMSG_LOG_MASK_DEFAULT ;return 9 ; } -else -return -EINVAL ; +return -EINVAL ; }static int __init control_devkmsg (char *str)
_
Patches currently in -mm which might be from [email protected] are
i-need-old-gcc.patch
arch-alpha-kernel-systblss-remove-debug-check.patch arm-arch-arm-include-asm-pageh-needs-personalityh.patch ocfs2-improve-recovery-performance-v2-fix.patch ocfs2-dlm-disable-bug_on-when-dlm_lock_res_dropping_ref-is-cleared-before-dlm_deref_lockres_done_handler-fix.patch mm.patch
mm-reorganize-slab-freelist-randomization-fix.patch mm-balloon-use-general-non-lru-movable-page-feature-fix.patch mm-compaction-split-freepages-without-holding-the-zone-lock-fix-2.patch mm-frontswap-convert-frontswap_enabled-to-static-key-checkpatch-fixes.patch mm-add-nr_zsmalloc-to-vmstat-fix.patch mm-memcg-use-consistent-gfp-flags-during-readahead-checkpatch-fixes.patch mm-thp-make-swapin-readahead-under-down_read-of-mmap_sem-fix-2-fix.patch mm-fix-build-warnings-in-linux-compactionh-fix.patch mm-update-the-comment-in-__isolate_free_page-checkpatch-fixes.patch treewide-replace-obsolete-_refok-by-__ref-checkpatch-fixes.patch printk-create-pr_level-functions-fix.patch printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patch kexec-ensure-user-memory-sizes-do-not-wrap-fix.patch kexec-allow-architectures-to-override-boot-mapping-fix.patch allow-kdump-with-crash_kexec_post_notifiers-fix.patch
linux-next-rejects.patch
drivers-net-wireless-intel-iwlwifi-dvm-calibc-fix-min-warning.patch bitmap-bitmap_equal-memcmp-optimization-fix.patch kernel-forkc-export-kernel_thread-to-modules.patch
slab-leaks3-default-y.patch
Hi Andrew,
Quoted 28 lines · On Mon, Jul 18, 2016 at 02:27:48PM -0700, [email protected] wrote:
The patch titled
Subject: printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes
has been added to the -mm tree. Its filename is
printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patchThis patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixes.patchBefore you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's*** Remember to use
Documentation/SubmitChecklistwhen testing your code ***The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: printk-add-kernel-parameter-to-control-writes-to-dev-kmsg-checkpatch-fixesERROR: else should follow close brace '}'
#160: FILE:kernel/printk/printk.c:120:
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + else
Thanks for catching this, here's an updated 2/2 patch with the above integrated and the SYSTEM_BOOTING check removed because we set system_state to SYSTEM_RUNNING before we start init.
---
From: Borislav Petkov <[email protected]>
Date: Tue, 14 Jun 2016 11:55:58 +0200
Subject: [PATCH -v5.1] printk: Add kernel parameter to control writes to /dev/kmsg
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add a "printk.devkmsg" kernel command line parameter which controls how userspace writes into /dev/kmsg. It has three options:
* ratelimit - ratelimit logging from userspace.
* on - unlimited logging from userspace
* off - logging from userspace gets ignored
The default setting is to ratelimit the messages written to it.
This changes the kernel default setting of "on" to "ratelimit" and we do that because we want to keep userspace spamming /dev/kmsg to sane levels. This is especially moot when a small kernel log buffer wraps around and messages get lost. So the ratelimiting setting should be a sane setting where kernel messages should have a bit higher chance of survival from all the spamming.
Furthermore, we can control the logging from a lower priority sysctl interface - kernel.printk_devkmsg.
That interface will succeed only if printk.devkmsg *hasn't* been supplied on the command line. If it has, then printk.devkmsg is a one-time setting which remains for the duration of the system lifetime. This "locking" of the setting is to prevent userspace from changing the logging on us through sysctl(2).
This patch is based on previous patches from Linus and Steven.
--- Documentation/kernel-parameters.txt | 7 ++ Documentation/sysctl/kernel.txt | 14 ++++ include/linux/printk.h | 9 +++ kernel/printk/printk.c | 142 ++++++++++++++++++++++++++++++++++-- kernel/sysctl.c | 7 ++ 5 files changed, 171 insertions(+), 8 deletions(-)
Documentation/kernel-parameters.txt +7 -0
@@ -3150,6 +3150,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted. Format: <bool> (1/Y/y=enable, 0/N/n=disable) default: disabled + printk.devkmsg={on,off,ratelimit} + Control writing to /dev/kmsg. + on - unlimited logging to /dev/kmsg from userspace + off - logging to /dev/kmsg disabled + ratelimit - ratelimit the logging + Default: ratelimit + printk.time= Show timing data prefixed to each printk message line Format: <bool> (1/Y/y=enable, 0/N/n=disable)
Documentation/sysctl/kernel.txt +14 -0
@@ -752,6 +752,20 @@ send before ratelimiting kicks in. ============================================================== +printk_devkmsg: + +Control the logging to /dev/kmsg from userspace: + +ratelimit: default, ratelimited +on: unlimited logging to /dev/kmsg from userspace +off: logging to /dev/kmsg disabled + +The kernel command line parameter printk.devkmsg= overrides this and is +a one-time setting until next reboot: once set, it cannot be changed by +this sysctl interface anymore. + +============================================================== + randomize_va_space: This option can be used to select the type of process address
include/linux/printk.h +9 -0
@@ -61,6 +61,11 @@ static inline void console_verbose(void) console_loglevel =CONSOLE_LOGLEVEL_MOTORMOUTH ; } +/* strlen("ratelimit") + 1 */ +#define DEVKMSG_STR_MAX_SIZE 10 +extern char devkmsg_log_str[]; +struct ctl_table ; +struct va_format {const char *fmt;va_list *va;
@@ -172,6 +177,10 @@ extern int printk_delay_msec;extern int dmesg_restrict;extern int kptr_restrict; +extern int +devkmsg_sysctl_set_loglvl (struct ctl_table *table,int write,void __user *buf, +size_t *lenp,loff_t *ppos); +extern void wake_up_klogd (void );char *log_buf_addr_get (void );
kernel/printk/printk.c +134 -8
182 lines not on this page · raw message
kernel/sysctl.c +7 -0
@@ -814,6 +814,13 @@ static struct ctl_table kern_table[] = { .extra2 = &ten_thousand, }, { + .procname = "printk_devkmsg", + .data = devkmsg_log_str, + .maxlen = DEVKMSG_STR_MAX_SIZE, + .mode = 0644, + .proc_handler = devkmsg_sysctl_set_loglvl, + }, + { .procname = "dmesg_restrict", .data = &dmesg_restrict, .maxlen = sizeof(int),
Signature · 10 lines
2.8.4
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--kbuild test robot
build botRe: [PATCH -v5.1] printk: Add kernel parameter to control writes to /dev/kmsg
reproduce:
Hi,
[auto build test ERROR on stable/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Borislav-Petkov/printk-Add-kernel-parameter-to-control-writes-to-dev-kmsg/20160725-003035 base: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master config: x86_64-randconfig-x012-201630 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
kernel/printk/printk.c: In function 'devkmsg_open':
>> kernel/printk/printk.c:937:2: error: implicit declaration of function 'ratelimit_default_init' [-Werror=implicit-function-declaration]
ratelimit_default_init(&user->rs);
^~~~~~~~~~~~~~~~~~~~~~
>> kernel/printk/printk.c:938:2: error: implicit declaration of function 'ratelimit_set_flags' [-Werror=implicit-function-declaration]
ratelimit_set_flags(&user->rs, RATELIMIT_MSG_ON_RELEASE);
^~~~~~~~~~~~~~~~~~~
>> kernel/printk/printk.c:938:33: error: 'RATELIMIT_MSG_ON_RELEASE' undeclared (first use in this function)
ratelimit_set_flags(&user->rs, RATELIMIT_MSG_ON_RELEASE);
^~~~~~~~~~~~~~~~~~~~~~~~
kernel/printk/printk.c:938:33: note: each undeclared identifier is reported only once for each function it appears in
kernel/printk/printk.c: In function 'devkmsg_release':
>> kernel/printk/printk.c:958:2: error: implicit declaration of function 'ratelimit_state_exit' [-Werror=implicit-function-declaration]
ratelimit_state_exit(&user->rs);
^~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/ratelimit_default_init +937 kernel/printk/printk.c
931 }
932
933 user = kmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);
934 if (!user)
935 return -ENOMEM;
936
> 937 ratelimit_default_init(&user->rs);
> 938 ratelimit_set_flags(&user->rs, RATELIMIT_MSG_ON_RELEASE);
939
940 mutex_init(&user->lock);
941
942 raw_spin_lock_irq(&logbuf_lock);
943 user->idx = log_first_idx;
944 user->seq = log_first_seq;
945 raw_spin_unlock_irq(&logbuf_lock);
946
947 file->private_data = user;
948 return 0;
949 }
950
951 static int devkmsg_release(struct inode *inode, struct file *file)
952 {
953 struct devkmsg_user *user = file->private_data;
954
955 if (!user)
956 return 0;
957
> 958 ratelimit_state_exit(&user->rs); 959
960 mutex_destroy(&user->lock);
961 kfree(user);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH -v5.1] printk: Add kernel parameter to control writes to /dev/kmsg
Quoted 7 lines · kbuild test robot
Hi,
[auto build test ERROR on stable/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Borislav-Petkov/printk-Add-kernel-parameter-to-control-writes-to-dev-kmsg/20160725-003035 base: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git master
Yes, that's definitely the wrong tree.
Those patches are queued in the mm tree, you can test that one.
Thanks.
Signature · 7 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--