alpine 3.6
buffer weakness #79

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Easily used incorrectly.

File Name:

oprofile/src/oprofile-0.9.9/opjitconv/opjitconv.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 buffer weakness.

 		rc = OP_JIT_CONV_NO_ANON_SAMPLES;
		goto rm_tmp;
	}
	/* When using get_matching_pathnames to find anon samples,
	 * the list that's returned may contain multiple entries for
	 * one or more processes; e.g.,
	 *    6868.0x100000.0x103000
	 *    6868.0xdfe77000.0xdec40000
	 *    7012.0x100000.0x103000
	 *    7012.0xdfe77000.0xdec40000
	 *
	 * So we must filter the list so there's only one entry per
	 * process.
	 */
	filter_anon_samples_list(&anon_dnames);

	/* get_matching_pathnames returns only filename segment when
	 * NO_RECURSION is passed, so below, we add back the JIT
	 * dump directory path to the name.
	 */
	list_for_each_safe(pos1, pos2, &jd_fnames) {
		struct pathname * dmpfile =
			list_entry(pos1, struct pathname, neighbor);
		strncpy(jitdumpfile, jitdump_dir, PATH_MAX);
		strncat(jitdumpfile, dmpfile->name, PATH_MAX);
		rc = process_jit_dumpfile(jitdumpfile, &anon_dnames,
					  start_time, end_time, tmp_conv_dir);
		if (rc == OP_JIT_CONV_FAIL) {
			verbprintf(debug, "JIT convert error %d\n", rc);
			goto rm_tmp;
		}
		delete_pathname(dmpfile);
	}
	delete_path_names_list(&anon_dnames);
	
rm_tmp:
	/* Delete temporary working directory with all its files
	 * (i.e. dump and ELF file).
	 */
	sprintf(sys_cmd_buffer, "/bin/rm -rf '%s'", tmp_conv_dir);
	if (system(sys_cmd_buffer) != 0) {
		printf("opjitconv: Removing temporary working directory failed.\n");
		rc = OP_JIT_CONV_TMPDIR_NOT_REMOVED;
	}
	
out:
	return rc;
}

static void _cleanup_jitdumps(void) 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.