All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] io: make sure we don't close stdio fds
@ 2026-10-16 23:09 Filip Hejsek
  2026-10-16 23:09 ` [PATCH v3 1/2] char-stdio: avoid closing " Filip Hejsek
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Filip Hejsek @ 2026-10-16 23:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé, Marc-André Lureau, Paolo Bonzini

The stdio chardev currently closes the stdin and stdout fds when it is
destroyed. This means that, assuming char0 is a stdio chardev, invoking
the HMP command

    chardev-change char0 null

will cause QEMU to run with descriptors 0 and 1 closed. That's not a
great situation, as:
  - the stdio chardev cannot be recreated
  - code assuming fds 0 and 1 are open will misbehave
  - the fds 0 and 1 will get assigned to newly opened files, possibly
    causing them to be confused for actual stdin/stdout

The fist patch fixes the problem by duplicating the fds before they get
passed to qio_channel_file_new_fd(), the second patch adds a warning
that is printed when qio_channel_file_new_fd() is called with a stdio
fd and modifies the documentation of that function to say that passing
stdio descriptors is incorrect.

Changes in v3:
- Add documentation changes
- Link to v2: https://lore.kernel.org/qemu-devel/20261015-fix-stdio-close-v2-0-0f01e6580e24@gmail.com

Changes in v2:
- Code style fixes
- Set *errp when dup fails
- Link to v1: https://lore.kernel.org/qemu-devel/20261013-fix-stdio-close-v1-0-4ecfa416c7bc@gmail.com

Signed-off-by: Filip Hejsek <filip.hejsek@gmail.com>
---
Filip Hejsek (2):
      char-stdio: avoid closing stdio fds
      io: report a warning when a file channel is created from a stdio fd

 chardev/char-stdio.c      | 16 +++++++++++++++-
 include/io/channel-file.h | 12 ++++++++----
 io/channel-file.c         |  6 ++++++
 3 files changed, 29 insertions(+), 5 deletions(-)
---
base-commit: 7e8d3c7fc460fe7cd28a3e423d7466fa292bc269
change-id: 20261012-fix-stdio-close-98864055d473

Best regards,
--  
Filip Hejsek <filip.hejsek@gmail.com>



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

end of thread, other threads:[~2026-10-20 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 23:09 [PATCH v3 0/2] io: make sure we don't close stdio fds Filip Hejsek
2026-10-16 23:09 ` [PATCH v3 1/2] char-stdio: avoid closing " Filip Hejsek
2026-10-16 23:09 ` [PATCH v3 2/2] io: report a warning when a file channel is created from a stdio fd Filip Hejsek
2026-10-20 13:44 ` [PATCH v3 0/2] io: make sure we don't close stdio fds marcandre.lureau

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.