Commit 9ef0298a8e5730d9a46d640014c727f3b4152870
Committed by
Patrick McHardy
1 parent
ff75f40f44
Exists in
master
and in
20 other branches
netfilter: nf_log: avoid oops in (un)bind with invalid nfproto values
Like many other places, we have to check that the array index is within allowed limits, or otherwise, a kernel oops and other nastiness can ensue when we access memory beyond the end of the array. [ 5954.115381] BUG: unable to handle kernel paging request at 0000004000000000 [ 5954.120014] IP: __find_logger+0x6f/0xa0 [ 5954.123979] nf_log_bind_pf+0x2b/0x70 [ 5954.123979] nfulnl_recv_config+0xc0/0x4a0 [nfnetlink_log] [ 5954.123979] nfnetlink_rcv_msg+0x12c/0x1b0 [nfnetlink] ... The problem goes back to v2.6.30-rc1~1372~1342~31 where nf_log_bind was decoupled from nf_log_register. Reported-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>, via irc.freenode.net/#netfilter Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff
net/netfilter/nf_log.c
... | ... | @@ -85,6 +85,8 @@ |
85 | 85 | |
86 | 86 | int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger) |
87 | 87 | { |
88 | + if (pf >= ARRAY_SIZE(nf_loggers)) | |
89 | + return -EINVAL; | |
88 | 90 | mutex_lock(&nf_log_mutex); |
89 | 91 | if (__find_logger(pf, logger->name) == NULL) { |
90 | 92 | mutex_unlock(&nf_log_mutex); |
... | ... | @@ -98,6 +100,8 @@ |
98 | 100 | |
99 | 101 | void nf_log_unbind_pf(u_int8_t pf) |
100 | 102 | { |
103 | + if (pf >= ARRAY_SIZE(nf_loggers)) | |
104 | + return; | |
101 | 105 | mutex_lock(&nf_log_mutex); |
102 | 106 | rcu_assign_pointer(nf_loggers[pf], NULL); |
103 | 107 | mutex_unlock(&nf_log_mutex); |