All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] bat_socket_read missing checks
@ 2011-12-10 14:01 Paul
  2011-12-10 14:28 ` [B.A.T.M.A.N.] [PATCHv2 1/3] batman-adv: " Sven Eckelmann
  0 siblings, 1 reply; 8+ messages in thread
From: Paul @ 2011-12-10 14:01 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 153 bytes --]

Writing a icmp_packet_rr and then reading icmp_packet can lead to kernel
memory corruption, if __user *buf is just below TASK_SIZE.

-- 
Regards,
Paul



[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 622 bytes --]

diff --git a/icmp_socket.c b/icmp_socket.c
index 5bc8649..f6a6536 100644
--- a/icmp_socket.c
+++ b/icmp_socket.c
@@ -136,7 +136,9 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf,
 
        spin_unlock_bh(&socket_client->lock);
 
-       error = __copy_to_user(buf, &socket_packet->icmp_packet,
+       //queue can contain packets larger than icmp_packet (like icmp_packet_rr),
+       //so we can't rely just on the access_ok above
+       error = copy_to_user(buf, &socket_packet->icmp_packet,
                               socket_packet->icmp_len);
 
        packet_len = socket_packet->icmp_len;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-12 10:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-10 14:01 [B.A.T.M.A.N.] bat_socket_read missing checks Paul
2011-12-10 14:28 ` [B.A.T.M.A.N.] [PATCHv2 1/3] batman-adv: " Sven Eckelmann
2011-12-10 14:28   ` [B.A.T.M.A.N.] [PATCHv2 2/3] batman-adv: Directly check read of icmp packet in copy_from_user Sven Eckelmann
2011-12-12 10:45     ` Marek Lindner
2011-12-10 14:28   ` [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: Only write requested number of byte to user buffer Sven Eckelmann
2011-12-12 10:48     ` Marek Lindner
2011-12-10 15:36   ` [B.A.T.M.A.N.] [PATCHv3 1/2] " Sven Eckelmann
2011-12-12 10:44   ` [B.A.T.M.A.N.] [PATCHv2 1/3] batman-adv: bat_socket_read missing checks Marek Lindner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.