linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sysrq: Restore original console_loglevel when sysrq disabled
Date: Fri, 11 Jan 2019 22:07:29 +0900	[thread overview]
Message-ID: <20190111130729.GA31790@tigerII.localdomain> (raw)
In-Reply-To: <20190111124515.11017-1-pmladek@suse.com>

On (01/11/19 13:45), Petr Mladek wrote:
> The sysrq header line is printed with an increased loglevel
> to provide users some positive feedback.
> 
> The original loglevel is not restored when the sysrq operation
> is disabled. This bug was introduced in 2.6.12 (pre-git-history)
> by the commit ("Allow admin to enable only some of the Magic-Sysrq
> functions").


Good find, and the patch looks OK to me. A small comment below.
FWIW,
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>


---

A side note (nitpick, etc.); it's Friday night in here, I'm enjoying
my beer; so maybe I'm wrong about the whole thing.


> @@ -553,6 +553,7 @@ void __handle_sysrq(int key, bool check_mask)
>  			op_p->handler(key);
>  		} else {
>  			pr_cont("This sysrq operation is disabled.\n");
> +			console_loglevel = orig_log_level;
>  		}

This looks a bit racy.

When we do

	printk("FOO\n");
	console_loglevel = XYZ;

We don't have any real guarantees that printk("FOO\n") will print
anything straight ahead. It is possible that console_sem is already
locked and the owner is preempted, so by the time the console_sem
owner picks up that FOO\n messages, console_loglevel is back to
orig_log_level and suppress_message_printing() will just tell us
to skip the message.

Do we need pr_cont() there? Maybe we can just have a normal pr_err()
which would always tell that "key" sysrq is disabled? (we also
would need to change the error message a bit).

	-ss

  reply	other threads:[~2019-01-11 13:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11 12:45 [PATCH] sysrq: Restore original console_loglevel when sysrq disabled Petr Mladek
2019-01-11 13:07 ` Sergey Senozhatsky [this message]
2019-01-11 15:32   ` Petr Mladek
2019-01-14  5:36     ` Sergey Senozhatsky
2019-01-14 14:37       ` Petr Mladek
2019-01-11 16:24   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190111130729.GA31790@tigerII.localdomain \
    --to=sergey.senozhatsky@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).