The 'count' argument to strncpy_from_user() is supposed to include space
for the null terminator, so add it in. Also, refuse names that have more
than IFNAMSIZ-1 characters outright, instead of truncating them.
struct vport *vport;
struct dp_port *dp_port;
int err = 0;
+ int retval;
- if (strncpy_from_user(devname, udevname, IFNAMSIZ - 1) < 0)
+ retval = strncpy_from_user(devname, udevname, IFNAMSIZ);
+ if (retval < 0)
return -EFAULT;
- devname[IFNAMSIZ - 1] = '\0';
+ else if (retval >= IFNAMSIZ)
+ return -ENAMETOOLONG;
rtnl_lock();