The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Mathias Krause <minipli@googlemail.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	"yrl.pp-manager.tt@hitachi.com" <yrl.pp-manager.tt@hitachi.com>
Subject: Re: [PATCH] kprobes: handle empty/invalid input to debugfs "enabled" file
Date: Mon, 03 Jun 2013 14:47:25 +0900	[thread overview]
Message-ID: <51AC2DED.90706@hitachi.com> (raw)
In-Reply-To: <1370034910-16268-1-git-send-email-minipli@googlemail.com>

(2013/06/01 6:15), Mathias Krause wrote:
> When writing invalid input to 'debug/kprobes/enabled' it'll silently
> be ignored. Even worse, when writing an empty string to this file,
> the outcome is purely random as the switch statement will make its
> decision based on the value of an uninitialized stack variable.

Oops, right.

> 
> Fix this by handling invalid/empty input as error returning -EINVAL.

Thanks!

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

> 
> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> ---
>  kernel/kprobes.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3fed7f0..948b597 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2322,6 +2322,7 @@ static ssize_t write_enabled_file_bool(struct file *file,
>  	if (copy_from_user(buf, user_buf, buf_size))
>  		return -EFAULT;
>  
> +	buf[buf_size] = '\0';
>  	switch (buf[0]) {
>  	case 'y':
>  	case 'Y':
> @@ -2333,6 +2334,8 @@ static ssize_t write_enabled_file_bool(struct file *file,
>  	case '0':
>  		disarm_all_kprobes();
>  		break;
> +	default:
> +		return -EINVAL;
>  	}
>  
>  	return count;
> 


-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



      reply	other threads:[~2013-06-03  5:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 21:15 [PATCH] kprobes: handle empty/invalid input to debugfs "enabled" file Mathias Krause
2013-06-03  5:47 ` Masami Hiramatsu [this message]

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=51AC2DED.90706@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minipli@googlemail.com \
    --cc=yrl.pp-manager.tt@hitachi.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