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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 Nov 2021 16:37:59 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Daniel Bristot de Oliveira <bristot@...nel.org>
Cc:     Tao Zhou <tao.zhou@...ux.dev>, Ingo Molnar <mingo@...hat.com>,
        Tom Zanussi <zanussi@...nel.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Clark Williams <williams@...hat.com>,
        John Kacur <jkacur@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        linux-rt-users@...r.kernel.org, linux-trace-devel@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH V7 02/14] rtla: Helper functions for rtla

On Fri, 29 Oct 2021 21:26:05 +0200
Daniel Bristot de Oliveira <bristot@...nel.org> wrote:

> +/*
> + * enable_tracer_by_name - enable a tracer on the given instance
> + */
> +int enable_tracer_by_name(struct tracefs_instance *inst, const char *tracer)
> +{
> +	enum tracefs_tracers t;
> +	int retval;
> +
> +	t = TRACEFS_TRACER_CUSTOM;
> +
> +	debug_msg("enabling %s tracer\n", tracer);
> +
> +	retval = tracefs_tracer_set(inst, t, tracer);

Interesting. We had discussions about having the custom option (which I
fought for, for this very reason).

> +	if (retval < 0) {
> +		if (errno == ENODEV)
> +			err_msg("tracer %s not found!\n", tracer);
> +
> +		err_msg("failed to enable the tracer %s\n", tracer);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +/*
> + * disable_tracer - set nop tracer to the insta
> + */
> +void disable_tracer(struct tracefs_instance *inst)
> +{
> +	enum tracefs_tracers t = TRACEFS_TRACER_NOP;
> +	int retval;
> +
> +	retval = tracefs_tracer_set(inst, t);
> +	if (retval < 0)
> +		err_msg("oops, error disabling tracer\n");
> +}
> +
> +/*
> + * create_instance - create a trace instance with *instance_name
> + */
> +struct tracefs_instance *create_instance(char *instance_name)
> +{
> +	return tracefs_instance_create(instance_name);
> +}
> +
> +/*
> + * destroy_instance - remove a trace instance and free the data
> + */
> +void destroy_instance(struct tracefs_instance *inst)
> +{
> +	tracefs_instance_destroy(inst);
> +	tracefs_instance_free(inst);
> +}
> +
> +/*
> + * save_trace_to_file - save the trace output of the instance to the file
> + */
> +int save_trace_to_file(struct tracefs_instance *inst, const char *filename)
> +{
> +	const char *file = "trace";
> +	mode_t mode = 0644;
> +	char *buffer[4096];

Did you really mean to have buffer be 4096 strings?

Or did you mean:

	char buffer[4096];

(i.e. a single string of 4096 size)?

-- Steve

> +	int out_fd, in_fd;
> +	int retval = -1;
> +
> +	in_fd = tracefs_instance_file_open(inst, file, O_RDONLY);
> +	if (in_fd < 0) {
> +		err_msg("Failed to open trace file\n");
> +		return -1;
> +	}
> +
> +	out_fd = creat(filename, mode);
> +	if (out_fd < 0) {
> +		err_msg("Failed to create output file %s\n", filename);
> +		goto out_close_in;
> +	}
> +
> +	do {
> +		retval = read(in_fd, buffer, sizeof(buffer));
> +		if (retval <= 0)
> +			goto out_close;
> +
> +		retval = write(out_fd, buffer, retval);
> +		if (retval < 0)
> +			goto out_close;
> +	} while (retval > 0);
> +
> +	retval = 0;
> +out_close:
> +	close(out_fd);
> +out_close_in:
> +	close(in_fd);
> +	return retval;
> +}
> +
> +/*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ