mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Clemens Ladisch <clemens@ladisch.de>,
	Stefan Richter <stefanr@s5r6.in-berlin.de>,
	Nick Piggin <npiggin@suse.de>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	Krzysztof Helt <krzysztof.h1@poczta.fm>
Subject: [08/19] mm: fix wrong vmap address calculations with odd NR_CPUS values
Date: Fri, 26 Aug 2011 14:58:29 -0700	[thread overview]
Message-ID: <20110826220120.404233543@clark.kroah.org> (raw)
In-Reply-To: <20110826220137.GA14059@kroah.com>

2.6.32-longterm review patch.  If anyone has any objections, please let us know.

------------------

From: Clemens Ladisch <clemens@ladisch.de>

commit f982f91516fa4cfd9d20518833cd04ad714585be upstream.

Commit db64fe02258f ("mm: rewrite vmap layer") introduced code that does
address calculations under the assumption that VMAP_BLOCK_SIZE is a
power of two.  However, this might not be true if CONFIG_NR_CPUS is not
set to a power of two.

Wrong vmap_block index/offset values could lead to memory corruption.
However, this has never been observed in practice (or never been
diagnosed correctly); what caught this was the BUG_ON in vb_alloc() that
checks for inconsistent vmap_block indices.

To fix this, ensure that VMAP_BLOCK_SIZE always is a power of two.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=31572
Reported-by: Pavel Kysilka <goldenfish@linuxsoft.cz>
Reported-by: Matias A. Fonzo <selk@dragora.org>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 mm/vmalloc.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -671,9 +671,10 @@ static void free_unmap_vmap_area_addr(un
 #define VMAP_BBMAP_BITS_MIN	(VMAP_MAX_ALLOC*2)
 #define VMAP_MIN(x, y)		((x) < (y) ? (x) : (y)) /* can't use min() */
 #define VMAP_MAX(x, y)		((x) > (y) ? (x) : (y)) /* can't use max() */
-#define VMAP_BBMAP_BITS		VMAP_MIN(VMAP_BBMAP_BITS_MAX,		\
-					VMAP_MAX(VMAP_BBMAP_BITS_MIN,	\
-						VMALLOC_PAGES / NR_CPUS / 16))
+#define VMAP_BBMAP_BITS		\
+		VMAP_MIN(VMAP_BBMAP_BITS_MAX,	\
+		VMAP_MAX(VMAP_BBMAP_BITS_MIN,	\
+			VMALLOC_PAGES / roundup_pow_of_two(NR_CPUS) / 16))
 
 #define VMAP_BLOCK_SIZE		(VMAP_BBMAP_BITS * PAGE_SIZE)
 



  parent reply	other threads:[~2011-08-27 14:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 22:01 [00/19] 2.6.32.46-longterm review Greg KH
2011-08-26 21:58 ` [01/19] USB: xhci: fix OS want to own HC Greg KH
2011-08-26 21:58 ` [02/19] USB: assign instead of equal in usbtmc.c Greg KH
2011-08-26 21:58 ` [03/19] USB: usb-storage: unusual_devs entry for ARM V2M motherboard Greg KH
2011-08-26 21:58 ` [04/19] USB: Serial: Added device ID for Qualcomm Modem in Sagemcom's HiLo3G Greg KH
2011-08-26 21:58 ` [05/19] atm: br2864: sent packets truncated in VC routed mode Greg KH
2011-08-26 21:58 ` [06/19] hwmon: (ibmaem) add missing kfree Greg KH
2011-08-26 21:58 ` [07/19] ALSA: snd-usb-caiaq: Correct offset fields of outbound iso_frame_desc Greg KH
2011-08-26 21:58 ` Greg KH [this message]
2011-08-26 21:58 ` [09/19] perf tools: do not look at ./config for configuration Greg KH
2011-08-26 21:58 ` [10/19] fs/partitions/efi.c: corrupted GUID partition tables can cause kernel oops Greg KH
2011-08-26 21:58 ` [11/19] befs: Validate length of long symbolic links Greg KH
2011-08-26 21:58 ` [12/19] ALSA: snd_usb_caiaq: track submitted output urbs Greg KH
2011-08-26 21:58 ` [13/19] ALSA: ac97: Add HP Compaq dc5100 SFF(PT003AW) to Headphone Jack Sense whitelist Greg KH
2011-08-26 21:58 ` [14/19] futex: Fix regression with read only mappings Greg KH
2011-08-26 21:58 ` [15/19] x86-32, vdso: On system call restart after SYSENTER, use int $0x80 Greg KH
2011-08-26 21:58 ` [16/19] x86, UV: Remove UV delay in starting slave cpus Greg KH
2011-08-26 21:58 ` [17/19] drm/ttm: fix ttm_bo_add_ttm(user) failure path Greg KH
2011-08-26 21:58 ` [18/19] fuse: check size of FUSE_NOTIFY_INVAL_ENTRY message Greg KH
2011-08-26 21:58 ` [19/19] igb: Fix lack of flush after register write and before delay Greg KH
2011-08-27 15:27 ` [00/19] 2.6.32.46-longterm review Christoph Biedl
2011-08-27 16:05   ` Greg KH
2011-08-27 16:25     ` Christoph Biedl
2011-08-28 12:34 ` Stratos Psomadakis
2011-08-28 15:07   ` [stable] " Greg KH

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=20110826220120.404233543@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=clemens@ladisch.de \
    --cc=jeremy@goop.org \
    --cc=krzysztof.h1@poczta.fm \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=torvalds@linux-foundation.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®