NFS: Do not memcpy from NULL when encoding an empty opaque #112
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:ubsan-xdr-empty-opaque"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
xdr_bytes() copied data->size bytes from data->data even when the size was 0, and an empty opaque (for example the AUTH_NONE verifier of every RPC reply) has a NULL data pointer. memcpy() with a NULL source is undefined behaviour even for 0 bytes; UBSan (-fsanitize=undefined) stops the NFS server at its first reply.
Tested: a small program that encodes an empty opaque through
xdr_impl.cpp, built with-fsanitize=undefined -fno-sanitize-recover=all, stops on master withxdr_impl_inline.h:162:19: runtime error: null pointer passed as argument 2and runs clean with this commit.vitastor-nfsbuilds.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA