* [PATCH] netfilter: ctnetlink: fix timeout calculation
@ 2011-12-30 15:40 Xi Wang
2011-12-31 15:58 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Xi Wang @ 2011-12-30 15:40 UTC (permalink / raw)
To: Pablo Neira Ayuso, Patrick McHardy, David S. Miller
Cc: netfilter-devel, netdev, Xi Wang
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 <xi.wang@gmail.com>
---
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)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] netfilter: ctnetlink: fix timeout calculation
2011-12-30 15:40 [PATCH] netfilter: ctnetlink: fix timeout calculation Xi Wang
@ 2011-12-31 15:58 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2011-12-31 15:58 UTC (permalink / raw)
To: Xi Wang; +Cc: Patrick McHardy, David S. Miller, netfilter-devel, netdev
On Fri, Dec 30, 2011 at 10:40:17AM -0500, Xi Wang wrote:
> 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 <xi.wang@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-31 15:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-30 15:40 [PATCH] netfilter: ctnetlink: fix timeout calculation Xi Wang
2011-12-31 15:58 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).