[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.6 63/63] tpm: fix crash when FD >= 1024 and unnecessary erro
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.6 63/63] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR |
Date: |
Wed, 20 Sep 2023 15:15:48 +0300 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Replace select() with poll() to fix a crash when QEMU has a large number
of FDs. Also use RETRY_ON_EINTR to avoid unnecessary errors due to EINTR.
Cc: qemu-stable@nongnu.org
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2020133
Fixes: 56a3c24ffc ("tpm: Probe for connected TPM 1.2 or TPM 2")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
(cherry picked from commit 8e32ddff69b6b4547cc00592ad816484e160817a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: use TFR() instead of RETRY_ON_EINTR() before v7.2.0-538-g8b6aa69365)
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index a6e6d3e72f..a9d6f7a1c4 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -112,12 +112,8 @@ static int tpm_util_request(int fd,
void *response,
size_t responselen)
{
- fd_set readfds;
+ GPollFD fds[1] = { {.fd = fd, .events = G_IO_IN } };
int n;
- struct timeval tv = {
- .tv_sec = 1,
- .tv_usec = 0,
- };
n = write(fd, request, requestlen);
if (n < 0) {
@@ -127,11 +123,8 @@ static int tpm_util_request(int fd,
return -EFAULT;
}
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
-
/* wait for a second */
- n = select(fd + 1, &readfds, NULL, NULL, &tv);
+ TFR(n = g_poll(fds, 1, 1000));
if (n != 1) {
return -errno;
}
--
2.39.2
- [Stable-7.2.6 54/63] hw/char/riscv_htif: Fix printing of console characters on big endian hosts, (continued)
- [Stable-7.2.6 54/63] hw/char/riscv_htif: Fix printing of console characters on big endian hosts, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 53/63] arm64: Restore trapless ptimer access, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 55/63] hw/intc: Fix upper/lower mtime write calculation, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 56/63] hw/intc: Make rtc variable names consistent, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 60/63] hw/tpm: TIS on sysbus: Remove unsupport ppi command line option, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 62/63] s390x/ap: fix missing subsystem reset registration, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 61/63] ui: fix crash when there are no active_console, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 59/63] target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 57/63] linux-user/riscv: Use abi type for target_ucontext, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 58/63] hw/riscv: virt: Fix riscv,pmu DT node path, Michael Tokarev, 2023/09/20
- [Stable-7.2.6 63/63] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR,
Michael Tokarev <=