From: Christophe Alladoum Subject: Possible integer overflow in ping_common.c Date: Fri, 9 Mar 2012 17:33:00 +0100 Message-ID: <20120309163300.GC1925@taz.hsc.fr> Reply-To: Christophe.Alladoum@hsc.fr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Content-Transfer-Encoding: 8bit Cc: Romain Coltel To: netdev@vger.kernel.org Return-path: Received: from itesec.hsc.fr ([192.70.106.33]:33459 "EHLO itesec.hsc.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756764Ab2CIQmg (ORCPT ); Fri, 9 Mar 2012 11:42:36 -0500 Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: --/04w6evG8XlLl3ft Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi list, A collegue and I found a possible integer overflow in ping_common.c that could lead to excessive CPU usage when triggered. PoC : {{{ $ ping -i 3600 google.com PING google.com (173.194.66.102) 56(84) bytes of data. 64 bytes from we-in-f102.1e100.net (173.194.66.102): icmp_req=1 ttl=50 time=11.4 ms [...] (check your CPU usage) }}} Here, ping will loop in main_loop() loop in this section of code : {{{ /* from iputils-s20101006 source */ /* ping_common.c */ 546 void main_loop(int icmp_sock, __u8 *packet, int packlen) 547 { [...] 559 for (;;) { [...] 572 do { 573 next = pinger(); 574 next = schedule_exit(next); 575 } while (next <= 0); [...] 588 if ((options & (F_ADAPTIVE|F_FLOOD_POLL)) || next Hervé Schauer Consultants - --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ping_interger_overflow.patch" --- /home/chris/downloads/iputils-s20101006/ping_common.c 2010-10-06 13:59:20.000000000 +0200 +++ /home/chris/downloads/iputils-s20101006-patched/ping_common.c 2012-03-09 16:42:46.878151032 +0100 @@ -590,7 +590,7 @@ /* If we are here, recvmsg() is unable to wait for * required timeout. */ - if (1000*next <= 1000000/(int)HZ) { + if (((long long)1000*next) <= (long long)1000000/(int)HZ) { /* Very short timeout... So, if we wait for * something, we sleep for MININTERVAL. * Otherwise, spin! */ --/04w6evG8XlLl3ft--