ofono/gatchat
Martin Hundebøll d5bfc2ab41 gatmux: disable destroy notification on read watcher
With the reference in place in received_data(), the address sanitizer
now encounters a use-after-free when the destroy notification is
dispatched for the read watcher (see below).

Fix this by remove the destroy notification callback, as it isn't really
used except in the shutdown function.

==5797==ERROR: AddressSanitizer: heap-use-after-free on address 0x621000ac5904 at pc 0x55c1243b1f14 bp 0x7ffdef001340 sp 0x7ffdef001330
WRITE of size 4 at 0x621000ac5904 thread T0
    #0 0x55c1243b1f13 in read_watcher_destroy_notify ../git/gatchat/gatmux.c:660
    #1 0x7f08a8676742  (/usr/lib/libglib-2.0.so.0+0x62742)
    #2 0x7f08a867e2e4 in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x6a2e4)
    #3 0x7f08a8680210  (/usr/lib/libglib-2.0.so.0+0x6c210)
    #4 0x7f08a8681122 in g_main_loop_run (/usr/lib/libglib-2.0.so.0+0x6d122)
    #5 0x55c1243d6703 in main ../git/src/main.c:286
    #6 0x7f08a8423152 in __libc_start_main (/usr/lib/libc.so.6+0x27152)
    #7 0x55c1241fe1ad in _start (/home/martin/projects/ofono/x86/src/ofonod+0xfd1ad)

0x621000ac5904 is located 4 bytes inside of 4672-byte region [0x621000ac5900,0x621000ac6b40)
freed by thread T0 here:
    #0 0x7f08a88cc6b0 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:122
    #1 0x55c1243b1ebf in g_at_mux_unref ../git/gatchat/gatmux.c:652
    #2 0x55c1243b062c in received_data ../git/gatchat/gatmux.c:276
    #3 0x7f08a867e2ce in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x6a2ce)

previously allocated by thread T0 here:
    #0 0x7f08a88cccd8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153
    #1 0x55c1243b1bf1 in g_at_mux_new ../git/gatchat/gatmux.c:613
    #2 0x55c1243b4b53 in g_at_mux_new_gsm0710_basic ../git/gatchat/gatmux.c:1172
    #3 0x55c124386abd in cmux_gatmux ../git/plugins/quectel.c:871
    #4 0x55c12438779f in cmux_cb ../git/plugins/quectel.c:1023
    #5 0x55c1243a368e in at_chat_finish_command ../git/gatchat/gatchat.c:459
    #6 0x55c1243a3bc8 in at_chat_handle_command_response ../git/gatchat/gatchat.c:521
    #7 0x55c1243a4408 in have_line ../git/gatchat/gatchat.c:600
    #8 0x55c1243a539e in new_bytes ../git/gatchat/gatchat.c:759
    #9 0x55c1243ae2f9 in received_data ../git/gatchat/gatio.c:122
    #10 0x7f08a867e2ce in g_main_context_dispatch (/usr/lib/libglib-2.0.so.0+0x6a2ce)

SUMMARY: AddressSanitizer: heap-use-after-free ../git/gatchat/gatmux.c:660 in read_watcher_destroy_notify
Shadow bytes around the buggy address:
  0x0c4280150ad0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4280150ae0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4280150af0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4280150b00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4280150b10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c4280150b20:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4280150b30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4280150b40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4280150b50: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4280150b60: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c4280150b70: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==5797==ABORTING
2019-10-08 14:49:22 -05:00
..
crc-ccitt.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
crc-ccitt.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gat.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatchat.c gatchat: add g_at_chat_retry() 2019-08-13 02:09:09 -05:00
gatchat.h gatchat: add g_at_chat_retry() 2019-08-13 02:09:09 -05:00
gathdlc.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gathdlc.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatio.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatio.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatmux.c gatmux: disable destroy notification on read watcher 2019-10-08 14:49:22 -05:00
gatmux.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatppp.c gatchat: support for auth NONE 2018-10-03 11:44:03 -05:00
gatppp.h gatchat: support for auth NONE 2018-10-03 11:44:03 -05:00
gatrawip.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatrawip.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatresult.c gatresult: strip trailing spaces from unquoted strings 2019-07-17 10:25:12 -05:00
gatresult.h gatresult: include glib header 2019-07-05 17:17:41 -05:00
gatserver.c gatchat: Reword the fall through cases to avoid compiler warnings 2017-07-11 10:44:15 -07:00
gatserver.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatsyntax.c gatchat: Fix parsing fields with odd number of quotation marks 2016-11-10 10:18:26 -06:00
gatsyntax.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gattty.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gattty.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gatutil.c gatchat: Fix use of unterminated strings 2019-07-16 23:15:10 -05:00
gatutil.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gsm0710.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gsm0710.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
gsmdial.c gsmdial: Set recording after ppp_open 2012-01-02 10:57:27 -06:00
ppp.h gatchat: implement PAP authentication 2014-06-21 11:50:34 -05:00
ppp_auth.c gatchat: Fix up minor coding style issues 2014-06-21 11:54:26 -05:00
ppp_cp.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
ppp_cp.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
ppp_ipcp.c gatchat: Reword the fall through cases to avoid compiler warnings 2017-07-11 10:44:15 -07:00
ppp_ipv6cp.c gatchat: Reword the fall through cases to avoid compiler warnings 2017-07-11 10:44:15 -07:00
ppp_lcp.c gatchat: support for auth NONE 2018-10-03 11:44:03 -05:00
ppp_net.c ppp_net: Make static analysis tools happy 2015-07-28 10:16:16 -05:00
ringbuffer.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
ringbuffer.h gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
test-qcdm.c gatchat: Update copyright information 2011-10-10 13:39:25 -07:00
test-server.c gatchat: Add support for shutting down the server 2016-01-11 15:32:54 -06:00