Re: [PATCH v4] net: don't call strlen() on the user buffer in packet_bind_spkt()

From: David Miller
Date: Thu Mar 02 2017 - 01:14:30 EST


From: Alexander Potapenko <glider@xxxxxxxxxx>
Date: Wed, 1 Mar 2017 12:57:20 +0100

> KMSAN (KernelMemorySanitizer, a new error detection tool) reports use of
> uninitialized memory in packet_bind_spkt():
...
> This happens because addr.sa_data copied from the userspace is not
> zero-terminated, and copying it with strlcpy() in packet_bind_spkt()
> results in calling strlen() on the kernel copy of that non-terminated
> buffer.
>
> Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx>
> ---
> Changes since v3:
> - addressed comments by Eric Dumazet (avoid using constants,
> use memcpy() instead of strncpy())

Applied and queued up for -stable.