mirror of https://lore.kernel.org/lkml/
 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,
	Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>,
	Baoquan He <bhe@redhat.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Vivek Goyal <vgoyal@redhat.com>, Dave Young <dyoung@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.4 018/118] kexec: fix double-free when failing to relocate the purgatory
Date: Thu, 22 Sep 2016 19:28:38 +0200	[thread overview]
Message-ID: <20160922172939.542044097@linuxfoundation.org> (raw)
In-Reply-To: <20160922172938.643879685@linuxfoundation.org>

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

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

From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>

commit 070c43eea5043e950daa423707ae3c77e2f48edb upstream.

If kexec_apply_relocations fails, kexec_load_purgatory frees pi->sechdrs
and pi->purgatory_buf.  This is redundant, because in case of error
kimage_file_prepare_segments calls kimage_file_post_load_cleanup, which
will also free those buffers.

This causes two warnings like the following, one for pi->sechdrs and the
other for pi->purgatory_buf:

  kexec-bzImage64: Loading purgatory failed
  ------------[ cut here ]------------
  WARNING: CPU: 1 PID: 2119 at mm/vmalloc.c:1490 __vunmap+0xc1/0xd0
  Trying to vfree() nonexistent vm area (ffffc90000e91000)
  Modules linked in:
  CPU: 1 PID: 2119 Comm: kexec Not tainted 4.8.0-rc3+ #5
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
  Call Trace:
    dump_stack+0x4d/0x65
    __warn+0xcb/0xf0
    warn_slowpath_fmt+0x4f/0x60
    ? find_vmap_area+0x19/0x70
    ? kimage_file_post_load_cleanup+0x47/0xb0
    __vunmap+0xc1/0xd0
    vfree+0x2e/0x70
    kimage_file_post_load_cleanup+0x5e/0xb0
    SyS_kexec_file_load+0x448/0x680
    ? putname+0x54/0x60
    ? do_sys_open+0x190/0x1f0
    entry_SYSCALL_64_fastpath+0x13/0x8f
  ---[ end trace 158bb74f5950ca2b ]---

Fix by setting pi->sechdrs an pi->purgatory_buf to NULL, since vfree
won't try to free a NULL pointer.

Link: http://lkml.kernel.org/r/1472083546-23683-1-git-send-email-bauerman@linux.vnet.ibm.com
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
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>

---
 kernel/kexec_file.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -934,7 +934,10 @@ int kexec_load_purgatory(struct kimage *
 	return 0;
 out:
 	vfree(pi->sechdrs);
+	pi->sechdrs = NULL;
+
 	vfree(pi->purgatory_buf);
+	pi->purgatory_buf = NULL;
 	return ret;
 }
 

  parent reply	other threads:[~2016-09-22 17:33 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160922173501uscas1p243aed76c609383566946bc6ebe30e40d@uscas1p2.samsung.com>
2016-09-22 17:28 ` [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 001/118] ext4: use __GFP_NOFAIL in ext4_free_blocks() Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 002/118] fscrypto: add authorization check for setting encryption policy Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 003/118] clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 005/118] Revert "KVM: x86: fix missed hardware breakpoints" Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 006/118] fscrypto: require write access to mount to set encryption policy Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 008/118] tipc: move linearization of buffers to generic code Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 009/118] powerpc/tm: do not use r13 for tabort_syscall Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 010/118] powerpc/powernv : Drop reference added by kset_find_obj() Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 011/118] powerpc/mm: Dont alias user region to other regions below PAGE_OFFSET Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 012/118] kernfs: dont depend on d_find_any_alias() when generating notifications Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 013/118] pNFS: The client must not do I/O to the DS if its lease has expired Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 014/118] NFSv4.x: Fix a refcount leak in nfs_callback_up_net Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 015/118] nfsd: Close race between nfsd4_release_lockowner and nfsd4_lock Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 016/118] pNFS: Ensure LAYOUTGET and LAYOUTRETURN are properly serialised Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 017/118] NFSv4.1: Fix the CREATE_SESSION slot number accounting Greg Kroah-Hartman
2016-09-22 17:28   ` Greg Kroah-Hartman [this message]
2016-09-22 17:28   ` [PATCH 4.4 019/118] mm: introduce get_task_exe_file Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 020/118] audit: fix exe_file access in audit_exe_compare Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 021/118] dm flakey: fix reads to be issued if drop_writes configured Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 022/118] IB/uverbs: Fix race between uverbs_close and remove_one Greg Kroah-Hartman
2016-10-03 12:28     ` Vegard Nossum
2016-10-03 17:05       ` Jason Gunthorpe
2016-09-22 17:28   ` [PATCH 4.4 025/118] x86/AMD: Apply erratum 665 on machines without a BIOS fix Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 026/118] kvm-arm: Unmap shadow pagetables properly Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 027/118] iio: accel: kxsd9: Fix raw read return Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 028/118] iio: proximity: as3935: set up buffer timestamps for non-zero values Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 029/118] iio: adc: rockchip_saradc: reset saradc controller before programming it Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 030/118] iio: adc: ti_am335x_adc: Protect FIFO1 from concurrent access Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 031/118] iio: adc: ti_am335x_adc: Increase timeout value waiting for ADC sample Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 032/118] iio: ad799x: Fix buffered capture for ad7991/ad7995/ad7999 Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 033/118] iio: adc: at91: unbreak channel adc channel 3 Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 034/118] iio: accel: bmc150: reset chip at init time Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 035/118] iio: fix pressure data output unit in hid-sensor-attributes Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 036/118] iio: accel: kxsd9: Fix scaling bug Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 037/118] iio:core: fix IIO_VAL_FRACTIONAL sign handling Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 038/118] iio: ensure ret is initialized to zero before entering do loop Greg Kroah-Hartman
2016-09-22 17:28   ` [PATCH 4.4 039/118] serial: 8250_mid: fix divide error bug if baud rate is 0 Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 040/118] serial: 8250: added acces i/o products quad and octal serial cards Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 041/118] USB: serial: simple: add support for another Infineon flashloader Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 042/118] usb: renesas_usbhs: fix clearing the {BRDY,BEMP}STS condition Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 043/118] usb: chipidea: udc: fix NULL ptr dereference in isr_setup_status_phase Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 044/118] ARM: dts: STiH410: Handle interconnect clock required by EHCI/OHCI (USB) Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 045/118] USB: change bInterval default to 10 ms Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 046/118] cxl: use pcibios_free_controller_deferred() when removing vPHBs Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 047/118] net: thunderx: Fix OOPs with ethtool --register-dump Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 048/118] cpuset: make sure new tasks conform to the current config of the cpuset Greg Kroah-Hartman
2016-09-26 12:34     ` Takashi Iwai
2016-09-26 15:38       ` Greg Kroah-Hartman
2016-09-26 15:44         ` Takashi Iwai
2016-09-22 17:29   ` [PATCH 4.4 049/118] ARM: AM43XX: hwmod: Fix RSTST register offset for pruss Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 050/118] ARM: imx6: add missing BM_CLPCR_BYP_MMDC_CH0_LPM_HS setting for imx6ul Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 051/118] ARM: imx6: add missing BM_CLPCR_BYPASS_PMIC_READY setting for imx6sx Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 052/118] ARM: kirkwood: ib62x0: fix size of u-boot environment partition Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 053/118] ARM: OMAP3: hwmod data: Add sysc information for DSI Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 054/118] ARM: dts: imx6qdl: Fix SPDIF regression Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 055/118] ARM: dts: overo: fix gpmc nand cs0 range Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 056/118] ARM: dts: overo: fix gpmc nand on boards with ethernet Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 057/118] ARM: dts: STiH407-family: Provide interconnect clock for consumption in ST SDHCI Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 058/118] bus: arm-ccn: Fix PMU handling of MN Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 059/118] bus: arm-ccn: Do not attempt to configure XPs for cycle counter Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 060/118] bus: arm-ccn: Fix XP watchpoint settings bitmask Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 061/118] dm log writes: fix check of kthread_run() return value Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 062/118] dm log writes: move IO accounting earlier to fix error path Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 063/118] dm crypt: fix error with too large bios Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 064/118] pinctrl: pistachio: fix mfio pll_lock pinmux Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 065/118] pinctrl: sunxi: fix uart1 CTS/RTS pins at PG on A23/A33 Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 066/118] arm64: spinlocks: implement smp_mb__before_spinlock() as smp_mb() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 067/118] crypto: cryptd - initialize child shash_desc on import Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 068/118] Btrfs: remove root_log_ctx from ctx list before btrfs_sync_log returns Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 069/118] fuse: direct-io: dont dirty ITER_BVEC pages Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 070/118] xhci: fix null pointer dereference in stop command timeout function Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 071/118] md-cluster: make md-cluster also can work when compiled into kernel Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 072/118] ath9k: fix using sta->drv_priv before initializing it Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 073/118] Revert "wext: Fix 32 bit iwpriv compatibility issue with 64 bit Kernel" Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 074/118] sched/core: Fix a race between try_to_wake_up() and a woken up task Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 075/118] ipv6: addrconf: fix dev refcont leak when DAD failed Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 076/118] gma500: remove annoying deprecation warning Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 079/118] mmc: dw_mmc: use resource_size_t to store physical address Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 080/118] pinctrl: at91-pio4: use %pr format string for resource Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 081/118] soc: qcom/spm: shut up uninitialized variable warning Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 082/118] kconfig: tinyconfig: provide whole choice blocks to avoid warnings Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 083/118] net: simplify napi_synchronize() " Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 084/118] drm: atmel-hlcdc: Fix vertical scaling Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 085/118] drm: Only use compat ioctl for addfb2 on X86/IA64 Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 086/118] genirq: Provide irq_gc_{lock_irqsave,unlock_irqrestore}() helpers Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 087/118] irqchip/atmel-aic: Fix potential deadlock in ->xlate() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 088/118] fix iov_iter_fault_in_readable() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 089/118] microblaze: fix __get_user() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 090/118] avr32: fix copy_from_user() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 091/118] microblaze: " Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 092/118] fix minor infoleak in get_user_ex() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 093/118] mn10300: failing __get_user() and get_user() should zero Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 094/118] m32r: fix __get_user() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 095/118] sh64: failing __get_user() should zero Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 096/118] nios2: fix __get_user() Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 097/118] score: fix __get_user/get_user Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 098/118] s390: get_user() should zero on failure Greg Kroah-Hartman
2016-09-22 17:29   ` [PATCH 4.4 099/118] ARC: uaccess: get_user to zero out dest in cause of fault Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 100/118] asm-generic: make get_user() clear the destination on errors Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 101/118] frv: fix clear_user() Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 102/118] cris: buggered copy_from_user/copy_to_user/clear_user Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 103/118] blackfin: fix copy_from_user() Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 104/118] score: fix copy_from_user() and friends Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 105/118] sh: fix copy_from_user() Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 106/118] hexagon: fix strncpy_from_user() error return Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 107/118] mips: copy_from_user() must zero the destination on access_ok() failure Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 108/118] asm-generic: make copy_from_user() zero the destination properly Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 109/118] alpha: fix copy_from_user() Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 110/118] metag: copy_from_user() should zero the destination on access_ok() failure Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 111/118] parisc: fix copy_from_user() Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 112/118] openrisc: " Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 113/118] nios2: copy_from_user() should zero the tail of destination Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 114/118] mn10300: copy_from_user() should zero on access_ok() failure Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 115/118] sparc32: fix copy_from_user() Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 116/118] ppc32: " Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 117/118] genirq/msi: Fix broken debug output Greg Kroah-Hartman
2016-09-22 17:30   ` [PATCH 4.4 118/118] ia64: copy_from_user() should zero the destination on access_ok() failure Greg Kroah-Hartman
2016-09-22 19:56   ` [PATCH 4.4 000/118] 4.4.22-stable review Holger Hoffstätte
2016-09-23  8:14     ` Greg Kroah-Hartman
2016-09-23  8:43       ` Holger Hoffstätte
2016-09-23  9:21         ` Greg Kroah-Hartman
2016-09-22 23:43   ` Guenter Roeck
2016-09-23  3:01   ` Guenter Roeck
2016-09-23  8:05     ` Greg Kroah-Hartman
2016-09-23  8:08     ` Greg Kroah-Hartman
2016-09-23 13:25       ` Guenter Roeck
2016-09-23 15:11         ` Greg Kroah-Hartman
2016-09-23 15:30           ` Greg Kroah-Hartman
2016-09-28  8:45             ` Andrew Donnellan
2016-09-28 13:29               ` Mauricio Faria de Oliveira
2016-10-10  8:39                 ` Greg Kroah-Hartman
2016-09-23  8:10     ` Greg Kroah-Hartman
2016-09-23  8:11     ` Greg Kroah-Hartman
2016-09-23 16:02   ` Shuah Khan

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=20160922172939.542044097@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=bauerman@linux.vnet.ibm.com \
    --cc=bhe@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vgoyal@redhat.com \
    /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

Powered by JetHome