From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C80CD3A7595 for ; Sat, 8 Aug 2026 08:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786176675; cv=none; b=VGvZqa/ZbTPkLO5iE+aoYRadQxXUJ+L2gP8JPVWUC2/xr1M1Z6pUDnIgHJWKAnFlBC4GIzGBkbDgelvOk80dB8QkMEjI3T6XZu4IkDwiR8p6kQImAaSFLJkWwSJgdQav/j7sa+CYnHFhtXcaHLawNszsH/QXwRKd5NSdFZdfNzI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786176675; c=relaxed/simple; bh=lrC44I8iM/31bF4d4aI5ZoY4vfzbALhpHlYJjauf8dI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qdOHzt4DfS6ReDY2UyWUSajxy5n1pUXsSqPFgl/cLvJ7tNWlWRee1IbJ6je+PbmzkQGYJ01nbmGtUUGRdrqOam5SdRFZY9orKiSZ0GFu1bCNI7r0MXhRiiHViGBAxUHuZRLpgtvVuAbPAc88D+GtUbEogpqlsHYw/Yr9l36wpD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BTBw2R30; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BTBw2R30" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-84830c774a0so226635b3a.1 for ; Sat, 08 Aug 2026 01:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786176673; x=1786781473; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Wux81zj1Lg+H9qFJc6k3PJIeFmxAFwN6X2fCIKjgs3Q=; b=BTBw2R30csVw3GOoGpvRoEGzCEaaKUwTfG3930kwuMxABiZg0TxbiJnM6qTe9IJ2al Dog/pOsMhbJL+13DEHCgTfIIbMcKshUSeYUCDWQi0aWRGEAAYTRgAMPwuPhkOXvQJO2A cJlJukzY+/+gMhAl7H06JuVpzwwveRLJIwJKo44ZfjmF3PSadApJzqFffgu/RqrQhZdg pVzfQC/V22Yl9ztdPwKZ1i1D4Tq5uKE9B6xkSGBd6HJgTdWQgrOffYjBBqBzdewKqlzr BQymPEufd4r7BbQ23Ee/5u915IDZOFxz5XJoCB2ax8x5Vc0ArZ62Gtck+a8nfieRHXoB x9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786176673; x=1786781473; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Wux81zj1Lg+H9qFJc6k3PJIeFmxAFwN6X2fCIKjgs3Q=; b=ht9vgXOxmI09ugAhqIA84OLAr7yHXE1oExRCvgiqUP8B/g22rgbaGqWgT+im/E+Q9/ kYFI0pHYd/F3U1kU/93CjsrBLCZA81YCrH9NBNUpwcvVNMiYY/+S4nGGIM8Yu3RUEOCn +5BJeCOOkoV55rw7WM0TFRbHbuTp88X0IR6KIIALldpKfJXMy4pZhM322lfWMNkfzwv4 d/eaNr5wtiXNSjLsWbz4Mlleb13y5budA3L91pD03imvakr8CCKmoL73lhPW95mC2Gfo +InYechhD8Vav/EPtu3G9u6bL6q+skg/x0Y3F99xq80ylBcRV5bQfzUTvZyUVKxcmIZT EyDw== X-Forwarded-Encrypted: i=1; AHgh+RoSonLwgdGzLru1iIiKUAK51xFuflydM4GXSiyMtbC4H+aPWUn4B5iKDZTRLatCO9bC00mA4BJwXeR5SHE=@vger.kernel.org X-Gm-Message-State: AOJu0YwN3KNwIokJU5J8IaY/C8bcY1z00nwerz5uKDaA7+mPCskTrIhZ Ziqsjvpa+BiAc2jaXF7nb5MJ3khySB5AT8t60PcYZ69RBLrYoQFNcd8c X-Gm-Gg: AR+sD10R9/aIorEMRP1o5aZVpX3j67cx/fBhuU1s8t5wIeLrhfSWljTerWywrpHsTRs 0ocUUZ2RV3OtgWpkkJRuMGb0GYG5g5pErKyOcvl81OQilZkLgh53+CSnOuGoV8JdwcBG4no5AMt sNixo9rN96tTmdncpYBSn5CXPKdP/6rd8PuCN0/p49Gz0w6/XS7B/sEPKfDysZh+MWqUGvIep9k o9u2NA8rz8Sw9XtZ22sLpq9rfr4l1f/OWZukaERuliEZ0FUXRbzwpYdtYvrGifmdl2ffHuF0vRQ 5vKvQ29ErIUyDLt8RnoKIuPhdeSlGo4XsFGRfS/2bmjcyEW+Ldj+41hA3+depu2agEsAtBd9v+f PvlKxa5U4rfPsfdB5V886q9t9B6DqAiSwu3IAk/MpHnGeeW5asfqvqyh3yIYFgwxhkS170kQd/J CX0pVh3nZuUBWzBWcrL0dBBkTqYjvfxQFTctUGyb+wxomLXeKq1Z8dDv6T25Ji8HkLod0C8AzW8 w== X-Received: by 2002:a05:6a20:430b:b0:3c3:6928:8b25 with SMTP id adf61e73a8af0-3cbce8d4439mr6418307637.17.1786176673027; Sat, 08 Aug 2026 01:11:13 -0700 (PDT) Received: from 10-86-27-207.ban-spse ([165.204.217.251]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be8a754dsm15208279eec.11.2026.08.08.01.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2026 01:11:12 -0700 (PDT) From: Gokul K To: Sean Christopherson , Paolo Bonzini Cc: Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/2] KVM: selftests: Fix two VMs leaked on early returns Date: Sat, 8 Aug 2026 13:40:48 +0530 Message-ID: <20260808081050.408657-1-gokul02k@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Two x86 selftests create a VM and then take an early return that skips the kvm_vm_free() at the end of the function. Patch 1 is the plain-SEV path of sev_smoke_test(), which returns straight out of the UCALL_DONE case instead of leaving the loop. The SEV-ES path next to it breaks out and frees correctly. Patch 2 is nx_huge_pages_test, which returns as soon as it has confirmed that disabling NX huge pages is denied without CAP_SYS_BOOT. This one is not an unusual error path: nx_huge_pages_test.sh runs the test without CAP_SYS_BOOT for any non-root user, so a normal run always takes it. Neither leak causes a failure today, since the process exits shortly afterwards. They do mean those paths never exercise VM teardown. The two patches are independent and either can be applied on its own. Found by auditing every function under tools/testing/selftests/kvm/ that creates a VM and later calls kvm_vm_free(), looking for returns in between. Seven other hits were false positives, mostly returns after REPORT_GUEST_ASSERT() or TEST_FAIL(), which abort the process and make the return unreachable. Two more that do look real, in get-reg-list.c and arm64/external_aborts.c, are left out here because they belong to different maintainers. Compile-tested only. This host has neither SEV (kvm_amd sev=N) nor hugetlb configured, so both tests SKIP rather than run. Note patch 1 touches sev_smoke_test.c, which an unrelated patch I sent earlier also touches [1]. They modify different functions, do not conflict, and neither depends on the other. [1] https://lore.kernel.org/all/20260807071026.195503-1-gokul02k@gmail.com/ Gokul K (2): KVM: selftests: Free the VM when the SEV smoke test's guest completes KVM: selftests: Free the VM when NX hugepage disabling is denied tools/testing/selftests/kvm/x86/nx_huge_pages_test.c | 1 + tools/testing/selftests/kvm/x86/sev_smoke_test.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) -- 2.54.0