Skip to content

Commit c121638

Browse files
xiwummakynes
authored andcommitted
netfilter: ctnetlink: fix timeout calculation
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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 52793db commit c121638

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/netfilter/nf_conntrack_netlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct)
135135
static inline int
136136
ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
137137
{
138-
long timeout = (ct->timeout.expires - jiffies) / HZ;
138+
long timeout = ((long)ct->timeout.expires - (long)jiffies) / HZ;
139139

140140
if (timeout < 0)
141141
timeout = 0;
@@ -1641,7 +1641,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
16411641
const struct nf_conntrack_expect *exp)
16421642
{
16431643
struct nf_conn *master = exp->master;
1644-
long timeout = (exp->timeout.expires - jiffies) / HZ;
1644+
long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ;
16451645
struct nf_conn_help *help;
16461646

16471647
if (timeout < 0)

0 commit comments

Comments
 (0)