aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPhil Sutter2013-02-01 01:21:41 -0600
committerGreg Kroah-Hartman2013-02-14 12:47:34 -0600
commit069d8ee0271bdf29ac0fc1186cbedb3815f94255 (patch)
tree382f61c4da0eef4dd7f3c86d42a37678613708ce /net
parentd72b29e562214c7c5b635c3f44884a37bd115739 (diff)
downloadkernel-common-069d8ee0271bdf29ac0fc1186cbedb3815f94255.tar.gz
kernel-common-069d8ee0271bdf29ac0fc1186cbedb3815f94255.tar.xz
kernel-common-069d8ee0271bdf29ac0fc1186cbedb3815f94255.zip
packet: fix leakage of tx_ring memory
[ Upstream commit 9665d5d62487e8e7b1f546c00e11107155384b9a ] When releasing a packet socket, the routine packet_set_ring() is reused to free rings instead of allocating them. But when calling it for the first time, it fills req->tp_block_nr with the value of rb->pg_vec_len which in the second invocation makes it bail out since req->tp_block_nr is greater zero but req->tp_block_size is zero. This patch solves the problem by passing a zeroed auto-variable to packet_set_ring() upon each invocation from packet_release(). As far as I can tell, this issue exists even since 69e3c75 (net: TX_RING and packet mmap), i.e. the original inclusion of TX ring support into af_packet, but applies only to sockets with both RX and TX ring allocated, which is probably why this was unnoticed all the time. Signed-off-by: Phil Sutter <phil.sutter@viprinet.com> Cc: Johann Baudy <johann.baudy@gnu-log.net> Cc: Daniel Borkmann <dborkman@redhat.com> Acked-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/packet/af_packet.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 1ab5a0203ac..4058afe0c5a 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1349,13 +1349,15 @@ static int packet_release(struct socket *sock)
1349 1349
1350 packet_flush_mclist(sk); 1350 packet_flush_mclist(sk);
1351 1351
1352 memset(&req, 0, sizeof(req)); 1352 if (po->rx_ring.pg_vec) {
1353 1353 memset(&req, 0, sizeof(req));
1354 if (po->rx_ring.pg_vec)
1355 packet_set_ring(sk, &req, 1, 0); 1354 packet_set_ring(sk, &req, 1, 0);
1355 }
1356 1356
1357 if (po->tx_ring.pg_vec) 1357 if (po->tx_ring.pg_vec) {
1358 memset(&req, 0, sizeof(req));
1358 packet_set_ring(sk, &req, 1, 1); 1359 packet_set_ring(sk, &req, 1, 1);
1360 }
1359 1361
1360 synchronize_net(); 1362 synchronize_net();
1361 /* 1363 /*