The following issues were found
tools/testing/selftests/resctrl/fill_buf.c
2 issues
Line: 123
Column: 7
CWE codes:
362
}
/* Consume read result so that reading memory is not optimized out. */
fp = fopen("/dev/null", "w");
if (!fp)
perror("Unable to write to /dev/null");
fprintf(fp, "Sum: %d ", ret);
fclose(fp);
Reported by FlawFinder.
Line: 70
Column: 12
CWE codes:
676
Suggestion:
Use posix_memalign instead (defined in POSIX's 1003.1d). Don't switch to valloc(); it is marked as obsolete in BSD 4.3, as legacy in SUSv2, and is no longer defined in SUSv3. In some cases, malloc()'s alignment may be sufficient
uint64_t *p64;
size_t s64;
void *p = memalign(PAGE_SIZE, s);
p64 = (uint64_t *)p;
s64 = s / sizeof(uint64_t);
while (s64 > 0) {
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/test_stacktrace_map.c
2 issues
Line: 44
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
/* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */
struct sched_switch_args {
unsigned long long pad;
char prev_comm[16];
int prev_pid;
int prev_prio;
long long prev_state;
char next_comm[16];
int next_pid;
Reported by FlawFinder.
Line: 48
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 prev_pid;
int prev_prio;
long long prev_state;
char next_comm[16];
int next_pid;
int next_prio;
};
SEC("tracepoint/sched/sched_switch")
Reported by FlawFinder.
tools/testing/selftests/resctrl/mbm_test.c
2 issues
Line: 53
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
static int check_results(int span)
{
unsigned long bw_imc[NUM_OF_RUNS], bw_resc[NUM_OF_RUNS];
char temp[1024], *token_array[8];
char output[] = RESULT_FILE_NAME;
int runs, ret;
FILE *fp;
ksft_print_msg("Checking for pass/fail\n");
Reported by FlawFinder.
Line: 60
Column: 7
CWE codes:
362
ksft_print_msg("Checking for pass/fail\n");
fp = fopen(output, "r");
if (!fp) {
perror(output);
return errno;
}
Reported by FlawFinder.
tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
2 issues
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
static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx)
{
unsigned char i;
char name[sizeof(tcp_mem_name)];
int ret;
memset(name, 0, sizeof(name));
ret = bpf_sysctl_get_name(ctx, name, sizeof(name), 0);
if (ret < 0 || ret != sizeof(tcp_mem_name) - 1)
Reported by FlawFinder.
Line: 45
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 sysctl_tcp_mem(struct bpf_sysctl *ctx)
{
unsigned long tcp_mem[TCP_MEM_LOOPS] = {};
char value[MAX_VALUE_STR_LEN];
unsigned char i, off = 0;
/* a workaround to prevent compiler from generating
* codes verifier cannot handle yet.
*/
volatile int ret;
Reported by FlawFinder.
tools/testing/selftests/net/fin_ack_lat.c
2 issues
Line: 65
Column: 7
CWE codes:
120
20
error(-1, errno, "connect");
send(sock, &buffer, sizeof(buffer), 0);
if (read(sock, &buffer, sizeof(buffer)) == -1)
error(-1, errno, "waiting read");
gettimeofday(&end, NULL);
lat = timediff(start, end);
sum_lat += lat;
Reported by FlawFinder.
tools/testing/selftests/arm64/fp/vlset.c
2 issues
Line: 147
Column: 2
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
assert(optind < argc);
path = argv[optind];
execvp(path, &argv[optind]);
e = errno;
if (errno == ENOENT)
ret = 127; /* same as sh(1) not-found error */
fprintf(stderr, "%s: %s: %s\n", program_name, path, strerror(e));
Reported by FlawFinder.
Line: 48
Column: 14
CWE codes:
120
20
Suggestion:
Check implementation on installation, or limit the size of all string inputs
else
program_name = argv[0];
while ((c = getopt_long(argc, argv, "Mfhi", options, NULL)) != -1)
switch (c) {
case 'M': vl = SVE_VL_MAX; break;
case 'f': force = 1; break;
case 'i': inherit = 1; break;
case 0: break;
Reported by FlawFinder.
tools/include/linux/compiler.h
2 issues
Line: 178
Column: 27
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
#define READ_ONCE(x) \
({ \
union { typeof(x) __val; char __c[1]; } __u = \
{ .__c = { 0 } }; \
__read_once_size(&(x), __u.__c, sizeof(x)); \
__u.__val; \
})
Reported by FlawFinder.
Line: 186
Column: 27
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
#define WRITE_ONCE(x, val) \
({ \
union { typeof(x) __val; char __c[1]; } __u = \
{ .__val = (val) }; \
__write_once_size(&(x), __u.__c, sizeof(x)); \
__u.__val; \
})
Reported by FlawFinder.
tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
2 issues
Line: 371
Column: 13
CWE codes:
120
20
Suggestion:
Check implementation on installation, or limit the size of all string inputs
bool *migrate, int *delay_usecs)
{
for (;;) {
int opt = getopt(argc, argv, "s:d:m");
if (opt == -1)
break;
switch (opt) {
case 's':
Reported by FlawFinder.
Line: 363
Column: 3
CWE codes:
676
Suggestion:
Use nanosleep(2) or setitimer(2) instead
hlt_count = data->hlt_count;
wake_count = data->wake_count;
}
usleep(delay_usecs);
}
}
void get_cmdline_args(int argc, char *argv[], int *run_secs,
bool *migrate, int *delay_usecs)
Reported by FlawFinder.
sound/usb/usx2y/usbus428ctldefs.h
2 issues
Line: 42
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
struct us428_ctls {
unsigned char fader[9];
unsigned char transport;
unsigned char modifier;
unsigned char filters_elect;
unsigned char select;
unsigned char mute;
Reported by FlawFinder.
Line: 50
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 char mute;
unsigned char unknown;
unsigned char wswitch;
unsigned char wheel[5];
};
struct us428_set_byte {
unsigned char offset,
value;
Reported by FlawFinder.
tools/perf/tests/openat-syscall.c
2 issues
Line: 22
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
struct evsel *evsel;
unsigned int nr_openat_calls = 111, i;
struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE];
char errbuf[BUFSIZ];
if (threads == NULL) {
pr_debug("thread_map__new\n");
return -1;
Reported by FlawFinder.
Line: 23
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
unsigned int nr_openat_calls = 111, i;
struct perf_thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE];
char errbuf[BUFSIZ];
if (threads == NULL) {
pr_debug("thread_map__new\n");
return -1;
}
Reported by FlawFinder.