Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1510431 > unrolled thread
| Started by | Petr Mladek <pmladek@suse.com> |
|---|---|
| First post | 2016-10-27 18:00 +0200 |
| Last post | 2016-10-31 10:00 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/4] printk: Fixes and hardening related to KERN_CONT Petr Mladek <pmladek@suse.com> - 2016-10-27 18:00 +0200
[PATCH 3/4] printk/btrfs: Handle more message headers Petr Mladek <pmladek@suse.com> - 2016-10-27 18:00 +0200
Re: [PATCH 3/4] printk/btrfs: Handle more message headers Joe Perches <joe@perches.com> - 2016-10-27 18:20 +0200
Re: [PATCH 3/4] printk/btrfs: Handle more message headers David Sterba <dsterba@suse.cz> - 2016-10-31 10:00 +0100
| From | Petr Mladek <pmladek@suse.com> |
|---|---|
| Date | 2016-10-27 18:00 +0200 |
| Subject | [PATCH 0/4] printk: Fixes and hardening related to KERN_CONT |
| Message-ID | <swVfX-3Pm-7@gated-at.bofh.it> |
The first patch fixes a messed output of continuous lines when printing backtraces for all CPUs via NMI. It works well for me. The other patches fix problems that I noticed when working on the first patch. It would be great if the respective maintainers could do some more testing of them. Well, it touches several modules. But they are related to one commit so I send them together. Note that the 4th patch depends on the 2nd one. Petr Mladek (4): printk/NMI: Handle continuous lines and missing newline printk/kdb: Handle more message headers printk/btrfs: Handle more message headers printk/sound: Handle more message headers fs/btrfs/super.c | 28 +++++++++-------- include/linux/printk.h | 8 +++++ kernel/debug/kdb/kdb_io.c | 2 +- kernel/printk/nmi.c | 78 +++++++++++++++++++++++++++++------------------ sound/core/misc.c | 22 +++++++------ 5 files changed, 86 insertions(+), 52 deletions(-) -- 1.8.5.6
[toc] | [next] | [standalone]
| From | Petr Mladek <pmladek@suse.com> |
|---|---|
| Date | 2016-10-27 18:00 +0200 |
| Subject | [PATCH 3/4] printk/btrfs: Handle more message headers |
| Message-ID | <swVfY-3Pm-49@gated-at.bofh.it> |
| In reply to | #1510431 |
The commit 4bcc595ccd80decb4245096e ("printk: reinstate KERN_CONT for
printing continuation lines") allows to define more message headers
for a single message. The motivation is that continuous lines might
get mixed. Therefore it make sense to define the right log level
for every piece of a cont line.
The current btrfs_printk() macros do not support continuous lines
at the moment. But better be prepared for a custom messages and
avoid potential "lvl" buffer overflow.
This patch iterates over the entire message header. It is interested
only into the message level like the original code.
Note that 3 bytes should be enough for the header buffer. I am not
sure where the 4 bytes came from. Maybe it expected that both
KERN_SOH and the log level strings end with '\0' but they
are concatenated.
Also I fixed the default ratelimit level. It looked very strange
when it was different from the default log level.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
fs/btrfs/super.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 74ed5aae6cea..2d836c676895 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -202,27 +202,29 @@ void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function
void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
{
struct super_block *sb = fs_info->sb;
- char lvl[4];
+ char lvl[3];
struct va_format vaf;
va_list args;
- const char *type = logtypes[4];
+ const char *type = NULL;
int kern_level;
struct ratelimit_state *ratelimit;
va_start(args, fmt);
- kern_level = printk_get_level(fmt);
- if (kern_level) {
- size_t size = printk_skip_level(fmt) - fmt;
- memcpy(lvl, fmt, size);
- lvl[size] = '\0';
- fmt += size;
- type = logtypes[kern_level - '0'];
- ratelimit = &printk_limits[kern_level - '0'];
- } else {
+ while ((kern_level = printk_get_level(fmt)) != 0) {
+ if (kern_level >= '0' || kern_level <= '7') {
+ memcpy(lvl, fmt, 2);
+ lvl[2] = '\0';
+ type = logtypes[kern_level - '0'];
+ ratelimit = &printk_limits[kern_level - '0'];
+ }
+ fmt += 2;
+ }
+
+ if (!type) {
*lvl = '\0';
- /* Default to debug output */
- ratelimit = &printk_limits[7];
+ type = logtypes[4];
+ ratelimit = &printk_limits[4];
}
vaf.fmt = fmt;
--
1.8.5.6
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-27 18:20 +0200 |
| Subject | Re: [PATCH 3/4] printk/btrfs: Handle more message headers |
| Message-ID | <swVzj-4eL-15@gated-at.bofh.it> |
| In reply to | #1510437 |
On Thu, 2016-10-27 at 17:52 +0200, Petr Mladek wrote:
> Note that 3 bytes should be enough for the header buffer. I am not
> sure where the 4 bytes came from. Maybe it expected that both
> KERN_SOH and the log level strings end with '\0' but they
> are concatenated.
I believe it was from when KERN_<LEVEL> was ascii "<[0-7]>"
and not KERN_SOH "[0-7]". I just didn't change the size.
see: commit e2aed8dfa50b ("btrfs: use printk_get_level and printk_skip_level, add __printf, fix fallout")
[toc] | [prev] | [next] | [standalone]
| From | David Sterba <dsterba@suse.cz> |
|---|---|
| Date | 2016-10-31 10:00 +0100 |
| Subject | Re: [PATCH 3/4] printk/btrfs: Handle more message headers |
| Message-ID | <sygBI-8tq-13@gated-at.bofh.it> |
| In reply to | #1510437 |
On Thu, Oct 27, 2016 at 05:52:53PM +0200, Petr Mladek wrote:
> The commit 4bcc595ccd80decb4245096e ("printk: reinstate KERN_CONT for
> printing continuation lines") allows to define more message headers
> for a single message. The motivation is that continuous lines might
> get mixed. Therefore it make sense to define the right log level
> for every piece of a cont line.
>
> The current btrfs_printk() macros do not support continuous lines at
> the moment. But better be prepared for a custom messages and avoid
> potential "lvl" buffer overflow.
I don't think we'll want to support continued lines. The macros just
print additional information about the filesystem and the message is
supposed to be on one line. If there's multi-line string, the raw printk
calls are used (and currently only for debugging purposes).
Acked-by: David Sterba <dsterba@suse.com>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web