Messages in this thread | | | Date | Tue, 28 Apr 2015 14:48:45 -0700 | Subject | Re: revert "fs/befs/linuxvfs.c: replace strncpy by strlcpy" | From | Linus Torvalds <> |
| |
On Tue, Apr 28, 2015 at 2:38 PM, Chris Metcalf <cmetcalf@ezchip.com> wrote: > > To do that we'd probably want to provide a generic version that > just copied byte-by-byte, and encourage architecture variants > that were more efficient.
Our generic "strncpy_from_user()" is actually fairly efficient, and reasonably portable. It almost has to be, since this is actually a much more common - and much more critical - load than any regular strncpy I know of in the kernel.
I suspect you could take that lib/strncpy_from_user.c and massage it reasonably trivially to be a good function.
That said, I can't think of a single strncpy (or strlcpy) in kernel space that is actually worth even optimizing for. They just don't tend to be in the critical path. So correctness is likely *much* more important than worrying about performance.
Linus
| |