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

Remove support for PacketBufferTLVReader using chained buffers. #9592

Merged

Conversation

bzbarsky-apple
Copy link
Contributor

It was unused, and if we can guarantee a contiguous buffer consumers can be safer

Problem

Reading from a TLVPacketBufferBackingStore is probably broken in practice for reasons similar to those described in #9575. And we have people doing unsafe things involving GetLength with TLV readers initialized with packet buffers.

Change overview

Drop the likely-broken and unused support for chained buffers in PacketBufferTLVReader and expose safer span-getting methods on it.

Testing

Existing unit tests modified accordingly.

@woody-apple woody-apple marked this pull request as draft September 10, 2021 14:57
@woody-apple woody-apple marked this pull request as ready for review September 10, 2021 14:57
It was unused, and if we can guarantee a contiguous buffer consumers can be safer
@bzbarsky-apple bzbarsky-apple force-pushed the safer-packet-buffer-reader branch from 361e522 to 25813e3 Compare September 10, 2021 15:02
@github-actions
Copy link

Size increase report for "gn_qpg-example-build" from 5d2654a

File Section File VM
chip-qpg6100-lighting-example.out .text 16 16
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.debug_info,0,479
.debug_str,0,44
.symtab,0,32
.text,16,16
.debug_abbrev,0,10
.strtab,0,7
.shstrtab,0,1
[Unmapped],0,-16
.debug_aranges,0,-24
.debug_frame,0,-120
.debug_ranges,0,-288
.debug_line,0,-471
.debug_loc,0,-766


@woody-apple woody-apple marked this pull request as draft September 10, 2021 15:33
@woody-apple woody-apple marked this pull request as ready for review September 10, 2021 15:33
@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 5d2654a

File Section File VM
chip-lock.elf text 4 4
chip-lock.elf device_handles -4 -4
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.debug_info,0,610
.symtab,0,48
.debug_str,0,43
.strtab,0,18
.debug_abbrev,0,8
text,4,4
.shstrtab,0,2
device_handles,-4,-4
.debug_aranges,0,-24
.debug_frame,0,-116
.debug_ranges,0,-296
.debug_line,0,-474
.debug_loc,0,-639


@github-actions
Copy link

Size increase report for "esp32-example-build" from 5d2654a

File Section File VM
chip-bridge-app.elf .flash.text 24 24
chip-temperature-measurement-app.elf .flash.text -4 -4
chip-lock-app.elf .flash.text 24 24
chip-all-clusters-app.elf .flash.text 12 12
chip-ipv6only-app.elf .flash.text 172 172
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-bridge-app.elf and ./pull_artifact/chip-bridge-app.elf:

sections,vmsize,filesize
[Unmapped],0,4072
.symtab,0,80
.strtab,0,70
.debug_str,0,40
[ELF Section Headers],0,40
.xt.prop._ZN4chip6System21PacketBufferTLVReader4InitEONS0_18PacketBufferHandleE,0,36
.xt.prop._ZN4chip6System21PacketBufferTLVReaderC2Ev,0,36
.flash.text,24,24
.xt.prop._ZN4chip6System27TLVPacketBufferBackingStoreD5Ev,0,12
.xt.lit._ZN4chip6System27TLVPacketBufferBackingStoreD5Ev,0,8
.debug_abbrev,0,-12
.shstrtab,0,-22
.debug_aranges,0,-24
.xt.prop._ZN4chip6System21PacketBufferTLVReader4InitEONS0_18PacketBufferHandleEb,0,-36
.debug_info,0,-58
.xt.prop._ZN4chip6System27TLVPacketBufferBackingStore4InitEONS0_18PacketBufferHandleEb,0,-60
.debug_frame,0,-72
.debug_ranges,0,-464
.debug_loc,0,-742
.debug_line,0,-1052

Comparing ./master_artifact/chip-temperature-measurement-app.elf and ./pull_artifact/chip-temperature-measurement-app.elf:

sections,vmsize,filesize
.strtab,0,80
.symtab,0,80
.debug_str,0,40
[ELF Section Headers],0,40
.xt.prop._ZN4chip6System21PacketBufferTLVReader4InitEONS0_18PacketBufferHandleE,0,36
.xt.prop._ZN4chip6System21PacketBufferTLVReaderC2Ev,0,36
.xt.prop._ZN4chip6System27TLVPacketBufferBackingStoreD5Ev,0,12
.xt.lit._ZN4chip6System27TLVPacketBufferBackingStoreD5Ev,0,8
[Unmapped],0,4
.flash.text,-4,-4
.debug_abbrev,0,-12
.shstrtab,0,-20
.debug_aranges,0,-24
.xt.prop._ZN4chip6System21PacketBufferTLVReader4InitEONS0_18PacketBufferHandleEb,0,-36
.debug_info,0,-57
.xt.prop._ZN4chip6System27TLVPacketBufferBackingStore4InitEONS0_18PacketBufferHandleEb,0,-60
.debug_frame,0,-72
.debug_ranges,0,-464
.debug_loc,0,-743
.debug_line,0,-1080

Comparing ./master_artifact/chip-lock-app.elf and ./pull_artifact/chip-lock-app.elf:

sections,vmsize,filesize
.symtab,0,80
.strtab,0,70
.debug_str,0,44
[ELF Section Headers],0,40
.xt.prop._ZN4chip6System21PacketBufferTLVReader4InitEONS0_18PacketBufferHandleE,0,36
.xt.prop._ZN4chip6System21PacketBufferTLVReaderC2Ev,0,36
.flash.text,24,24
.xt.prop._ZN4chip6System27TLVPacketBufferBackingStoreD5Ev,0,12
.xt.lit._ZN4chip6System27TLVPacketBufferBackingStoreD5Ev,0,8
.debug_abbrev,0,-12
.shstrtab,0,-22
.debug_aranges,0,-24
[Unmapped],0,-24
.xt.prop._ZN4chip6System21PacketBufferTLVReader4InitEONS0_18PacketBufferHandleEb,0,-36
.xt.prop._ZN4chip6System27TLVPacketBufferBackingStore4InitEONS0_18PacketBufferHandleEb,0,-60
.debug_info,0,-69
.debug_frame,0,-72
.debug_ranges,0,-464
.debug_loc,0,-883
.debug_line,0,-1052

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.debug_info,0,409
.strtab,0,71
.symtab,0,64
.debug_str,0,43
.flash.text,12,12
.shstrtab,0,1
.debug_abbrev,0,-12
[Unmapped],0,-12
.debug_aranges,0,-24
.debug_frame,0,-120
.debug_ranges,0,-160
.debug_line,0,-583
.debug_loc,0,-989

Comparing ./master_artifact/chip-persistent-storage.elf and ./pull_artifact/chip-persistent-storage.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-ipv6only-app.elf and ./pull_artifact/chip-ipv6only-app.elf:

sections,vmsize,filesize
[Unmapped],0,3924
.flash.text,172,172


@bzbarsky-apple
Copy link
Contributor Author

@msandstedt @saurabhst @LuDuda @jmartinez-silabs Please take a look?

@bzbarsky-apple bzbarsky-apple merged commit 7bc58b9 into project-chip:master Sep 13, 2021
@bzbarsky-apple bzbarsky-apple deleted the safer-packet-buffer-reader branch September 13, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants