Re: [PATCH net-next] bpf: avoid copying junk bytes in bpf_get_current_comm()

2016-03-11 Thread Alexei Starovoitov
On 3/11/16 10:02 AM, Daniel Borkmann wrote: Would strscpy() help in this case (see 30035e45753b ("string: provide strscpy()"))? I've looked at it too, but 990486c8af04 scared me a little, it's not easily backport-able and mainly I don't think it's faster than strlcpy for small strings like comm

Re: [PATCH net-next] bpf: avoid copying junk bytes in bpf_get_current_comm()

2016-03-11 Thread Daniel Borkmann
On 03/11/2016 06:20 PM, Alexei Starovoitov wrote: On 3/11/16 2:24 AM, Daniel Borkmann wrote: On 03/10/2016 05:02 AM, Alexei Starovoitov wrote: Lots of places in the kernel use memcpy(buf, comm, TASK_COMM_LEN); but the result is typically passed to print("%s", buf) and extra bytes after zero don

Re: [PATCH net-next] bpf: avoid copying junk bytes in bpf_get_current_comm()

2016-03-11 Thread Alexei Starovoitov
On 3/11/16 2:24 AM, Daniel Borkmann wrote: On 03/10/2016 05:02 AM, Alexei Starovoitov wrote: Lots of places in the kernel use memcpy(buf, comm, TASK_COMM_LEN); but the result is typically passed to print("%s", buf) and extra bytes after zero don't cause any harm. In bpf the result of bpf_get_cur

Re: [PATCH net-next] bpf: avoid copying junk bytes in bpf_get_current_comm()

2016-03-11 Thread Daniel Borkmann
On 03/10/2016 05:02 AM, Alexei Starovoitov wrote: Lots of places in the kernel use memcpy(buf, comm, TASK_COMM_LEN); but the result is typically passed to print("%s", buf) and extra bytes after zero don't cause any harm. In bpf the result of bpf_get_current_comm() is used as the part of map key a

Re: [PATCH net-next] bpf: avoid copying junk bytes in bpf_get_current_comm()

2016-03-09 Thread David Miller
From: Alexei Starovoitov Date: Wed, 9 Mar 2016 20:02:33 -0800 > Lots of places in the kernel use memcpy(buf, comm, TASK_COMM_LEN); but > the result is typically passed to print("%s", buf) and extra bytes > after zero don't cause any harm. > In bpf the result of bpf_get_current_comm() is used as t

[PATCH net-next] bpf: avoid copying junk bytes in bpf_get_current_comm()

2016-03-09 Thread Alexei Starovoitov
Lots of places in the kernel use memcpy(buf, comm, TASK_COMM_LEN); but the result is typically passed to print("%s", buf) and extra bytes after zero don't cause any harm. In bpf the result of bpf_get_current_comm() is used as the part of map key and was causing spurious hash map mismatches. Use str