mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] genalloc: fix overflow of ending address of memory chunk
Date: Fri, 9 Aug 2013 16:13:57 -0700	[thread overview]
Message-ID: <20130809161357.5a1d5c0ff6f5bedb8a66be86@linux-foundation.org> (raw)
In-Reply-To: <1375853178-12046-1-git-send-email-jy0922.shim@samsung.com>

On Wed, 07 Aug 2013 14:26:18 +0900 Joonyoung Shim <jy0922.shim@samsung.com> wrote:

> In struct gen_pool_chunk, end_addr means ending address of memory chunk,
> but actually it is starting address + size of memory chunk in codes, so
> it points the address increased one instead of correct ending address.
> 
> The ending address of memory chunk increased one will cause overflow on
> the case to use memory chunk including last address of memory map, e.g.
> when starting address is 0xFFF00000 and size is 0x100000 on 32bit
> machine, ending address will be 0x100000000.
> 
> Use correct ending address like starting address + size - 1.

This might help:

From: Andrew Morton <akpm@linux-foundation.org>
Subject: genalloc-fix-overflow-of-ending-address-of-memory-chunk-fix

add comment to struct gen_pool_chunk:end_addr

Cc: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/genalloc.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -puN lib/genalloc.c~genalloc-fix-overflow-of-ending-address-of-memory-chunk-fix lib/genalloc.c
diff -puN include/linux/genalloc.h~genalloc-fix-overflow-of-ending-address-of-memory-chunk-fix include/linux/genalloc.h
--- a/include/linux/genalloc.h~genalloc-fix-overflow-of-ending-address-of-memory-chunk-fix
+++ a/include/linux/genalloc.h
@@ -66,8 +66,8 @@ struct gen_pool_chunk {
 	struct list_head next_chunk;	/* next chunk in pool */
 	atomic_t avail;
 	phys_addr_t phys_addr;		/* physical starting address of memory chunk */
-	unsigned long start_addr;	/* starting address of memory chunk */
-	unsigned long end_addr;		/* ending address of memory chunk */
+	unsigned long start_addr;	/* start address of memory chunk */
+	unsigned long end_addr;		/* end address of memory chunk (inclusive) */
 	unsigned long bits[0];		/* bitmap for allocating memory chunk */
 };
 
_


      reply	other threads:[~2013-08-09 23:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07  5:26 Joonyoung Shim
2013-08-09 23:13 ` Andrew Morton [this message]

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=20130809161357.5a1d5c0ff6f5bedb8a66be86@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=jy0922.shim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®