Thread (46 messages) 46 messages, 6 authors, 2020-05-19

Re: [PATCH 11/18] maccess: remove strncpy_from_unsafe

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2020-05-13 23:03:43
Also in: bpf, linux-mm, linux-um, lkml

On Wed, May 13, 2020 at 3:36 PM Daniel Borkmann [off-list ref] wrote:
It's used for both.
Daniel, BPF real;ly needs to make up its mind about that.

You *cannot* use ti for both.

Yes, it happens to work on x86 and some other architectures.

But on other architectures, the exact same pointer value can be a
kernel pointer or a user pointer.
Given this is enabled on pretty much all program types, my
assumption would be that usage is still more often on kernel memory than user one.
You need to pick one.

If you know it is a user pointer, use strncpy_from_user() (possibly
with disable_pagefault() aka strncpy_from_user_nofault()).

And if you know it is a kernel pointer, use strncpy_from_unsafe() (aka
strncpy_from_kernel_nofault()).

You really can't pick the "randomly one or the other guess what I mean " option.

                  Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help