qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL v2 0/1] Merge tpm 2023/09/12 v2
@ 2023-09-13 11:54 Stefan Berger
  2023-09-13 11:54 ` [PULL v2 1/1] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR Stefan Berger
  2023-09-13 12:27 ` [PULL v2 0/1] Merge tpm 2023/09/12 v2 Philippe Mathieu-Daudé
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Berger @ 2023-09-13 11:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Stefan Berger

Hello!

  This PR contains a fix for the case where the TPM file descriptor is >= 1024
and the select() call cannot be used. It also avoids unnecessary errors due to
EINTR being returned from the syscall.

Regards,
   Stefan

The following changes since commit 9ef497755afc252fb8e060c9ea6b0987abfd20b6:

  Merge tag 'pull-vfio-20230911' of https://github.com/legoater/qemu into staging (2023-09-11 09:13:08 -0400)

are available in the Git repository at:

  https://github.com/stefanberger/qemu-tpm.git tags/pull-tpm-2023-09-12-2

for you to fetch changes up to 07160c57e47ce38bd256af3eae0481543fb52626:

  tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR (2023-09-13 07:46:59 -0400)

----------------------------------------------------------------

Marc-Andr޸ Lureau (1):
  tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR

 backends/tpm/tpm_util.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PULL v2 1/1] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR
  2023-09-13 11:54 [PULL v2 0/1] Merge tpm 2023/09/12 v2 Stefan Berger
@ 2023-09-13 11:54 ` Stefan Berger
  2023-09-13 12:01   ` Michael Tokarev
  2023-09-13 12:27 ` [PULL v2 0/1] Merge tpm 2023/09/12 v2 Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Berger @ 2023-09-13 11:54 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Marc-Andr޸ Lureau, qemu-stable,
	Michael Tokarev, Stefan Berger

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.

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PULL v2 1/1] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR
  2023-09-13 11:54 ` [PULL v2 1/1] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR Stefan Berger
@ 2023-09-13 12:01   ` Michael Tokarev
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Tokarev @ 2023-09-13 12:01 UTC (permalink / raw)
  To: Stefan Berger, qemu-devel
  Cc: peter.maydell, Marc-André Lureau, qemu-stable

13.09.2023 14:54, Stefan Berger:

> Signed-off-by: Marc-Andr޸ Lureau <marcandre.lureau@redhat.com>

It looks like this UTF8 glitch is within the commit itself, since
https://github.com/stefanberger/qemu-tpm/commit/07160c57e47ce38bd256af3eae0481543fb52626
is also displayed wrongly but the page itself is in UTF8.

/mjt


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PULL v2 0/1] Merge tpm 2023/09/12 v2
  2023-09-13 11:54 [PULL v2 0/1] Merge tpm 2023/09/12 v2 Stefan Berger
  2023-09-13 11:54 ` [PULL v2 1/1] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR Stefan Berger
@ 2023-09-13 12:27 ` Philippe Mathieu-Daudé
  2023-09-13 12:40   ` Stefan Berger
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-09-13 12:27 UTC (permalink / raw)
  To: Stefan Berger, qemu-devel; +Cc: peter.maydell

Hi Stefan,

On 13/9/23 13:54, Stefan Berger wrote:
> Hello!
> 
>    This PR contains a fix for the case where the TPM file descriptor is >= 1024
> and the select() call cannot be used. It also avoids unnecessary errors due to
> EINTR being returned from the syscall.
> 
> Regards,
>     Stefan
> 
> The following changes since commit 9ef497755afc252fb8e060c9ea6b0987abfd20b6:
> 
>    Merge tag 'pull-vfio-20230911' of https://github.com/legoater/qemu into staging (2023-09-11 09:13:08 -0400)
> 
> are available in the Git repository at:
> 
>    https://github.com/stefanberger/qemu-tpm.git tags/pull-tpm-2023-09-12-2
> 
> for you to fetch changes up to 07160c57e47ce38bd256af3eae0481543fb52626:
> 
>    tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR (2023-09-13 07:46:59 -0400)
> 
> ----------------------------------------------------------------
> 
> Marc-Andr޸ Lureau (1):
>    tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR

I recommend you the b4 tool, see:
https://pypi.org/project/b4/
https://people.kernel.org/monsieuricon/introducing-b4-and-patch-attestation


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PULL v2 0/1] Merge tpm 2023/09/12 v2
  2023-09-13 12:27 ` [PULL v2 0/1] Merge tpm 2023/09/12 v2 Philippe Mathieu-Daudé
@ 2023-09-13 12:40   ` Stefan Berger
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Berger @ 2023-09-13 12:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: peter.maydell


On 9/13/23 08:27, Philippe Mathieu-Daudé wrote:
> Hi Stefan,
>
> On 13/9/23 13:54, Stefan Berger wrote:
>> Hello!
>>
>>    This PR contains a fix for the case where the TPM file descriptor 
>> is >= 1024
>> and the select() call cannot be used. It also avoids unnecessary 
>> errors due to
>> EINTR being returned from the syscall.
>>
>> Regards,
>>     Stefan
>>
>> The following changes since commit 
>> 9ef497755afc252fb8e060c9ea6b0987abfd20b6:
>>
>>    Merge tag 'pull-vfio-20230911' of https://github.com/legoater/qemu 
>> into staging (2023-09-11 09:13:08 -0400)
>>
>> are available in the Git repository at:
>>
>>    https://github.com/stefanberger/qemu-tpm.git 
>> tags/pull-tpm-2023-09-12-2
>>
>> for you to fetch changes up to 07160c57e47ce38bd256af3eae0481543fb52626:
>>
>>    tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR 
>> (2023-09-13 07:46:59 -0400)
>>
>> ----------------------------------------------------------------
>>
>> Marc-Andr޸ Lureau (1):
>>    tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR
>
> I recommend you the b4 tool, see:
> https://pypi.org/project/b4/
> https://people.kernel.org/monsieuricon/introducing-b4-and-patch-attestation 
>

I had tried to use 'patches' but it doesn't seem to work anymore on the 
python level. So I ended up saving the email via Thunderbird and applied 
it. Maybe that's the mistake? Otherwise I know the b4 tool and typically 
am using it for Linux patches but I see now that there's lore.kernel.org 
for qemu-devel as well. Alright, v3 coming up soon.

    Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-13 12:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-13 11:54 [PULL v2 0/1] Merge tpm 2023/09/12 v2 Stefan Berger
2023-09-13 11:54 ` [PULL v2 1/1] tpm: fix crash when FD >= 1024 and unnecessary errors due to EINTR Stefan Berger
2023-09-13 12:01   ` Michael Tokarev
2023-09-13 12:27 ` [PULL v2 0/1] Merge tpm 2023/09/12 v2 Philippe Mathieu-Daudé
2023-09-13 12:40   ` Stefan Berger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).