Skip to content

Commit 38762a0

Browse files
ethan42takaswie
authored andcommitted
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 <[email protected]> Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent e67572c commit 38762a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/firewire/nosy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)
148148
if (atomic_read(&buffer->size) == 0)
149149
return -ENODEV;
150150

151-
/* FIXME: Check length <= user_length. */
151+
length = buffer->head->length;
152+
153+
if (length > user_length)
154+
return 0;
152155

153156
end = buffer->data + buffer->capacity;
154-
length = buffer->head->length;
155157

156158
if (&buffer->head->data[length] < end) {
157159
if (copy_to_user(data, buffer->head->data, length))

0 commit comments

Comments
 (0)