News for hackers. Stuff that matters.
Re:Kernel module for advanced rickrolling replaces open() call by 0x12 on Thursday September 08, 2011 @06:26AM (#2973299)
> It uses strncpy_from_user to do this and uses PATH_MAX as the maximum length. So even the linux kernel does rely on the fact that there is a null terminator in the string.

The PATH_MAX guarantees that the string copy will terminate even if no null character is present.

Now if any routines that call strncpy_from_user assume that it leaves them with a null terminated string there is still a potential for trouble but that does not stem from the use of strncpy_from_user.

Check the implementation for do_getname:

http://lxr.free-electrons.com/source/fs/namei.c

And you'll see that it returns -ENAMETOOLONG when the name is >= the buffer allocated, only < len is allowed. (line 133 in the link above).

There are no comments on this comment yet.