Thread (74 messages) 74 messages, 7 authors, 2020-09-11

Re: [PATCH 03/23] lib: uaccess: provide getline_from_user()

From: Bartosz Golaszewski <hidden>
Date: 2020-09-07 12:03:19
Also in: linux-acpi, linux-gpio, lkml

On Mon, Sep 7, 2020 at 1:45 PM Andy Shevchenko
[off-list ref] wrote:
On Mon, Sep 07, 2020 at 12:28:05PM +0200, Bartosz Golaszewski wrote:
quoted
On Mon, Sep 7, 2020 at 12:19 PM Andy Shevchenko
[off-list ref] wrote:
quoted
On Mon, Sep 7, 2020 at 1:05 PM Bartosz Golaszewski
[off-list ref] wrote:
quoted
On Fri, Sep 4, 2020 at 6:35 PM Andy Shevchenko
[off-list ref] wrote:
quoted
On Fri, Sep 04, 2020 at 05:45:27PM +0200, Bartosz Golaszewski wrote:
quoted
From: Bartosz Golaszewski <redacted>
quoted
quoted
Doesn't mm/util.c provides us something like this?
strndup_user()?
Yes, there's both strndup_user() as well as strncpy_from_user(). The
problem is that they rely on the strings being NULL-terminated. This
is not guaranteed for debugfs file_operations write callbacks. We need
some helper that takes the minimum of bytes provided by userspace and
the buffer size and figure out how many bytes to actually copy IMO.
Wouldn't this [1] approach work?

[1]: https://elixir.bootlin.com/linux/v5.9-rc3/source/arch/x86/kernel/cpu/mtrr/if.c#L93
Sure, but this is pretty much what I do in getline_from_user(). If
anything we should port mtrr_write() to using getline_from_user() once
it's available upstream, no?
But you may provide getline_from_user() as inline in the same header where
strncpy_from_user() is declared. It will be like 3 LOCs?
May be more than that. I'll see what I can do.

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