All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] audio/jack: fix use after free segfault
@ 2020-08-18 12:40 Geoffrey McRae
  2020-08-18 13:41 ` no-reply
  2020-08-18 18:11 ` Christian Schoenebeck
  0 siblings, 2 replies; 12+ messages in thread
From: Geoffrey McRae @ 2020-08-18 12:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

Due to a ridiculous commit in the Jack library, the client may have been
freed already by a secondary audio device recovering its session.

https://github.com/jackaudio/jack2/issues/627

Until there is a proper fix for this we can not risk using the pointer
at all if we have been notified of a shutdown as it may have been freed
by the jack library, as such the close call is commented out to prevent
a use after free segfault.

At this time, this will not cause a memory leak as the recovery routine
will trigger the "cleanup" code in the jack library, however, if this is
ever corrected in the jack library this will need to be revisited.

Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
---
 audio/jackaudio.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/audio/jackaudio.c b/audio/jackaudio.c
index 72ed7c4929..e8faf1bb89 100644
--- a/audio/jackaudio.c
+++ b/audio/jackaudio.c
@@ -563,7 +563,22 @@ static void qjack_client_fini(QJackClient *c)
         /* fallthrough */
 
     case QJACK_STATE_SHUTDOWN:
-        jack_client_close(c->client);
+        /*
+         * Due to a rediculous commit in the Jack library, the client may have
+         * been freed already.
+         *
+         * Until there is a proper fix for this we can not risk using the
+         * pointer at all if we have been notified of a shutdown, as such the
+         * below line is commented out to prevent a use after free segfault.
+         * This will not cause a memory leak as the recovery routine will trigger
+         * the "cleanup" code in the jack library.
+         *
+         * https://github.com/jackaudio/jack2/commit/171a3c4a0ddd18d2afae56f3af6291c8e96ee3ac
+         */
+
+        //jack_client_close(c->client);
+        c->client = NULL;
+
         /* fallthrough */
 
     case QJACK_STATE_DISCONNECTED:
-- 
2.20.1



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

end of thread, other threads:[~2020-08-20 13:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 12:40 [PATCH] audio/jack: fix use after free segfault Geoffrey McRae
2020-08-18 13:41 ` no-reply
2020-08-18 18:11 ` Christian Schoenebeck
2020-08-18 22:20   ` Geoffrey McRae
2020-08-19 11:30     ` Christian Schoenebeck
2020-08-19 11:45       ` Geoffrey McRae
2020-08-19 12:41         ` Christian Schoenebeck
2020-08-19 12:51           ` Geoffrey McRae
2020-08-19 15:51             ` Christian Schoenebeck
2020-08-19 15:57               ` Geoffrey McRae
2020-08-20 13:14                 ` Christian Schoenebeck
2020-08-19 13:30         ` Gerd Hoffmann

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.