sbin/hammer: Don't access beyond 16KB of HAMMER userspace buffer
commit7d0dab482a8621fa2fcb8ae0d5f27e62aed4c9f4
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Fri, 4 Mar 2016 16:08:46 +0000 (5 01:08 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 5 Mar 2016 09:44:02 +0000 (5 18:44 +0900)
treea325ada77b806ec1016ea2a40648f7c6ac616cbc
parentefc166b1f2d2982633c55d8628afe6fa3e772ca2
sbin/hammer: Don't access beyond 16KB of HAMMER userspace buffer

HAMMER userspace only supports upto 16KB buffer size while HAMMER
filesystem itself supports both 16KB and 64KB. This means even if
a leaf node elm says the record data is >16KB, HAMMER userspace can
only retrieve the first 16KB of the record data. Anything beyond
16KB is not supported (not malloc'd in userspace).

print_record() in hammer show is passing a pointer to maximum 16KB
buffer to hexdump(3), but is also passing data_len which is taken
from elm->leaf.data_len. This becomes an issue when the file size
is >1MB where HAMMER starts to use 64KB buffer for data beyond 1MB.
elm->leaf.data_len will typically say the length is 64KB, but
the maximum HAMMER userspace can handle is still 16KB regardless
of what the leaf node elm says. hammer show needs to omit anything
beyond 16KB (for now).

 # hammer -vvvv -f /dev/da1:/dev/da2:/dev/da3 show > /dev/null
 zsh: segmentation fault (core dumped)  hammer -vvvv -f /dev/da1:/dev/da2:/dev/da3 show > /dev/null
sbin/hammer/cmd_show.c