From patchwork Sun Nov 14 07:35:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Le X-Patchwork-Id: 71091 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6F0FBB710F for ; Sun, 14 Nov 2010 18:37:11 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753773Ab0KNHge (ORCPT ); Sun, 14 Nov 2010 02:36:34 -0500 Received: from mail-pz0-f46.google.com ([209.85.210.46]:58449 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753614Ab0KNHgd (ORCPT ); Sun, 14 Nov 2010 02:36:33 -0500 Received: by pzk28 with SMTP id 28so802724pzk.19 for ; Sat, 13 Nov 2010 23:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:from:to:cc :subject:date:message-id:x-mailer; bh=Q63RT2IK1CJLANdfWOFORaLysKNp+yhXRvldBFpHxAg=; b=llq7UhDtgBpONJxy6lpsrz3h7OSArPFXBlU9qWA8QtDA2NjlCG+oEJx9siOtoXZuJi q1uzi3aB+yOITgrxncHwXtFUTbSExhPUu9M+38PnNdVFWBVxklPQRRG4tyu43p6yG7y+ 3DF6sBISc8P9eigJc1ZipLtnQzbq+gIy4iJZE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=PGzPAAagfF8Xm3+FG1apET4q53WnooZEtk4dI2p/XbBLdFKH2ABZnGPmoKy/rdjQBK UEU6ACz7fzrnLRJKtNHZdtYyOssM3VXetAi0AoxGQjFQRZDN6r8rgHt3hU/fyqj7JU1q PWGYR81GXwCXooVz6kdmCu4aqbzxyExrkt64k= Received: by 10.142.48.3 with SMTP id v3mr3715653wfv.119.1289720192685; Sat, 13 Nov 2010 23:36:32 -0800 (PST) Received: from robert.zhangle@gmail.com ([183.37.1.213]) by mx.google.com with ESMTPS id p8sm6777444wff.16.2010.11.13.23.36.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Nov 2010 23:36:31 -0800 (PST) Received: by robert.zhangle@gmail.com (sSMTP sendmail emulation); Sun, 14 Nov 2010 15:36:22 +0800 From: Zhang Le To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Zhang Le , "David S. Miller" , Alexey Kuznetsov , "Pekka Savola (ipv6)" , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Subject: [PATCH] ipv4: mitigate an integer underflow when comparing tcp timestamps Date: Sun, 14 Nov 2010 15:35:56 +0800 Message-Id: <1289720156-30118-1-git-send-email-r0bertz@gentoo.org> X-Mailer: git-send-email 1.7.3.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Behind a loadbalancer which does NAT, peer->tcp_ts could be much smaller than req->ts_recent. In this case, theoretically the req should not be ignored. But in fact, it could be ignored, if peer->tcp_ts is so small that the difference between this two number is larger than 2 to the power of 31. I understand that under this situation, timestamp does not make sense any more, because it actually comes from difference machines. However, if anyone ever need to do the same investigation which I have done, this will save some time for him. Signed-off-by: Zhang Le --- net/ipv4/tcp_ipv4.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 8f8527d..1eb4974 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1352,8 +1352,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) peer->v4daddr == saddr) { inet_peer_refcheck(peer); if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL && - (s32)(peer->tcp_ts - req->ts_recent) > - TCP_PAWS_WINDOW) { + ((s32)(peer->tcp_ts - req->ts_recent) > TCP_PAWS_WINDOW && + peer->tcp_ts > req->ts_recent)) { NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_PAWSPASSIVEREJECTED); goto drop_and_release; }