Re: [PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-17 Thread Ivan Kokshaysky
On Mon, Nov 16, 2020 at 02:44:56PM -0800, Linus Torvalds wrote: > On Mon, Nov 16, 2020 at 2:15 PM Linus Torvalds > wrote: > > > > So I've verified that at least on x86-64, this doesn't really make > > code generation any worse, and I'm ok with the patch from that > > standpoint. > > .. looking

Re: [PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-16 Thread Daniel Xu
Hi Linus, On Mon, Nov 16, 2020 at 02:15:52PM -0800, Linus Torvalds wrote: > On Mon, Nov 16, 2020 at 1:17 PM Daniel Xu wrote: > > > > Based on on-list discussion and some off-list discussion with Alexei, > > I'd like to propose the v4-style patch without the `(*out & ~mask)` > > bit. > > So I've

Re: [PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-16 Thread Linus Torvalds
On Mon, Nov 16, 2020 at 2:15 PM Linus Torvalds wrote: > > So I've verified that at least on x86-64, this doesn't really make > code generation any worse, and I'm ok with the patch from that > standpoint. .. looking closer, it will generate extra code on big-endian architectures and on alpha,

Re: [PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-16 Thread Linus Torvalds
On Mon, Nov 16, 2020 at 1:17 PM Daniel Xu wrote: > > Based on on-list discussion and some off-list discussion with Alexei, > I'd like to propose the v4-style patch without the `(*out & ~mask)` > bit. So I've verified that at least on x86-64, this doesn't really make code generation any worse,

[PATCH bpf v6 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-16 Thread Daniel Xu
do_strncpy_from_user() may copy some extra bytes after the NUL terminator into the destination buffer. This usually does not matter for normal string operations. However, when BPF programs key BPF maps with strings, this matters a lot. A BPF program may read strings from user memory by calling