From: Stefan Berger <stefanb@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
"Marc-Andr Lureau" <marcandre.lureau@redhat.com>,
qemu-stable@nongnu.org, "Michael Tokarev" <mjt@tls.msk.ru>,
"Stefan Berger" <stefanb@linux.ibm.com>
Subject: [PULL v1 1/1] tpm: fix crash when FD >= 1024
Date: Tue, 12 Sep 2023 17:41:10 -0400 [thread overview]
Message-ID: <20230912214110.482744-2-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20230912214110.482744-1-stefanb@linux.ibm.com>
From: Marc-Andr Lureau <marcandre.lureau@redhat.com>
Replace select() with poll() to fix a crash when QEMU has a large number
of FDs.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=2020133
Cc: qemu-stable@nongnu.org
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>
---
backends/tpm/tpm_util.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index a6e6d3e72f..1856589c3b 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);
+ n = RETRY_ON_EINTR(g_poll(fds, 1, 1000));
if (n != 1) {
return -errno;
}
--
2.41.0
next prev parent reply other threads:[~2023-09-12 21:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 21:41 [PULL v1 0/1] Merge tpm 2023/09/12 v1 Stefan Berger
2023-09-12 21:41 ` Stefan Berger [this message]
2023-09-13 6:41 ` [PULL v1 1/1] tpm: fix crash when FD >= 1024 Michael Tokarev
2023-09-13 8:09 ` Daniel P. Berrangé
2023-09-13 5:57 ` [PULL v1 0/1] Merge tpm 2023/09/12 v1 Philippe Mathieu-Daudé
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=20230912214110.482744-2-stefanb@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=marcandre.lureau@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.