bluez icon indicating copy to clipboard operation
bluez copied to clipboard

obexd 5.87 - SIGSEGV in gobex read_packet when non-error GIOStatus leaves read_err NULL

Open erikwb opened this issue 3 months ago • 1 comments

Description

obexd 5.87 crashed with SIGSEGV while reading from the transport underneath a live OBEX session during disconnect. In read_packet(), a non-G_IO_STATUS_NORMAL return from g_io_channel_read_chars() is treated as implying that the GError out-parameter was populated. But GLib sets the GError only for G_IO_STATUS_ERROR, and leaves it NULL for G_IO_STATUS_EOF and G_IO_STATUS_AGAIN. The error path then dereferences read_err->message through a NULL pointer.

see gobex/gobex.c:1287-1308:

static gboolean read_packet(GObex *obex, GError **err)
{
        GIOChannel *io = obex->io;
        GError *read_err = NULL;
        GIOStatus status;
        gsize rbytes;
        guint16 u16;

        if (obex->rx_data > 0) {
                g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR,
                                "RX buffer not empty before reading packet");
                goto fail;
        }

        status = g_io_channel_read_chars(io, (char *) obex->rx_buf,
                                        obex->rx_mtu, &rbytes, &read_err);
        if (status != G_IO_STATUS_NORMAL) {
                g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR,
                                "Unable to read data: %s", read_err->message);
                g_error_free(read_err);
                goto fail;
        }

read_err is NULL whenever the status is G_IO_STATUS_EOF orG_IO_STATUS_AGAIN, so the read_err->message fails. Because the pointer being dereferenced is either a real GError or NULL, I don't believe that there are any security implications from this crash.

To reproduce

A client I'm developing had MAP and PBAP sessions open simultaneously to the same paired iPhone. It then reset the device's LE bearer via Bearer.LE1.Disconnect while both OBEX sessions were still live. Loss of both OBEX transports followed immediately. The available journal does not establish whether the LE operation directly caused the BR/EDR transport loss or the remote dropped it concurrently.

Observed sequence:

17:59:36.950  client requests an LE bearer reset (both OBEX sessions live)
17:59:37      obexd: "Transport got disconnected"   <- handled G_IO_HUP/G_IO_ERR path
17:59:37.365  client observes the PBAP session disappear
17:59:37.366  client calls Client1.RemoveSession() on the MAP session
17:59:37      obexd: DISCONNECT(0x1), <unknown>(0xff)
17:59:37      obexd: DISCONNECT(0x1), Success(0x20)
17:59:37      obexd dumps core
17:59:52      systemd restarts obex.service

btmon trace

No response

Analysis focus

None

Privacy

  • [ ] Skip anonymization — Send the raw decoded trace to the LLM without scrubbing MAC addresses or device names.

  • [ ] I understand this trace will be processed by a third-party LLM API and I have the right to share this data.

Other logs


Versions

  • BlueZ version: 5.87-2 (Arch package)
  • Kernel version: 7.1.8-arch1-3
  • Problematic device: iPhone 17, Intel AX210 (I don't believe these devices are implicated here)

erikwb avatar Aug 16 '26 23:08 erikwb

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 16 '26 06:09 github-actions[bot]