[PATCH] NET: Ensure device name passed to SO_BINDTODEVICE is NULL terminated.
The user can pass us arbitrary garbage so we should ensure the string they give us is null terminated before we pass it on to dev_get_by_index() et al. Found by Solar Designer. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9620554ca9
commit
d4852ff218
+3
-2
@@ -404,8 +404,9 @@ set_rcvbuf:
|
||||
if (!valbool) {
|
||||
sk->sk_bound_dev_if = 0;
|
||||
} else {
|
||||
if (optlen > IFNAMSIZ)
|
||||
optlen = IFNAMSIZ;
|
||||
if (optlen > IFNAMSIZ - 1)
|
||||
optlen = IFNAMSIZ - 1;
|
||||
memset(devname, 0, sizeof(devname));
|
||||
if (copy_from_user(devname, optval, optlen)) {
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user