* [PATCH] perf tools: fix off-by-one comparison on maximum code
@ 2016-04-24 18:56 Colin King
2016-04-25 23:29 ` Arnaldo Carvalho de Melo
2016-04-27 15:33 ` [tip:perf/core] perf intel-pt: Fix " tip-bot for Colin Ian King
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-04-24 18:56 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Alexander Shishkin, Adrian Hunter
Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The check for the maximum code is off-by-one; the current
comparison of a code that is INTEL_PT_ERR_MAX will cause the
strlcpy to perform an out of bounds array access on the
intel_pt_err_msgs array. Fix this with a >= comparison.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 9409d01..9c8f15d 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -356,7 +356,7 @@ static const char *intel_pt_err_msgs[] = {
int intel_pt__strerror(int code, char *buf, size_t buflen)
{
- if (code < 1 || code > INTEL_PT_ERR_MAX)
+ if (code < 1 || code >= INTEL_PT_ERR_MAX)
code = INTEL_PT_ERR_UNK;
strlcpy(buf, intel_pt_err_msgs[code], buflen);
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf tools: fix off-by-one comparison on maximum code
2016-04-24 18:56 [PATCH] perf tools: fix off-by-one comparison on maximum code Colin King
@ 2016-04-25 23:29 ` Arnaldo Carvalho de Melo
2016-04-27 15:33 ` [tip:perf/core] perf intel-pt: Fix " tip-bot for Colin Ian King
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-04-25 23:29 UTC (permalink / raw)
To: Colin King
Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Adrian Hunter,
linux-kernel
Em Sun, Apr 24, 2016 at 07:56:43PM +0100, Colin King escreveu:
> From: Colin Ian King <colin.king@canonical.com>
>
> The check for the maximum code is off-by-one; the current
> comparison of a code that is INTEL_PT_ERR_MAX will cause the
> strlcpy to perform an out of bounds array access on the
> intel_pt_err_msgs array. Fix this with a >= comparison.
Applied, thanks.
- Arnaldo
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> index 9409d01..9c8f15d 100644
> --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> @@ -356,7 +356,7 @@ static const char *intel_pt_err_msgs[] = {
>
> int intel_pt__strerror(int code, char *buf, size_t buflen)
> {
> - if (code < 1 || code > INTEL_PT_ERR_MAX)
> + if (code < 1 || code >= INTEL_PT_ERR_MAX)
> code = INTEL_PT_ERR_UNK;
> strlcpy(buf, intel_pt_err_msgs[code], buflen);
> return 0;
> --
> 2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:perf/core] perf intel-pt: Fix off-by-one comparison on maximum code
2016-04-24 18:56 [PATCH] perf tools: fix off-by-one comparison on maximum code Colin King
2016-04-25 23:29 ` Arnaldo Carvalho de Melo
@ 2016-04-27 15:33 ` tip-bot for Colin Ian King
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Colin Ian King @ 2016-04-27 15:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, colin.king, linux-kernel, mingo, alexander.shishkin, tglx,
hpa, peterz, adrian.hunter
Commit-ID: c0664893050cc6b2d8b02d3e035f82fbfd0cd4cf
Gitweb: http://git.kernel.org/tip/c0664893050cc6b2d8b02d3e035f82fbfd0cd4cf
Author: Colin Ian King <colin.king@canonical.com>
AuthorDate: Sun, 24 Apr 2016 19:56:43 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 25 Apr 2016 20:35:59 -0300
perf intel-pt: Fix off-by-one comparison on maximum code
The check for the maximum code is off-by-one; the current comparison of
a code that is INTEL_PT_ERR_MAX will cause the strlcpy to perform an out
of bounds array access on the intel_pt_err_msgs array.
Fix this with a >= comparison.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1461524203-10224-1-git-send-email-colin.king@canonical.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 9409d01..9c8f15d 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -356,7 +356,7 @@ static const char *intel_pt_err_msgs[] = {
int intel_pt__strerror(int code, char *buf, size_t buflen)
{
- if (code < 1 || code > INTEL_PT_ERR_MAX)
+ if (code < 1 || code >= INTEL_PT_ERR_MAX)
code = INTEL_PT_ERR_UNK;
strlcpy(buf, intel_pt_err_msgs[code], buflen);
return 0;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-27 15:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-24 18:56 [PATCH] perf tools: fix off-by-one comparison on maximum code Colin King
2016-04-25 23:29 ` Arnaldo Carvalho de Melo
2016-04-27 15:33 ` [tip:perf/core] perf intel-pt: Fix " tip-bot for Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).