The following issues were found

tools/lib/bpf/bpf_gen_internal.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 25 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              	int error;
	struct ksym_relo_desc *relos;
	int relo_cnt;
	char attach_target[128];
	int attach_kind;
};

void bpf_gen__init(struct bpf_gen *gen, int log_level);
int bpf_gen__finish(struct bpf_gen *gen);

            

Reported by FlawFinder.

tools/perf/util/parse-events.h
1 issues
system - This causes a new program to execute and is difficult to use safely
Security

Line: 23 Column: 8 CWE codes: 78
Suggestion: try using a library call that implements the same functionality if available

              struct perf_pmu;

struct tracepoint_path {
	char *system;
	char *name;
	struct tracepoint_path *next;
};

struct tracepoint_path *tracepoint_id_to_path(u64 config);

            

Reported by FlawFinder.

tools/perf/util/parse-sublevel-options.c
1 issues
atoi - Unless checked, the resulting number can exceed the expected range
Security

Line: 38 Column: 7 CWE codes: 190
Suggestion: If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)

              	}

	if (vstr)
		v = atoi(vstr);

	*opt->value_ptr = v;
	free(s);
	return 0;
}

            

Reported by FlawFinder.

tools/perf/util/pfm.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 125 Column: 14 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              	return -1;
}

static const char *srcs[PFM_ATTR_CTRL_MAX] = {
	[PFM_ATTR_CTRL_UNKNOWN] = "???",
	[PFM_ATTR_CTRL_PMU] = "PMU",
	[PFM_ATTR_CTRL_PERF_EVENT] = "perf_event",
};


            

Reported by FlawFinder.

tools/perf/util/pmu.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 72 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              	char *str;
	struct list_head terms; /* HEAD struct parse_events_term -> list */
	struct list_head list;  /* ELEM */
	char unit[UNIT_MAX_LEN+1];
	double scale;
	bool per_pkg;
	bool snapshot;
	bool deprecated;
	char *metric_expr;

            

Reported by FlawFinder.

tools/lib/api/io.h
1 issues
read - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 48 Column: 15 CWE codes: 120 20

              		return -1;

	if (ptr == io->end) {
		ssize_t n = read(io->fd, io->buf, io->buf_len);

		if (n <= 0) {
			io->eof = true;
			return -1;
		}

            

Reported by FlawFinder.

tools/lib/api/debug.c
1 issues
vfprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 13 Column: 8 CWE codes: 134
Suggestion: Use a constant for the format specification

              	int err;

	va_start(args, format);
	err = vfprintf(stderr, format, args);
	va_end(args);
	return err;
}

libapi_print_fn_t __pr_warn    = __base_pr;

            

Reported by FlawFinder.

tools/perf/util/record.c
1 issues
atoi - Unless checked, the resulting number can exceed the expected range
Security

Line: 290 Column: 10 CWE codes: 190
Suggestion: If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)

              		}
		pr_info("info: Using a maximum frequency rate of %'d Hz\n", freq);
	} else {
		freq = atoi(str);
	}

	opts->user_freq = freq;
	return 0;
}

            

Reported by FlawFinder.

tools/perf/util/s390-cpumsf-kernel.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 58 Column: 11 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              		unsigned long long flags;	/* 0 - 64: All indicators     */
	};
	unsigned long long overflow;	 /* 64 - sample Overflow count	      */
	unsigned char timestamp[16];	 /* 16 - 31 timestamp		      */
	unsigned long long reserved1;	 /* 32 -Reserved		      */
	unsigned long long reserved2;	 /*				      */
	union {				 /* 48 - reserved for programming use */
		struct {
			unsigned long long clock_base:1; /* in progusage2 */

            

Reported by FlawFinder.

tools/lib/api/cpu.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 9 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
int cpu__get_max_freq(unsigned long long *freq)
{
	char entry[PATH_MAX];
	int cpu;

	if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
		return -1;


            

Reported by FlawFinder.