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]
Message-ID: <54E5F963.50200@gmail.com>
Date:	Thu, 19 Feb 2015 07:55:31 -0700
From:	David Ahern <dsahern@...il.com>
To:	Adrian Hunter <adrian.hunter@...el.com>,
	David Ahern <david.ahern@...cle.com>, acme@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf: Fix probing for PERF_FLAG_FD_CLOEXEC flag

On 2/19/15 12:06 AM, Adrian Hunter wrote:
>>   	/* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */
>> -	fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
>> +	fd = sys_perf_event_open(&attr, 0, cpu, -1, 0);
>
> I would prefer to avoid pid = 0 unless necessary and so just do the same
> thing again i.e.
>
> 	while (1) {
> 		fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
> 		if (fd < 0 && pid == -1 && errno == EACCES) {
> 			pid = 0;
> 			continue;
> 		}
> 		break;
> 	}
>

The probing is getting of hand. In this case the intent is a probe for a 
flag and flags are the first thing checked kernel side. Given that the 
parameters passed to sys_perf_event_open should be as simple and known 
safe as possible. pid = -1 has known limitations. Why can't pid just be 
getpid() in both cases?

Simplifies this function a lot and removes the need for sched_getcpu(). So
     pid = getpid();

     fd = sys_perf_event_open(&attr, pid, -1, -1, PERF_FLAG_FD_CLOEXEC);

and if that fails

     fd = sys_perf_event_open(&attr, pid, -1, -1, 0);

Why is anything more complicated needed?

David


--
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