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]
Date:	Tue, 13 Oct 2015 11:54:44 -0300
From:	Arnaldo Carvalho de Melo <acme@...nel.org>
To:	Yannick Brosseau <scientist@...com>
Cc:	linux-kernel@...r.kernel.org, kernel-team@...com,
	zhu.wen-jie@...com, ak@...ux.intel.com
Subject: Re: [PATCH] perf: Correctly identify anon_hugepage when generating
 map

Em Wed, Oct 07, 2015 at 05:31:46PM -0700, Yannick Brosseau escreveu:
> When parsing /proc/xxx/maps, the sscanf in perf_event__synthesize_mmap_events
> truncate the map name at the space in "/anon_hugepage (deleted)".
> is_anon_memory then only receive the string "/anon_hugepage" and do not detect it.
> We change is_anon_memory to only compare the first part of the string
> effectively ignoring if the (deleted) part is there or not.
> 
> +++ b/tools/perf/util/map.c
> @@ -26,8 +26,8 @@ const char *map_type__name[MAP__NR_TYPES] = {
>  static inline int is_anon_memory(const char *filename)
>  {
>  	return !strcmp(filename, "//anon") ||
> -	       !strcmp(filename, "/dev/zero (deleted)") ||
> -	       !strcmp(filename, "/anon_hugepage (deleted)");
> +	       !strncmp(filename, "/dev/zero", sizeof("/dev/zero")) ||
> +	       !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage"));

Have you tested this?

[acme@zoo ~]$ cat strncmp_sizeof.c
#include <string.h>
#include <stdio.h>

int main(void)
{
#define pattern "/anon_hugepage"
	size_t sz = sizeof(pattern);

	return printf("sizeof=%zd\nstrncmp(sz    )=%d\nstrncmp(sz - 1)=%d\n", sz,
			strncmp("/anon_hugepage (deleted)", pattern, sz),
			strncmp("/anon_hugepage (deleted)", pattern, sz - 1));
}
[acme@zoo ~]$ make strncmp_sizeof
cc     strncmp_sizeof.c   -o strncmp_sizeof
[acme@zoo ~]$ ./strncmp_sizeof
sizeof=15
strncmp(sz    )=32
strncmp(sz - 1)=0
[acme@zoo ~]$

Hint, you're not considering the '\0'.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ