From 0c705be9609931920c299e76811b21acc9502f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Aur=C3=A8le=20La=20France?= Date: Mon, 20 Feb 2023 22:10:32 -0700 Subject: [PATCH 1/3] Remove orphaned CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the commit 93d102f094be9beab2 ("printk: remove safe buffers"), CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT is no longer useful. Remove it. Signed-off-by: Marc Aurèle La France Reviewed-by: John Ogness Reviewed-by: Sergey Senozhatsky Reviewed-by: Petr Mladek [pmladek@suse.cz: Cleaned up the commit message.] Signed-off-by: Petr Mladek Fixes: 93d102f094be9beab ("printk: remove safe buffers") Link: https://lore.kernel.org/r/5c19e248-1b6b-330c-7c4c-a824688daefe@tuyoix.net --- arch/powerpc/configs/microwatt_defconfig | 1 - arch/riscv/configs/nommu_k210_defconfig | 1 - .../riscv/configs/nommu_k210_sdcard_defconfig | 1 - arch/riscv/configs/nommu_virt_defconfig | 1 - init/Kconfig | 24 ------------------- 5 files changed, 28 deletions(-) diff --git a/arch/powerpc/configs/microwatt_defconfig b/arch/powerpc/configs/microwatt_defconfig index 18d4fe4108cb..795a127908e7 100644 --- a/arch/powerpc/configs/microwatt_defconfig +++ b/arch/powerpc/configs/microwatt_defconfig @@ -4,7 +4,6 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_PREEMPT_VOLUNTARY=y CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_LOG_BUF_SHIFT=16 -CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12 CONFIG_CGROUPS=y CONFIG_BLK_DEV_INITRD=y CONFIG_CC_OPTIMIZE_FOR_SIZE=y diff --git a/arch/riscv/configs/nommu_k210_defconfig b/arch/riscv/configs/nommu_k210_defconfig index 79b3ccd58ff0..e36fffd6fb18 100644 --- a/arch/riscv/configs/nommu_k210_defconfig +++ b/arch/riscv/configs/nommu_k210_defconfig @@ -1,6 +1,5 @@ # CONFIG_CPU_ISOLATION is not set CONFIG_LOG_BUF_SHIFT=13 -CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12 CONFIG_BLK_DEV_INITRD=y # CONFIG_RD_GZIP is not set # CONFIG_RD_BZIP2 is not set diff --git a/arch/riscv/configs/nommu_k210_sdcard_defconfig b/arch/riscv/configs/nommu_k210_sdcard_defconfig index 6b80bb13b8ed..c1ad85f0a4f7 100644 --- a/arch/riscv/configs/nommu_k210_sdcard_defconfig +++ b/arch/riscv/configs/nommu_k210_sdcard_defconfig @@ -1,6 +1,5 @@ # CONFIG_CPU_ISOLATION is not set CONFIG_LOG_BUF_SHIFT=13 -CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12 CONFIG_CC_OPTIMIZE_FOR_SIZE=y # CONFIG_SYSFS_SYSCALL is not set # CONFIG_FHANDLE is not set diff --git a/arch/riscv/configs/nommu_virt_defconfig b/arch/riscv/configs/nommu_virt_defconfig index 4cf0f297091e..b794e2f8144e 100644 --- a/arch/riscv/configs/nommu_virt_defconfig +++ b/arch/riscv/configs/nommu_virt_defconfig @@ -1,6 +1,5 @@ # CONFIG_CPU_ISOLATION is not set CONFIG_LOG_BUF_SHIFT=16 -CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12 CONFIG_BLK_DEV_INITRD=y # CONFIG_RD_BZIP2 is not set # CONFIG_RD_LZMA is not set diff --git a/init/Kconfig b/init/Kconfig index 77a4318a6043..77c89142e44f 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -769,30 +769,6 @@ config LOG_CPU_MAX_BUF_SHIFT 13 => 8 KB for each CPU 12 => 4 KB for each CPU -config PRINTK_SAFE_LOG_BUF_SHIFT - int "Temporary per-CPU printk log buffer size (12 => 4KB, 13 => 8KB)" - range 10 21 - default 13 - depends on PRINTK - help - Select the size of an alternate printk per-CPU buffer where messages - printed from unsafe contexts are temporary stored. One example would - be NMI messages, another one - printk recursion. The messages are - copied to the main log buffer in a safe context to avoid a deadlock. - The value defines the size as a power of 2. - - Those messages are rare and limited. The largest one is when - a backtrace is printed. It usually fits into 4KB. Select - 8KB if you want to be on the safe side. - - Examples: - 17 => 128 KB for each CPU - 16 => 64 KB for each CPU - 15 => 32 KB for each CPU - 14 => 16 KB for each CPU - 13 => 8 KB for each CPU - 12 => 4 KB for each CPU - config PRINTK_INDEX bool "Printk indexing debugfs interface" depends on PRINTK && DEBUG_FS From 48e1a66fecb4e8b64cf2a0a8978c048990181d94 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 27 Mar 2023 17:27:21 +0300 Subject: [PATCH 2/3] lib/vsprintf: Use isodigit() for the octal number check Use isodigit() to test the octal number instead of homegrown approach. Signed-off-by: Andy Shevchenko Reviewed-by: Sergey Senozhatsky Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20230327142721.48378-1-andriy.shevchenko@linux.intel.com --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index be71a03c936a..426418253fd4 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -3621,7 +3621,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args) if (!digit || (base == 16 && !isxdigit(digit)) || (base == 10 && !isdigit(digit)) - || (base == 8 && (!isdigit(digit) || digit > '7')) + || (base == 8 && !isodigit(digit)) || (base == 0 && !isdigit(digit))) break; From bee43904dc774b35bb159693ff3f3ff222590bb1 Mon Sep 17 00:00:00 2001 From: Stanislav Kinsburskii Date: Mon, 20 Mar 2023 00:02:01 -0700 Subject: [PATCH 3/3] printk: Remove obsoleted check for non-existent "user" object The original check for non-null "user" object was introduced by commit e11fea92e13f ("kmsg: export printk records to the /dev/kmsg interface") when "user" could be NULL if /dev/ksmg was opened for writing. Subsequent change 750afe7babd1 ("printk: add kernel parameter to control writes to /dev/kmsg") made "user" context required for files opened for write, but didn't remove now redundant checks for it to be non-NULL. This patch removes the dead code while preserving the current logic. Signed-off-by: Stanislav Kinsburskii CC: Petr Mladek CC: Sergey Senozhatsky CC: Steven Rostedt CC: John Ogness CC: linux-kernel@vger.kernel.org Reviewed-by: Sergey Senozhatsky Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/167929571877.2810.9926967619100618792.stgit@skinsburskii.localdomain --- kernel/printk/printk.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index fd0c9f913940..9644f6e5bf15 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -730,7 +730,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) size_t len = iov_iter_count(from); ssize_t ret = len; - if (!user || len > PRINTKRB_RECORD_MAX) + if (len > PRINTKRB_RECORD_MAX) return -EINVAL; /* Ignore when user logging is disabled. */ @@ -792,9 +792,6 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, }; ssize_t ret; - if (!user) - return -EBADF; - ret = mutex_lock_interruptible(&user->lock); if (ret) return ret; @@ -859,8 +856,6 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence) struct devkmsg_user *user = file->private_data; loff_t ret = 0; - if (!user) - return -EBADF; if (offset) return -ESPIPE; @@ -893,9 +888,6 @@ static __poll_t devkmsg_poll(struct file *file, poll_table *wait) struct printk_info info; __poll_t ret = 0; - if (!user) - return EPOLLERR|EPOLLNVAL; - poll_wait(file, &log_wait, wait); if (prb_read_valid_info(prb, atomic64_read(&user->seq), &info, NULL)) { @@ -944,9 +936,6 @@ static int devkmsg_release(struct inode *inode, struct file *file) { struct devkmsg_user *user = file->private_data; - if (!user) - return 0; - ratelimit_state_exit(&user->rs); mutex_destroy(&user->lock);