Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firewire: nosy: ensure user_length is taken into account when fetching packet contents

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>

authored by

Thanassis Avgerinos and committed by
Takashi Sakamoto
38762a07 e67572cd

+4 -2
+4 -2
drivers/firewire/nosy.c
··· 148 148 if (atomic_read(&buffer->size) == 0) 149 149 return -ENODEV; 150 150 151 - /* FIXME: Check length <= user_length. */ 151 + length = buffer->head->length; 152 + 153 + if (length > user_length) 154 + return 0; 152 155 153 156 end = buffer->data + buffer->capacity; 154 - length = buffer->head->length; 155 157 156 158 if (&buffer->head->data[length] < end) { 157 159 if (copy_to_user(data, buffer->head->data, length))