bpf: Use memmove for bpf_dynptr_{read,write}
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Wed, 7 Dec 2022 20:41:40 +0000 (02:11 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 9 Dec 2022 02:39:28 +0000 (18:39 -0800)
commit76d16077bef0954528ec3896710f9eda8b2b4db1
treef99d754b4bb61f95c24dbc7c3026e2fa2727f742
parentf6ee298fa140f6b5bae3acf6d6108741278bcced
bpf: Use memmove for bpf_dynptr_{read,write}

It may happen that destination buffer memory overlaps with memory dynptr
points to. Hence, we must use memmove to correctly copy from dynptr to
destination buffer, or source buffer to dynptr.

This actually isn't a problem right now, as memcpy implementation falls
back to memmove on detecting overlap and warns about it, but we
shouldn't be relying on that.

Acked-by: Joanne Koong <joannelkoong@gmail.com>
Acked-by: David Vernet <void@manifault.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20221207204141.308952-7-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/helpers.c