lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250421114103.3c006379@gandalf.local.home>
Date: Mon, 21 Apr 2025 11:41:03 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Jeongjun Park <aha310510@...il.com>
Cc: mhiramat@...nel.org, linux-kernel@...r.kernel.org,
 linux-trace-kernel@...r.kernel.org,
 syzbot+c8cd2d2c412b868263fb@...kaller.appspotmail.com
Subject: Re: [PATCH v2] tracing: fix oob write in trace_seq_to_buffer()

On Tue, 22 Apr 2025 00:28:50 +0900
Jeongjun Park <aha310510@...il.com> wrote:

> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -6784,7 +6784,7 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
>  	};
>  	ssize_t ret;
>  	size_t rem;
> -	unsigned int i;
> +	unsigned int i, copy_len;

FYI, I don't care for variables to be on the same line unless they are
related. As "i" and "copy_len" are not related, the should be separate
declarations.

	unsigned int copy_len;
	unsigned int i;

>  
>  	if (splice_grow_spd(pipe, &spd))
>  		return -ENOMEM;
> @@ -6818,16 +6818,18 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
>  
>  		rem = tracing_fill_pipe_page(rem, iter);
>  
> +		copy_len = trace_seq_used(&iter->seq);

Why not have the min here?

		copy_len = min(trace_seq_used(&iter->seq), PAGE_SIZE);

??

> +
>  		/* Copy the data into the page, so we can start over. */
>  		ret = trace_seq_to_buffer(&iter->seq,
>  					  page_address(spd.pages[i]),
> -					  trace_seq_used(&iter->seq));
> +					  min(copy_len, PAGE_SIZE));
>  		if (ret < 0) {
>  			__free_page(spd.pages[i]);
>  			break;
>  		}
>  		spd.partial[i].offset = 0;
> -		spd.partial[i].len = trace_seq_used(&iter->seq);
> +		spd.partial[i].len = min(copy_len, PAGE_SIZE);

And actually, len should equal ret as that's how much was copied.

-- Steve


>  
>  		trace_seq_init(&iter->seq);
>  	}
> --


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ