stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.0 07/60] nilfs2: fix sanity check of btree level in nilfs_btree_root_broken()
Date: Fri, 15 May 2015 16:14:08 -0700	[thread overview]
Message-ID: <20150515231019.037728786@linuxfoundation.org> (raw)
In-Reply-To: <20150515231018.815421141@linuxfoundation.org>

4.0-stable review patch.  If anyone has any objections, please let me know.

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

From: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>

commit d8fd150fe3935e1692bf57c66691e17409ebb9c1 upstream.

The range check for b-tree level parameter in nilfs_btree_root_broken()
is wrong; it accepts the case of "level == NILFS_BTREE_LEVEL_MAX" even
though the level is limited to values in the range of 0 to
(NILFS_BTREE_LEVEL_MAX - 1).

Since the level parameter is read from storage device and used to index
nilfs_btree_path array whose element count is NILFS_BTREE_LEVEL_MAX, it
can cause memory overrun during btree operations if the boundary value
is set to the level parameter on device.

This fixes the broken sanity check and adds a comment to clarify that
the upper bound NILFS_BTREE_LEVEL_MAX is exclusive.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/nilfs2/btree.c         |    2 +-
 include/linux/nilfs2_fs.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -388,7 +388,7 @@ static int nilfs_btree_root_broken(const
 	nchildren = nilfs_btree_node_get_nchildren(node);
 
 	if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN ||
-		     level > NILFS_BTREE_LEVEL_MAX ||
+		     level >= NILFS_BTREE_LEVEL_MAX ||
 		     nchildren < 0 ||
 		     nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) {
 		pr_crit("NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n",
--- a/include/linux/nilfs2_fs.h
+++ b/include/linux/nilfs2_fs.h
@@ -460,7 +460,7 @@ struct nilfs_btree_node {
 /* level */
 #define NILFS_BTREE_LEVEL_DATA          0
 #define NILFS_BTREE_LEVEL_NODE_MIN      (NILFS_BTREE_LEVEL_DATA + 1)
-#define NILFS_BTREE_LEVEL_MAX           14
+#define NILFS_BTREE_LEVEL_MAX           14	/* Max level (exclusive) */
 
 /**
  * struct nilfs_palloc_group_desc - block group descriptor



  parent reply	other threads:[~2015-05-15 23:14 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 23:14 [PATCH 4.0 00/60] 4.0.4-stable review Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 01/60] x86/spinlocks: Fix regression in spinlock contention detection Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 02/60] ACPI / SBS: Add 5 us delay to fix SBS hangs on MacBook Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 03/60] x86/PCI/ACPI: Make all resources except [io 0xcf8-0xcff] available on PCI bus Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 04/60] ACPI / PNP: add two IDs to list for PNPACPI device enumeration Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 05/60] ocfs2: dlm: fix race between purge and get lock resource Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 06/60] rtc: armada38x: fix concurrency access in armada38x_rtc_set_time Greg Kroah-Hartman
2015-05-15 23:14 ` Greg Kroah-Hartman [this message]
2015-05-15 23:14 ` [PATCH 4.0 08/60] RDMA/CMA: Canonize IPv4 on IPV6 sockets properly Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 09/60] gpio: sysfs: fix memory leaks and device hotplug Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 10/60] mnt: Fix fs_fully_visible to verify the root directory is visible Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 11/60] mm/memory-failure: call shake_page() when error hits thp tail page Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 12/60] path_openat(): fix double fput() Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 13/60] writeback: use |1 instead of +1 to protect against div by zero Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 14/60] mm: soft-offline: fix num_poisoned_pages counting on concurrent events Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 15/60] [media] marvell-ccic: fix YCbCr ordering Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 16/60] vfio: Fix runaway interruptible timeout Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 17/60] xen/events: Clear cpu_evtchn_mask before resuming Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 18/60] xen/xenbus: Update xenbus event channel on resume Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 19/60] xen/console: Update console " Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 20/60] xen/events: Set irq_info->evtchn before binding the channel to CPU in __startup_pirq() Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 21/60] xen-pciback: Add name prefix to global permissive variable Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 22/60] Revert "dm crypt: fix deadlock when async crypto algorithm returns -EBUSY" Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 23/60] block: destroy bdi before blockdev is unregistered Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 24/60] blk-mq: fix race between timeout and CPU hotplug Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 25/60] blk-mq: fix CPU hotplug handling Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 26/60] ARM: dts: OMAP3-N900: Add microphone bias voltages Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 27/60] ARM: dts: imx25: Add #pwm-cells to pwm4 Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 28/60] ARM: dts: imx6: phyFLEX: USB VBUS control is active-high Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 29/60] ARM: dts: imx28: Fix AUART4 TX-DMA interrupt name Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 30/60] ARM: dts: imx23-olinuxino: Fix dr_mode of usb0 Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 31/60] ARM: dts: imx23-olinuxino: Fix polarity of LED GPIO Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 32/60] ARM: mvebu: armada-xp-openblocks-ax3-4: Disable internal RTC Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 33/60] ARM: OMAP2+: Fix omap off idle power consumption creeping up Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 34/60] ARM: net fix emit_udiv() for BPF_ALU | BPF_DIV | BPF_K intruction Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 35/60] ARM: ux500: Move GPIO regulator for SD-card into board DTSs Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 36/60] ARM: ux500: Enable GPIO regulator for SD-card for HREF boards Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 37/60] ARM: ux500: Enable GPIO regulator for SD-card for snowball Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 40/60] drm/i915: Add missing MacBook Pro models with dual channel LVDS Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 41/60] drm/i915/dp: there is no audio on port A Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 42/60] drm/amdkfd: allow unregister process with queues Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 43/60] drm/amdkfd: Initialize sdma vm when creating sdma queue Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 45/60] drm/radeon: dont setup audio on asics that dont support it Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 50/60] pinctrl: Dont just pretend to protect pinctrl_maps, do it for real Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 51/60] mmc: card: Dont access RPMB partitions for normal read/write Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 52/60] mmc: core: add missing pm event in mmc_pm_notify to fix hib restore Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 53/60] mmc: sh_mmcif: Fix timeout value for command request Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 54/60] ARM: 8307/1: psci: move psci firmware calls out of line Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 55/60] sound/oss: fix deadlock in sequencer_ioctl(SNDCTL_SEQ_OUTOFBAND) Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 56/60] coredump: accept any write method Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 57/60] ACPICA: Tables: Change acpi_find_root_pointer() to use acpi_physical_address Greg Kroah-Hartman
2015-05-15 23:14 ` [PATCH 4.0 58/60] ACPICA: Utilities: Cleanup to enforce ACPI_PHYSADDR_TO_PTR()/ACPI_PTR_TO_PHYSADDR() Greg Kroah-Hartman
2015-05-15 23:15 ` [PATCH 4.0 59/60] ACPICA: Utilities: Cleanup to convert physical address printing formats Greg Kroah-Hartman
2015-05-15 23:15 ` [PATCH 4.0 60/60] ACPICA: Utilities: Cleanup to remove useless ACPI_PRINTF/FORMAT_xxx helpers Greg Kroah-Hartman
2015-05-16  3:16 ` [PATCH 4.0 00/60] 4.0.4-stable review Guenter Roeck
2015-05-16 15:26   ` Greg Kroah-Hartman
2015-05-16  3:16 ` Shuah Khan
2015-05-16 15:27   ` Greg Kroah-Hartman

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=20150515231019.037728786@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=konishi.ryusuke@lab.ntt.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).