DynamoRIO / DynamoRIO/drmemory

-share_xl8 double-adds the offset for some sub-dword memrefs

Open
#2,032 1 comment 0 reactions 1 assignee Claimed by @derekbruening View on GitHub
Bug-FalseNegative
Dominant language
C
Stars
2.7k
Forks
290
PR merge metrics
No merged PRs in 30d

Description

On the addronly-reg test, the fastpath reports just 3 unaddrs, but
-no_share_xl8 and -no_fastpath both report a 4th unaddr, the "dec
0x80(%eax)" that's right after the 3rd unaddr's "dec 0x7c(%eax)".

The address doesn't seem to be near a shadow block boundary:
```
Error #3: UNADDRESSABLE ACCESS beyond heap bounds: reading 0x0804e630-0x0804e631 1 byte(s)
```

Looking at the instru below, why are there both "add $1,%edx" and "inc %edx"?
The sharing code has a bug there.

```
scratch: dec 0x7c(%eax)[1byte] -> 0x7c(%eax)[1byte]| r1=%edxspill#0, r2=%ecxspill#1
fastpath: dec 0x7c(%eax)[1byte] -> 0x7c(%eax)[1byte]| prop=0 srcsz=1 dstsz=1 checkdef=0 markdef=1 checkunaddr=0
eflags are dead so not saving
eflags are dead so not saving
eflags are dead so not saving
scratch: dec 0x80(%eax)[1byte] -> 0x80(%eax)[1byte]| r1=%edxspill#0, r2=%ecxspill#1
fastpath: dec 0x80(%eax)[1byte] -> 0x80(%eax)[1byte]| prop=0 srcsz=1 dstsz=1 checkdef=0 markdef=1 checkunaddr=0
sharing shadow addr: disp = 128 - (124 + 0) => 4 /4 - 0
eflags are dead so not saving
eflags are dead so not saving
eflags are dead so not saving
whole-bb scratch: r1=used, r2=used, efl=unused
final ilist:
TAG 0x08048f34
+0 m4 @0xe78b5774 64 89 0d 6c 00 00 00 mov %ecx -> %fs:0x0000006c[4byte]
+7 m4 @0xe7819abc 64 89 15 68 00 00 00 mov %edx -> %fs:0x00000068[4byte]
+14 m4 @0xe781a38c
+14 m4 @0xe781a898 8d 50 7c lea 0x7c(%eax) -> %edx
+17 m4 @0xe781a520 8b ca mov %edx -> %ecx
+19 m4 @0xe78b56b4 c1 e9 10 shr $0x00000010 %ecx -> %ecx
+22 m4 @0xe78b632c c1 ea 02 shr $0x00000002 %edx -> %edx
+25 m4 @0xe7818b68 03 14 8d 80 a0 a7 73 add 0x73a7a080(,%ecx,4)[4byte] %edx -> %edx
+32 m4 @0xe78b5734 80 3a 01 cmp (%edx)[1byte] $0x01
+35 m4 @0xe78191b0
+35 m4 @0xe781b1e8 75 fe jnz @0xe7819ecc[4byte]
+37 m4 @0xe781a604 0f 0b ud2a
+39 m4 @0xe78b67d4 ba 00 94 84 e7 mov $0xe7849400 -> %edx
+44 m4 @0xe7819ecc
+44 m4 @0xe78b61a4
+44 m4 @0xe7819338
+44 m4 @0xe781a9bc
+44 L3 fe 48 7c dec 0x7c(%eax)[1byte] -> 0x7c(%eax)[1byte]
+47 m4 @0xe78b6ac0
+47 m4 @0xe78188c8 8d 88 80 00 00 00 lea 0x80(%eax) -> %ecx
+53 m4 @0xe781974c 83 e1 03 and $0x00000003 %ecx -> %ecx
+56 m4 @0xe781b19c 81 f9 00 00 00 00 cmp %ecx $0x00000000
+62 m4 @0xe781a120 0f 84 fa ff ff ff jz @0xe78b5c88[4byte]
+68 m4 @0xe78b5674 e9 fb ff ff ff jmp @0xe781a284[4byte]
+73 m4 @0xe78b5c88
+73 m4 @0xe7818cb0 83 c2 01 add $0x00000001 %edx -> %edx
+76 m4 @0xe781a284
+76 m4 @0xe78bc300 42 inc %edx -> %edx
+77 m4 @0xe78b66fc 80 3a 01 cmp (%edx)[1byte] $0x01
+80 m4 @0xe78191fc
+80 m4 @0xe781ae94 75 fe jnz @0xe781a650[4byte]
+82 m4 @0xe7819d10 0f 0b ud2a
+84 m4 @0xe781a650
+84 m4 @0xe78bd2a4
+84 m4 @0xe781ad64
+84 m4 @0xe7819de8
+84 L3 fe 88 80 00 00 00 dec 0x80(%eax)[1byte] -> 0x80(%eax)[1byte]
+90 L3 83 c4 00 add $0x00000000 %esp -> %esp
+93 L3 5b pop %esp (%esp)[4byte] -> %ebx %esp
+94 m4 @0xe781b274 64 8b 15 68 00 00 00 mov %fs:0x00000068[4byte] -> %edx
+101 m4 @0xe7819a70 64 8b 0d 6c 00 00 00 mov %fs:0x0000006c[4byte] -> %ecx
+108 L3 c3 ret %esp (%esp)[4byte] -> %esp
END 0x08048f34
```

This sub-dword code is from #1597. It makes no sense to me: the sharing
doesn't impose any relationship on the address delta, so how does checking
just the 2nd address's alignment tell you whether you crossed? As here,
they can both be 4-aligned, with no adjustment needed. This code needs to
include the delta in its check.

For now, esp given the #2009 crash (which makes me wonder if some of the
other filed crashes have the same cause), I'm going to disable for
sub-dword -- and maybe in general??

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.