summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanassis Avgerinos <thanassis.avgerinos@gmail.com>2024-04-17 11:30:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-05-17 11:42:42 +0200
commit67f34f093c0f7bf33f5b4ae64d3d695a3b978285 (patch)
tree2b5ec268d25b9b56f8d8f3783b59c9579061198c
parenta36ae0ec2353015f0f6762e59f4c2dbc0c906423 (diff)
downloadlinux-stable-67f34f093c0f7bf33f5b4ae64d3d695a3b978285.tar.gz
linux-stable-67f34f093c0f7bf33f5b4ae64d3d695a3b978285.tar.bz2
linux-stable-67f34f093c0f7bf33f5b4ae64d3d695a3b978285.zip
firewire: nosy: ensure user_length is taken into account when fetching packet contents
commit 38762a0763c10c24a4915feee722d7aa6e73eb98 upstream. Ensure that packet_buffer_get respects the user_length provided. If the length of the head packet exceeds the user_length, packet_buffer_get will now return 0 to signify to the user that no data were read and a larger buffer size is required. Helps prevent user space overflows. Signed-off-by: Thanassis Avgerinos <thanassis.avgerinos@gmail.com> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/firewire/nosy.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index ac85e03e88e1..f3784c054dd6 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -161,10 +161,12 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)
if (atomic_read(&buffer->size) == 0)
return -ENODEV;
- /* FIXME: Check length <= user_length. */
+ length = buffer->head->length;
+
+ if (length > user_length)
+ return 0;
end = buffer->data + buffer->capacity;
- length = buffer->head->length;
if (&buffer->head->data[length] < end) {
if (copy_to_user(data, buffer->head->data, length))