Skip to content

Commit f55a057

Browse files
shuahkhgregkh
authored andcommitted
usbip: fix vhci_hcd to check for stream socket
Fix attach_store() to validate the passed in file descriptor is a stream socket. If the file descriptor passed was a SOCK_DGRAM socket, sock_recvmsg() can't detect end of stream. Cc: stable@vger.kernel.org Suggested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://lore.kernel.org/r/52712aa308915bda02cece1589e04ee8b401d1f3.1615171203.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 47ccc8f commit f55a057

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/usb/usbip/vhci_sysfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,16 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr,
349349

350350
/* Extract socket from fd. */
351351
socket = sockfd_lookup(sockfd, &err);
352-
if (!socket)
352+
if (!socket) {
353+
dev_err(dev, "failed to lookup sock");
353354
return -EINVAL;
355+
}
356+
if (socket->type != SOCK_STREAM) {
357+
dev_err(dev, "Expecting SOCK_STREAM - found %d",
358+
socket->type);
359+
sockfd_put(socket);
360+
return -EINVAL;
361+
}
354362

355363
/* now need lock until setting vdev status as used */
356364

0 commit comments

Comments
 (0)