1 From d824548dae220820bdf69b2d1561b7c4b072783f Mon Sep 17 00:00:00 2001
2 From: Florian Westphal <fw@strlen.de>
3 Date: Tue, 19 Feb 2019 00:37:21 +0100
4 Subject: netfilter: ebtables: remove BUGPRINT messages
6 From: Florian Westphal <fw@strlen.de>
8 commit d824548dae220820bdf69b2d1561b7c4b072783f upstream.
10 They are however frequently triggered by syzkaller, so remove them.
12 ebtables userspace should never trigger any of these, so there is little
13 value in making them pr_debug (or ratelimited).
15 Signed-off-by: Florian Westphal <fw@strlen.de>
16 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 net/bridge/netfilter/ebtables.c | 131 +++++++++++-----------------------------
21 1 file changed, 39 insertions(+), 92 deletions(-)
23 --- a/net/bridge/netfilter/ebtables.c
24 +++ b/net/bridge/netfilter/ebtables.c
26 /* needed for logical [in,out]-dev filtering */
27 #include "../br_private.h"
29 -#define BUGPRINT(format, args...) printk("kernel msg: ebtables bug: please "\
30 - "report to author: "format, ## args)
31 -/* #define BUGPRINT(format, args...) */
33 /* Each cpu has its own set of counters, so there is no need for write_lock in
35 * For reading or updating the counters, the user context needs to
36 @@ -466,8 +462,6 @@ static int ebt_verify_pointers(const str
37 /* we make userspace set this right,
38 * so there is no misunderstanding
40 - BUGPRINT("EBT_ENTRY_OR_ENTRIES shouldn't be set "
41 - "in distinguisher\n");
44 if (i != NF_BR_NUMHOOKS)
45 @@ -485,18 +479,14 @@ static int ebt_verify_pointers(const str
46 offset += e->next_offset;
49 - if (offset != limit) {
50 - BUGPRINT("entries_size too small\n");
51 + if (offset != limit)
55 /* check if all valid hooks have a chain */
56 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
57 if (!newinfo->hook_entry[i] &&
58 - (valid_hooks & (1 << i))) {
59 - BUGPRINT("Valid hook without chain\n");
60 + (valid_hooks & (1 << i)))
66 @@ -523,26 +513,20 @@ ebt_check_entry_size_and_hooks(const str
67 /* this checks if the previous chain has as many entries
71 - BUGPRINT("nentries does not equal the nr of entries "
77 if (((struct ebt_entries *)e)->policy != EBT_DROP &&
78 ((struct ebt_entries *)e)->policy != EBT_ACCEPT) {
79 /* only RETURN from udc */
80 if (i != NF_BR_NUMHOOKS ||
81 - ((struct ebt_entries *)e)->policy != EBT_RETURN) {
82 - BUGPRINT("bad policy\n");
83 + ((struct ebt_entries *)e)->policy != EBT_RETURN)
87 if (i == NF_BR_NUMHOOKS) /* it's a user defined chain */
89 - if (((struct ebt_entries *)e)->counter_offset != *totalcnt) {
90 - BUGPRINT("counter_offset != totalcnt");
91 + if (((struct ebt_entries *)e)->counter_offset != *totalcnt)
94 *n = ((struct ebt_entries *)e)->nentries;
97 @@ -550,15 +534,13 @@ ebt_check_entry_size_and_hooks(const str
98 /* a plain old entry, heh */
99 if (sizeof(struct ebt_entry) > e->watchers_offset ||
100 e->watchers_offset > e->target_offset ||
101 - e->target_offset >= e->next_offset) {
102 - BUGPRINT("entry offsets not in right order\n");
103 + e->target_offset >= e->next_offset)
107 /* this is not checked anywhere else */
108 - if (e->next_offset - e->target_offset < sizeof(struct ebt_entry_target)) {
109 - BUGPRINT("target size too small\n");
110 + if (e->next_offset - e->target_offset < sizeof(struct ebt_entry_target))
117 @@ -678,18 +660,15 @@ ebt_check_entry(struct ebt_entry *e, str
121 - if (e->bitmask & ~EBT_F_MASK) {
122 - BUGPRINT("Unknown flag for bitmask\n");
123 + if (e->bitmask & ~EBT_F_MASK)
126 - if (e->invflags & ~EBT_INV_MASK) {
127 - BUGPRINT("Unknown flag for inv bitmask\n");
129 + if (e->invflags & ~EBT_INV_MASK)
132 - if ((e->bitmask & EBT_NOPROTO) && (e->bitmask & EBT_802_3)) {
133 - BUGPRINT("NOPROTO & 802_3 not allowed\n");
135 + if ((e->bitmask & EBT_NOPROTO) && (e->bitmask & EBT_802_3))
139 /* what hook do we belong to? */
140 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
141 if (!newinfo->hook_entry[i])
142 @@ -748,13 +727,11 @@ ebt_check_entry(struct ebt_entry *e, str
143 t->u.target = target;
144 if (t->u.target == &ebt_standard_target) {
145 if (gap < sizeof(struct ebt_standard_target)) {
146 - BUGPRINT("Standard target size too big\n");
148 goto cleanup_watchers;
150 if (((struct ebt_standard_target *)t)->verdict <
151 -NUM_STANDARD_TARGETS) {
152 - BUGPRINT("Invalid standard target\n");
154 goto cleanup_watchers;
156 @@ -813,10 +790,9 @@ static int check_chainloops(const struct
157 if (strcmp(t->u.name, EBT_STANDARD_TARGET))
159 if (e->target_offset + sizeof(struct ebt_standard_target) >
161 - BUGPRINT("Standard target size too big\n");
166 verdict = ((struct ebt_standard_target *)t)->verdict;
167 if (verdict >= 0) { /* jump to another chain */
168 struct ebt_entries *hlp2 =
169 @@ -825,14 +801,12 @@ static int check_chainloops(const struct
170 if (hlp2 == cl_s[i].cs.chaininfo)
172 /* bad destination or loop */
173 - if (i == udc_cnt) {
174 - BUGPRINT("bad destination\n");
178 - if (cl_s[i].cs.n) {
179 - BUGPRINT("loop\n");
185 if (cl_s[i].hookmask & (1 << hooknr))
187 /* this can't be 0, so the loop test is correct */
188 @@ -865,24 +839,21 @@ static int translate_table(struct net *n
190 while (i < NF_BR_NUMHOOKS && !newinfo->hook_entry[i])
192 - if (i == NF_BR_NUMHOOKS) {
193 - BUGPRINT("No valid hooks specified\n");
194 + if (i == NF_BR_NUMHOOKS)
197 - if (newinfo->hook_entry[i] != (struct ebt_entries *)newinfo->entries) {
198 - BUGPRINT("Chains don't start at beginning\n");
200 + if (newinfo->hook_entry[i] != (struct ebt_entries *)newinfo->entries)
204 /* make sure chains are ordered after each other in same order
205 * as their corresponding hooks
207 for (j = i + 1; j < NF_BR_NUMHOOKS; j++) {
208 if (!newinfo->hook_entry[j])
210 - if (newinfo->hook_entry[j] <= newinfo->hook_entry[i]) {
211 - BUGPRINT("Hook order must be followed\n");
212 + if (newinfo->hook_entry[j] <= newinfo->hook_entry[i])
219 @@ -900,15 +871,11 @@ static int translate_table(struct net *n
224 - BUGPRINT("nentries does not equal the nr of entries in the "
229 - if (k != newinfo->nentries) {
230 - BUGPRINT("Total nentries is wrong\n");
232 + if (k != newinfo->nentries)
236 /* get the location of the udc, put them in an array
237 * while we're at it, allocate the chainstack
238 @@ -942,7 +909,6 @@ static int translate_table(struct net *n
239 ebt_get_udc_positions, newinfo, &i, cl_s);
242 - BUGPRINT("i != udc_cnt\n");
246 @@ -1042,7 +1008,6 @@ static int do_replace_finish(struct net
249 if (repl->num_counters && repl->num_counters != t->private->nentries) {
250 - BUGPRINT("Wrong nr. of counters requested\n");
254 @@ -1118,15 +1083,12 @@ static int do_replace(struct net *net, c
255 if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
258 - if (len != sizeof(tmp) + tmp.entries_size) {
259 - BUGPRINT("Wrong len argument\n");
260 + if (len != sizeof(tmp) + tmp.entries_size)
264 - if (tmp.entries_size == 0) {
265 - BUGPRINT("Entries_size never zero\n");
266 + if (tmp.entries_size == 0)
271 if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) /
272 NR_CPUS - SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
273 @@ -1153,7 +1115,6 @@ static int do_replace(struct net *net, c
276 newinfo->entries, tmp.entries, tmp.entries_size) != 0) {
277 - BUGPRINT("Couldn't copy entries from userspace\n");
281 @@ -1194,10 +1155,8 @@ int ebt_register_table(struct net *net,
283 if (input_table == NULL || (repl = input_table->table) == NULL ||
284 repl->entries == NULL || repl->entries_size == 0 ||
285 - repl->counters != NULL || input_table->private != NULL) {
286 - BUGPRINT("Bad table data for ebt_register_table!!!\n");
287 + repl->counters != NULL || input_table->private != NULL)
291 /* Don't add one table to multiple lists. */
292 table = kmemdup(input_table, sizeof(struct ebt_table), GFP_KERNEL);
293 @@ -1235,13 +1194,10 @@ int ebt_register_table(struct net *net,
294 ((char *)repl->hook_entry[i] - repl->entries);
296 ret = translate_table(net, repl->name, newinfo);
298 - BUGPRINT("Translate_table failed\n");
300 goto free_chainstack;
303 if (table->check && table->check(newinfo, table->valid_hooks)) {
304 - BUGPRINT("The table doesn't like its own initial data, lol\n");
306 goto free_chainstack;
308 @@ -1252,7 +1208,6 @@ int ebt_register_table(struct net *net,
309 list_for_each_entry(t, &net->xt.tables[NFPROTO_BRIDGE], list) {
310 if (strcmp(t->name, table->name) == 0) {
312 - BUGPRINT("Table name already exists\n");
316 @@ -1320,7 +1275,6 @@ static int do_update_counters(struct net
319 if (num_counters != t->private->nentries) {
320 - BUGPRINT("Wrong nr of counters\n");
324 @@ -1447,10 +1401,8 @@ static int copy_counters_to_user(struct
325 if (num_counters == 0)
328 - if (num_counters != nentries) {
329 - BUGPRINT("Num_counters wrong\n");
330 + if (num_counters != nentries)
334 counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp)));
336 @@ -1496,15 +1448,11 @@ static int copy_everything_to_user(struc
337 (tmp.num_counters ? nentries * sizeof(struct ebt_counter) : 0))
340 - if (tmp.nentries != nentries) {
341 - BUGPRINT("Nentries wrong\n");
342 + if (tmp.nentries != nentries)
346 - if (tmp.entries_size != entries_size) {
347 - BUGPRINT("Wrong size\n");
348 + if (tmp.entries_size != entries_size)
352 ret = copy_counters_to_user(t, oldcounters, tmp.counters,
353 tmp.num_counters, nentries);
354 @@ -1576,7 +1524,6 @@ static int do_ebt_get_ctl(struct sock *s
356 mutex_unlock(&ebt_mutex);
357 if (copy_to_user(user, &tmp, *len) != 0) {
358 - BUGPRINT("c2u Didn't work\n");