From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Oleksandr Natalenko <onatalen@redhat.com>,
Gil Kupfer <gilkup@gmail.com>, Nadav Amit <namit@vmware.com>,
Xavier Deguillard <xdeguillard@vmware.com>,
Oleksandr Natalenko <oleksandr@redhat.com>
Subject: [PATCH 4.4 20/24] vmw_balloon: fixing double free when batching mode is off
Date: Thu, 14 Jun 2018 16:05:15 +0200 [thread overview]
Message-ID: <20180614132725.294268374@linuxfoundation.org> (raw)
In-Reply-To: <20180614132724.483802160@linuxfoundation.org>
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gil Kupfer <gilkup@gmail.com>
commit b23220fe054e92f616b82450fae8cd3ab176cc60 upstream.
The balloon.page field is used for two different purposes if batching is
on or off. If batching is on, the field point to the page which is used
to communicate with with the hypervisor. If it is off, balloon.page
points to the page that is about to be (un)locked.
Unfortunately, this dual-purpose of the field introduced a bug: when the
balloon is popped (e.g., when the machine is reset or the balloon driver
is explicitly removed), the balloon driver frees, unconditionally, the
page that is held in balloon.page. As a result, if batching is
disabled, this leads to double freeing the last page that is sent to the
hypervisor.
The following error occurs during rmmod when kernel checkers are on, and
the balloon is not empty:
[ 42.307653] ------------[ cut here ]------------
[ 42.307657] Kernel BUG at ffffffffba1e4b28 [verbose debug info unavailable]
[ 42.307720] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC
[ 42.312512] Modules linked in: vmw_vsock_vmci_transport vsock ppdev joydev vmw_balloon(-) input_leds serio_raw vmw_vmci parport_pc shpchp parport i2c_piix4 nfit mac_hid autofs4 vmwgfx drm_kms_helper hid_generic syscopyarea sysfillrect usbhid sysimgblt fb_sys_fops hid ttm mptspi scsi_transport_spi ahci mptscsih drm psmouse vmxnet3 libahci mptbase pata_acpi
[ 42.312766] CPU: 10 PID: 1527 Comm: rmmod Not tainted 4.12.0+ #5
[ 42.312803] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 09/30/2016
[ 42.313042] task: ffff9bf9680f8000 task.stack: ffffbfefc1638000
[ 42.313290] RIP: 0010:__free_pages+0x38/0x40
[ 42.313510] RSP: 0018:ffffbfefc163be98 EFLAGS: 00010246
[ 42.313731] RAX: 000000000000003e RBX: ffffffffc02b9720 RCX: 0000000000000006
[ 42.313972] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9bf97e08e0a0
[ 42.314201] RBP: ffffbfefc163be98 R08: 0000000000000000 R09: 0000000000000000
[ 42.314435] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffc02b97e4
[ 42.314505] R13: ffffffffc02b9748 R14: ffffffffc02b9728 R15: 0000000000000200
[ 42.314550] FS: 00007f3af5fec700(0000) GS:ffff9bf97e080000(0000) knlGS:0000000000000000
[ 42.314599] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 42.314635] CR2: 00007f44f6f4ab24 CR3: 00000003a7d12000 CR4: 00000000000006e0
[ 42.314864] Call Trace:
[ 42.315774] vmballoon_pop+0x102/0x130 [vmw_balloon]
[ 42.315816] vmballoon_exit+0x42/0xd64 [vmw_balloon]
[ 42.315853] SyS_delete_module+0x1e2/0x250
[ 42.315891] entry_SYSCALL_64_fastpath+0x23/0xc2
[ 42.315924] RIP: 0033:0x7f3af5b0e8e7
[ 42.315949] RSP: 002b:00007fffe6ce0148 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
[ 42.315996] RAX: ffffffffffffffda RBX: 000055be676401e0 RCX: 00007f3af5b0e8e7
[ 42.316951] RDX: 000000000000000a RSI: 0000000000000800 RDI: 000055be67640248
[ 42.317887] RBP: 0000000000000003 R08: 0000000000000000 R09: 1999999999999999
[ 42.318845] R10: 0000000000000883 R11: 0000000000000206 R12: 00007fffe6cdf130
[ 42.319755] R13: 0000000000000000 R14: 0000000000000000 R15: 000055be676401e0
[ 42.320606] Code: c0 74 1c f0 ff 4f 1c 74 02 5d c3 85 f6 74 07 e8 0f d8 ff ff 5d c3 31 f6 e8 c6 fb ff ff 5d c3 48 c7 c6 c8 0f c5 ba e8 58 be 02 00 <0f> 0b 66 0f 1f 44 00 00 66 66 66 66 90 48 85 ff 75 01 c3 55 48
[ 42.323462] RIP: __free_pages+0x38/0x40 RSP: ffffbfefc163be98
[ 42.325735] ---[ end trace 872e008e33f81508 ]---
To solve the bug, we eliminate the dual purpose of balloon.page.
Fixes: f220a80f0c2e ("VMware balloon: add batching to the vmw_balloon.")
Cc: stable@vger.kernel.org
Reported-by: Oleksandr Natalenko <onatalen@redhat.com>
Signed-off-by: Gil Kupfer <gilkup@gmail.com>
Signed-off-by: Nadav Amit <namit@vmware.com>
Reviewed-by: Xavier Deguillard <xdeguillard@vmware.com>
Tested-by: Oleksandr Natalenko <oleksandr@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/misc/vmw_balloon.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -576,15 +576,9 @@ static void vmballoon_pop(struct vmballo
}
}
- if (b->batch_page) {
- vunmap(b->batch_page);
- b->batch_page = NULL;
- }
-
- if (b->page) {
- __free_page(b->page);
- b->page = NULL;
- }
+ /* Clearing the batch_page unconditionally has no adverse effect */
+ free_page((unsigned long)b->batch_page);
+ b->batch_page = NULL;
}
/*
@@ -991,16 +985,13 @@ static const struct vmballoon_ops vmball
static bool vmballoon_init_batching(struct vmballoon *b)
{
- b->page = alloc_page(VMW_PAGE_ALLOC_NOSLEEP);
- if (!b->page)
- return false;
+ struct page *page;
- b->batch_page = vmap(&b->page, 1, VM_MAP, PAGE_KERNEL);
- if (!b->batch_page) {
- __free_page(b->page);
+ page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+ if (!page)
return false;
- }
+ b->batch_page = page_address(page);
return true;
}
next prev parent reply other threads:[~2018-06-14 14:13 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-14 14:04 [PATCH 4.4 00/24] 4.4.138-stable review Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 01/24] x86/fpu: Fix early FPU command-line parsing Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 02/24] x86: Remove unused function cpu_has_ht_siblings() Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 03/24] x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 04/24] x86/fpu: Disable MPX when eagerfpu is off Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 05/24] x86/fpu: Disable AVX " Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 06/24] x86/fpu: Default eagerfpu=on on all CPUs Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 07/24] x86/fpu: Fix no387 regression Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 08/24] x86/fpu: Revert ("x86/fpu: Disable AVX when eagerfpu is off") Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 09/24] x86/fpu: Fix eager-FPU handling on legacy FPU machines Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 10/24] x86/fpu: Hard-disable lazy FPU mode Greg Kroah-Hartman
2018-06-15 4:24 ` Daniel Sangorrin
2018-06-15 4:56 ` 'Greg Kroah-Hartman'
2018-06-15 5:23 ` Daniel Sangorrin
2018-06-15 7:06 ` 'Greg Kroah-Hartman'
2018-06-15 9:49 ` Daniel Sangorrin
2018-06-19 15:02 ` Ben Hutchings
2018-06-14 14:05 ` [PATCH 4.4 11/24] x86/fpu: Fix FNSAVE usage in eagerfpu mode Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 12/24] x86/fpu: Fix math emulation in eager fpu mode Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 13/24] af_key: Always verify length of provided sadb_key Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 14/24] x86/crypto, x86/fpu: Remove X86_FEATURE_EAGER_FPU #ifdef from the crc32c code Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 15/24] gpio: No NULL owner Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 16/24] Clarify (and fix) MAX_LFS_FILESIZE macros Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 17/24] KVM: x86: introduce linear_{read,write}_system Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 18/24] KVM: x86: pass kvm_vcpu to kvm_read_guest_virt and kvm_write_guest_virt_system Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 19/24] serial: samsung: fix maxburst parameter for DMA transactions Greg Kroah-Hartman
2018-06-14 14:05 ` Greg Kroah-Hartman [this message]
2018-06-14 14:05 ` [PATCH 4.4 21/24] kvm: x86: use correct privilege level for sgdt/sidt/fxsave/fxrstor access Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 22/24] Input: goodix - add new ACPI id for GPD Win 2 touch screen Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 23/24] Input: elan_i2c - add ELAN0612 (Lenovo v330 14IKB) ACPI ID Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 24/24] crypto: vmx - Remove overly verbose printk from AES init routines Greg Kroah-Hartman
2018-06-14 16:57 ` [PATCH 4.4 00/24] 4.4.138-stable review Nathan Chancellor
2018-06-14 18:47 ` Greg Kroah-Hartman
2018-06-14 22:43 ` Shuah Khan
2018-06-15 0:24 ` Naresh Kamboju
2018-06-15 15:18 ` Guenter Roeck
2018-06-19 14:28 ` Ben Hutchings
2018-06-28 4:09 ` Daniel Sangorrin
2018-07-05 16:08 ` 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=20180614132725.294268374@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=gilkup@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namit@vmware.com \
--cc=oleksandr@redhat.com \
--cc=onatalen@redhat.com \
--cc=stable@vger.kernel.org \
--cc=xdeguillard@vmware.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;
as well as URLs for NNTP newsgroup(s).