Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3944521pxj; Mon, 21 Jun 2021 09:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMi7prA/gqFLOaEEqo8JE1IiPkqQKgB8YTK/6uJK/E8KrYSQncHp/NfJpi4losGBedSnkg X-Received: by 2002:a17:907:1611:: with SMTP id hb17mr12568417ejc.450.1624294546348; Mon, 21 Jun 2021 09:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624294546; cv=none; d=google.com; s=arc-20160816; b=ijAJFbQp8x83Z/hk06TXA58GIaOrg06oiab8VH8WMN03agviMsl91UKMcmgkjQ+fWx 5UEEiL/zrQGZzN3GW6elkvsVlkqMx4ZSGTfTrfmDC9fbHB4Xh0AGgwDe8yChf3a5VquF Rdokw4nmcuHc80rL2l8sPaHRqhVjXgazvQyEctI6+h5X3ZamWNN7jL3rRX9AOdUFRybl 4L6uPng2m1ExZlfB0gGi1KN7KO9IPTD0LZy2Xr233H80JgBqlN2caPl494hFA0vflt8E 3UHsnA3sj6t3OBtiMZOPruWVTb6K3sQcECgaBfluMpyzRRmikPXe8f/5tl3/Go0g5EVo Dv9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rT1SMjd1SvSIycGn25hStjtGSVe3M3WyzQAK88EW86w=; b=vR0jnJ71YMAVW/S7wEbqLn+vzoHQhbNBd8gT/qBD/qfDCFxIp+J417leHTQtliAHPq fNT9dEnUUE4s3ZoE+dc0WBKoOB3EZfQUVnk828/R5IVSbg55PblgWzEavg994dPjAQSX Dli+S8eujUSkkADCEs2K7JK3X9BG1Hv45w8ZND1sSGl+kFTLWVTax7x/aeavnxGqN/IM NVPh59pQB2/AxIW9d73IQr6tlkHqE+NZpZ3BnWnfMZhD+Ds0s8icjzWyfGUwdiBQH5sr kxDr5rxVT01P8n447E+ckGkfLdX2ViMoCqSqQPDQGoAzJmIpa6IqsT1WvzpqYBwj/o8n QEKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QZ3cj848; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs19si11200240ejb.398.2021.06.21.09.55.23; Mon, 21 Jun 2021 09:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QZ3cj848; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233297AbhFUQyR (ORCPT + 99 others); Mon, 21 Jun 2021 12:54:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:41416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233538AbhFUQtz (ORCPT ); Mon, 21 Jun 2021 12:49:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 788E661466; Mon, 21 Jun 2021 16:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293291; bh=ztOFQtRDJh1fFvx2oSEzVnYkyu7Wjyefhrj19t49ZjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZ3cj8484wOEQi2V4G2ty6mBoiAuMfQ9U5R5btDc6nqrbOQsAJ7zXM8Fr2EW2kVvj tTXOAj6sUy4D6nISxc/3vXc/eMNrPSZLOJsPOnudubh9bGA6dAtSvneXo/u7QJKYsL dOM6LPC8L8eUHzNoatnkam6EG3AJOOH+iFdR8Y/4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wanpeng Li , Paolo Bonzini Subject: [PATCH 5.12 136/178] KVM: X86: Fix x86_emulator slab cache leak Date: Mon, 21 Jun 2021 18:15:50 +0200 Message-Id: <20210621154927.405045365@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li commit dfdc0a714d241bfbf951886c373cd1ae463fcc25 upstream. Commit c9b8b07cded58 (KVM: x86: Dynamically allocate per-vCPU emulation context) tries to allocate per-vCPU emulation context dynamically, however, the x86_emulator slab cache is still exiting after the kvm module is unload as below after destroying the VM and unloading the kvm module. grep x86_emulator /proc/slabinfo x86_emulator 36 36 2672 12 8 : tunables 0 0 0 : slabdata 3 3 0 This patch fixes this slab cache leak by destroying the x86_emulator slab cache when the kvm module is unloaded. Fixes: c9b8b07cded58 (KVM: x86: Dynamically allocate per-vCPU emulation context) Cc: stable@vger.kernel.org Signed-off-by: Wanpeng Li Message-Id: <1623387573-5969-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8150,6 +8150,7 @@ void kvm_arch_exit(void) kvm_x86_ops.hardware_enable = NULL; kvm_mmu_module_exit(); free_percpu(user_return_msrs); + kmem_cache_destroy(x86_emulator_cache); kmem_cache_destroy(x86_fpu_cache); #ifdef CONFIG_KVM_XEN static_key_deferred_flush(&kvm_xen_enabled);