From patchwork Fri Dec 30 15:40:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Wang X-Patchwork-Id: 133681 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 C7304B6FA8 for ; Sat, 31 Dec 2011 02:42:08 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751260Ab1L3PmB (ORCPT ); Fri, 30 Dec 2011 10:42:01 -0500 Received: from mail-qw0-f46.google.com ([209.85.216.46]:65196 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899Ab1L3PmA (ORCPT ); Fri, 30 Dec 2011 10:42:00 -0500 Received: by qadc12 with SMTP id c12so8332616qad.19 for ; Fri, 30 Dec 2011 07:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=fvv9Pya/sPpaiQC/kMRKmRniKCPbBQRo815HJfbMf98=; b=fpgHWSOL0tUHWeMSB8Jwo/TbineyJevz76qUUtgJwrzjefy2mQ8PZbGOIjSLNps0e4 D4rdTf8mx1Tp/e2WHt5vk6pxPn+25ISMGauqwUWgMFH055wDX0NZc/4K6GwC123W8zzV DKCydow0QCWWYMYtNCMsGp7Bo5+ZaZtXRL0N0= Received: by 10.224.109.2 with SMTP id h2mr4297018qap.90.1325259719492; Fri, 30 Dec 2011 07:41:59 -0800 (PST) Received: from localhost.localdomain (hchen.csail.mit.edu. [18.26.5.5]) by mx.google.com with ESMTPS id o8sm58816650qaj.0.2011.12.30.07.41.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Dec 2011 07:41:58 -0800 (PST) From: Xi Wang To: Pablo Neira Ayuso , Patrick McHardy , "David S. Miller" Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, Xi Wang Subject: [PATCH] netfilter: ctnetlink: fix timeout calculation Date: Fri, 30 Dec 2011 10:40:17 -0500 Message-Id: <1325259617-22034-1-git-send-email-xi.wang@gmail.com> X-Mailer: git-send-email 1.7.5.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The sanity check (timeout < 0) never works; the dividend is unsigned and so is the division, which should have been a signed division. long timeout = (ct->timeout.expires - jiffies) / HZ; if (timeout < 0) timeout = 0; This patch converts the time values to signed for the division. Signed-off-by: Xi Wang --- net/netfilter/nf_conntrack_netlink.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index b697777..257e772 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -135,7 +135,7 @@ nla_put_failure: static inline int ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) { - long timeout = (ct->timeout.expires - jiffies) / HZ; + long timeout = ((long)ct->timeout.expires - (long)jiffies) / HZ; if (timeout < 0) timeout = 0; @@ -1641,7 +1641,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, const struct nf_conntrack_expect *exp) { struct nf_conn *master = exp->master; - long timeout = (exp->timeout.expires - jiffies) / HZ; + long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ; struct nf_conn_help *help; if (timeout < 0)