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: <20250311102928.ae96ceb8870e73e30f6f1279@kernel.org>
Date: Tue, 11 Mar 2025 10:29:28 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH] tracing: probe-events: Cleanup entry-arg storing code

On Thu, 6 Mar 2025 19:14:04 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:

> On Mon,  3 Mar 2025 18:02:29 +0900
> "Masami Hiramatsu (Google)" <mhiramat@...nel.org> wrote:
> 
> > +	/* Search the offset for the sprcified argnum. */
> > +	for (i = 0; i < earg->size - 1 && earg->code[i].op != FETCH_OP_END; i++) {
> > +		if (earg->code[i].op != FETCH_OP_ARG || earg->code[i].param != argnum)
> > +			continue;
> 
> I wonder if you can save a loop by changing this to:
> 
> 		if (earg->code[i].op != FETCH_OP_ARG) {
> 			last_offset = earg->code[i].offset;
> 			continue;
> 		}
> 
> 		if (earg->code[i].param != argnum)
> 			continue;
> 
> 
> > +
> > +		if (WARN_ON_ONCE(earg->code[i + 1].op != FETCH_OP_ST_EDATA))
> > +			continue;
> > +
> > +		return earg->code[i + 1].offset;
> >  	}
> > -	return -ENOSPC;
> > +	if (i >= earg->size - 1)
> > +		return -ENOSPC;
> > +
> > +	/* Not found, append new entry if possible. */
> > +	offset = get_entry_arg_max_offset(earg) + sizeof(unsigned long);
> 
> Then here you could use last_offset instead of running the loop again?

Yeah, but I would like it easier to read and safer (adding WARN_ON)
especially, 

> 		if (earg->code[i].op != FETCH_OP_ARG) {
> 			last_offset = earg->code[i].offset;
> 			continue;
> 		}

this is a bit unsafe if we introduce another operation except for
the FETCH_OP_ARG and FETCH_OP_ST_EDATA. (and it is expecting the
offset is always increased.)

Thank you,

> 
> -- Steve
> 
> 
> > +	store_entry_arg_at(&earg->code[i], argnum, offset);
> > +	return offset;
> >  }
> >  


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ