mISDN: make sure device name is NUL terminated
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 22 May 2019 08:45:13 +0000 (11:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Jun 2019 06:17:22 +0000 (08:17 +0200)
commitf13d6b305a5cf528580fb9b6b3e6221075be3ff2
tree25e05119b1871143d06c6bd3cf9365c09abd619d
parentb11278eb5a231cc4b2109170e5ec4e69e43ed3a0
mISDN: make sure device name is NUL terminated

[ Upstream commit ccfb62f27beb295103e9392462b20a6ed807d0ea ]

The user can change the device_name with the IMSETDEVNAME ioctl, but we
need to ensure that the user's name is NUL terminated.  Otherwise it
could result in a buffer overflow when we copy the name back to the user
with IMGETDEVINFO ioctl.

I also changed two strcpy() calls which handle the name to strscpy().
Hopefully, there aren't any other ways to create a too long name, but
it's nice to do this as a kernel hardening measure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/isdn/mISDN/socket.c