Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There seems to be a heap-buffer-overflow in parse_vlanid #10629

Closed
evverx opened this issue Nov 3, 2018 · 1 comment
Closed

There seems to be a heap-buffer-overflow in parse_vlanid #10629

evverx opened this issue Nov 3, 2018 · 1 comment
Labels
bug 🐛 Programming errors, that need preferential fixing network
Milestone

Comments

@evverx
Copy link
Member

evverx commented Nov 3, 2018

The networkd fuzzer I mentioned in #10628 keeps finding issues in networkd (though, it can't even get past the initial corpus). The following netdev config causes a heap-buffer-overflow in parse_vlanid:

[NetDev]
Name=vlan99
Kind=vcan

[VLAN]
Id=99
GVRP=true
MVRP=true
LooseBinding=true
ReorderHeader=true
==2748==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60b000000210 at pc 0x7fbc716ec9cd bp 0x7ffd6f992f50 sp 0x7ffd6f992f40
WRITE of size 2 at 0x60b000000210 thread T0
    #0 0x7fbc716ec9cc in parse_vlanid ../src/shared/vlan-util.c:18
    #1 0x7fbc716ecce0 in config_parse_vlanid ../src/shared/vlan-util.c:68
    #2 0x7fbc71631acc in next_assignment ../src/shared/conf-parser.c:138
    #3 0x7fbc71632e77 in parse_line ../src/shared/conf-parser.c:263
    #4 0x7fbc71633d89 in config_parse ../src/shared/conf-parser.c:380
    #5 0x5612b024b57b in netdev_load_one ../src/network/netdev/netdev.c:662
    #6 0x5612b023d7b2 in LLVMFuzzerTestOneInput ../src/network/fuzz-networkd.c:30
    #7 0x5612b023dca8 in main ../src/fuzz/fuzz-main.c:33
    #8 0x7fbc6fc3511a in __libc_start_main (/lib64/libc.so.6+0x2311a)
    #9 0x5612b023d279 in _start (/home/vagrant/systemd/build/fuzz-networkd+0x24d279)

0x60b000000210 is located 0 bytes to the right of 112-byte region [0x60b0000001a0,0x60b000000210)
allocated by thread T0 here:
    #0 0x7fbc7280ae50 in calloc (/lib64/libasan.so.5+0xeee50)
    #1 0x5612b024aa0b in netdev_load_one ../src/network/netdev/netdev.c:650
    #2 0x5612b023d7b2 in LLVMFuzzerTestOneInput ../src/network/fuzz-networkd.c:30
    #3 0x5612b023dca8 in main ../src/fuzz/fuzz-main.c:33
    #4 0x7fbc6fc3511a in __libc_start_main (/lib64/libc.so.6+0x2311a)

SUMMARY: AddressSanitizer: heap-buffer-overflow ../src/shared/vlan-util.c:18 in parse_vlanid
Shadow bytes around the buggy address:
  0x0c167fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c167fff8000: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c167fff8010: 00 00 00 00 00 fa fa fa fa fa fa fa fa fa 00 00
  0x0c167fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
  0x0c167fff8030: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c167fff8040: 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c167fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c167fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c167fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c167fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c167fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
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
==2748==ABORTING

By the way, does anybody know what's up with the wireguard code? The example from the documentation crashes the fuzzer with something like:

wg0: loaded wireguard
wg0: Creating
Assertion '!w->unresolved_endpoints' failed at ../src/network/netdev/wireguard.c:679, function wireguard_done(). Aborting.

Here's how networkd reacts to the same config:

Started Network Service.
wg0: netdev could not be created: Operation not supported
Stopping Network Service...
Assertion '!w->unresolved_endpoints' failed at ../src/network/netdev/wireguard.c:679, function wireguard_done(). Aborting.
systemd-networkd.service: Main process exited, code=killed, status=6/ABRT
systemd-networkd.service: Failed with result 'signal'.

@Mic92 do you know what that could be?

@evverx evverx added bug 🐛 Programming errors, that need preferential fixing network labels Nov 3, 2018
@evverx evverx added this to the v240 milestone Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
@Mic92
Copy link
Contributor

Mic92 commented Nov 3, 2018

The solution provided @yuwata should fix this particular assertion.

yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 3, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 4, 2018
evverx added a commit to evverx/systemd that referenced this issue Nov 4, 2018
yuwata added a commit to yuwata/systemd that referenced this issue Nov 5, 2018
evverx added a commit to evverx/systemd that referenced this issue Nov 5, 2018
evverx added a commit to evverx/systemd that referenced this issue Nov 6, 2018
toanju pushed a commit to toanju/systemd that referenced this issue Dec 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing network
Development

No branches or pull requests

3 participants