mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
firewire: nosy: ensure user_length is taken into account when fetching packet contents
commit 38762a0763
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>
This commit is contained in:
parent
a36ae0ec23
commit
67f34f093c
@ -161,10 +161,12 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)
|
|||||||
if (atomic_read(&buffer->size) == 0)
|
if (atomic_read(&buffer->size) == 0)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
/* FIXME: Check length <= user_length. */
|
length = buffer->head->length;
|
||||||
|
|
||||||
|
if (length > user_length)
|
||||||
|
return 0;
|
||||||
|
|
||||||
end = buffer->data + buffer->capacity;
|
end = buffer->data + buffer->capacity;
|
||||||
length = buffer->head->length;
|
|
||||||
|
|
||||||
if (&buffer->head->data[length] < end) {
|
if (&buffer->head->data[length] < end) {
|
||||||
if (copy_to_user(data, buffer->head->data, length))
|
if (copy_to_user(data, buffer->head->data, length))
|
||||||
|
Loading…
Reference in New Issue
Block a user