public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Victor Gallardo <vgallardo@amcc.com>
To: linux-mtd@lists.infradead.org
Cc: Prodyut Hazarika <phazarika@amcc.com>,
	linuxppc-dev@ozlabs.org, Victor Gallardo <vgallardo@amcc.com>,
	Feng Kan <fkan@amcc.com>
Subject: [PATCH] [JFFS2] Fix csize integer overflow issue due to truncation
Date: Fri, 21 Aug 2009 15:43:15 -0700	[thread overview]
Message-ID: <1250894595-21052-1-git-send-email-vgallardo@amcc.com> (raw)

This fixes a kernel BUG_ON(tn->size == 0) panic in check_node_data
due to integer overflow in read_dnone().

The code incorrectly assigns a uin32_t local variable (csize) to
uint16_t structure member in jffs2_tmp_dnode_info. This results
in an overflow when the local variable csize is greater than
65536 (0x10000)

This issue is seen when kernel PAGE_SIZE is 64K.

The following example illustrates the issue:

fs/jffs2/nodelist.h
  struct jffs2_tmp_dnode_info
  {
    ...
    uint16_t csize;
    ...
  };

fs/jffs2/readinode.c
  static inline int read_dnode(...)
  {
    struct jffs2_tmp_dnode_info *tn;
    uint32_t len, csize;
    ...
    csize = je32_to_cpu(rd->csize);
    ...
    tn->csize = csize;  // <=== result truncated if > 0x10000
    ...
  }

  static int check_node_data(...)
  {
    ...
    BUG_ON(tn->csize == 0);
    ...
  }

Signed-off-by: Victor Gallardo <vgallardo@amcc.com>
Acked-by: Prodyut Hazarika <phazarika@amcc.com>
Acked-by: Feng Kan <fkan@amcc.com>
---
 fs/jffs2/nodelist.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 507ed6e..67f36c3 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -231,7 +231,7 @@ struct jffs2_tmp_dnode_info
 	uint32_t version;
 	uint32_t data_crc;
 	uint32_t partial_crc;
-	uint16_t csize;
+	uint32_t csize;
 	uint16_t overlapped;
 };
 
-- 
1.5.5

             reply	other threads:[~2009-08-21 22:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-21 22:43 Victor Gallardo [this message]
     [not found] <25217471.1985431251223831787.JavaMail.nabble@isper.nabble.com>
2009-08-27 23:37 ` [PATCH] [JFFS2] Fix csize integer overflow issue due to truncation Victor Gallardo
2009-08-28  5:18   ` Artem Bityutskiy
2009-08-28 13:52     ` Victor Gallardo
2009-09-19 20:40   ` David Woodhouse
2009-09-19 21:05     ` David Woodhouse
2009-09-20  5:57     ` Victor Gallardo
2009-09-20 12:33       ` David Woodhouse
2009-09-20 13:40         ` Victor Gallardo
2009-09-22 22:55     ` Victor Gallardo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250894595-21052-1-git-send-email-vgallardo@amcc.com \
    --to=vgallardo@amcc.com \
    --cc=fkan@amcc.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=phazarika@amcc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox