linux-kernel.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, Sami Tolvanen <samitolvanen@google.com>,
	Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 4.10 023/110] dm verity fec: limit error correction recursion
Date: Mon, 10 Apr 2017 18:42:14 +0200	[thread overview]
Message-ID: <20170410164202.536447292@linuxfoundation.org> (raw)
In-Reply-To: <20170410164201.247583164@linuxfoundation.org>

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

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

From: Sami Tolvanen <samitolvanen@google.com>

commit f1a880a93baaadb14c10a348fd199f1cdb6bcccd upstream.

If the hash tree itself is sufficiently corrupt in addition to data blocks,
it's possible for error correction to end up in a deep recursive loop,
which eventually causes a kernel panic.  This change limits the
recursion to a reasonable level during a single I/O operation.

Fixes: a739ff3f543a ("dm verity: add support for forward error correction")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-verity-fec.c |   12 +++++++++++-
 drivers/md/dm-verity-fec.h |    4 ++++
 2 files changed, 15 insertions(+), 1 deletion(-)

--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -439,6 +439,13 @@ int verity_fec_decode(struct dm_verity *
 	if (!verity_fec_is_enabled(v))
 		return -EOPNOTSUPP;
 
+	if (fio->level >= DM_VERITY_FEC_MAX_RECURSION) {
+		DMWARN_LIMIT("%s: FEC: recursion too deep", v->data_dev->name);
+		return -EIO;
+	}
+
+	fio->level++;
+
 	if (type == DM_VERITY_BLOCK_TYPE_METADATA)
 		block += v->data_blocks;
 
@@ -470,7 +477,7 @@ int verity_fec_decode(struct dm_verity *
 	if (r < 0) {
 		r = fec_decode_rsb(v, io, fio, rsb, offset, true);
 		if (r < 0)
-			return r;
+			goto done;
 	}
 
 	if (dest)
@@ -480,6 +487,8 @@ int verity_fec_decode(struct dm_verity *
 		r = verity_for_bv_block(v, io, iter, fec_bv_copy);
 	}
 
+done:
+	fio->level--;
 	return r;
 }
 
@@ -520,6 +529,7 @@ void verity_fec_init_io(struct dm_verity
 	memset(fio->bufs, 0, sizeof(fio->bufs));
 	fio->nbufs = 0;
 	fio->output = NULL;
+	fio->level = 0;
 }
 
 /*
--- a/drivers/md/dm-verity-fec.h
+++ b/drivers/md/dm-verity-fec.h
@@ -27,6 +27,9 @@
 #define DM_VERITY_FEC_BUF_MAX \
 	(1 << (PAGE_SHIFT - DM_VERITY_FEC_BUF_RS_BITS))
 
+/* maximum recursion level for verity_fec_decode */
+#define DM_VERITY_FEC_MAX_RECURSION	4
+
 #define DM_VERITY_OPT_FEC_DEV		"use_fec_from_device"
 #define DM_VERITY_OPT_FEC_BLOCKS	"fec_blocks"
 #define DM_VERITY_OPT_FEC_START		"fec_start"
@@ -58,6 +61,7 @@ struct dm_verity_fec_io {
 	unsigned nbufs;		/* number of buffers allocated */
 	u8 *output;		/* buffer for corrected output */
 	size_t output_pos;
+	unsigned level;		/* recursion level */
 };
 
 #ifdef CONFIG_DM_VERITY_FEC

  parent reply	other threads:[~2017-04-10 17:17 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 16:41 [PATCH 4.10 000/110] 4.10.10-stable review Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 001/110] drm/vmwgfx: Type-check lookups of fence objects Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 002/110] drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl() Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 003/110] drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl() Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 004/110] drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 005/110] drm/vmwgfx: Remove getparam error message Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 006/110] drm/vmwgfx: fix integer overflow in vmw_surface_define_ioctl() Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 007/110] PCI: thunder-pem: Add legacy firmware support for Cavium ThunderX host controller Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 008/110] PCI: thunder-pem: Fix legacy firmware PEM-specific resources Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 009/110] sysfs: be careful of error returns from ops->show() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 010/110] staging: android: ashmem: lseek failed due to no FMODE_LSEEK Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 011/110] arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 012/110] arm/arm64: KVM: Take mmap_sem in kvm_arch_prepare_memory_region Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 013/110] kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 014/110] iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 015/110] iio: st_pressure: initialize lps22hb bootime Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 016/110] iio: bmg160: reset chip when probing Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 017/110] arm64: mm: unaligned access by user-land should be received as SIGBUS Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 018/110] cfg80211: check rdev resume callback only for registered wiphy Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 019/110] Reset TreeId to zero on SMB2 TREE_CONNECT Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 020/110] mm/page_alloc.c: fix print order in show_free_areas() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 021/110] ptrace: fix PTRACE_LISTEN race corrupting task->state Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 022/110] dax: fix radix tree insertion race Greg Kroah-Hartman
2017-04-10 16:42 ` Greg Kroah-Hartman [this message]
2017-04-10 16:42 ` [PATCH 4.10 024/110] dm verity fec: fix bufio leaks Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 025/110] ACPI / gpio: do not fall back to parsing _CRS when we get a deferral Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 026/110] ACPI / scan: Prefer devices without _HID for _ADR matching Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 027/110] Kbuild: use cc-disable-warning consistently for maybe-uninitialized Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 028/110] jump label: fix passing kbuild_cflags when checking for asm goto support Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 029/110] orangefs: move features validation to fix filesystem hang Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 030/110] xfs: Honor FALLOC_FL_KEEP_SIZE when punching ends of files Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 031/110] ring-buffer: Fix return value check in test_ringbuffer() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 032/110] mac80211: unconditionally start new netdev queues with iTXQ support Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 033/110] brcmfmac: use local iftype avoiding use-after-free of virtual interface Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 034/110] metag/usercopy: Drop unused macros Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 035/110] metag/usercopy: Fix alignment error checking Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 036/110] metag/usercopy: Add early abort to copy_to_user Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 037/110] metag/usercopy: Zero rest of buffer from copy_from_user Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 038/110] metag/usercopy: Set flags before ADDZ Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 039/110] metag/usercopy: Fix src fixup in from user rapf loops Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 040/110] metag/usercopy: Add missing fixups Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 041/110] drm/msm: adreno: fix build error without debugfs Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 042/110] powerpc: Disable HFSCR[TM] if TM is not supported Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 043/110] powerpc/mm: Add missing global TLB invalidate if cxl is active Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 044/110] powerpc/64: Fix flush_(d|i)cache_range() called from modules Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 045/110] powerpc: Dont try to fix up misaligned load-with-reservation instructions Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 046/110] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 048/110] x86/mce: Dont print MCEs when mcelog is active Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 049/110] nios2: reserve boot memory for device tree Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 050/110] xtensa: make __pa work with uncached KSEG addresses Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 051/110] s390/decompressor: fix initrd corruption caused by bss clear Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 052/110] s390/uaccess: get_user() should zero on failure (again) Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 053/110] MIPS: Force o32 fp64 support on 32bit MIPS64r6 kernels Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 054/110] MIPS: ralink: Fix typos in rt3883 pinctrl Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 055/110] MIPS: End spinlocks with .insn Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 056/110] MIPS: Lantiq: fix missing xbar kernel panic Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 057/110] MIPS: Check TLB before handle_ri_rdhwr() for Loongson-3 Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 058/110] MIPS: Add MIPS_CPU_FTLB for Loongson-3A R2 Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 059/110] MIPS: Flush wrong invalid FTLB entry for huge page Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 060/110] MIPS: c-r4k: Fix Loongson-3s vcache/scache waysize calculation Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 061/110] drm/i915/gvt: Fix gvt scheduler interval time Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 062/110] drm/i915/kvmgt: fix suspicious rcu dereference usage Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 063/110] usb: dwc3: gadget: delay unmap of bounced requests Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 064/110] Documentation: stable-kernel-rules: fix stable-tag format Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 065/110] mm/mempolicy.c: fix error handling in set_mempolicy and mbind Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 066/110] random: use chacha20 for get_random_int/long Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 067/110] kvm: fix page struct leak in handle_vmon Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 068/110] HID: multitouch: enable the Surface 4 Type Cover Pro (JP) to report multitouch data Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 069/110] drm/edid: constify edid quirk list Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 070/110] drm/i915: fix INTEL_BDW_IDS definition Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 071/110] drm/i915: more .is_mobile cleanups for BDW Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 072/110] drm/i915: actually drive the BDW reserved IDs Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 073/110] ASoC: Intel: bytcr_rt5640: quirks for Insyde devices Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 074/110] ARM: OMAP2+: Fix init for multiple quirks for the same SoC Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 075/110] usb: chipidea: msm: Rely on core to override AHBBURST Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 076/110] serial: 8250_omap: Add OMAP_DMA_TX_KICK quirk for AM437x Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 077/110] ARM: davinci: add skeleton for pdata-quirks Greg Kroah-Hartman
2017-04-11  8:13   ` Sekhar Nori
2017-04-11 14:41     ` Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 079/110] usb: host: xhci-plat: enable BROKEN_PED quirk if platform requested Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 080/110] usb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 081/110] drm/mga: remove device_is_agp callback Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 082/110] PCI: Add ACS quirk for Intel Union Point Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 083/110] PCI: xgene: Fix double free on init error Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 084/110] [media] rx51: broken build Greg Kroah-Hartman
2017-04-11 11:44   ` Sean Young
2017-04-11 14:42     ` Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 085/110] sata: ahci-da850: implement a workaround for the softreset quirk Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 086/110] ACPI / button: Change default behavior to lid_init_state=open Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 087/110] ASoC: codecs: rt5670: add quirk for Lenovo Thinkpad 10 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 088/110] ASoC: Intel: Baytrail: " Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 089/110] ASoC: Intel: cht_bsw_rt5645: harden ACPI device detection Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 090/110] ASoC: Intel: cht_bsw_rt5645: add Baytrail MCLK support Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 091/110] ACPI: save NVS memory for Lenovo G50-45 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 092/110] usb: musb: da8xx: Fix host mode suspend Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 094/110] HID: wacom: dont apply generic settings to old devices Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 095/110] arm: kernel: Add SMC structure parameter Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 096/110] firmware: qcom: scm: Fix interrupted SCM calls Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 097/110] ARM: smccc: Update HVC comment to describe new quirk parameter Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 098/110] PCI: Add Broadcom Northstar2 PAXC quirk for device class and MPSS Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 099/110] PCI: Disable MSI for HiSilicon Hip06/Hip07 Root Ports Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 100/110] mmc: sdhci-of-esdhc: remove default broken-cd for ARM Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 101/110] PCI: Sort the list of devices with D3 delay quirk by ID Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 102/110] PCI: Add ACS quirk for Qualcomm QDF2400 and QDF2432 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 103/110] watchdog: s3c2410: Fix infinite interrupt in soft mode Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 105/110] tools/power turbostat: decode Baytrail CC6 and MC6 demotion configuration Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 106/110] tools/power turbostat: dump Atom P-states correctly Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 107/110] x86/reboot/quirks: Add ASUS EeeBook X205TA reboot quirk Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 108/110] x86/reboot/quirks: Add ASUS EeeBook X205TA/W " Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 109/110] usb-storage: Add ignore-residue quirk for Initio INIC-3619 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 110/110] x86/reboot/quirks: Fix typo in ASUS EeeBook X205TA reboot quirk Greg Kroah-Hartman
2017-04-10 20:39 ` [PATCH 4.10 000/110] 4.10.10-stable review Shuah Khan
2017-04-11  4:58   ` Greg Kroah-Hartman
2017-04-11  3:17 ` Guenter Roeck
2017-04-11  4:48   ` Greg Kroah-Hartman
2017-04-11  5:04     ` Guenter Roeck
2017-04-11  5:02 ` 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=20170410164202.536447292@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=snitzer@redhat.com \
    --cc=stable@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;
as well as URLs for NNTP newsgroup(s).