staging/lustre/llite: fix ll_getname user buffer copy
authorOleg Drokin <green@linuxhacker.ru>
Thu, 11 Jun 2015 05:37:51 +0000 (01:37 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Jun 2015 16:03:59 +0000 (09:03 -0700)
commita75034345b3026f1cf5668e70688ea53184e49c1
treef11252b2eb7182abff4b385b659560f6480ae646
parentd8bc89a7f34242d67e7eefade6fc0df057c34ec1
staging/lustre/llite: fix ll_getname user buffer copy

strncpy_from_user could return negative values on error,
so need to take those into account.
Since ll_getname is used to get a single component name from userspace
to transfer to server as-is, there's no need to allocate 4k buffer
as done by __getname. Allocate NAME_MAX+1 buffer instead to ensure
we have enough for a null terminated max valid length buffer.

This was discovered by Al Viro in https://lkml.org/lkml/2015/4/11/243

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/llite/dir.c