mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: m.stachyra@samsung.com
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-trace-kernel@vger.kernel.org" 
	<linux-trace-kernel@vger.kernel.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"mhiramat@kernel.org" <mhiramat@kernel.org>
Subject: Re: [PATCH v2] trace: fix null pointer dereference in tracing_err_log_open()
Date: Wed, 5 Jul 2023 21:52:30 +0900	[thread overview]
Message-ID: <20230705215230.9aafc44d8bd764b6416cf655@kernel.org> (raw)
In-Reply-To: <20230704102706eucms1p30d7ecdcc287f46ad67679fc8491b2e0f@eucms1p3>

On Tue, 04 Jul 2023 12:27:06 +0200
Mateusz Stachyra <m.stachyra@samsung.com> wrote:

> Fix an issue in function 'tracing_err_log_open'.
> The function doesn't call 'seq_open' if file is opened only with
> write permissions, which results in 'file->private_data' being left at null.
> If we then use 'lseek' on that opened file, 'seq_lseek' dereferences
> 'file->private_data' in 'mutex_lock(&m->lock)', resulting in a Kernel panic.
> Writing to this node requires root privilages, therefore this bug
> has very little security impact.
> 
> Tracefs node: /sys/kernel/tracing/error_log
> 
> Example Kernel panic:
> 
> Unable to handle kernel NULL pointer dereference at virtual address 0000000000000038
> Call trace:
>  mutex_lock+0x30/0x110
>  seq_lseek+0x34/0xb8
>  __arm64_sys_lseek+0x6c/0xb8
>  invoke_syscall+0x58/0x13c
>  el0_svc_common+0xc4/0x10c
>  do_el0_svc+0x24/0x98
>  el0_svc+0x24/0x88
>  el0t_64_sync_handler+0x84/0xe4
>  el0t_64_sync+0x1b4/0x1b8
> Code: d503201f aa0803e0 aa1f03e1 aa0103e9 (c8e97d02)
> ---[ end trace 561d1b49c12cf8a5 ]---
> Kernel panic - not syncing: Oops: Fatal exception
> 

Good catch! This looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks!

> Signed-off-by: Mateusz Stachyra <m.stachyra@samsung.com>
> Suggested-by: Steven Rostedt <rostedt@goodmis.org>
> ---
>  kernel/trace/trace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index b04f52e7c..4529e264c 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -8146,7 +8146,7 @@ static const struct file_operations tracing_err_log_fops = {
>  	.open           = tracing_err_log_open,
>  	.write		= tracing_err_log_write,
>  	.read           = seq_read,
> -	.llseek         = seq_lseek,
> +	.llseek         = tracing_lseek,
>  	.release        = tracing_err_log_release,
>  };
>  
> -- 
> 2.25.1


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2023-07-05 12:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230704102706eucms1p30d7ecdcc287f46ad67679fc8491b2e0f@eucms1p3>
2023-07-04 10:27 ` Mateusz Stachyra
2023-07-05 12:52   ` 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=20230705215230.9aafc44d8bd764b6416cf655@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=m.stachyra@samsung.com \
    --cc=rostedt@goodmis.org \
    /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

Powered by JetHome