Fix btmon crash 14/162514/1
authorSeungyoun Ju <sy39.ju@samsung.com>
Tue, 14 Nov 2017 06:15:00 +0000 (15:15 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 4 Dec 2017 05:20:32 +0000 (14:20 +0900)
commit26502e3a501eb39810bb831c8dabe9b659d7d58b
tree65d869ea5ca99356b5d94acc819683190bd32540
parent60b83a1279350206596c951195b7ae563d1bb75e
Fix btmon crash

[Problem] btmon crash happens
[Cause & Measure] When SDP continuation is handled, other variable's
 value is overwritten because invalid array index is used for memcpy's
 src.
[Checking Method] Run btmon -> Connect Android phone to KITT ->
 Terminate btmon. In this procedure, btmon crash happens randomly.

When issue happens, irk_list's value is corrupted by invalid memcpy.
This causes crash when it accesses to irk_list.

1: irk_list = (struct queue *) 0xb7cda0a0
(gdb)
499 memcpy(cont_list[i].cont, data + bytes, data[bytes] + 1);
1: irk_list = (struct queue *) 0xb7cda0a0
(gdb)
0xb6f5f1a8 in memcpy@plt ()
1: irk_list = (struct queue *) 0xb7cda0a0
(gdb)
Single stepping until exit from function memcpy@plt,
which has no line number information.
memcpy () at ../sysdeps/arm/memcpy.S:63

...

1: irk_list = (struct queue *) 0xb7000002
(gdb)
search_attr_rsp (frame=0xbeadd3f8, tid=0xb6fcd760 <tid_list>) at monitor/sdp.c:669
669 clear_tid(tid);
1: irk_list = (struct queue *) 0xb7000002
(gdb) p cont_list
$5 = {{channel = 0, cont = '\000' <repeats 16 times>, data = 0xb7cda3a0, size = 656}, {channel = 0, cont = '\000' <repeats 16 times>, data = 0x0, size = 0}, {channel = 0,
    cont = '\000' <repeats 16 times>, data = 0x0, size = 0}, {channel = 0, cont = '\000' <repeats 16 times>, data = 0x0, size = 0}, {channel = 0, cont = '\000' <repeats 16 times>,
    data = 0x0, size = 0}, {channel = 0, cont = '\000' <repeats 16 times>, data = 0x0, size = 0}, {channel = 0, cont = '\000' <repeats 16 times>, data = 0x0, size = 0}, {channel = 0,
    cont = '\000' <repeats 16 times>, data = 0x0, size = 0}}

Change-Id: I3608d1b9cf14bbfc87d17fbad6a443bdcbdf87af
Signed-off-by: Seungyoun Ju <sy39.ju@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
monitor/sdp.c