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: <20160728084306.9b2ea62c38c34760bf86d6db@kernel.org>
Date:	Thu, 28 Jul 2016 08:43:06 +0900
From:	Masami Hiramatsu <mhiramat@...nel.org>
To:	Tomoki Sekiyama <tomoki.sekiyama.qu@...achi.com>
Cc:	linux-kernel@...r.kernel.org, ltc-kernel@...ml.intra.hitachi.co.jp,
	masumi.moritani.ju@...achi.com, Jiri Olsa <jolsa@...nel.org>,
	David Ahern <dsahern@...il.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Masami Hiramatsu <mhiramat@...nel.org>
Subject: Re: [PATCH v2] perf sched: fix wrong conversion of task state

On Thu, 28 Jul 2016 01:07:40 +0900
Tomoki Sekiyama <tomoki.sekiyama.qu@...achi.com> wrote:

> sched_out_state() converts the prev_state u64 bitmask to a char in
> a wrong way, which may cause wrong results of 'perf sched latency'.
> This patch fixes the conversion.
> Also, preempted tasks must be considered that they are in the
> THREAD_WAIT_CPU state.

Hmm, this includes several fixes and enhancements.
1. Use first bit of the state instead of state itself (critical bug to avoid crash?)
2. Check the range of the array and return '?' if out (minor bug, it can access data area)
3. Fix TASK_STATE_TO_CHAR_STR to swap X and Z.
4. Add new 'N+' to TASK_STATE_TO_CHAR_STR. (how about 'n'?)
5. Treat a preempted task as THREAD_WAIT_CPU.

so IMHO, it is better to split this patch into atleast 2, #1 and #2 (critical bugfix),
#3, #4, and #5 (minor update).

[..]
> @@ -897,9 +898,10 @@ static int thread_atoms_insert(struct perf_sched *sched, struct thread *thread)
>  
>  static char sched_out_state(u64 prev_state)
>  {
> -	const char *str = TASK_STATE_TO_CHAR_STR;
> +	const char str[] = TASK_STATE_TO_CHAR_STR;
> +	unsigned int bit = prev_state ? __ffs(prev_state) + 1 : 0;
>  
> -	return str[prev_state];
> +	return bit < sizeof(str) - 1 ? str[bit] : '?';

You'd better use ARRAY_SIZE(str) instead of sizeof() for array here.

Thank you,


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ