From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: Only write requested number of byte to user buffer
Date: Sat, 10 Dec 2011 15:28:36 +0100 [thread overview]
Message-ID: <1323527316-15071-3-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1323527316-15071-1-git-send-email-sven@narfation.org>
Don't write more than the requested number of bytes of an batman-adv icmp
packet to the userspace buffer. Otherwise unrelated userspace memory might get
overridden by the kernel.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
icmp_socket.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/icmp_socket.c b/icmp_socket.c
index 4dc55e8..5d69e10 100644
--- a/icmp_socket.c
+++ b/icmp_socket.c
@@ -136,10 +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,
- socket_packet->icmp_len);
+ packet_len = min(count, socket_packet->icmp_len);
+ error = copy_to_user(buf, &socket_packet->icmp_packet, packet_len);
- packet_len = socket_packet->icmp_len;
kfree(socket_packet);
if (error)
--
1.7.7.3
next prev parent reply other threads:[~2011-12-10 14:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Sven Eckelmann [this message]
2011-12-12 10:48 ` [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: Only write requested number of byte to user buffer 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323527316-15071-3-git-send-email-sven@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox