Skip to content

Commit 329f0b9

Browse files
Reset816Florian Westphal
authored andcommitted
netfilter: xt_IDLETIMER: reject rev0 reuse of ALARM timer labels
IDLETIMER revision 0 rules reuse existing timers by label and always call mod_timer() on timer->timer. If the label was created first by revision 1 with XT_IDLETIMER_ALARM, the object uses alarm timer semantics and timer->timer is never initialized. Reusing that object from revision 0 causes mod_timer() on an uninitialized timer_list, triggering debugobjects warnings and possible panic when panic_on_warn=1. Fix this by rejecting revision 0 rule insertion when an existing timer with the same label is of ALARM type. Fixes: 68983a3 ("netfilter: xtables: Add snapshot of hardidletimer target") Co-developed-by: Yifan Wu <yifanwucs@gmail.com> Signed-off-by: Yifan Wu <yifanwucs@gmail.com> Co-developed-by: Juefei Pu <tomapufckgml@gmail.com> Signed-off-by: Juefei Pu <tomapufckgml@gmail.com> Signed-off-by: Yuan Tan <tanyuan98@outlook.com> Signed-off-by: Xin Liu <dstsmallbird@foxmail.com> Signed-off-by: Florian Westphal <fw@strlen.de>
1 parent 6dcee84 commit 329f0b9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

net/netfilter/xt_IDLETIMER.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par)
318318

319319
info->timer = __idletimer_tg_find_by_label(info->label);
320320
if (info->timer) {
321+
if (info->timer->timer_type & XT_IDLETIMER_ALARM) {
322+
pr_debug("Adding/Replacing rule with same label and different timer type is not allowed\n");
323+
mutex_unlock(&list_mutex);
324+
return -EINVAL;
325+
}
326+
321327
info->timer->refcnt++;
322328
mod_timer(&info->timer->timer,
323329
secs_to_jiffies(info->timeout) + jiffies);

0 commit comments

Comments
 (0)