lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220909152056.1335261-1-stefanb@linux.vnet.ibm.com>
Date:   Fri,  9 Sep 2022 11:20:56 -0400
From:   Stefan Berger <stefanb@...ux.vnet.ibm.com>
To:     jarkko@...nel.org, linux-integrity@...r.kernel.org
Cc:     peterhuewe@....de, linux-kernel@...r.kernel.org,
        linux-kselftest@...r.kernel.org, skhan@...uxfoundation.org,
        Stefan Berger <stefanb@...ux.ibm.com>,
        Shuah Khan <shuah@...nel.org>
Subject: [PATCH] selftests: tpm2: Implement class desstructor to close file descriptor

From: Stefan Berger <stefanb@...ux.ibm.com>

Implement a class destructor to close the open TPM file descriptor
and avoid the following error message:

 test_flush_context (tpm2_tests.SpaceTest) ... \
   /usr/lib64/python3.6/unittest/case.py:605: ResourceWarning: \
   unclosed file <_io.FileIO name='/dev/tpmrm0' mode='rb+' closefd=True>

Fixes: 6ea3dfe1e0732 ("selftests: add TPM 2.0 tests")
Cc: Shuah Khan <shuah@...nel.org>
Cc: linux-kselftest@...r.kernel.org
Cc: Jarkko Sakkinen <jarkko@...nel.org>
Signed-off-by: Stefan Berger <stefanb@...ux.ibm.com>

---
 tools/testing/selftests/tpm2/tpm2.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py
index 057a4f49c79d..c7363c6764fc 100644
--- a/tools/testing/selftests/tpm2/tpm2.py
+++ b/tools/testing/selftests/tpm2/tpm2.py
@@ -371,6 +371,10 @@ class Client:
             fcntl.fcntl(self.tpm, fcntl.F_SETFL, flags)
             self.tpm_poll = select.poll()
 
+    def __del__(self):
+        if self.tpm:
+            self.tpm.close()
+
     def close(self):
         self.tpm.close()
 
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ