firewire: nosy: don't read packets bigger than requested
PATCH 1/1 firewire: nosy: don't read packets bigger than requested
In general, accessing userspace memory beyond the length of the supplied buffer in VFS read/write handlers can lead to both kernel memory corruption (via kernel_read()/kernel_write(), which can e.g. be triggered via sys_splice()) and privilege escalation inside userspace.
---
No CC stable because this device shouldn't be available to unprivileged code by default and should be pretty rare.
drivers/firewire/nosy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/firewire/nosy.c +3 -2
@@ -161,11 +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. */ - end = buffer->data + buffer->capacity; length = buffer->head->length; +if (length > user_length) +return -EINVAL ; +if (&buffer->head->data[length] < end) {if (copy_to_user (data, buffer->head->data, length))return -EFAULT ;
Signature · 1 line
2.18.0.399.gad0ab374a1-goog
Quoted 23 lines · Jann Horn
In general, accessing userspace memory beyond the length of the supplied buffer in VFS read/write handlers can lead to both kernel memory corruption (via kernel_read()/kernel_write(), which can e.g. be triggered via
sys_splice()) and privilege escalation inside userspace.Fixes 286468210d83 ("firewire: new driver: nosy - IEEE 1394 traffic sniffer")Signed-off-by Jann Horn <[email protected]>---
No CC stable because this device shouldn't be available to unprivileged code by default and should be pretty rare.drivers/firewire/nosy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/firewire/nosy.c +0
-1@@ -161,11 +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. */
drivers/firewire/nosy.c packet_buffer_get(struct client *client, char __user *data, size_t user_length) · line 172
Quoted 10 lines
drivers/firewire/nosy.c +3
-1- end = buffer->data + buffer->capacity; length = buffer->head->length; +if (length > user_length) +return -EINVAL ; +if (&buffer->head->data[length] < end) {if (copy_to_user (data, buffer->head->data, length))return -EFAULT ;
Ping. I sent this about two months ago, I haven't received a reply, and from what I can tell, it hasn't landed in any tree so far...
Quoted 28 lines · Jann Horn
Quoted 27 lines · Jann Horn
In general, accessing userspace memory beyond the length of the supplied buffer in VFS read/write handlers can lead to both kernel memory corruption (via kernel_read()/kernel_write(), which can e.g. be triggered via
sys_splice()) and privilege escalation inside userspace.Fixes 286468210d83 ("firewire: new driver: nosy - IEEE 1394 traffic sniffer")Signed-off-by Jann Horn <[email protected]>---
No CC stable because this device shouldn't be available to unprivileged code by default and should be pretty rare.drivers/firewire/nosy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/firewire/nosy.c +0
-2@@ -161,11 +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. */ - end = buffer->data + buffer->capacity; length = buffer->head->length;
Quoted 10 lines
drivers/firewire/nosy.c packet_buffer_get(struct client *client, char __user *data, size_t user_length) · line 172
Quoted 6 lines
drivers/firewire/nosy.c +3
-0+if (length > user_length) +return -EINVAL ; +if (&buffer->head->data[length] < end) {if (copy_to_user (data, buffer->head->data, length))return -EFAULT ;Ping. I sent this about two months ago, I haven't received a reply, and from what I can tell, it hasn't landed in any tree so far...
:(
I have that same problem with some Firewire documentation patches. I plan to ask someone else to merge my patches.
Signature · 1 line
~Randy
Quoted 9 lines · On Sep 03 Randy Dunlap wrote:
Quoted 8 lines · Jann Horn
Quoted 7 lines · Jann Horn
In general, accessing userspace memory beyond the length of the supplied buffer in VFS read/write handlers can lead to both kernel memory corruption (via kernel_read()/kernel_write(), which can e.g. be triggered via
sys_splice()) and privilege escalation inside userspace.Fixes 286468210d83 ("firewire: new driver: nosy - IEEE 1394 traffic sniffer")Signed-off-by Jann Horn <[email protected]>
[...]
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/firewire/nosy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
[...]
Quoted 7 lines
Quoted 3 lines
Ping. I sent this about two months ago, I haven't received a reply, and from what I can tell, it hasn't landed in any tree so far...
:(
I have that same problem with some Firewire documentation patches. I plan to ask someone else to merge my patches.
Jann,
sorry for not responding in July (was buried in other work and been effectively absent from maintainership for many months). And sorry for missing your ping in September (it must have been misplaced into the spam folder and I apparently overlooked it there).
This week is another one in which I will not be able to check your patch. Next week I will have a vacation of sorts and will use it to (a) review and merge your patch and (b) clean out my mailbox and update my mail sorting filters (long overdue after my mail service provider changed backends).
Again sorry, and thank you for your extraordinary patience.
Signature · 3 lines
Stefan Richter -======---=- =--= =--=- http://arcgraph.de/sr/