qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v3 0/8] crypto,io,migration: Add support to gnutls_bye()
@ 2025-02-07 19:53 Fabiano Rosas
  2025-02-07 19:53 ` [RFC PATCH v3 1/8] crypto: Allow gracefully ending the TLS session Fabiano Rosas
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Fabiano Rosas @ 2025-02-07 19:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Xu, Maciej S . Szmigiero, Daniel P . Berrangé

(cover-letter update I forgot on v2:)

This series now contains the two approches we've been discussing to
avoid the TLS termination error on the multifd_recv threads.

The source machine now ends the TLS session with gnutls_bye() and the
destination will consider a premature termination an error. The only
exception is the src <9.1 case where there's a compatibility issue, in
which case the presence of multifd-tls-clean-termination=false will
cause the destination to (always) ignore a premature termination
error.

changes in v3:

Reordered the patches to have the io/crypto stuff at the start and the
compat property before the code that breaks compat.

Commit message improvements.

Turned assert into an warning when gnutls_bye() fails but migration
succeeded (should never happen).

Other minor fixes asked by Daniel.

CI run: https://gitlab.com/farosas/qemu/-/pipelines/1661172595

v2:
https://lore.kernel.org/r/20250207142758.6936-1-farosas@suse.de

v1:
https://lore.kernel.org/r/20250206175824.22664-1-farosas@suse.de

Hi,

We've been discussing a way to stop multifd recv threads from getting
an error at the end of migration when the source threads close the
iochannel without ending the TLS session.

The original issue was introduced by commit 1d457daf86
("migration/multifd: Further remove the SYNC on complete") which
altered the synchronization of the source and destination in a manner
that causes the destination to already be waiting at recv() when the
source closes the connection.

One approach would be to issue gnutls_bye() at the source after all
the data has been sent. The destination would then gracefully exit
when it gets EOF.

Aside from stopping the recv thread from seeing an error, this also
creates a contract that all connections should be closed only after
the TLS session is ended. This helps to avoid masking a legitimate
issue where the connection is closed prematurely.

Fabiano Rosas (8):
  crypto: Allow gracefully ending the TLS session
  io: tls: Add qio_channel_tls_bye
  crypto: Remove qcrypto_tls_session_get_handshake_status
  io: Add flags argument to qio_channel_readv_full_all_eof
  io: Add a read flag for relaxed EOF
  migration/multifd: Terminate the TLS connection
  migration/multifd: Add a compat property for TLS termination
  migration: Check migration error after loadvm

 crypto/tlssession.c                 | 96 ++++++++++++++++++-----------
 hw/core/machine.c                   |  1 +
 hw/remote/mpqemu-link.c             |  2 +-
 include/crypto/tlssession.h         | 46 ++++++++------
 include/io/channel-tls.h            | 12 ++++
 include/io/channel.h                |  3 +
 io/channel-tls.c                    | 92 ++++++++++++++++++++++++++-
 io/channel.c                        |  9 ++-
 io/trace-events                     |  5 ++
 migration/migration.h               | 33 ++++++++++
 migration/multifd.c                 | 53 +++++++++++++++-
 migration/multifd.h                 |  2 +
 migration/options.c                 |  2 +
 migration/savevm.c                  |  6 +-
 migration/tls.c                     |  5 ++
 migration/tls.h                     |  2 +-
 tests/unit/test-crypto-tlssession.c | 12 ++--
 17 files changed, 305 insertions(+), 76 deletions(-)

-- 
2.35.3



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

end of thread, other threads:[~2025-02-10 17:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-07 19:53 [RFC PATCH v3 0/8] crypto,io,migration: Add support to gnutls_bye() Fabiano Rosas
2025-02-07 19:53 ` [RFC PATCH v3 1/8] crypto: Allow gracefully ending the TLS session Fabiano Rosas
2025-02-07 19:53 ` [RFC PATCH v3 2/8] io: tls: Add qio_channel_tls_bye Fabiano Rosas
2025-02-07 19:53 ` [RFC PATCH v3 3/8] crypto: Remove qcrypto_tls_session_get_handshake_status Fabiano Rosas
2025-02-07 19:53 ` [RFC PATCH v3 4/8] io: Add flags argument to qio_channel_readv_full_all_eof Fabiano Rosas
2025-02-10  9:04   ` Daniel P. Berrangé
2025-02-07 19:53 ` [RFC PATCH v3 5/8] io: Add a read flag for relaxed EOF Fabiano Rosas
2025-02-07 19:53 ` [RFC PATCH v3 6/8] migration/multifd: Terminate the TLS connection Fabiano Rosas
2025-02-07 19:53 ` [RFC PATCH v3 7/8] migration/multifd: Add a compat property for TLS termination Fabiano Rosas
2025-02-10 17:11   ` Peter Xu
2025-02-07 19:53 ` [RFC PATCH v3 8/8] migration: Check migration error after loadvm Fabiano Rosas
2025-02-10 17:12   ` Peter Xu

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).