All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/9] dmapool: fix boundary comparison
@ 2018-11-12 15:41 ` Tony Battersby
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Battersby @ 2018-11-12 15:41 UTC (permalink / raw)
  To: Matthew Wilcox, Christoph Hellwig, Marek Szyprowski,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA

Fix the boundary comparison when constructing the list of free blocks
for the case that 'size' is a power of two.  Since 'boundary' is also a
power of two, that would make 'boundary' a multiple of 'size', in which
case a single block would never cross the boundary.  This bug would
cause some of the allocated memory to be wasted (but not leaked).

Example:

size       = 512
boundary   = 2048
allocation = 4096

Address range
   0 -  511
 512 - 1023
1024 - 1535
1536 - 2047 *
2048 - 2559
2560 - 3071
3072 - 3583
3584 - 4095 *

Prior to this fix, the address ranges marked with "*" would not have
been used even though they didn't cross the given boundary.

Fixes: e34f44b3517f ("pool: Improve memory usage for devices which can't cross boundaries")
Signed-off-by: Tony Battersby <tonyb-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
---

Even though I described this as a "fix", it does not seem important
enough to Cc: stable from a strict reading of the stable kernel rules. 
IOW, it is not "bothering" anyone.

--- linux/mm/dmapool.c.orig	2018-08-01 17:57:04.000000000 -0400
+++ linux/mm/dmapool.c	2018-08-01 17:57:16.000000000 -0400
@@ -210,7 +210,7 @@ static void pool_initialise_page(struct 
 
 	do {
 		unsigned int next = offset + pool->size;
-		if (unlikely((next + pool->size) >= next_boundary)) {
+		if (unlikely((next + pool->size) > next_boundary)) {
 			next = next_boundary;
 			next_boundary += pool->boundary;
 		}

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

* [PATCH v4 1/9] dmapool: fix boundary comparison
@ 2018-11-12 15:41 ` Tony Battersby
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Battersby @ 2018-11-12 15:41 UTC (permalink / raw)
  To: Matthew Wilcox, Christoph Hellwig, Marek Szyprowski, iommu, linux-mm
  Cc: linux-scsi

Fix the boundary comparison when constructing the list of free blocks
for the case that 'size' is a power of two.  Since 'boundary' is also a
power of two, that would make 'boundary' a multiple of 'size', in which
case a single block would never cross the boundary.  This bug would
cause some of the allocated memory to be wasted (but not leaked).

Example:

size       = 512
boundary   = 2048
allocation = 4096

Address range
   0 -  511
 512 - 1023
1024 - 1535
1536 - 2047 *
2048 - 2559
2560 - 3071
3072 - 3583
3584 - 4095 *

Prior to this fix, the address ranges marked with "*" would not have
been used even though they didn't cross the given boundary.

Fixes: e34f44b3517f ("pool: Improve memory usage for devices which can't cross boundaries")
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
---

Even though I described this as a "fix", it does not seem important
enough to Cc: stable from a strict reading of the stable kernel rules. 
IOW, it is not "bothering" anyone.

--- linux/mm/dmapool.c.orig	2018-08-01 17:57:04.000000000 -0400
+++ linux/mm/dmapool.c	2018-08-01 17:57:16.000000000 -0400
@@ -210,7 +210,7 @@ static void pool_initialise_page(struct 
 
 	do {
 		unsigned int next = offset + pool->size;
-		if (unlikely((next + pool->size) >= next_boundary)) {
+		if (unlikely((next + pool->size) > next_boundary)) {
 			next = next_boundary;
 			next_boundary += pool->boundary;
 		}

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

* Re: [PATCH v4 1/9] dmapool: fix boundary comparison
  2018-11-12 15:41 ` Tony Battersby
@ 2018-11-13  6:13     ` Matthew Wilcox
  -1 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2018-11-13  6:13 UTC (permalink / raw)
  To: Tony Battersby
  Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Christoph Hellwig, linux-scsi-u79uwXL29TY76Z2rM5mHXA

On Mon, Nov 12, 2018 at 10:41:34AM -0500, Tony Battersby wrote:
> Fixes: e34f44b3517f ("pool: Improve memory usage for devices which can't cross boundaries")
> Signed-off-by: Tony Battersby <tonyb-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>

Acked-by: Matthew Wilcox <willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>

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

* Re: [PATCH v4 1/9] dmapool: fix boundary comparison
@ 2018-11-13  6:13     ` Matthew Wilcox
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2018-11-13  6:13 UTC (permalink / raw)
  To: Tony Battersby
  Cc: Christoph Hellwig, Marek Szyprowski, iommu, linux-mm, linux-scsi

On Mon, Nov 12, 2018 at 10:41:34AM -0500, Tony Battersby wrote:
> Fixes: e34f44b3517f ("pool: Improve memory usage for devices which can't cross boundaries")
> Signed-off-by: Tony Battersby <tonyb@cybernetics.com>

Acked-by: Matthew Wilcox <willy@infradead.org>

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

end of thread, other threads:[~2018-11-13  6:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 15:41 [PATCH v4 1/9] dmapool: fix boundary comparison Tony Battersby
2018-11-12 15:41 ` Tony Battersby
     [not found] ` <acce3a38-9930-349d-5299-95d2aa5c47e4-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
2018-11-13  6:13   ` Matthew Wilcox
2018-11-13  6:13     ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.