linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ia64: bitvector_process could read out of bounds
@ 2015-12-02 19:07 Geyslan G. Bem
  2015-12-07 10:07 ` Peter Senna Tschudin
  0 siblings, 1 reply; 2+ messages in thread
From: Geyslan G. Bem @ 2015-12-02 19:07 UTC (permalink / raw)
  To: peter.senna, jg.victorino1, raphaelscarv
  Cc: Geyslan G. Bem, Tony Luck, Fenghua Yu, linux-ia64, linux-kernel

The units[] array could be accessed out of its bounds due the lack of
verification of the max vector value.

To make this function not prone to error "P" and "E" suffixes were added.
Despite the new suffixes are unrelated to current ia64 vm magnitudes, they
make the code ready for it and avoid misleadings.

Catched using static analysis (cppcheck).

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
 arch/ia64/kernel/palinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index c39c3cd..160aba1 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -126,7 +126,7 @@ static const char *mem_attrib[]={
 static void bitvector_process(struct seq_file *m, u64 vector)
 {
 	int i,j;
-	static const char *units[]={ "", "K", "M", "G", "T" };
+	static const char *units[] = { "", "K", "M", "G", "T", "P", "E" };
 
 	for (i=0, j=0; i < 64; i++ , j=i/10) {
 		if (vector & 0x1)
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ia64: bitvector_process could read out of bounds
  2015-12-02 19:07 [PATCH] ia64: bitvector_process could read out of bounds Geyslan G. Bem
@ 2015-12-07 10:07 ` Peter Senna Tschudin
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Senna Tschudin @ 2015-12-07 10:07 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: João Guilherme Victorino, raphaelscarv, Tony Luck,
	Fenghua Yu, linux-ia64, linux-kernel

On Wed, Dec 2, 2015 at 8:07 PM, Geyslan G. Bem <geyslan@gmail.com> wrote:
> The units[] array could be accessed out of its bounds due the lack of
> verification of the max vector value.
>
> To make this function not prone to error "P" and "E" suffixes were added.
> Despite the new suffixes are unrelated to current ia64 vm magnitudes, they
> make the code ready for it and avoid misleadings.

I would mention that you also fix some white space issues, but other than that:

Acked-by: Peter Senna Tschudin <peter.senna@gmail.com>
>
> Catched using static analysis (cppcheck).
>
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>

> ---
>  arch/ia64/kernel/palinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
> index c39c3cd..160aba1 100644
> --- a/arch/ia64/kernel/palinfo.c
> +++ b/arch/ia64/kernel/palinfo.c
> @@ -126,7 +126,7 @@ static const char *mem_attrib[]={
>  static void bitvector_process(struct seq_file *m, u64 vector)
>  {
>         int i,j;
> -       static const char *units[]={ "", "K", "M", "G", "T" };
> +       static const char *units[] = { "", "K", "M", "G", "T", "P", "E" };
>
>         for (i=0, j=0; i < 64; i++ , j=i/10) {
>                 if (vector & 0x1)
> --
> 2.6.2
>



-- 
Peter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-07 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 19:07 [PATCH] ia64: bitvector_process could read out of bounds Geyslan G. Bem
2015-12-07 10:07 ` Peter Senna Tschudin

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